diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 09:03:36 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 09:03:36 (GMT) |
commit | f3dbc2ec871da22028969540424a63ff51404cfd (patch) | |
tree | 4225e3007008839ec710fcc17ed6cc9bf8db748c /gl | |
parent | 5c8dd483ccc5f4cf2d86c4ae386efb86e3b259cd (diff) | |
download | monitoring-plugins-f3dbc2ec871da22028969540424a63ff51404cfd.tar.gz |
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 8 | ||||
-rw-r--r-- | gl/fsusage.c | 13 | ||||
-rw-r--r-- | gl/m4/fcntl-o.m4 | 8 | ||||
-rw-r--r-- | gl/m4/fsusage.m4 | 28 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 2 | ||||
-rw-r--r-- | gl/m4/lib-link.m4 | 4 | ||||
-rw-r--r-- | gl/m4/malloc.m4 | 31 | ||||
-rw-r--r-- | gl/m4/stdlib_h.m4 | 12 | ||||
-rw-r--r-- | gl/stdlib.in.h | 29 | ||||
-rw-r--r-- | gl/str-two-way.h | 59 | ||||
-rw-r--r-- | gl/string.in.h | 38 |
11 files changed, 163 insertions, 69 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index e9e2302..edc7db1 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am | |||
@@ -1182,6 +1182,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
1182 | sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | 1182 | sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ |
1183 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | 1183 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ |
1184 | -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ | 1184 | -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ |
1185 | -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \ | ||
1185 | -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ | 1186 | -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ |
1186 | -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ | 1187 | -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ |
1187 | -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ | 1188 | -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ |
@@ -1206,13 +1207,12 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
1206 | -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ | 1207 | -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ |
1207 | -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ | 1208 | -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ |
1208 | -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ | 1209 | -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ |
1210 | -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ | ||
1209 | -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ | 1211 | -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ |
1210 | -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ | ||
1211 | -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ | 1212 | -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ |
1212 | -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ | 1213 | -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ |
1213 | -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ | 1214 | -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ |
1214 | -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ | 1215 | -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ |
1215 | -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ | ||
1216 | -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ | 1216 | -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ |
1217 | -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ | 1217 | -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ |
1218 | -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ | 1218 | -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ |
@@ -1221,7 +1221,6 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
1221 | -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ | 1221 | -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ |
1222 | -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ | 1222 | -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ |
1223 | -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ | 1223 | -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ |
1224 | -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ | ||
1225 | -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ | 1224 | -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ |
1226 | -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ | 1225 | -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ |
1227 | -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ | 1226 | -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ |
@@ -1232,9 +1231,12 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
1232 | -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ | 1231 | -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ |
1233 | -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ | 1232 | -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ |
1234 | -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ | 1233 | -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ |
1234 | -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ | ||
1235 | -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ | 1235 | -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ |
1236 | -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ | ||
1236 | -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ | 1237 | -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ |
1237 | -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ | 1238 | -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ |
1239 | -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ | ||
1238 | -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ | 1240 | -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ |
1239 | -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ | 1241 | -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ |
1240 | -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ | 1242 | -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ |
diff --git a/gl/fsusage.c b/gl/fsusage.c index 10db467..17102aa 100644 --- a/gl/fsusage.c +++ b/gl/fsusage.c | |||
@@ -94,7 +94,7 @@ | |||
94 | int | 94 | int |
95 | get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) | 95 | get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) |
96 | { | 96 | { |
97 | #if defined STAT_STATVFS /* POSIX */ | 97 | #if defined STAT_STATVFS /* POSIX, except glibc/Linux */ |
98 | 98 | ||
99 | struct statvfs fsd; | 99 | struct statvfs fsd; |
100 | 100 | ||
@@ -156,7 +156,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) | |||
156 | : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); | 156 | : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); |
157 | fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode); | 157 | fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode); |
158 | 158 | ||
159 | #elif defined STAT_STATFS3_OSF1 | 159 | #elif defined STAT_STATFS3_OSF1 /* OSF/1 */ |
160 | 160 | ||
161 | struct statfs fsd; | 161 | struct statfs fsd; |
162 | 162 | ||
@@ -165,7 +165,9 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) | |||
165 | 165 | ||
166 | fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); | 166 | fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); |
167 | 167 | ||
168 | #elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ | 168 | #elif defined STAT_STATFS2_BSIZE /* glibc/Linux, 4.3BSD, SunOS 4, \ |
169 | MacOS X < 10.4, FreeBSD < 5.0, \ | ||
170 | NetBSD < 3.0, OpenBSD < 4.4 */ | ||
169 | 171 | ||
170 | struct statfs fsd; | 172 | struct statfs fsd; |
171 | 173 | ||
@@ -189,7 +191,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) | |||
189 | } | 191 | } |
190 | # endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ | 192 | # endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ |
191 | 193 | ||
192 | #elif defined STAT_STATFS2_FSIZE /* 4.4BSD */ | 194 | #elif defined STAT_STATFS2_FSIZE /* 4.4BSD and older NetBSD */ |
193 | 195 | ||
194 | struct statfs fsd; | 196 | struct statfs fsd; |
195 | 197 | ||
@@ -198,7 +200,8 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) | |||
198 | 200 | ||
199 | fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); | 201 | fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); |
200 | 202 | ||
201 | #elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ | 203 | #elif defined STAT_STATFS4 /* SVR3, Dynix, old Irix, old AIX, \ |
204 | Dolphin */ | ||
202 | 205 | ||
203 | # if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN | 206 | # if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN |
204 | # define f_bavail f_bfree | 207 | # define f_bavail f_bfree |
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4 index d416a61..1adacc8 100644 --- a/gl/m4/fcntl-o.m4 +++ b/gl/m4/fcntl-o.m4 | |||
@@ -1,4 +1,4 @@ | |||
1 | # fcntl-o.m4 serial 1 | 1 | # fcntl-o.m4 serial 2 |
2 | dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
@@ -12,7 +12,11 @@ dnl Written by Paul Eggert. | |||
12 | AC_DEFUN([gl_FCNTL_O_FLAGS], | 12 | AC_DEFUN([gl_FCNTL_O_FLAGS], |
13 | [ | 13 | [ |
14 | dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. | 14 | dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. |
15 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | 15 | dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes |
16 | dnl AC_GNU_SOURCE. | ||
17 | m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], | ||
18 | [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], | ||
19 | [AC_REQUIRE([AC_GNU_SOURCE])]) | ||
16 | AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], | 20 | AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], |
17 | [AC_RUN_IFELSE( | 21 | [AC_RUN_IFELSE( |
18 | [AC_LANG_PROGRAM( | 22 | [AC_LANG_PROGRAM( |
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4 index 216b9dd..68684c2 100644 --- a/gl/m4/fsusage.m4 +++ b/gl/m4/fsusage.m4 | |||
@@ -1,4 +1,4 @@ | |||
1 | # serial 25 | 1 | # serial 26 |
2 | # Obtaining file system usage information. | 2 | # Obtaining file system usage information. |
3 | 3 | ||
4 | # Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc. | 4 | # Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc. |
@@ -44,7 +44,8 @@ ac_fsusage_space=no | |||
44 | # systems. That system is reported to work fine with STAT_STATFS4 which | 44 | # systems. That system is reported to work fine with STAT_STATFS4 which |
45 | # is what it gets when this test fails. | 45 | # is what it gets when this test fails. |
46 | if test $ac_fsusage_space = no; then | 46 | if test $ac_fsusage_space = no; then |
47 | # SVR4 | 47 | # glibc/{Hurd,kFreeBSD}, MacOS X >= 10.4, FreeBSD >= 5.0, NetBSD >= 3.0, |
48 | # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. | ||
48 | AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], | 49 | AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], |
49 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> | 50 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
50 | #if defined __GLIBC__ && defined __linux__ | 51 | #if defined __GLIBC__ && defined __linux__ |
@@ -97,8 +98,13 @@ if test $ac_fsusage_space = no; then | |||
97 | fi | 98 | fi |
98 | 99 | ||
99 | if test $ac_fsusage_space = no; then | 100 | if test $ac_fsusage_space = no; then |
100 | # AIX | 101 | # glibc/Linux, MacOS X < 10.4, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. |
101 | AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl | 102 | # (glibc/{Hurd,kFreeBSD}, MacOS X >= 10.4, FreeBSD >= 5.0, NetBSD >= 3.0, |
103 | # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) | ||
104 | # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and | ||
105 | # <sys/vfs.h>.) | ||
106 | # (On Solaris, statfs has 4 arguments.) | ||
107 | AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl | ||
102 | member (AIX, 4.3BSD)]) | 108 | member (AIX, 4.3BSD)]) |
103 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], | 109 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], |
104 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 110 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
@@ -131,7 +137,8 @@ member (AIX, 4.3BSD)]) | |||
131 | fi | 137 | fi |
132 | 138 | ||
133 | if test $ac_fsusage_space = no; then | 139 | if test $ac_fsusage_space = no; then |
134 | # SVR3 | 140 | # SVR3 |
141 | # (Solaris already handled above.) | ||
135 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) | 142 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) |
136 | AC_CACHE_VAL([fu_cv_sys_stat_statfs4], | 143 | AC_CACHE_VAL([fu_cv_sys_stat_statfs4], |
137 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 144 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
@@ -150,13 +157,17 @@ if test $ac_fsusage_space = no; then | |||
150 | if test $fu_cv_sys_stat_statfs4 = yes; then | 157 | if test $fu_cv_sys_stat_statfs4 = yes; then |
151 | ac_fsusage_space=yes | 158 | ac_fsusage_space=yes |
152 | AC_DEFINE([STAT_STATFS4], [1], | 159 | AC_DEFINE([STAT_STATFS4], [1], |
153 | [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)]) | 160 | [ Define if statfs takes 4 args. (SVR3, Dynix, old Irix, old AIX, Dolphin)]) |
154 | fi | 161 | fi |
155 | fi | 162 | fi |
156 | 163 | ||
157 | if test $ac_fsusage_space = no; then | 164 | if test $ac_fsusage_space = no; then |
158 | # 4.4BSD and NetBSD | 165 | # 4.4BSD and older NetBSD |
159 | AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl | 166 | # (OSF/1 already handled above.) |
167 | # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.) | ||
168 | # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in | ||
169 | # <sys/mount.h>.) | ||
170 | AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl | ||
160 | member (4.4BSD and NetBSD)]) | 171 | member (4.4BSD and NetBSD)]) |
161 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize], | 172 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize], |
162 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 173 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
@@ -223,6 +234,7 @@ fi | |||
223 | 234 | ||
224 | if test $ac_fsusage_space = no; then | 235 | if test $ac_fsusage_space = no; then |
225 | # SVR2 | 236 | # SVR2 |
237 | # (AIX, HP-UX, OSF/1 already handled above.) | ||
226 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h> | 238 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h> |
227 | ]])], | 239 | ]])], |
228 | [AC_DEFINE([STAT_READ_FILSYS], [1], | 240 | [AC_DEFINE([STAT_READ_FILSYS], [1], |
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index fc3f353..b5e6b43 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 | |||
@@ -254,7 +254,7 @@ AC_DEFUN([gl_INIT], | |||
254 | # Code from module locale: | 254 | # Code from module locale: |
255 | gl_LOCALE_H | 255 | gl_LOCALE_H |
256 | # Code from module malloc: | 256 | # Code from module malloc: |
257 | AC_FUNC_MALLOC | 257 | gl_FUNC_MALLOC_GNU |
258 | AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.]) | 258 | AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.]) |
259 | # Code from module malloc-posix: | 259 | # Code from module malloc-posix: |
260 | gl_FUNC_MALLOC_POSIX | 260 | gl_FUNC_MALLOC_POSIX |
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4 index 59b367d..9f3be3a 100644 --- a/gl/m4/lib-link.m4 +++ b/gl/m4/lib-link.m4 | |||
@@ -1,4 +1,4 @@ | |||
1 | # lib-link.m4 serial 23 (gettext-0.18.2) | 1 | # lib-link.m4 serial 24 (gettext-0.18.2) |
2 | dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
@@ -165,7 +165,7 @@ AC_DEFUN([AC_LIB_FROMPACKAGE], | |||
165 | pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], | 165 | pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], |
166 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) | 166 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
167 | define([acl_libsinpackage_]PACKUP, | 167 | define([acl_libsinpackage_]PACKUP, |
168 | m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) | 168 | m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) |
169 | popdef([PACKUP]) | 169 | popdef([PACKUP]) |
170 | popdef([PACK]) | 170 | popdef([PACK]) |
171 | ]) | 171 | ]) |
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4 index 910ac92..fe5befc 100644 --- a/gl/m4/malloc.m4 +++ b/gl/m4/malloc.m4 | |||
@@ -1,25 +1,40 @@ | |||
1 | # malloc.m4 serial 9 | 1 | # malloc.m4 serial 10 |
2 | dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | # gl_FUNC_MALLOC_GNU | ||
8 | # ------------------ | ||
9 | # Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if | ||
10 | # it is not. | ||
11 | AC_DEFUN([gl_FUNC_MALLOC_GNU], | ||
12 | [ | ||
13 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
14 | dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. | ||
15 | _AC_FUNC_MALLOC_IF( | ||
16 | [AC_DEFINE([HAVE_MALLOC], [1], | ||
17 | [Define to 1 if your system has a GNU libc compatible 'malloc' | ||
18 | function, and to 0 otherwise.])], | ||
19 | [AC_DEFINE([HAVE_MALLOC], [0]) | ||
20 | gl_REPLACE_MALLOC | ||
21 | ]) | ||
22 | ]) | ||
23 | |||
7 | # gl_FUNC_MALLOC_POSIX | 24 | # gl_FUNC_MALLOC_POSIX |
8 | # -------------------- | 25 | # -------------------- |
9 | # Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it | 26 | # Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it |
10 | # fails), and replace malloc if it is not. | 27 | # fails), and replace malloc if it is not. |
11 | AC_DEFUN([gl_FUNC_MALLOC_POSIX], | 28 | AC_DEFUN([gl_FUNC_MALLOC_POSIX], |
12 | [ | 29 | [ |
30 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
13 | AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) | 31 | AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) |
14 | if test $gl_cv_func_malloc_posix = yes; then | 32 | if test $gl_cv_func_malloc_posix = yes; then |
15 | HAVE_MALLOC_POSIX=1 | ||
16 | AC_DEFINE([HAVE_MALLOC_POSIX], [1], | 33 | AC_DEFINE([HAVE_MALLOC_POSIX], [1], |
17 | [Define if the 'malloc' function is POSIX compliant.]) | 34 | [Define if the 'malloc' function is POSIX compliant.]) |
18 | else | 35 | else |
19 | AC_LIBOBJ([malloc]) | 36 | gl_REPLACE_MALLOC |
20 | HAVE_MALLOC_POSIX=0 | ||
21 | fi | 37 | fi |
22 | AC_SUBST([HAVE_MALLOC_POSIX]) | ||
23 | ]) | 38 | ]) |
24 | 39 | ||
25 | # Test whether malloc, realloc, calloc are POSIX compliant, | 40 | # Test whether malloc, realloc, calloc are POSIX compliant, |
@@ -39,3 +54,9 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX], | |||
39 | ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no]) | 54 | ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no]) |
40 | ]) | 55 | ]) |
41 | ]) | 56 | ]) |
57 | |||
58 | AC_DEFUN([gl_REPLACE_MALLOC], | ||
59 | [ | ||
60 | AC_LIBOBJ([malloc]) | ||
61 | REPLACE_MALLOC=1 | ||
62 | ]) | ||
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4 index dd84796..fc15019 100644 --- a/gl/m4/stdlib_h.m4 +++ b/gl/m4/stdlib_h.m4 | |||
@@ -1,4 +1,4 @@ | |||
1 | # stdlib_h.m4 serial 28 | 1 | # stdlib_h.m4 serial 30 |
2 | dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
@@ -33,7 +33,7 @@ AC_DEFUN([gl_STDLIB_H], | |||
33 | #if HAVE_RANDOM_H | 33 | #if HAVE_RANDOM_H |
34 | # include <random.h> | 34 | # include <random.h> |
35 | #endif | 35 | #endif |
36 | ]], [atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp | 36 | ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp |
37 | mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r | 37 | mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r |
38 | setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt | 38 | setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt |
39 | unsetenv]) | 39 | unsetenv]) |
@@ -50,6 +50,7 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], | |||
50 | 50 | ||
51 | AC_DEFUN([gl_STDLIB_H_DEFAULTS], | 51 | AC_DEFUN([gl_STDLIB_H_DEFAULTS], |
52 | [ | 52 | [ |
53 | GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT]) | ||
53 | GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) | 54 | GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) |
54 | GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) | 55 | GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) |
55 | GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) | 56 | GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) |
@@ -75,13 +76,12 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], | |||
75 | GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) | 76 | GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) |
76 | GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) | 77 | GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) |
77 | dnl Assume proper GNU behavior unless another module says otherwise. | 78 | dnl Assume proper GNU behavior unless another module says otherwise. |
79 | HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) | ||
78 | HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) | 80 | HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) |
79 | HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX]) | ||
80 | HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) | 81 | HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) |
81 | HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) | 82 | HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) |
82 | HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) | 83 | HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) |
83 | HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) | 84 | HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) |
84 | HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX]) | ||
85 | HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) | 85 | HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) |
86 | HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) | 86 | HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) |
87 | HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) | 87 | HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) |
@@ -89,7 +89,6 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], | |||
89 | HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) | 89 | HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) |
90 | HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) | 90 | HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) |
91 | HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) | 91 | HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) |
92 | HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX]) | ||
93 | HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) | 92 | HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) |
94 | HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) | 93 | HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) |
95 | HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) | 94 | HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) |
@@ -100,9 +99,12 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], | |||
100 | HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) | 99 | HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) |
101 | HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) | 100 | HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) |
102 | HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) | 101 | HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) |
102 | REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) | ||
103 | REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) | 103 | REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) |
104 | REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) | ||
104 | REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) | 105 | REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) |
105 | REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) | 106 | REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) |
107 | REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) | ||
106 | REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) | 108 | REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) |
107 | REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) | 109 | REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) |
108 | REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) | 110 | REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) |
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h index d74c251..d4ac469 100644 --- a/gl/stdlib.in.h +++ b/gl/stdlib.in.h | |||
@@ -74,6 +74,12 @@ struct random_data | |||
74 | # include <unistd.h> | 74 | # include <unistd.h> |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #ifndef __attribute__ | ||
78 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) | ||
79 | # define __attribute__(Spec) /* empty */ | ||
80 | # endif | ||
81 | #endif | ||
82 | |||
77 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | 83 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
78 | 84 | ||
79 | /* The definition of _GL_ARG_NONNULL is copied here. */ | 85 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
@@ -95,6 +101,23 @@ struct random_data | |||
95 | #endif | 101 | #endif |
96 | 102 | ||
97 | 103 | ||
104 | #if @GNULIB__EXIT@ | ||
105 | /* Terminate the current process with the given return code, without running | ||
106 | the 'atexit' handlers. */ | ||
107 | # if !@HAVE__EXIT@ | ||
108 | _GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); | ||
109 | # endif | ||
110 | _GL_CXXALIAS_SYS (_Exit, void, (int status)); | ||
111 | _GL_CXXALIASWARN (_Exit); | ||
112 | #elif defined GNULIB_POSIXCHECK | ||
113 | # undef _Exit | ||
114 | # if HAVE_RAW_DECL__EXIT | ||
115 | _GL_WARN_ON_USE (_Exit, "_Exit is unportable - " | ||
116 | "use gnulib module _Exit for portability"); | ||
117 | # endif | ||
118 | #endif | ||
119 | |||
120 | |||
98 | #if @GNULIB_ATOLL@ | 121 | #if @GNULIB_ATOLL@ |
99 | /* Parse a signed decimal integer. | 122 | /* Parse a signed decimal integer. |
100 | Returns the value of the integer. Errors are not detected. */ | 123 | Returns the value of the integer. Errors are not detected. */ |
@@ -112,7 +135,7 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - " | |||
112 | #endif | 135 | #endif |
113 | 136 | ||
114 | #if @GNULIB_CALLOC_POSIX@ | 137 | #if @GNULIB_CALLOC_POSIX@ |
115 | # if !@HAVE_CALLOC_POSIX@ | 138 | # if @REPLACE_CALLOC@ |
116 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 139 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
117 | # undef calloc | 140 | # undef calloc |
118 | # define calloc rpl_calloc | 141 | # define calloc rpl_calloc |
@@ -218,7 +241,7 @@ _GL_WARN_ON_USE (ptsname, "grantpt is not portable - " | |||
218 | #endif | 241 | #endif |
219 | 242 | ||
220 | #if @GNULIB_MALLOC_POSIX@ | 243 | #if @GNULIB_MALLOC_POSIX@ |
221 | # if !@HAVE_MALLOC_POSIX@ | 244 | # if @REPLACE_MALLOC@ |
222 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 245 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
223 | # undef malloc | 246 | # undef malloc |
224 | # define malloc rpl_malloc | 247 | # define malloc rpl_malloc |
@@ -477,7 +500,7 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " | |||
477 | 500 | ||
478 | 501 | ||
479 | #if @GNULIB_REALLOC_POSIX@ | 502 | #if @GNULIB_REALLOC_POSIX@ |
480 | # if !@HAVE_REALLOC_POSIX@ | 503 | # if @REPLACE_REALLOC@ |
481 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 504 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
482 | # undef realloc | 505 | # undef realloc |
483 | # define realloc rpl_realloc | 506 | # define realloc rpl_realloc |
diff --git a/gl/str-two-way.h b/gl/str-two-way.h index c08f60e..4d555f9 100644 --- a/gl/str-two-way.h +++ b/gl/str-two-way.h | |||
@@ -95,26 +95,37 @@ | |||
95 | A critical factorization has the property that the local period | 95 | A critical factorization has the property that the local period |
96 | equals the global period. All strings have at least one critical | 96 | equals the global period. All strings have at least one critical |
97 | factorization with the left half smaller than the global period. | 97 | factorization with the left half smaller than the global period. |
98 | And while some strings have more than one critical factorization, | ||
99 | it is provable that with an ordered alphabet, at least one of the | ||
100 | critical factorizations corresponds to a maximal suffix. | ||
98 | 101 | ||
99 | Given an ordered alphabet, a critical factorization can be computed | 102 | Given an ordered alphabet, a critical factorization can be computed |
100 | in linear time, with 2 * NEEDLE_LEN comparisons, by computing the | 103 | in linear time, with 2 * NEEDLE_LEN comparisons, by computing the |
101 | larger of two ordered maximal suffixes. The ordered maximal | 104 | shorter of two ordered maximal suffixes. The ordered maximal |
102 | suffixes are determined by lexicographic comparison of | 105 | suffixes are determined by lexicographic comparison while tracking |
103 | periodicity. */ | 106 | periodicity. */ |
104 | static size_t | 107 | static size_t |
105 | critical_factorization (const unsigned char *needle, size_t needle_len, | 108 | critical_factorization (const unsigned char *needle, size_t needle_len, |
106 | size_t *period) | 109 | size_t *period) |
107 | { | 110 | { |
108 | /* Index of last byte of left half, or SIZE_MAX. */ | 111 | /* Index of last byte of left half. */ |
109 | size_t max_suffix, max_suffix_rev; | 112 | size_t max_suffix, max_suffix_rev; |
110 | size_t j; /* Index into NEEDLE for current candidate suffix. */ | 113 | size_t j; /* Index into NEEDLE for current candidate suffix. */ |
111 | size_t k; /* Offset into current period. */ | 114 | size_t k; /* Offset into current period. */ |
112 | size_t p; /* Intermediate period. */ | 115 | size_t p; /* Intermediate period. */ |
113 | unsigned char a, b; /* Current comparison bytes. */ | 116 | unsigned char a, b; /* Current comparison bytes. */ |
114 | 117 | ||
118 | /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered | ||
119 | out 0-length needles. */ | ||
120 | if (needle_len < 3) | ||
121 | { | ||
122 | *period = 1; | ||
123 | return needle_len - 1; | ||
124 | } | ||
125 | |||
115 | /* Invariants: | 126 | /* Invariants: |
116 | 0 <= j < NEEDLE_LEN - 1 | 127 | 1 <= j < NEEDLE_LEN - 1 |
117 | -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) | 128 | 0 <= max_suffix{,_rev} < j |
118 | min(max_suffix, max_suffix_rev) < global period of NEEDLE | 129 | min(max_suffix, max_suffix_rev) < global period of NEEDLE |
119 | 1 <= p <= global period of NEEDLE | 130 | 1 <= p <= global period of NEEDLE |
120 | p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] | 131 | p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] |
@@ -122,9 +133,8 @@ critical_factorization (const unsigned char *needle, size_t needle_len, | |||
122 | */ | 133 | */ |
123 | 134 | ||
124 | /* Perform lexicographic search. */ | 135 | /* Perform lexicographic search. */ |
125 | max_suffix = SIZE_MAX; | 136 | max_suffix = 0; |
126 | j = 0; | 137 | j = k = p = 1; |
127 | k = p = 1; | ||
128 | while (j + k < needle_len) | 138 | while (j + k < needle_len) |
129 | { | 139 | { |
130 | a = CANON_ELEMENT (needle[j + k]); | 140 | a = CANON_ELEMENT (needle[j + k]); |
@@ -157,9 +167,8 @@ critical_factorization (const unsigned char *needle, size_t needle_len, | |||
157 | *period = p; | 167 | *period = p; |
158 | 168 | ||
159 | /* Perform reverse lexicographic search. */ | 169 | /* Perform reverse lexicographic search. */ |
160 | max_suffix_rev = SIZE_MAX; | 170 | max_suffix_rev = 0; |
161 | j = 0; | 171 | j = k = p = 1; |
162 | k = p = 1; | ||
163 | while (j + k < needle_len) | 172 | while (j + k < needle_len) |
164 | { | 173 | { |
165 | a = CANON_ELEMENT (needle[j + k]); | 174 | a = CANON_ELEMENT (needle[j + k]); |
@@ -190,8 +199,20 @@ critical_factorization (const unsigned char *needle, size_t needle_len, | |||
190 | } | 199 | } |
191 | } | 200 | } |
192 | 201 | ||
193 | /* Choose the longer suffix. Return the first byte of the right | 202 | /* Choose the shorter suffix. Return the index of the first byte of |
194 | half, rather than the last byte of the left half. */ | 203 | the right half, rather than the last byte of the left half. |
204 | |||
205 | For some examples, 'banana' has two critical factorizations, both | ||
206 | exposed by the two lexicographic extreme suffixes of 'anana' and | ||
207 | 'nana', where both suffixes have a period of 2. On the other | ||
208 | hand, with 'aab' and 'bba', both strings have a single critical | ||
209 | factorization of the last byte, with the suffix having a period | ||
210 | of 1. While the maximal lexicographic suffix of 'aab' is 'b', | ||
211 | the maximal lexicographic suffix of 'bba' is 'ba', which is not a | ||
212 | critical factorization. Conversely, the maximal reverse | ||
213 | lexicographic suffix of 'a' works for 'bba', but not 'ab' for | ||
214 | 'aab'. The shorter suffix of the two will always be a critical | ||
215 | factorization. */ | ||
195 | if (max_suffix_rev + 1 < max_suffix + 1) | 216 | if (max_suffix_rev + 1 < max_suffix + 1) |
196 | return max_suffix + 1; | 217 | return max_suffix + 1; |
197 | *period = p; | 218 | *period = p; |
@@ -226,9 +247,9 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, | |||
226 | first. */ | 247 | first. */ |
227 | if (CMP_FUNC (needle, needle + period, suffix) == 0) | 248 | if (CMP_FUNC (needle, needle + period, suffix) == 0) |
228 | { | 249 | { |
229 | /* Entire needle is periodic; a mismatch can only advance by the | 250 | /* Entire needle is periodic; a mismatch in the left half can |
230 | period, so use memory to avoid rescanning known occurrences | 251 | only advance by the period, so use memory to avoid rescanning |
231 | of the period. */ | 252 | known occurrences of the period in the right half. */ |
232 | size_t memory = 0; | 253 | size_t memory = 0; |
233 | j = 0; | 254 | j = 0; |
234 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) | 255 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
@@ -330,9 +351,9 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, | |||
330 | first. */ | 351 | first. */ |
331 | if (CMP_FUNC (needle, needle + period, suffix) == 0) | 352 | if (CMP_FUNC (needle, needle + period, suffix) == 0) |
332 | { | 353 | { |
333 | /* Entire needle is periodic; a mismatch can only advance by the | 354 | /* Entire needle is periodic; a mismatch in the left half can |
334 | period, so use memory to avoid rescanning known occurrences | 355 | only advance by the period, so use memory to avoid rescanning |
335 | of the period. */ | 356 | known occurrences of the period in the right half. */ |
336 | size_t memory = 0; | 357 | size_t memory = 0; |
337 | size_t shift; | 358 | size_t shift; |
338 | j = 0; | 359 | j = 0; |
diff --git a/gl/string.in.h b/gl/string.in.h index 13c0f09..f64fce3 100644 --- a/gl/string.in.h +++ b/gl/string.in.h | |||
@@ -41,10 +41,12 @@ | |||
41 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | 41 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) |
42 | # define __attribute__(Spec) /* empty */ | 42 | # define __attribute__(Spec) /* empty */ |
43 | # endif | 43 | # endif |
44 | #endif | ||
44 | /* The attribute __pure__ was added in gcc 2.96. */ | 45 | /* The attribute __pure__ was added in gcc 2.96. */ |
45 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) | 46 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) |
46 | # define __pure__ /* empty */ | 47 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
47 | # endif | 48 | #else |
49 | # define _GL_ATTRIBUTE_PURE /* empty */ | ||
48 | #endif | 50 | #endif |
49 | 51 | ||
50 | 52 | ||
@@ -62,13 +64,13 @@ | |||
62 | # define memchr rpl_memchr | 64 | # define memchr rpl_memchr |
63 | # endif | 65 | # endif |
64 | _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) | 66 | _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) |
65 | __attribute__ ((__pure__)) | 67 | _GL_ATTRIBUTE_PURE |
66 | _GL_ARG_NONNULL ((1))); | 68 | _GL_ARG_NONNULL ((1))); |
67 | _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); | 69 | _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); |
68 | # else | 70 | # else |
69 | # if ! @HAVE_MEMCHR@ | 71 | # if ! @HAVE_MEMCHR@ |
70 | _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) | 72 | _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) |
71 | __attribute__ ((__pure__)) | 73 | _GL_ATTRIBUTE_PURE |
72 | _GL_ARG_NONNULL ((1))); | 74 | _GL_ARG_NONNULL ((1))); |
73 | # endif | 75 | # endif |
74 | /* On some systems, this function is defined as an overloaded function: | 76 | /* On some systems, this function is defined as an overloaded function: |
@@ -102,7 +104,8 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " | |||
102 | _GL_FUNCDECL_RPL (memmem, void *, | 104 | _GL_FUNCDECL_RPL (memmem, void *, |
103 | (void const *__haystack, size_t __haystack_len, | 105 | (void const *__haystack, size_t __haystack_len, |
104 | void const *__needle, size_t __needle_len) | 106 | void const *__needle, size_t __needle_len) |
105 | __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); | 107 | _GL_ATTRIBUTE_PURE |
108 | _GL_ARG_NONNULL ((1, 3))); | ||
106 | _GL_CXXALIAS_RPL (memmem, void *, | 109 | _GL_CXXALIAS_RPL (memmem, void *, |
107 | (void const *__haystack, size_t __haystack_len, | 110 | (void const *__haystack, size_t __haystack_len, |
108 | void const *__needle, size_t __needle_len)); | 111 | void const *__needle, size_t __needle_len)); |
@@ -111,7 +114,8 @@ _GL_CXXALIAS_RPL (memmem, void *, | |||
111 | _GL_FUNCDECL_SYS (memmem, void *, | 114 | _GL_FUNCDECL_SYS (memmem, void *, |
112 | (void const *__haystack, size_t __haystack_len, | 115 | (void const *__haystack, size_t __haystack_len, |
113 | void const *__needle, size_t __needle_len) | 116 | void const *__needle, size_t __needle_len) |
114 | __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); | 117 | _GL_ATTRIBUTE_PURE |
118 | _GL_ARG_NONNULL ((1, 3))); | ||
115 | # endif | 119 | # endif |
116 | _GL_CXXALIAS_SYS (memmem, void *, | 120 | _GL_CXXALIAS_SYS (memmem, void *, |
117 | (void const *__haystack, size_t __haystack_len, | 121 | (void const *__haystack, size_t __haystack_len, |
@@ -152,7 +156,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " | |||
152 | #if @GNULIB_MEMRCHR@ | 156 | #if @GNULIB_MEMRCHR@ |
153 | # if ! @HAVE_DECL_MEMRCHR@ | 157 | # if ! @HAVE_DECL_MEMRCHR@ |
154 | _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) | 158 | _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) |
155 | __attribute__ ((__pure__)) | 159 | _GL_ATTRIBUTE_PURE |
156 | _GL_ARG_NONNULL ((1))); | 160 | _GL_ARG_NONNULL ((1))); |
157 | # endif | 161 | # endif |
158 | /* On some systems, this function is defined as an overloaded function: | 162 | /* On some systems, this function is defined as an overloaded function: |
@@ -182,7 +186,7 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " | |||
182 | #if @GNULIB_RAWMEMCHR@ | 186 | #if @GNULIB_RAWMEMCHR@ |
183 | # if ! @HAVE_RAWMEMCHR@ | 187 | # if ! @HAVE_RAWMEMCHR@ |
184 | _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) | 188 | _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) |
185 | __attribute__ ((__pure__)) | 189 | _GL_ATTRIBUTE_PURE |
186 | _GL_ARG_NONNULL ((1))); | 190 | _GL_ARG_NONNULL ((1))); |
187 | # endif | 191 | # endif |
188 | /* On some systems, this function is defined as an overloaded function: | 192 | /* On some systems, this function is defined as an overloaded function: |
@@ -272,7 +276,7 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " | |||
272 | #if @GNULIB_STRCHRNUL@ | 276 | #if @GNULIB_STRCHRNUL@ |
273 | # if ! @HAVE_STRCHRNUL@ | 277 | # if ! @HAVE_STRCHRNUL@ |
274 | _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) | 278 | _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) |
275 | __attribute__ ((__pure__)) | 279 | _GL_ATTRIBUTE_PURE |
276 | _GL_ARG_NONNULL ((1))); | 280 | _GL_ARG_NONNULL ((1))); |
277 | # endif | 281 | # endif |
278 | /* On some systems, this function is defined as an overloaded function: | 282 | /* On some systems, this function is defined as an overloaded function: |
@@ -378,13 +382,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " | |||
378 | # define strnlen rpl_strnlen | 382 | # define strnlen rpl_strnlen |
379 | # endif | 383 | # endif |
380 | _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) | 384 | _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) |
381 | __attribute__ ((__pure__)) | 385 | _GL_ATTRIBUTE_PURE |
382 | _GL_ARG_NONNULL ((1))); | 386 | _GL_ARG_NONNULL ((1))); |
383 | _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); | 387 | _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); |
384 | # else | 388 | # else |
385 | # if ! @HAVE_DECL_STRNLEN@ | 389 | # if ! @HAVE_DECL_STRNLEN@ |
386 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) | 390 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) |
387 | __attribute__ ((__pure__)) | 391 | _GL_ATTRIBUTE_PURE |
388 | _GL_ARG_NONNULL ((1))); | 392 | _GL_ARG_NONNULL ((1))); |
389 | # endif | 393 | # endif |
390 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); | 394 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); |
@@ -414,7 +418,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " | |||
414 | #if @GNULIB_STRPBRK@ | 418 | #if @GNULIB_STRPBRK@ |
415 | # if ! @HAVE_STRPBRK@ | 419 | # if ! @HAVE_STRPBRK@ |
416 | _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) | 420 | _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) |
417 | __attribute__ ((__pure__)) | 421 | _GL_ATTRIBUTE_PURE |
418 | _GL_ARG_NONNULL ((1, 2))); | 422 | _GL_ARG_NONNULL ((1, 2))); |
419 | # endif | 423 | # endif |
420 | /* On some systems, this function is defined as an overloaded function: | 424 | /* On some systems, this function is defined as an overloaded function: |
@@ -514,7 +518,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - " | |||
514 | # define strstr rpl_strstr | 518 | # define strstr rpl_strstr |
515 | # endif | 519 | # endif |
516 | _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) | 520 | _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) |
517 | __attribute__ ((__pure__)) | 521 | _GL_ATTRIBUTE_PURE |
518 | _GL_ARG_NONNULL ((1, 2))); | 522 | _GL_ARG_NONNULL ((1, 2))); |
519 | _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); | 523 | _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); |
520 | # else | 524 | # else |
@@ -556,14 +560,16 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " | |||
556 | # endif | 560 | # endif |
557 | _GL_FUNCDECL_RPL (strcasestr, char *, | 561 | _GL_FUNCDECL_RPL (strcasestr, char *, |
558 | (const char *haystack, const char *needle) | 562 | (const char *haystack, const char *needle) |
559 | __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); | 563 | _GL_ATTRIBUTE_PURE |
564 | _GL_ARG_NONNULL ((1, 2))); | ||
560 | _GL_CXXALIAS_RPL (strcasestr, char *, | 565 | _GL_CXXALIAS_RPL (strcasestr, char *, |
561 | (const char *haystack, const char *needle)); | 566 | (const char *haystack, const char *needle)); |
562 | # else | 567 | # else |
563 | # if ! @HAVE_STRCASESTR@ | 568 | # if ! @HAVE_STRCASESTR@ |
564 | _GL_FUNCDECL_SYS (strcasestr, char *, | 569 | _GL_FUNCDECL_SYS (strcasestr, char *, |
565 | (const char *haystack, const char *needle) | 570 | (const char *haystack, const char *needle) |
566 | __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); | 571 | _GL_ATTRIBUTE_PURE |
572 | _GL_ARG_NONNULL ((1, 2))); | ||
567 | # endif | 573 | # endif |
568 | /* On some systems, this function is defined as an overloaded function: | 574 | /* On some systems, this function is defined as an overloaded function: |
569 | extern "C++" { const char * strcasestr (const char *, const char *); } | 575 | extern "C++" { const char * strcasestr (const char *, const char *); } |