[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8088] XS gnulib import strchrnul
From: |
gavinsmith0123 |
Subject: |
[8088] XS gnulib import strchrnul |
Date: |
Wed, 15 Aug 2018 16:24:18 -0400 (EDT) |
Revision: 8088
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8088
Author: gavin
Date: 2018-08-15 16:24:18 -0400 (Wed, 15 Aug 2018)
Log Message:
-----------
XS gnulib import strchrnul
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am
trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4
trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4
Added Paths:
-----------
trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.c
trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.valgrind
trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.c
trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.valgrind
trunk/tp/Texinfo/XS/gnulib/lib/sys/
trunk/tp/Texinfo/XS/gnulib/m4/rawmemchr.m4
trunk/tp/Texinfo/XS/gnulib/m4/strchrnul.m4
Property Changed:
----------------
trunk/tp/Texinfo/XS/gnulib/lib/
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-08-15 19:44:06 UTC (rev 8087)
+++ trunk/ChangeLog 2018-08-15 20:24:18 UTC (rev 8088)
@@ -1,6 +1,7 @@
2018-08-15 Gavin Smith <address@hidden>
* tp/Texinfo/XS: Run "gnulib --add-import iconv".
+ * tp/Texinfo/XS: Run "gnulib --add-import strchrnul".
2018-08-15 Gavin Smith <address@hidden>
Index: trunk/tp/Texinfo/XS/gnulib/lib
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib 2018-08-15 19:44:06 UTC (rev 8087)
+++ trunk/tp/Texinfo/XS/gnulib/lib 2018-08-15 20:24:18 UTC (rev 8088)
Property changes on: trunk/tp/Texinfo/XS/gnulib/lib
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,10 ##
+.deps
+Makefile
+Makefile.in
+alloca.h
+limits.h
+stddef.h
+stdint.h
+stdio.h
+string.h
+wchar.h
Modified: trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am 2018-08-15 19:44:06 UTC (rev
8087)
+++ trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am 2018-08-15 20:24:18 UTC (rev
8088)
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
vasprintf
+# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
strchrnul vasprintf
AUTOMAKE_OPTIONS = 1.9.6 gnits
@@ -211,6 +211,15 @@
## end gnulib module memchr
+## begin gnulib module rawmemchr
+
+
+EXTRA_DIST += rawmemchr.c rawmemchr.valgrind
+
+EXTRA_libgnu_la_SOURCES += rawmemchr.c
+
+## end gnulib module rawmemchr
+
## begin gnulib module size_max
libgnu_la_SOURCES += size_max.h
@@ -464,6 +473,15 @@
## end gnulib module stdio
+## begin gnulib module strchrnul
+
+
+EXTRA_DIST += strchrnul.c strchrnul.valgrind
+
+EXTRA_libgnu_la_SOURCES += strchrnul.c
+
+## end gnulib module strchrnul
+
## begin gnulib module string
BUILT_SOURCES += string.h
Added: trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.c
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.c (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.c 2018-08-15 20:24:18 UTC (rev
8088)
@@ -0,0 +1,136 @@
+/* Searching in a string.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Find the first occurrence of C in S. */
+void *
+rawmemchr (const void *s, int c_in)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned char c;
+
+ c = (unsigned char) c_in;
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ (size_t) char_ptr % sizeof (longword) != 0;
+ ++char_ptr)
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will
+ test a longword at a time. The tricky part is testing if *any of
+ the four* bytes in the longword in question are equal to NUL or
+ c. We first use an xor with repeated_c. This reduces the task
+ to testing whether *any of the four* bytes in longword1 is zero.
+
+ We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ The test whether any byte in longword1 is zero is equivalent
+ to testing whether tmp is nonzero.
+
+ This test can read beyond the end of a string, depending on where
+ C_IN is encountered. However, this is considered safe since the
+ initialization phase ensured that the read will be aligned,
+ therefore, the read will not cross page boundaries and will not
+ cause a fault. */
+
+ while (1)
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+
+ if ((((longword1 - repeated_one) & ~longword1)
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that one of the sizeof (longword) bytes
+ starting at char_ptr is == c. On little-endian machines, we
+ could determine the first such byte without any further memory
+ accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines.
+ Choose code that works in both cases. */
+
+ char_ptr = (unsigned char *) longword_ptr;
+ while (*char_ptr != c)
+ char_ptr++;
+ return (void *) char_ptr;
+}
Added: trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.valgrind
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.valgrind
(rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/lib/rawmemchr.valgrind 2018-08-15 20:24:18 UTC
(rev 8088)
@@ -0,0 +1,12 @@
+# Suppress a valgrind message about use of uninitialized memory in rawmemchr().
+# This use is OK because it provides only a speedup.
+{
+ rawmemchr-value4
+ Memcheck:Value4
+ fun:rawmemchr
+}
+{
+ rawmemchr-value8
+ Memcheck:Value8
+ fun:rawmemchr
+}
Added: trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.c
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.c (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.c 2018-08-15 20:24:18 UTC (rev
8088)
@@ -0,0 +1,142 @@
+/* Searching in a string.
+ Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Find the first occurrence of C in S or the final NUL byte. */
+char *
+strchrnul (const char *s, int c_in)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned char c;
+
+ c = (unsigned char) c_in;
+ if (!c)
+ return rawmemchr (s, 0);
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ (size_t) char_ptr % sizeof (longword) != 0;
+ ++char_ptr)
+ if (!*char_ptr || *char_ptr == c)
+ return (char *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will
+ test a longword at a time. The tricky part is testing if *any of
+ the four* bytes in the longword in question are equal to NUL or
+ c. We first use an xor with repeated_c. This reduces the task
+ to testing whether *any of the four* bytes in longword1 or
+ longword2 is zero.
+
+ Let's consider longword1. We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ The test whether any byte in longword1 or longword2 is zero is equivalent
+ to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine
+ this into a single test, whether (tmp1 | tmp2) is nonzero.
+
+ This test can read more than one byte beyond the end of a string,
+ depending on where the terminating NUL is encountered. However,
+ this is considered safe since the initialization phase ensured
+ that the read will be aligned, therefore, the read will not cross
+ page boundaries and will not cause a fault. */
+
+ while (1)
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+ longword longword2 = *longword_ptr;
+
+ if (((((longword1 - repeated_one) & ~longword1)
+ | ((longword2 - repeated_one) & ~longword2))
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that one of the sizeof (longword) bytes
+ starting at char_ptr is == 0 or == c. On little-endian machines,
+ we could determine the first such byte without any further memory
+ accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines.
+ Choose code that works in both cases. */
+
+ char_ptr = (unsigned char *) longword_ptr;
+ while (*char_ptr && (*char_ptr != c))
+ char_ptr++;
+ return (char *) char_ptr;
+}
Added: trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.valgrind
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.valgrind
(rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/lib/strchrnul.valgrind 2018-08-15 20:24:18 UTC
(rev 8088)
@@ -0,0 +1,12 @@
+# Suppress a valgrind message about use of uninitialized memory in strchrnul().
+# This use is OK because it provides only a speedup.
+{
+ strchrnul-value4
+ Memcheck:Value4
+ fun:strchrnul
+}
+{
+ strchrnul-value8
+ Memcheck:Value8
+ fun:strchrnul
+}
Index: trunk/tp/Texinfo/XS/gnulib/lib/sys
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/sys 2018-08-15 19:44:06 UTC (rev 8087)
+++ trunk/tp/Texinfo/XS/gnulib/lib/sys 2018-08-15 20:24:18 UTC (rev 8088)
Property changes on: trunk/tp/Texinfo/XS/gnulib/lib/sys
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+types.h
Modified: trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4 2018-08-15 19:44:06 UTC
(rev 8087)
+++ trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4 2018-08-15 20:24:18 UTC
(rev 8088)
@@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
vasprintf
+# gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
strchrnul vasprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@@ -34,6 +34,7 @@
gl_MODULES([
getline
iconv
+ strchrnul
vasprintf
])
gl_AVOID([])
Modified: trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4 2018-08-15 19:44:06 UTC
(rev 8087)
+++ trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4 2018-08-15 20:24:18 UTC
(rev 8088)
@@ -56,6 +56,7 @@
# Code from module limits-h:
# Code from module memchr:
# Code from module multiarch:
+ # Code from module rawmemchr:
# Code from module size_max:
# Code from module snippet/arg-nonnull:
# Code from module snippet/c++defs:
@@ -64,6 +65,7 @@
# Code from module stddef:
# Code from module stdint:
# Code from module stdio:
+ # Code from module strchrnul:
# Code from module string:
# Code from module sys_types:
# Code from module vasnprintf:
@@ -120,11 +122,23 @@
fi
gl_STRING_MODULE_INDICATOR([memchr])
gl_MULTIARCH
+ gl_FUNC_RAWMEMCHR
+ if test $HAVE_RAWMEMCHR = 0; then
+ AC_LIBOBJ([rawmemchr])
+ gl_PREREQ_RAWMEMCHR
+ fi
+ gl_STRING_MODULE_INDICATOR([rawmemchr])
gl_SIZE_MAX
gt_TYPE_SSIZE_T
gl_STDDEF_H
gl_STDINT_H
gl_STDIO_H
+ gl_FUNC_STRCHRNUL
+ if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then
+ AC_LIBOBJ([strchrnul])
+ gl_PREREQ_STRCHRNUL
+ fi
+ gl_STRING_MODULE_INDICATOR([strchrnul])
gl_HEADER_STRING_H
gl_SYS_TYPES_H
AC_PROG_MKDIR_P
@@ -292,10 +306,14 @@
lib/printf-args.h
lib/printf-parse.c
lib/printf-parse.h
+ lib/rawmemchr.c
+ lib/rawmemchr.valgrind
lib/size_max.h
lib/stddef.in.h
lib/stdint.in.h
lib/stdio.in.h
+ lib/strchrnul.c
+ lib/strchrnul.valgrind
lib/string.in.h
lib/sys_types.in.h
lib/vasnprintf.c
@@ -333,6 +351,7 @@
m4/off_t.m4
m4/onceonly.m4
m4/printf.m4
+ m4/rawmemchr.m4
m4/size_max.m4
m4/ssize_t.m4
m4/stddef_h.m4
@@ -339,6 +358,7 @@
m4/stdint.m4
m4/stdint_h.m4
m4/stdio_h.m4
+ m4/strchrnul.m4
m4/string_h.m4
m4/sys_types_h.m4
m4/vasnprintf.m4
Added: trunk/tp/Texinfo/XS/gnulib/m4/rawmemchr.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/rawmemchr.m4 (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/m4/rawmemchr.m4 2018-08-15 20:24:18 UTC (rev
8088)
@@ -0,0 +1,20 @@
+# rawmemchr.m4 serial 2
+dnl Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_RAWMEMCHR],
+[
+ dnl Persuade glibc <string.h> to declare rawmemchr().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_CHECK_FUNCS([rawmemchr])
+ if test $ac_cv_func_rawmemchr = no; then
+ HAVE_RAWMEMCHR=0
+ fi
+])
+
+# Prerequisites of lib/strchrnul.c.
+AC_DEFUN([gl_PREREQ_RAWMEMCHR], [:])
Added: trunk/tp/Texinfo/XS/gnulib/m4/strchrnul.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/strchrnul.m4 (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/m4/strchrnul.m4 2018-08-15 20:24:18 UTC (rev
8088)
@@ -0,0 +1,50 @@
+# strchrnul.m4 serial 9
+dnl Copyright (C) 2003, 2007, 2009-2017 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRCHRNUL],
+[
+ dnl Persuade glibc <string.h> to declare strchrnul().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_CHECK_FUNCS([strchrnul])
+ if test $ac_cv_func_strchrnul = no; then
+ HAVE_STRCHRNUL=0
+ else
+ AC_CACHE_CHECK([whether strchrnul works],
+ [gl_cv_func_strchrnul_works],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <string.h> /* for strchrnul */
+]], [[const char *buf = "a";
+ return strchrnul (buf, 'b') != buf + 1;
+ ]])],
+ [gl_cv_func_strchrnul_works=yes],
+ [gl_cv_func_strchrnul_works=no],
+ [dnl Cygwin 1.7.9 introduced strchrnul, but it was broken until 1.7.10
+ AC_EGREP_CPP([Lucky user],
+ [
+#if defined __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 9)
+ Lucky user
+ #endif
+#else
+ Lucky user
+#endif
+ ],
+ [gl_cv_func_strchrnul_works="guessing yes"],
+ [gl_cv_func_strchrnul_works="guessing no"])
+ ])
+ ])
+ case "$gl_cv_func_strchrnul_works" in
+ *yes) ;;
+ *) REPLACE_STRCHRNUL=1 ;;
+ esac
+ fi
+])
+
+# Prerequisites of lib/strchrnul.c.
+AC_DEFUN([gl_PREREQ_STRCHRNUL], [:])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8088] XS gnulib import strchrnul,
gavinsmith0123 <=