]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/functions.m4 (AC_FUNC_STRNLEN): New, from Jim
authorAkim Demaille <akim@epita.fr>
Fri, 11 Jan 2002 13:25:08 +0000 (13:25 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 11 Jan 2002 13:25:08 +0000 (13:25 +0000)
Meyering.
* doc/autoconf.texi (Function Portability): Document the strnlen
limitation.
(Particular Functions): Document AC_FUNC_STRNLEN.
* lib/autoscan/functions: Adjust.

ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/functions.m4
lib/autoscan/functions
tests/acfunctions.at

index de63a1373d1276e267356f8e3d025707e0b1f5ea..54421f5fb96c03924b10516a0eca203ff4956f10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2002-01-11  Akim Demaille  <akim@epita.fr>
+
+       * lib/autoconf/functions.m4 (AC_FUNC_STRNLEN): New, from Jim
+       Meyering.
+       * doc/autoconf.texi (Function Portability): Document the strnlen
+       limitation.
+       (Particular Functions): Document AC_FUNC_STRNLEN.
+       * lib/autoscan/functions: Adjust.
+
 2002-01-06  Akim Demaille  <akim@epita.fr>
 
        * lib/autoconf/autotest.m4 (AC_CONFIG_TESTDIR): Don't create
@@ -7,7 +16,7 @@
        * tests/Makefile.am (package.m4): New.
        EXTRA_DIST it since its a source.
 
-       
+
 2002-01-06  Akim Demaille  <akim@epita.fr>
 
        * lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS): Move the AC_SUBST
@@ -21,7 +30,7 @@
        * tests/tools.at (autoheader): Adjust.
        * tests/atspecific.m4 (AT_CHECK_DEFINES): Adjust.
 
-       
+
 2002-01-06  Akim Demaille  <akim@epita.fr>
 
        * bin/autoscan.in (scan_file): Use `&used'.
diff --git a/NEWS b/NEWS
index 44444c167fe416495505024ce85c69881816f30b..819fdeccc8488c21185e1086a1dcdd9fb1a9cff1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -97,6 +97,9 @@
 
 - AC_FUNC_STRTOD substitutes POW_LIB.
 
+- AC_FUNC_STRNLEN
+  New.
+
 \f
 * Major changes in Autoconf 2.52
 ** Documentation
index f33a1e51926535481cf1733497dab780c8d89df4..8bb439b37c78d20951641407a8806ce2f9b4ad86 100644 (file)
@@ -3360,6 +3360,24 @@ constant strings in read-only memory
 Porting the GNU Compiler Collection}).  Apparently in some cases even
 having format strings read-only can be a problem.
 
+@item @code{strnlen}
+@c @fuindex strnlen
+@prindex @code{strnlen}
+AIX 4.3 provides a broken version which produces funny results:
+
+@example
+strnlen ("foobar", 0) = 0
+strnlen ("foobar", 1) = 3
+strnlen ("foobar", 2) = 2
+strnlen ("foobar", 3) = 1
+strnlen ("foobar", 4) = 0
+strnlen ("foobar", 5) = 6
+strnlen ("foobar", 6) = 6
+strnlen ("foobar", 7) = 6
+strnlen ("foobar", 8) = 6
+strnlen ("foobar", 9) = 6
+@end example
+
 @item @code{unlink}
 @c @fuindex unlink
 @prindex @code{unlink}
@@ -3792,6 +3810,16 @@ Check for @code{strftime} in the @file{intl} library, for SCO @sc{unix}.
 Then, if @code{strftime} is available, define @code{HAVE_STRFTIME}.
 @end defmac
 
+@defmac AC_FUNC_STRNLEN
+@acindex FUNC_STRNLEN
+@cvindex HAVE_STRNLEN
+@c @fuindex strnlen
+@prindex @code{strnlen}
+Check for a working @code{strnlen}, and ask for its replacement.  Some
+architectures are know to provide broken versions of @code{strnlen}, such
+as AIX 4.3.
+@end defmac
+
 @defmac AC_FUNC_UTIME_NULL
 @acindex FUNC_UTIME_NULL
 @cvindex HAVE_UTIME_NULL
index 22f612e1b886111a549a6198bdf81ad265842bff..a8e12cd29e599a96d0f5786a867d69c381f9c9e9 100644 (file)
@@ -1262,6 +1262,33 @@ LIBS="-lintl $LIBS"])])dnl
 ])# AC_FUNC_STRFTIME
 
 
+# AC_FUNC_STRNLEN
+# --------------
+AC_DEFUN([AC_FUNC_STRNLEN],
+[AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
+[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
+#define S "foobar"
+#define S_LEN (sizeof S - 1)
+
+  /* At least one implementation is buggy: that of AIX 4.3 would
+     give strnlen (S, 1) == 3.  */
+
+  int i;
+  for (i = 0; i < S_LEN + 1; ++i)
+    {
+      int expected = i <= S_LEN ? i : S_LEN;
+      if (strnlen (S, i) != expected)
+       exit (1);
+    }
+  exit (0);
+]])],
+               [ac_cv_func_strnlen_working=yes],
+               [ac_cv_func_strnlen_working=no],
+               [ac_cv_func_strnlen_working=no])])
+test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
+])# AC_FUNC_STRNLEN
+
+
 # AC_FUNC_SETVBUF_REVERSED
 # ------------------------
 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
index 4e3d4c332142558ae848fbcf445c3380d9c236f3..8f555f2c45d9a5c2824b16d3922868391ec6e64d 100644 (file)
@@ -1,5 +1,5 @@
-# acfunctions -- autoscan's mapping from functions to Autoconf macros
-# Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001
+# functions -- autoscan's mapping from functions to Autoconf macros
+# Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -59,6 +59,7 @@ stat          AC_FUNC_STAT
 strcoll                AC_FUNC_STRCOLL
 strerror_r     AC_FUNC_STRERROR_R
 strftime       AC_FUNC_STRFTIME
+strnlen                AC_FUNC_STRNLEN
 strtod         AC_FUNC_STRTOD
 utime          AC_FUNC_UTIME_NULL
 utime          AC_CHECK_FUNCS
@@ -150,7 +151,6 @@ strdup
 strerror
 strncasecmp
 strndup
-strnlen
 strpbrk
 strrchr
 strspn
index e4e302ceb0b83db9b32e5b773bc9b075e8e2dc0b..c136764415404e92065e1966594b18a35a3ff2ad 100644 (file)
@@ -27,6 +27,7 @@ AT_CHECK_MACRO([AC_FUNC_STAT])
 AT_CHECK_MACRO([AC_FUNC_STRCOLL])
 AT_CHECK_MACRO([AC_FUNC_STRERROR_R])
 AT_CHECK_MACRO([AC_FUNC_STRFTIME])
+AT_CHECK_MACRO([AC_FUNC_STRNLEN])
 AT_CHECK_MACRO([AC_FUNC_STRTOD])
 AT_CHECK_MACRO([AC_FUNC_UTIME_NULL])
 AT_CHECK_MACRO([AC_FUNC_VPRINTF])