aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBill Wohler2013-02-18 10:11:43 -0800
committerBill Wohler2013-02-18 10:11:43 -0800
commit21733e4f154f8830fa568a347a0d6dbd59793c2b (patch)
tree3170dbbcdfafeb42f6c381d6b80b251e9f31b788 /lib
parent6d14beddb06b5ae86f9dd770a1661ebd24846f28 (diff)
parent587feed443522f738b65b57b22a31cc8a25525c5 (diff)
downloademacs-21733e4f154f8830fa568a347a0d6dbd59793c2b.tar.gz
emacs-21733e4f154f8830fa568a347a0d6dbd59793c2b.zip
Merge from trunk; up to 2013-02-18T01:30:27Z!monnier@iro.umontreal.ca.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/alloca.in.h2
-rw-r--r--lib/allocator.h2
-rw-r--r--lib/at-func.c2
-rw-r--r--lib/c-ctype.c2
-rw-r--r--lib/c-ctype.h2
-rw-r--r--lib/c-strcase.h2
-rw-r--r--lib/c-strcasecmp.c2
-rw-r--r--lib/c-strncasecmp.c2
-rw-r--r--lib/careadlinkat.c17
-rw-r--r--lib/careadlinkat.h11
-rw-r--r--lib/close-stream.c2
-rw-r--r--lib/dirent.in.h258
-rw-r--r--lib/dosname.h2
-rw-r--r--lib/dtotimespec.c2
-rw-r--r--lib/dup2.c5
-rw-r--r--lib/euidaccess.c2
-rw-r--r--lib/execinfo.in.h2
-rw-r--r--lib/faccessat.c2
-rw-r--r--lib/fcntl.in.h2
-rw-r--r--lib/fdopendir.c204
-rw-r--r--lib/filemode.c4
-rw-r--r--lib/filemode.h2
-rw-r--r--lib/fpending.c2
-rw-r--r--lib/fpending.h2
-rw-r--r--lib/fstatat.c135
-rw-r--r--lib/ftoastr.c2
-rw-r--r--lib/ftoastr.h2
-rw-r--r--lib/getgroups.c2
-rw-r--r--lib/getloadavg.c2
-rw-r--r--lib/getopt.c2
-rw-r--r--lib/getopt.in.h4
-rw-r--r--lib/getopt1.c2
-rw-r--r--lib/getopt_.h6
-rw-r--r--lib/getopt_int.h2
-rw-r--r--lib/gettext.h2
-rw-r--r--lib/gettime.c2
-rw-r--r--lib/gettimeofday.c2
-rw-r--r--lib/gnulib.mk211
-rw-r--r--lib/group-member.c2
-rw-r--r--lib/ignore-value.h2
-rw-r--r--lib/intprops.h2
-rw-r--r--lib/inttypes.in.h2
-rw-r--r--lib/lstat.c2
-rw-r--r--lib/makefile.w32-in12
-rw-r--r--lib/md5.c2
-rw-r--r--lib/md5.h2
-rw-r--r--lib/memrchr.c161
-rw-r--r--lib/mktime.c2
-rw-r--r--lib/openat-die.c6
-rw-r--r--lib/openat-priv.h64
-rw-r--r--lib/openat-proc.c110
-rw-r--r--lib/openat.h120
-rw-r--r--lib/pathmax.h2
-rw-r--r--lib/pselect.c2
-rw-r--r--lib/pthread_sigmask.c2
-rw-r--r--lib/putenv.c2
-rw-r--r--lib/readlink.c2
-rw-r--r--lib/readlinkat.c47
-rw-r--r--lib/root-uid.h2
-rw-r--r--lib/save-cwd.c3
-rw-r--r--lib/save-cwd.h46
-rw-r--r--lib/sha1.c2
-rw-r--r--lib/sha1.h2
-rw-r--r--lib/sha256.c2
-rw-r--r--lib/sha256.h2
-rw-r--r--lib/sha512.c2
-rw-r--r--lib/sha512.h2
-rw-r--r--lib/sig2str.c2
-rw-r--r--lib/sig2str.h2
-rw-r--r--lib/signal.in.h2
-rw-r--r--lib/stat-time.h2
-rw-r--r--lib/stat.c2
-rw-r--r--lib/stdalign.in.h2
-rw-r--r--lib/stdarg.in.h2
-rw-r--r--lib/stdbool.in.h2
-rw-r--r--lib/stddef.in.h2
-rw-r--r--lib/stdint.in.h4
-rw-r--r--lib/stdio.c3
-rw-r--r--lib/stdio.in.h29
-rw-r--r--lib/stdlib.in.h23
-rw-r--r--lib/strftime.c16
-rw-r--r--lib/strftime.h2
-rw-r--r--lib/string.in.h1029
-rw-r--r--lib/strtoimax.c2
-rw-r--r--lib/strtol.c2
-rw-r--r--lib/strtoll.c2
-rw-r--r--lib/strtoul.c2
-rw-r--r--lib/strtoull.c2
-rw-r--r--lib/symlink.c2
-rw-r--r--lib/sys_select.in.h19
-rw-r--r--lib/sys_stat.in.h6
-rw-r--r--lib/sys_time.in.h190
-rw-r--r--lib/sys_types.in.h2
-rw-r--r--lib/time.in.h2
-rw-r--r--lib/time_r.c2
-rw-r--r--lib/timespec-add.c2
-rw-r--r--lib/timespec-sub.c2
-rw-r--r--lib/timespec.h2
-rw-r--r--lib/u64.h2
-rw-r--r--lib/unistd.in.h25
-rw-r--r--lib/unsetenv.c6
-rw-r--r--lib/utimens.c2
-rw-r--r--lib/utimens.h2
-rw-r--r--lib/verify.h2
-rw-r--r--lib/xalloc-oversized.h2
106 files changed, 2655 insertions, 271 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 28fdafd4b45..a341609e895 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -8,3 +8,5 @@ AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
8DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src 8DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src
9 9
10include gnulib.mk 10include gnulib.mk
11
12libgnu_a_SOURCES += openat-die.c save-cwd.c
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index d20f4b8f1c3..72d28ee3066 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -1,6 +1,6 @@
1/* Memory allocation on the stack. 1/* Memory allocation on the stack.
2 2
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2012 Free Software Foundation, 3 Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
diff --git a/lib/allocator.h b/lib/allocator.h
index 81c4aa20a45..b71fbbbb53c 100644
--- a/lib/allocator.h
+++ b/lib/allocator.h
@@ -1,6 +1,6 @@
1/* Memory allocators such as malloc+free. 1/* Memory allocators such as malloc+free.
2 2
3 Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/at-func.c b/lib/at-func.c
index 481eea475a1..03c56788b08 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -1,5 +1,5 @@
1/* Define at-style functions like fstatat, unlinkat, fchownat, etc. 1/* Define at-style functions like fstatat, unlinkat, fchownat, etc.
2 Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/c-ctype.c b/lib/c-ctype.c
index 952d7a851f3..752d2e32aed 100644
--- a/lib/c-ctype.c
+++ b/lib/c-ctype.c
@@ -1,6 +1,6 @@
1/* Character handling in C locale. 1/* Character handling in C locale.
2 2
3 Copyright 2000-2003, 2006, 2009-2012 Free Software Foundation, Inc. 3 Copyright 2000-2003, 2006, 2009-2013 Free Software Foundation, Inc.
4 4
5This program is free software; you can redistribute it and/or modify 5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index 0b31309e960..3a66440ae9e 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -5,7 +5,7 @@
5 <ctype.h> functions' behaviour depends on the current locale set via 5 <ctype.h> functions' behaviour depends on the current locale set via
6 setlocale. 6 setlocale.
7 7
8 Copyright (C) 2000-2003, 2006, 2008-2012 Free Software Foundation, Inc. 8 Copyright (C) 2000-2003, 2006, 2008-2013 Free Software Foundation, Inc.
9 9
10This program is free software; you can redistribute it and/or modify 10This program is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by 11it under the terms of the GNU General Public License as published by
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index fdef2385eaf..49e1bb03dd0 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -1,5 +1,5 @@
1/* Case-insensitive string comparison functions in C locale. 1/* Case-insensitive string comparison functions in C locale.
2 Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2012 Free Software 2 Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index d8332caf839..ef85f0e67db 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -1,5 +1,5 @@
1/* c-strcasecmp.c -- case insensitive string comparator in C locale 1/* c-strcasecmp.c -- case insensitive string comparator in C locale
2 Copyright (C) 1998-1999, 2005-2006, 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2006, 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index 47fb5fdb678..04404b00cd4 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -1,5 +1,5 @@
1/* c-strncasecmp.c -- case insensitive string comparator in C locale 1/* c-strncasecmp.c -- case insensitive string comparator in C locale
2 Copyright (C) 1998-1999, 2005-2006, 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2006, 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c
index cd4aa846dca..e2c19d1c1f1 100644
--- a/lib/careadlinkat.c
+++ b/lib/careadlinkat.c
@@ -1,6 +1,6 @@
1/* Read symbolic links into a buffer without size limitation, relative to fd. 1/* Read symbolic links into a buffer without size limitation, relative to fd.
2 2
3 Copyright (C) 2001, 2003-2004, 2007, 2009-2012 Free Software Foundation, 3 Copyright (C) 2001, 2003-2004, 2007, 2009-2013 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
@@ -24,7 +24,6 @@
24 24
25#include <errno.h> 25#include <errno.h>
26#include <limits.h> 26#include <limits.h>
27#include <stdlib.h>
28#include <string.h> 27#include <string.h>
29#include <unistd.h> 28#include <unistd.h>
30 29
@@ -39,20 +38,6 @@
39 38
40#include "allocator.h" 39#include "allocator.h"
41 40
42/* Get the symbolic link value of FILENAME and put it into BUFFER, with
43 size BUFFER_SIZE. This function acts like readlink but has
44 readlinkat's signature. */
45ssize_t
46careadlinkatcwd (int fd, char const *filename, char *buffer,
47 size_t buffer_size)
48{
49 /* FD must be AT_FDCWD here, otherwise the caller is using this
50 function in contexts for which it was not meant for. */
51 if (fd != AT_FDCWD)
52 abort ();
53 return readlink (filename, buffer, buffer_size);
54}
55
56/* Assuming the current directory is FD, get the symbolic link value 41/* Assuming the current directory is FD, get the symbolic link value
57 of FILENAME as a null-terminated string and put it into a buffer. 42 of FILENAME as a null-terminated string and put it into a buffer.
58 If FD is AT_FDCWD, FILENAME is interpreted relative to the current 43 If FD is AT_FDCWD, FILENAME is interpreted relative to the current
diff --git a/lib/careadlinkat.h b/lib/careadlinkat.h
index c21d3f459cd..46f88ae288a 100644
--- a/lib/careadlinkat.h
+++ b/lib/careadlinkat.h
@@ -1,6 +1,6 @@
1/* Read symbolic links into a buffer without size limitation, relative to fd. 1/* Read symbolic links into a buffer without size limitation, relative to fd.
2 2
3 Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -52,21 +52,16 @@ char *careadlinkat (int fd, char const *filename,
52 ssize_t (*preadlinkat) (int, char const *, 52 ssize_t (*preadlinkat) (int, char const *,
53 char *, size_t)); 53 char *, size_t));
54 54
55/* Suitable values for careadlinkat's FD and PREADLINKAT arguments, 55/* Suitable value for careadlinkat's FD argument. */
56 when doing a plain readlink:
57 Pass FD = AT_FDCWD and PREADLINKAT = careadlinkatcwd. */
58#if HAVE_READLINKAT 56#if HAVE_READLINKAT
59/* AT_FDCWD is declared in <fcntl.h>. */ 57/* AT_FDCWD is declared in <fcntl.h>. */
60#else 58#else
61/* Define AT_FDCWD independently, so that the careadlinkat module does 59/* Define AT_FDCWD independently, so that the careadlinkat module does
62 not depend on the fcntl-h module. The value does not matter, since 60 not depend on the fcntl-h module. We might as well use the same value
63 careadlinkatcwd ignores it, but we might as well use the same value
64 as fcntl-h. */ 61 as fcntl-h. */
65# ifndef AT_FDCWD 62# ifndef AT_FDCWD
66# define AT_FDCWD (-3041965) 63# define AT_FDCWD (-3041965)
67# endif 64# endif
68#endif 65#endif
69ssize_t careadlinkatcwd (int fd, char const *filename,
70 char *buffer, size_t buffer_size);
71 66
72#endif /* _GL_CAREADLINKAT_H */ 67#endif /* _GL_CAREADLINKAT_H */
diff --git a/lib/close-stream.c b/lib/close-stream.c
index 04fa5ece09d..d6a869287e3 100644
--- a/lib/close-stream.c
+++ b/lib/close-stream.c
@@ -1,6 +1,6 @@
1/* Close a stream, with nicer error checking than fclose's. 1/* Close a stream, with nicer error checking than fclose's.
2 2
3 Copyright (C) 1998-2002, 2004, 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 1998-2002, 2004, 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
new file mode 100644
index 00000000000..fad3797b8ba
--- /dev/null
+++ b/lib/dirent.in.h
@@ -0,0 +1,258 @@
1/* A GNU-like <dirent.h>.
2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _@GUARD_PREFIX@_DIRENT_H
18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
24/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_DIRENT_H@
26# @INCLUDE_NEXT@ @NEXT_DIRENT_H@
27#endif
28
29#ifndef _@GUARD_PREFIX@_DIRENT_H
30#define _@GUARD_PREFIX@_DIRENT_H
31
32/* Get ino_t. Needed on some systems, including glibc 2.8. */
33#include <sys/types.h>
34
35#if !@HAVE_DIRENT_H@
36/* Define types DIR and 'struct dirent'. */
37# if !GNULIB_defined_struct_dirent
38struct dirent
39{
40 char d_type;
41 char d_name[1];
42};
43/* Possible values for 'd_type'. */
44# define DT_UNKNOWN 0
45# define DT_FIFO 1 /* FIFO */
46# define DT_CHR 2 /* character device */
47# define DT_DIR 4 /* directory */
48# define DT_BLK 6 /* block device */
49# define DT_REG 8 /* regular file */
50# define DT_LNK 10 /* symbolic link */
51# define DT_SOCK 12 /* socket */
52# define DT_WHT 14 /* whiteout */
53typedef struct gl_directory DIR;
54# define GNULIB_defined_struct_dirent 1
55# endif
56#endif
57
58/* The __attribute__ feature is available in gcc versions 2.5 and later.
59 The attribute __pure__ was added in gcc 2.96. */
60#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
61# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
62#else
63# define _GL_ATTRIBUTE_PURE /* empty */
64#endif
65
66/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
67
68/* The definition of _GL_ARG_NONNULL is copied here. */
69
70/* The definition of _GL_WARN_ON_USE is copied here. */
71
72
73/* Declare overridden functions. */
74
75#if @GNULIB_OPENDIR@
76# if @REPLACE_OPENDIR@
77# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
78# undef opendir
79# define opendir rpl_opendir
80# endif
81_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
82_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
83# else
84# if !@HAVE_OPENDIR@
85_GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
86# endif
87_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
88# endif
89_GL_CXXALIASWARN (opendir);
90#elif defined GNULIB_POSIXCHECK
91# undef opendir
92# if HAVE_RAW_DECL_OPENDIR
93_GL_WARN_ON_USE (opendir, "opendir is not portable - "
94 "use gnulib module opendir for portability");
95# endif
96#endif
97
98#if @GNULIB_READDIR@
99# if !@HAVE_READDIR@
100_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
101# endif
102_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
103_GL_CXXALIASWARN (readdir);
104#elif defined GNULIB_POSIXCHECK
105# undef readdir
106# if HAVE_RAW_DECL_READDIR
107_GL_WARN_ON_USE (readdir, "readdir is not portable - "
108 "use gnulib module readdir for portability");
109# endif
110#endif
111
112#if @GNULIB_REWINDDIR@
113# if !@HAVE_REWINDDIR@
114_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
115# endif
116_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
117_GL_CXXALIASWARN (rewinddir);
118#elif defined GNULIB_POSIXCHECK
119# undef rewinddir
120# if HAVE_RAW_DECL_REWINDDIR
121_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
122 "use gnulib module rewinddir for portability");
123# endif
124#endif
125
126#if @GNULIB_CLOSEDIR@
127# if @REPLACE_CLOSEDIR@
128# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
129# undef closedir
130# define closedir rpl_closedir
131# endif
132_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
133_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
134# else
135# if !@HAVE_CLOSEDIR@
136_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
137# endif
138_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
139# endif
140_GL_CXXALIASWARN (closedir);
141#elif defined GNULIB_POSIXCHECK
142# undef closedir
143# if HAVE_RAW_DECL_CLOSEDIR
144_GL_WARN_ON_USE (closedir, "closedir is not portable - "
145 "use gnulib module closedir for portability");
146# endif
147#endif
148
149#if @GNULIB_DIRFD@
150/* Return the file descriptor associated with the given directory stream,
151 or -1 if none exists. */
152# if @REPLACE_DIRFD@
153# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
154# undef dirfd
155# define dirfd rpl_dirfd
156# endif
157_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
158_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
159# else
160# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
161 /* dirfd is defined as a macro and not as a function.
162 Turn it into a function and get rid of the macro. */
163static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
164# undef dirfd
165# endif
166# if !(@HAVE_DECL_DIRFD@ || defined dirfd)
167_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
168# endif
169_GL_CXXALIAS_SYS (dirfd, int, (DIR *));
170# endif
171_GL_CXXALIASWARN (dirfd);
172#elif defined GNULIB_POSIXCHECK
173# undef dirfd
174# if HAVE_RAW_DECL_DIRFD
175_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
176 "use gnulib module dirfd for portability");
177# endif
178#endif
179
180#if @GNULIB_FDOPENDIR@
181/* Open a directory stream visiting the given directory file
182 descriptor. Return NULL and set errno if fd is not visiting a
183 directory. On success, this function consumes fd (it will be
184 implicitly closed either by this function or by a subsequent
185 closedir). */
186# if @REPLACE_FDOPENDIR@
187# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
188# undef fdopendir
189# define fdopendir rpl_fdopendir
190# endif
191_GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
192_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
193# else
194# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
195_GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
196# endif
197_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
198# endif
199_GL_CXXALIASWARN (fdopendir);
200#elif defined GNULIB_POSIXCHECK
201# undef fdopendir
202# if HAVE_RAW_DECL_FDOPENDIR
203_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
204 "use gnulib module fdopendir for portability");
205# endif
206#endif
207
208#if @GNULIB_SCANDIR@
209/* Scan the directory DIR, calling FILTER on each directory entry.
210 Entries for which FILTER returns nonzero are individually malloc'd,
211 sorted using qsort with CMP, and collected in a malloc'd array in
212 *NAMELIST. Returns the number of entries selected, or -1 on error. */
213# if !@HAVE_SCANDIR@
214_GL_FUNCDECL_SYS (scandir, int,
215 (const char *dir, struct dirent ***namelist,
216 int (*filter) (const struct dirent *),
217 int (*cmp) (const struct dirent **, const struct dirent **))
218 _GL_ARG_NONNULL ((1, 2, 4)));
219# endif
220/* Need to cast, because on glibc systems, the fourth parameter is
221 int (*cmp) (const void *, const void *). */
222_GL_CXXALIAS_SYS_CAST (scandir, int,
223 (const char *dir, struct dirent ***namelist,
224 int (*filter) (const struct dirent *),
225 int (*cmp) (const struct dirent **, const struct dirent **)));
226_GL_CXXALIASWARN (scandir);
227#elif defined GNULIB_POSIXCHECK
228# undef scandir
229# if HAVE_RAW_DECL_SCANDIR
230_GL_WARN_ON_USE (scandir, "scandir is unportable - "
231 "use gnulib module scandir for portability");
232# endif
233#endif
234
235#if @GNULIB_ALPHASORT@
236/* Compare two 'struct dirent' entries alphabetically. */
237# if !@HAVE_ALPHASORT@
238_GL_FUNCDECL_SYS (alphasort, int,
239 (const struct dirent **, const struct dirent **)
240 _GL_ATTRIBUTE_PURE
241 _GL_ARG_NONNULL ((1, 2)));
242# endif
243/* Need to cast, because on glibc systems, the parameters are
244 (const void *, const void *). */
245_GL_CXXALIAS_SYS_CAST (alphasort, int,
246 (const struct dirent **, const struct dirent **));
247_GL_CXXALIASWARN (alphasort);
248#elif defined GNULIB_POSIXCHECK
249# undef alphasort
250# if HAVE_RAW_DECL_ALPHASORT
251_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
252 "use gnulib module alphasort for portability");
253# endif
254#endif
255
256
257#endif /* _@GUARD_PREFIX@_DIRENT_H */
258#endif /* _@GUARD_PREFIX@_DIRENT_H */
diff --git a/lib/dosname.h b/lib/dosname.h
index 0468ce4dc81..ba63ce4bd37 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -1,6 +1,6 @@
1/* File names on MS-DOS/Windows systems. 1/* File names on MS-DOS/Windows systems.
2 2
3 Copyright (C) 2000-2001, 2004-2006, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c
index f30fa075077..ecce2e5bcc5 100644
--- a/lib/dtotimespec.c
+++ b/lib/dtotimespec.c
@@ -1,6 +1,6 @@
1/* Convert double to timespec. 1/* Convert double to timespec.
2 2
3 Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/dup2.c b/lib/dup2.c
index f6d0f1c73c5..9219eb38238 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -1,6 +1,6 @@
1/* Duplicate an open file descriptor to a specified file descriptor. 1/* Duplicate an open file descriptor to a specified file descriptor.
2 2
3 Copyright (C) 1999, 2004-2007, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 1999, 2004-2007, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -95,7 +95,10 @@ rpl_dup2 (int fd, int desired_fd)
95# ifdef F_GETFL 95# ifdef F_GETFL
96 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. 96 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
97 On Cygwin 1.5.x, dup2 (1, 1) returns 0. 97 On Cygwin 1.5.x, dup2 (1, 1) returns 0.
98 On Cygwin 1.7.17, dup2 (1, -1) dumps core.
98 On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ 99 On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
100 if (desired_fd < 0)
101 fd = desired_fd;
99 if (fd == desired_fd) 102 if (fd == desired_fd)
100 return fcntl (fd, F_GETFL) == -1 ? -1 : fd; 103 return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
101# endif 104# endif
diff --git a/lib/euidaccess.c b/lib/euidaccess.c
index ca2ceca5d22..f73438e6f47 100644
--- a/lib/euidaccess.c
+++ b/lib/euidaccess.c
@@ -1,6 +1,6 @@
1/* euidaccess -- check if effective user id can access file 1/* euidaccess -- check if effective user id can access file
2 2
3 Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2012 Free 3 Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2013 Free
4 Software Foundation, Inc. 4 Software Foundation, Inc.
5 5
6 This file is part of the GNU C Library. 6 This file is part of the GNU C Library.
diff --git a/lib/execinfo.in.h b/lib/execinfo.in.h
index d76b0e1b771..6cfc8d56d2d 100644
--- a/lib/execinfo.in.h
+++ b/lib/execinfo.in.h
@@ -1,6 +1,6 @@
1/* Information about executables. 1/* Information about executables.
2 2
3 Copyright (C) 2012 Free Software Foundation, Inc. 3 Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/faccessat.c b/lib/faccessat.c
index d11a3efaad6..f3c3f6736d2 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -1,5 +1,5 @@
1/* Check the access rights of a file relative to an open directory. 1/* Check the access rights of a file relative to an open directory.
2 Copyright (C) 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 604c31b7984..1e45a65a213 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -1,6 +1,6 @@
1/* Like <fcntl.h>, but with non-working flags defined to 0. 1/* Like <fcntl.h>, but with non-working flags defined to 0.
2 2
3 Copyright (C) 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/fdopendir.c b/lib/fdopendir.c
new file mode 100644
index 00000000000..63e06b92ae8
--- /dev/null
+++ b/lib/fdopendir.c
@@ -0,0 +1,204 @@
1/* provide a replacement fdopendir function
2 Copyright (C) 2004-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* written by Jim Meyering */
18
19#include <config.h>
20
21#include <dirent.h>
22
23#include <stdlib.h>
24#include <unistd.h>
25
26#if !HAVE_FDOPENDIR
27
28# include "openat.h"
29# include "openat-priv.h"
30# include "save-cwd.h"
31
32# if GNULIB_DIRENT_SAFER
33# include "dirent--.h"
34# endif
35
36# ifndef REPLACE_FCHDIR
37# define REPLACE_FCHDIR 0
38# endif
39
40static DIR *fdopendir_with_dup (int, int, struct saved_cwd const *);
41static DIR *fd_clone_opendir (int, struct saved_cwd const *);
42
43/* Replacement for POSIX fdopendir.
44
45 First, try to simulate it via opendir ("/proc/self/fd/..."). Failing
46 that, simulate it by using fchdir metadata, or by doing
47 save_cwd/fchdir/opendir(".")/restore_cwd.
48 If either the save_cwd or the restore_cwd fails (relatively unlikely),
49 then give a diagnostic and exit nonzero.
50
51 If successful, the resulting stream is based on FD in
52 implementations where streams are based on file descriptors and in
53 applications where no other thread or signal handler allocates or
54 frees file descriptors. In other cases, consult dirfd on the result
55 to find out whether FD is still being used.
56
57 Otherwise, this function works just like POSIX fdopendir.
58
59 W A R N I N G:
60
61 Unlike other fd-related functions, this one places constraints on FD.
62 If this function returns successfully, FD is under control of the
63 dirent.h system, and the caller should not close or modify the state of
64 FD other than by the dirent.h functions. */
65DIR *
66fdopendir (int fd)
67{
68 DIR *dir = fdopendir_with_dup (fd, -1, NULL);
69
70 if (! REPLACE_FCHDIR && ! dir)
71 {
72 int saved_errno = errno;
73 if (EXPECTED_ERRNO (saved_errno))
74 {
75 struct saved_cwd cwd;
76 if (save_cwd (&cwd) != 0)
77 openat_save_fail (errno);
78 dir = fdopendir_with_dup (fd, -1, &cwd);
79 saved_errno = errno;
80 free_cwd (&cwd);
81 errno = saved_errno;
82 }
83 }
84
85 return dir;
86}
87
88/* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known
89 to be a dup of FD which is less than FD - 1 and which will be
90 closed by the caller and not otherwise used by the caller. This
91 function makes sure that FD is closed and all file descriptors less
92 than FD are open, and then calls fd_clone_opendir on a dup of FD.
93 That way, barring race conditions, fd_clone_opendir returns a
94 stream whose file descriptor is FD.
95
96 If REPLACE_CHDIR or CWD is null, use opendir ("/proc/self/fd/...",
97 falling back on fchdir metadata. Otherwise, CWD is a saved version
98 of the working directory; use fchdir/opendir(".")/restore_cwd(CWD). */
99static DIR *
100fdopendir_with_dup (int fd, int older_dupfd, struct saved_cwd const *cwd)
101{
102 int dupfd = dup (fd);
103 if (dupfd < 0 && errno == EMFILE)
104 dupfd = older_dupfd;
105 if (dupfd < 0)
106 return NULL;
107 else
108 {
109 DIR *dir;
110 int saved_errno;
111 if (dupfd < fd - 1 && dupfd != older_dupfd)
112 {
113 dir = fdopendir_with_dup (fd, dupfd, cwd);
114 saved_errno = errno;
115 }
116 else
117 {
118 close (fd);
119 dir = fd_clone_opendir (dupfd, cwd);
120 saved_errno = errno;
121 if (! dir)
122 {
123 int fd1 = dup (dupfd);
124 if (fd1 != fd)
125 openat_save_fail (fd1 < 0 ? errno : EBADF);
126 }
127 }
128
129 if (dupfd != older_dupfd)
130 close (dupfd);
131 errno = saved_errno;
132 return dir;
133 }
134}
135
136/* Like fdopendir, except the result controls a clone of FD. It is
137 the caller's responsibility both to close FD and (if the result is
138 not null) to closedir the result. */
139static DIR *
140fd_clone_opendir (int fd, struct saved_cwd const *cwd)
141{
142 if (REPLACE_FCHDIR || ! cwd)
143 {
144 DIR *dir = NULL;
145 int saved_errno = EOPNOTSUPP;
146 char buf[OPENAT_BUFFER_SIZE];
147 char *proc_file = openat_proc_name (buf, fd, ".");
148 if (proc_file)
149 {
150 dir = opendir (proc_file);
151 saved_errno = errno;
152 if (proc_file != buf)
153 free (proc_file);
154 }
155# if REPLACE_FCHDIR
156 if (! dir && EXPECTED_ERRNO (saved_errno))
157 {
158 char const *name = _gl_directory_name (fd);
159 return (name ? opendir (name) : NULL);
160 }
161# endif
162 errno = saved_errno;
163 return dir;
164 }
165 else
166 {
167 if (fchdir (fd) != 0)
168 return NULL;
169 else
170 {
171 DIR *dir = opendir (".");
172 int saved_errno = errno;
173 if (restore_cwd (cwd) != 0)
174 openat_restore_fail (errno);
175 errno = saved_errno;
176 return dir;
177 }
178 }
179}
180
181#else /* HAVE_FDOPENDIR */
182
183# include <errno.h>
184# include <sys/stat.h>
185
186# undef fdopendir
187
188/* Like fdopendir, but work around GNU/Hurd bug by validating FD. */
189
190DIR *
191rpl_fdopendir (int fd)
192{
193 struct stat st;
194 if (fstat (fd, &st))
195 return NULL;
196 if (!S_ISDIR (st.st_mode))
197 {
198 errno = ENOTDIR;
199 return NULL;
200 }
201 return fdopendir (fd);
202}
203
204#endif /* HAVE_FDOPENDIR */
diff --git a/lib/filemode.c b/lib/filemode.c
index ed8c6c989f1..9e8735a5d7d 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -1,6 +1,6 @@
1/* filemode.c -- make a string describing file modes 1/* filemode.c -- make a string describing file modes
2 2
3 Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006, 2009-2012 Free 3 Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006, 2009-2013 Free
4 Software Foundation, Inc. 4 Software Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
@@ -78,7 +78,7 @@ ftypelet (mode_t bits)
78 return 'C'; 78 return 'C';
79 if (S_ISDOOR (bits)) 79 if (S_ISDOOR (bits))
80 return 'D'; 80 return 'D';
81 if (S_ISMPB (bits) || S_ISMPC (bits)) 81 if (S_ISMPB (bits) || S_ISMPC (bits) || S_ISMPX (bits))
82 return 'm'; 82 return 'm';
83 if (S_ISNWK (bits)) 83 if (S_ISNWK (bits))
84 return 'n'; 84 return 'n';
diff --git a/lib/filemode.h b/lib/filemode.h
index 3ca19b85623..a235cb0c106 100644
--- a/lib/filemode.h
+++ b/lib/filemode.h
@@ -1,6 +1,6 @@
1/* Make a string describing file modes. 1/* Make a string describing file modes.
2 2
3 Copyright (C) 1998-1999, 2003, 2006, 2009-2012 Free Software Foundation, 3 Copyright (C) 1998-1999, 2003, 2006, 2009-2013 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/lib/fpending.c b/lib/fpending.c
index 2591d534377..e917f4f15f6 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -1,5 +1,5 @@
1/* fpending.c -- return the number of pending output bytes on a stream 1/* fpending.c -- return the number of pending output bytes on a stream
2 Copyright (C) 2000, 2004, 2006-2007, 2009-2012 Free Software Foundation, 2 Copyright (C) 2000, 2004, 2006-2007, 2009-2013 Free Software Foundation,
3 Inc. 3 Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
diff --git a/lib/fpending.h b/lib/fpending.h
index 0365287ba76..bf40d3732e7 100644
--- a/lib/fpending.h
+++ b/lib/fpending.h
@@ -1,6 +1,6 @@
1/* Declare __fpending. 1/* Declare __fpending.
2 2
3 Copyright (C) 2000, 2003, 2005-2006, 2009-2012 Free Software Foundation, 3 Copyright (C) 2000, 2003, 2005-2006, 2009-2013 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/lib/fstatat.c b/lib/fstatat.c
new file mode 100644
index 00000000000..845c171fb45
--- /dev/null
+++ b/lib/fstatat.c
@@ -0,0 +1,135 @@
1/* Work around an fstatat bug on Solaris 9.
2
3 Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert and Jim Meyering. */
19
20/* If the user's config.h happens to include <sys/stat.h>, let it include only
21 the system's <sys/stat.h> here, so that orig_fstatat doesn't recurse to
22 rpl_fstatat. */
23#define __need_system_sys_stat_h
24#include <config.h>
25
26/* Get the original definition of fstatat. It might be defined as a macro. */
27#include <sys/types.h>
28#include <sys/stat.h>
29#undef __need_system_sys_stat_h
30
31#if HAVE_FSTATAT
32static int
33orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
34{
35 return fstatat (fd, filename, buf, flags);
36}
37#endif
38
39/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
40 eliminates this include because of the preliminary #include <sys/stat.h>
41 above. */
42#include "sys/stat.h"
43
44#include <errno.h>
45#include <fcntl.h>
46#include <string.h>
47
48#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG
49
50# ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK
51# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0
52# endif
53
54/* fstatat should always follow symbolic links that end in /, but on
55 Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified.
56 Likewise, trailing slash on a non-directory should be an error.
57 These are the same problems that lstat.c and stat.c address, so
58 solve it in a similar way.
59
60 AIX 7.1 fstatat (AT_FDCWD, ..., 0) always fails, which is a bug.
61 Work around this bug if FSTATAT_AT_FDCWD_0_BROKEN is nonzero. */
62
63int
64rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
65{
66 int result = orig_fstatat (fd, file, st, flag);
67 size_t len;
68
69 if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0)
70 return result;
71 len = strlen (file);
72 if (flag & AT_SYMLINK_NOFOLLOW)
73 {
74 /* Fix lstat behavior. */
75 if (file[len - 1] != '/' || S_ISDIR (st->st_mode))
76 return 0;
77 if (!S_ISLNK (st->st_mode))
78 {
79 errno = ENOTDIR;
80 return -1;
81 }
82 result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
83 }
84 /* Fix stat behavior. */
85 if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/')
86 {
87 errno = ENOTDIR;
88 return -1;
89 }
90 return result;
91}
92
93#else /* ! (HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG) */
94
95/* On mingw, the gnulib <sys/stat.h> defines 'stat' as a function-like
96 macro; but using it in AT_FUNC_F2 causes compilation failure
97 because the preprocessor sees a use of a macro that requires two
98 arguments but is only given one. Hence, we need an inline
99 forwarder to get past the preprocessor. */
100static int
101stat_func (char const *name, struct stat *st)
102{
103 return stat (name, st);
104}
105
106/* Likewise, if there is no native 'lstat', then the gnulib
107 <sys/stat.h> defined it as stat, which also needs adjustment. */
108# if !HAVE_LSTAT
109# undef lstat
110# define lstat stat_func
111# endif
112
113/* Replacement for Solaris' function by the same name.
114 <http://www.google.com/search?q=fstatat+site:docs.sun.com>
115 First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE").
116 Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd.
117 If either the save_cwd or the restore_cwd fails (relatively unlikely),
118 then give a diagnostic and exit nonzero.
119 Otherwise, this function works just like Solaris' fstatat. */
120
121# define AT_FUNC_NAME fstatat
122# define AT_FUNC_F1 lstat
123# define AT_FUNC_F2 stat_func
124# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
125# define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag
126# define AT_FUNC_POST_FILE_ARGS , st
127# include "at-func.c"
128# undef AT_FUNC_NAME
129# undef AT_FUNC_F1
130# undef AT_FUNC_F2
131# undef AT_FUNC_USE_F1_COND
132# undef AT_FUNC_POST_FILE_PARAM_DECLS
133# undef AT_FUNC_POST_FILE_ARGS
134
135#endif /* !HAVE_FSTATAT */
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index ebeed3e1347..518074f8a5a 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -1,6 +1,6 @@
1/* floating point to accurate string 1/* floating point to accurate string
2 2
3 Copyright (C) 2010-2012 Free Software Foundation, Inc. 3 Copyright (C) 2010-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
index 89869a2238f..5aa0930d29e 100644
--- a/lib/ftoastr.h
+++ b/lib/ftoastr.h
@@ -1,6 +1,6 @@
1/* floating point to accurate string 1/* floating point to accurate string
2 2
3 Copyright (C) 2010-2012 Free Software Foundation, Inc. 3 Copyright (C) 2010-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/getgroups.c b/lib/getgroups.c
index f9d36236afe..9856adc1a4d 100644
--- a/lib/getgroups.c
+++ b/lib/getgroups.c
@@ -1,6 +1,6 @@
1/* provide consistent interface to getgroups for systems that don't allow N==0 1/* provide consistent interface to getgroups for systems that don't allow N==0
2 2
3 Copyright (C) 1996, 1999, 2003, 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 1996, 1999, 2003, 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index a8ffefee33f..6e228191ee8 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -1,6 +1,6 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 2
3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2012 Free Software 3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with gnulib. 6 NOTE: The canonical source of this file is maintained with gnulib.
diff --git a/lib/getopt.c b/lib/getopt.c
index 4342a34104c..ef0f4ceec7c 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -2,7 +2,7 @@
2 NOTE: getopt is part of the C library, so if you don't know what 2 NOTE: getopt is part of the C library, so if you don't know what
3 "Keep this file name-space clean" means, talk to drepper@gnu.org 3 "Keep this file name-space clean" means, talk to drepper@gnu.org
4 before changing it! 4 before changing it!
5 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2012 Free Software 5 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software
6 Foundation, Inc. 6 Foundation, Inc.
7 This file is part of the GNU C Library. 7 This file is part of the GNU C Library.
8 8
diff --git a/lib/getopt.in.h b/lib/getopt.in.h
index 06b6dfc50c2..d9c7d8144ae 100644
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -1,5 +1,5 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2012 Free Software 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
@@ -49,7 +49,9 @@
49 linkers. */ 49 linkers. */
50#if defined __GETOPT_PREFIX && !defined __need_getopt 50#if defined __GETOPT_PREFIX && !defined __need_getopt
51# if !@HAVE_GETOPT_H@ 51# if !@HAVE_GETOPT_H@
52# define __need_system_stdlib_h
52# include <stdlib.h> 53# include <stdlib.h>
54# undef __need_system_stdlib_h
53# include <stdio.h> 55# include <stdio.h>
54# include <unistd.h> 56# include <unistd.h>
55# endif 57# endif
diff --git a/lib/getopt1.c b/lib/getopt1.c
index fb2a8f5a7b1..55a6b4eae45 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -1,5 +1,5 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt. 1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2012 Free Software 2 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
diff --git a/lib/getopt_.h b/lib/getopt_.h
index d69f57b9cf7..dd958138b22 100644
--- a/lib/getopt_.h
+++ b/lib/getopt_.h
@@ -1,5 +1,5 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2012 Free Software 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
@@ -53,7 +53,9 @@
53 linkers. */ 53 linkers. */
54#if defined __GETOPT_PREFIX && !defined __need_getopt 54#if defined __GETOPT_PREFIX && !defined __need_getopt
55# if !HAVE_GETOPT_H 55# if !HAVE_GETOPT_H
56# define __need_system_stdlib_h
56# include <stdlib.h> 57# include <stdlib.h>
58# undef __need_system_stdlib_h
57# include <stdio.h> 59# include <stdio.h>
58# include <unistd.h> 60# include <unistd.h>
59# endif 61# endif
@@ -128,7 +130,7 @@
128 130
129/* The definition of _GL_ARG_NONNULL is copied here. */ 131/* The definition of _GL_ARG_NONNULL is copied here. */
130/* A C macro for declaring that specific arguments must not be NULL. 132/* A C macro for declaring that specific arguments must not be NULL.
131 Copyright (C) 2009-2012 Free Software Foundation, Inc. 133 Copyright (C) 2009-2013 Free Software Foundation, Inc.
132 134
133 This program is free software: you can redistribute it and/or modify it 135 This program is free software: you can redistribute it and/or modify it
134 under the terms of the GNU General Public License as published 136 under the terms of the GNU General Public License as published
diff --git a/lib/getopt_int.h b/lib/getopt_int.h
index 2da020c995a..a6e4b9ea71c 100644
--- a/lib/getopt_int.h
+++ b/lib/getopt_int.h
@@ -1,5 +1,5 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2012 Free Software 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
diff --git a/lib/gettext.h b/lib/gettext.h
index 65ca1e6762e..d0215715a97 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,5 +1,5 @@
1/* Convenience header for conditional use of GNU <libintl.h>. 1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2012 Free Software 2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
diff --git a/lib/gettime.c b/lib/gettime.c
index 8075bfaf999..0a642dd2015 100644
--- a/lib/gettime.c
+++ b/lib/gettime.c
@@ -1,6 +1,6 @@
1/* gettime -- get the system clock 1/* gettime -- get the system clock
2 2
3 Copyright (C) 2002, 2004-2007, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2004-2007, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index 5d35060950a..ad65c6da8be 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -1,6 +1,6 @@
1/* Provide gettimeofday for systems that don't have it or for which it's broken. 1/* Provide gettimeofday for systems that don't have it or for which it's broken.
2 2
3 Copyright (C) 2001-2003, 2005-2007, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2001-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 420520fbce7..c130cbc65b8 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -1,6 +1,6 @@
1## DO NOT EDIT! GENERATED AUTOMATICALLY! 1## DO NOT EDIT! GENERATED AUTOMATICALLY!
2## Process this file with automake to produce Makefile.in. 2## Process this file with automake to produce Makefile.in.
3# Copyright (C) 2002-2012 Free Software Foundation, Inc. 3# Copyright (C) 2002-2013 Free Software Foundation, Inc.
4# 4#
5# This file is free software; you can redistribute it and/or modify 5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask putenv readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings 24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dup --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h fdopendir filemode fstatat getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings memrchr mktime pselect pthread_sigmask putenv readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -64,6 +64,17 @@ EXTRA_DIST += allocator.h
64 64
65## end gnulib module allocator 65## end gnulib module allocator
66 66
67## begin gnulib module at-internal
68
69if gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b
70
71endif
72EXTRA_DIST += openat-priv.h openat-proc.c
73
74EXTRA_libgnu_a_SOURCES += openat-proc.c
75
76## end gnulib module at-internal
77
67## begin gnulib module c-ctype 78## begin gnulib module c-ctype
68 79
69libgnu_a_SOURCES += c-ctype.h c-ctype.c 80libgnu_a_SOURCES += c-ctype.h c-ctype.c
@@ -124,6 +135,54 @@ EXTRA_DIST += sha512.h
124 135
125## end gnulib module crypto/sha512 136## end gnulib module crypto/sha512
126 137
138## begin gnulib module dirent
139
140BUILT_SOURCES += dirent.h
141
142# We need the following in order to create <dirent.h> when the system
143# doesn't have one that works with the given compiler.
144dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
145 $(AM_V_GEN)rm -f $@-t $@ && \
146 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
147 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
148 -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_H)|g' \
149 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
150 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
151 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
152 -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
153 -e 's/@''GNULIB_OPENDIR''@/$(GNULIB_OPENDIR)/g' \
154 -e 's/@''GNULIB_READDIR''@/$(GNULIB_READDIR)/g' \
155 -e 's/@''GNULIB_REWINDDIR''@/$(GNULIB_REWINDDIR)/g' \
156 -e 's/@''GNULIB_CLOSEDIR''@/$(GNULIB_CLOSEDIR)/g' \
157 -e 's/@''GNULIB_DIRFD''@/$(GNULIB_DIRFD)/g' \
158 -e 's/@''GNULIB_FDOPENDIR''@/$(GNULIB_FDOPENDIR)/g' \
159 -e 's/@''GNULIB_SCANDIR''@/$(GNULIB_SCANDIR)/g' \
160 -e 's/@''GNULIB_ALPHASORT''@/$(GNULIB_ALPHASORT)/g' \
161 -e 's/@''HAVE_OPENDIR''@/$(HAVE_OPENDIR)/g' \
162 -e 's/@''HAVE_READDIR''@/$(HAVE_READDIR)/g' \
163 -e 's/@''HAVE_REWINDDIR''@/$(HAVE_REWINDDIR)/g' \
164 -e 's/@''HAVE_CLOSEDIR''@/$(HAVE_CLOSEDIR)/g' \
165 -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
166 -e 's|@''HAVE_DECL_FDOPENDIR''@|$(HAVE_DECL_FDOPENDIR)|g' \
167 -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
168 -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
169 -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
170 -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
171 -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
172 -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \
173 -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
174 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
175 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
176 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
177 < $(srcdir)/dirent.in.h; \
178 } > $@-t && \
179 mv $@-t $@
180MOSTLYCLEANFILES += dirent.h dirent.h-t
181
182EXTRA_DIST += dirent.in.h
183
184## end gnulib module dirent
185
127## begin gnulib module dosname 186## begin gnulib module dosname
128 187
129if gl_GNULIB_ENABLED_dosname 188if gl_GNULIB_ENABLED_dosname
@@ -238,6 +297,15 @@ EXTRA_DIST += fcntl.in.h
238 297
239## end gnulib module fcntl-h 298## end gnulib module fcntl-h
240 299
300## begin gnulib module fdopendir
301
302
303EXTRA_DIST += fdopendir.c
304
305EXTRA_libgnu_a_SOURCES += fdopendir.c
306
307## end gnulib module fdopendir
308
241## begin gnulib module filemode 309## begin gnulib module filemode
242 310
243libgnu_a_SOURCES += filemode.c 311libgnu_a_SOURCES += filemode.c
@@ -255,6 +323,15 @@ EXTRA_libgnu_a_SOURCES += fpending.c
255 323
256## end gnulib module fpending 324## end gnulib module fpending
257 325
326## begin gnulib module fstatat
327
328
329EXTRA_DIST += at-func.c fstatat.c
330
331EXTRA_libgnu_a_SOURCES += at-func.c fstatat.c
332
333## end gnulib module fstatat
334
258## begin gnulib module getgroups 335## begin gnulib module getgroups
259 336
260if gl_GNULIB_ENABLED_getgroups 337if gl_GNULIB_ENABLED_getgroups
@@ -403,6 +480,15 @@ EXTRA_libgnu_a_SOURCES += lstat.c
403 480
404## end gnulib module lstat 481## end gnulib module lstat
405 482
483## begin gnulib module memrchr
484
485
486EXTRA_DIST += memrchr.c
487
488EXTRA_libgnu_a_SOURCES += memrchr.c
489
490## end gnulib module memrchr
491
406## begin gnulib module mktime 492## begin gnulib module mktime
407 493
408 494
@@ -412,6 +498,15 @@ EXTRA_libgnu_a_SOURCES += mktime.c
412 498
413## end gnulib module mktime 499## end gnulib module mktime
414 500
501## begin gnulib module openat-h
502
503if gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7
504
505endif
506EXTRA_DIST += openat.h
507
508## end gnulib module openat-h
509
415## begin gnulib module pathmax 510## begin gnulib module pathmax
416 511
417if gl_GNULIB_ENABLED_pathmax 512if gl_GNULIB_ENABLED_pathmax
@@ -457,6 +552,15 @@ EXTRA_libgnu_a_SOURCES += readlink.c
457 552
458## end gnulib module readlink 553## end gnulib module readlink
459 554
555## begin gnulib module readlinkat
556
557
558EXTRA_DIST += at-func.c readlinkat.c
559
560EXTRA_libgnu_a_SOURCES += at-func.c readlinkat.c
561
562## end gnulib module readlinkat
563
460## begin gnulib module root-uid 564## begin gnulib module root-uid
461 565
462if gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c 566if gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c
@@ -774,7 +878,6 @@ EXTRA_DIST += stdint.in.h
774## begin gnulib module stdio 878## begin gnulib module stdio
775 879
776BUILT_SOURCES += stdio.h 880BUILT_SOURCES += stdio.h
777libgnu_a_SOURCES += stdio.c
778 881
779# We need the following in order to create <stdio.h> when the system 882# We need the following in order to create <stdio.h> when the system
780# doesn't have one that works with the given compiler. 883# doesn't have one that works with the given compiler.
@@ -938,6 +1041,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
938 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ 1041 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
939 -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ 1042 -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
940 -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ 1043 -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \
1044 -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
941 -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ 1045 -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
942 -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ 1046 -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
943 -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ 1047 -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
@@ -966,6 +1070,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
966 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ 1070 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
967 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ 1071 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
968 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ 1072 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
1073 -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
969 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ 1074 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
970 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ 1075 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
971 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ 1076 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
@@ -1009,6 +1114,106 @@ EXTRA_DIST += strftime.h
1009 1114
1010## end gnulib module strftime 1115## end gnulib module strftime
1011 1116
1117## begin gnulib module string
1118
1119BUILT_SOURCES += string.h
1120
1121# We need the following in order to create <string.h> when the system
1122# doesn't have one that works with the given compiler.
1123string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1124 $(AM_V_GEN)rm -f $@-t $@ && \
1125 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1126 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1127 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1128 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1129 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1130 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
1131 -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
1132 -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
1133 -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
1134 -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
1135 -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
1136 -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \
1137 -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \
1138 -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \
1139 -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \
1140 -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \
1141 -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \
1142 -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \
1143 -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \
1144 -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
1145 -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
1146 -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
1147 -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
1148 -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
1149 -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \
1150 -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \
1151 -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \
1152 -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \
1153 -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \
1154 -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \
1155 -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \
1156 -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \
1157 -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \
1158 -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \
1159 -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \
1160 -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \
1161 -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \
1162 -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \
1163 -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
1164 -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
1165 -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
1166 -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
1167 -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
1168 < $(srcdir)/string.in.h | \
1169 sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
1170 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
1171 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
1172 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
1173 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
1174 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
1175 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
1176 -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
1177 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
1178 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
1179 -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
1180 -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
1181 -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
1182 -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
1183 -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
1184 -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
1185 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
1186 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
1187 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
1188 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
1189 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
1190 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
1191 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
1192 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
1193 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
1194 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
1195 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
1196 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
1197 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
1198 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
1199 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
1200 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
1201 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
1202 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
1203 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
1204 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
1205 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1206 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1207 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
1208 < $(srcdir)/string.in.h; \
1209 } > $@-t && \
1210 mv $@-t $@
1211MOSTLYCLEANFILES += string.h string.h-t
1212
1213EXTRA_DIST += string.in.h
1214
1215## end gnulib module string
1216
1012## begin gnulib module strtoimax 1217## begin gnulib module strtoimax
1013 1218
1014 1219
diff --git a/lib/group-member.c b/lib/group-member.c
index 5fcc7e01d0c..da015842c21 100644
--- a/lib/group-member.c
+++ b/lib/group-member.c
@@ -1,6 +1,6 @@
1/* group-member.c -- determine whether group id is in calling user's group list 1/* group-member.c -- determine whether group id is in calling user's group list
2 2
3 Copyright (C) 1994, 1997-1998, 2003, 2005-2006, 2009-2012 Free Software 3 Copyright (C) 1994, 1997-1998, 2003, 2005-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/lib/ignore-value.h b/lib/ignore-value.h
index 2e344350946..63ecde85136 100644
--- a/lib/ignore-value.h
+++ b/lib/ignore-value.h
@@ -1,6 +1,6 @@
1/* ignore a function return without a compiler warning 1/* ignore a function return without a compiler warning
2 2
3 Copyright (C) 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/intprops.h b/lib/intprops.h
index 2485c78d4ba..b473052d114 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -1,6 +1,6 @@
1/* intprops.h -- properties of integer types 1/* intprops.h -- properties of integer types
2 2
3 Copyright (C) 2001-2005, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2001-2005, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index b9da2b5b091..1893f5569d3 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2006-2012 Free Software Foundation, Inc. 1/* Copyright (C) 2006-2013 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Derek Price. 2 Written by Paul Eggert, Bruno Haible, Derek Price.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
diff --git a/lib/lstat.c b/lib/lstat.c
index 97fe6bb2d53..1a613a89c8d 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -1,6 +1,6 @@
1/* Work around a bug of lstat on some systems 1/* Work around a bug of lstat on some systems
2 2
3 Copyright (C) 1997-2006, 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 1997-2006, 2008-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/makefile.w32-in b/lib/makefile.w32-in
index b27e21032b3..cd62fbcd13d 100644
--- a/lib/makefile.w32-in
+++ b/lib/makefile.w32-in
@@ -1,5 +1,5 @@
1# -*- Makefile -*- for GNU Emacs on the Microsoft Windows API. 1# -*- Makefile -*- for GNU Emacs on the Microsoft Windows API.
2# Copyright (C) 2011-2012 Free Software Foundation, Inc. 2# Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 3
4# This file is part of GNU Emacs. 4# This file is part of GNU Emacs.
5 5
@@ -34,6 +34,7 @@ GNULIBOBJS = $(BLD)/c-ctype.$(O) \
34 $(BLD)/getopt.$(O) \ 34 $(BLD)/getopt.$(O) \
35 $(BLD)/getopt1.$(O) \ 35 $(BLD)/getopt1.$(O) \
36 $(BLD)/gettime.$(O) \ 36 $(BLD)/gettime.$(O) \
37 $(BLD)/memrchr.$(O) \
37 $(BLD)/strftime.$(O) \ 38 $(BLD)/strftime.$(O) \
38 $(BLD)/time_r.$(O) \ 39 $(BLD)/time_r.$(O) \
39 $(BLD)/timespec-add.$(O) \ 40 $(BLD)/timespec-add.$(O) \
@@ -103,6 +104,8 @@ U64_H = $(GNU_LIB)/u64.h \
103 $(NT_INC)/stdint.h 104 $(NT_INC)/stdint.h
104SHA512_H = $(GNU_LIB)/sha512.h \ 105SHA512_H = $(GNU_LIB)/sha512.h \
105 $(U64_H) 106 $(U64_H)
107SIG2STR_H = $(GNU_LIB)/sig2str.h \
108 $(GNU_LIB)/intprops.h
106STAT_TIME_H = $(GNU_LIB)/stat-time.h \ 109STAT_TIME_H = $(GNU_LIB)/stat-time.h \
107 $(NT_INC)/sys/stat.h 110 $(NT_INC)/sys/stat.h
108 111
@@ -199,6 +202,10 @@ $(BLD)/md5.$(O) : \
199 $(CONFIG_H) \ 202 $(CONFIG_H) \
200 $(MD5_H) 203 $(MD5_H)
201 204
205$(BLD)/memrchr.$(O) : \
206 $(GNU_LIB)/memrchr.c \
207 $(CONFIG_H)
208
202$(BLD)/sha1.$(O) : \ 209$(BLD)/sha1.$(O) : \
203 $(GNU_LIB)/sha1.c \ 210 $(GNU_LIB)/sha1.c \
204 $(NT_INC)/stdalign.h \ 211 $(NT_INC)/stdalign.h \
@@ -243,8 +250,7 @@ $(BLD)/filemode.$(O) : \
243$(BLD)/sig2str.$(O) : \ 250$(BLD)/sig2str.$(O) : \
244 $(GNU_LIB)/sig2str.c \ 251 $(GNU_LIB)/sig2str.c \
245 $(CONFIG_H) \ 252 $(CONFIG_H) \
246 $(GNU_LIB)/sig2str.h \ 253 $(SIG2STR_H)
247 $(GNU_LIB)/intprops.h
248 254
249 255
250# The following dependencies are for supporting parallel builds, where 256# The following dependencies are for supporting parallel builds, where
diff --git a/lib/md5.c b/lib/md5.c
index 6e6d61270dd..f41b5beb7ce 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -1,6 +1,6 @@
1/* Functions to compute MD5 message digest of files or memory blocks. 1/* Functions to compute MD5 message digest of files or memory blocks.
2 according to the definition of MD5 in RFC 1321 from April 1992. 2 according to the definition of MD5 in RFC 1321 from April 1992.
3 Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2012 Free Software 3 Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 This file is part of the GNU C Library. 5 This file is part of the GNU C Library.
6 6
diff --git a/lib/md5.h b/lib/md5.h
index 75d6bce5c33..634a7470f44 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -1,6 +1,6 @@
1/* Declaration of functions and data types used for MD5 sum computing 1/* Declaration of functions and data types used for MD5 sum computing
2 library functions. 2 library functions.
3 Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2012 Free Software 3 Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 This file is part of the GNU C Library. 5 This file is part of the GNU C Library.
6 6
diff --git a/lib/memrchr.c b/lib/memrchr.c
new file mode 100644
index 00000000000..5a023e0638a
--- /dev/null
+++ b/lib/memrchr.c
@@ -0,0 +1,161 @@
1/* memrchr -- find the last occurrence of a byte in a memory block
2
3 Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2013 Free Software
4 Foundation, Inc.
5
6 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
7 with help from Dan Sahlin (dan@sics.se) and
8 commentary by Jim Blandy (jimb@ai.mit.edu);
9 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
10 and implemented by Roland McGrath (roland@ai.mit.edu).
11
12 This program is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24
25#if defined _LIBC
26# include <memcopy.h>
27#else
28# include <config.h>
29# define reg_char char
30#endif
31
32#include <string.h>
33#include <limits.h>
34
35#undef __memrchr
36#ifdef _LIBC
37# undef memrchr
38#endif
39
40#ifndef weak_alias
41# define __memrchr memrchr
42#endif
43
44/* Search no more than N bytes of S for C. */
45void *
46__memrchr (void const *s, int c_in, size_t n)
47{
48 /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
49 long instead of a 64-bit uintmax_t tends to give better
50 performance. On 64-bit hardware, unsigned long is generally 64
51 bits already. Change this typedef to experiment with
52 performance. */
53 typedef unsigned long int longword;
54
55 const unsigned char *char_ptr;
56 const longword *longword_ptr;
57 longword repeated_one;
58 longword repeated_c;
59 unsigned reg_char c;
60
61 c = (unsigned char) c_in;
62
63 /* Handle the last few bytes by reading one byte at a time.
64 Do this until CHAR_PTR is aligned on a longword boundary. */
65 for (char_ptr = (const unsigned char *) s + n;
66 n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
67 --n)
68 if (*--char_ptr == c)
69 return (void *) char_ptr;
70
71 longword_ptr = (const longword *) char_ptr;
72
73 /* All these elucidatory comments refer to 4-byte longwords,
74 but the theory applies equally well to any size longwords. */
75
76 /* Compute auxiliary longword values:
77 repeated_one is a value which has a 1 in every byte.
78 repeated_c has c in every byte. */
79 repeated_one = 0x01010101;
80 repeated_c = c | (c << 8);
81 repeated_c |= repeated_c << 16;
82 if (0xffffffffU < (longword) -1)
83 {
84 repeated_one |= repeated_one << 31 << 1;
85 repeated_c |= repeated_c << 31 << 1;
86 if (8 < sizeof (longword))
87 {
88 size_t i;
89
90 for (i = 64; i < sizeof (longword) * 8; i *= 2)
91 {
92 repeated_one |= repeated_one << i;
93 repeated_c |= repeated_c << i;
94 }
95 }
96 }
97
98 /* Instead of the traditional loop which tests each byte, we will test a
99 longword at a time. The tricky part is testing if *any of the four*
100 bytes in the longword in question are equal to c. We first use an xor
101 with repeated_c. This reduces the task to testing whether *any of the
102 four* bytes in longword1 is zero.
103
104 We compute tmp =
105 ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
106 That is, we perform the following operations:
107 1. Subtract repeated_one.
108 2. & ~longword1.
109 3. & a mask consisting of 0x80 in every byte.
110 Consider what happens in each byte:
111 - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
112 and step 3 transforms it into 0x80. A carry can also be propagated
113 to more significant bytes.
114 - If a byte of longword1 is nonzero, let its lowest 1 bit be at
115 position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
116 the byte ends in a single bit of value 0 and k bits of value 1.
117 After step 2, the result is just k bits of value 1: 2^k - 1. After
118 step 3, the result is 0. And no carry is produced.
119 So, if longword1 has only non-zero bytes, tmp is zero.
120 Whereas if longword1 has a zero byte, call j the position of the least
121 significant zero byte. Then the result has a zero at positions 0, ...,
122 j-1 and a 0x80 at position j. We cannot predict the result at the more
123 significant bytes (positions j+1..3), but it does not matter since we
124 already have a non-zero bit at position 8*j+7.
125
126 So, the test whether any byte in longword1 is zero is equivalent to
127 testing whether tmp is nonzero. */
128
129 while (n >= sizeof (longword))
130 {
131 longword longword1 = *--longword_ptr ^ repeated_c;
132
133 if ((((longword1 - repeated_one) & ~longword1)
134 & (repeated_one << 7)) != 0)
135 {
136 longword_ptr++;
137 break;
138 }
139 n -= sizeof (longword);
140 }
141
142 char_ptr = (const unsigned char *) longword_ptr;
143
144 /* At this point, we know that either n < sizeof (longword), or one of the
145 sizeof (longword) bytes starting at char_ptr is == c. On little-endian
146 machines, we could determine the first such byte without any further
147 memory accesses, just by looking at the tmp result from the last loop
148 iteration. But this does not work on big-endian machines. Choose code
149 that works in both cases. */
150
151 while (n-- > 0)
152 {
153 if (*--char_ptr == c)
154 return (void *) char_ptr;
155 }
156
157 return NULL;
158}
159#ifdef weak_alias
160weak_alias (__memrchr, memrchr)
161#endif
diff --git a/lib/mktime.c b/lib/mktime.c
index 74d1b84949b..e660a23c3be 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -1,5 +1,5 @@
1/* Convert a 'struct tm' to a time_t value. 1/* Convert a 'struct tm' to a time_t value.
2 Copyright (C) 1993-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@twinsun.com>. 4 Contributed by Paul Eggert <eggert@twinsun.com>.
5 5
diff --git a/lib/openat-die.c b/lib/openat-die.c
new file mode 100644
index 00000000000..f09123ea785
--- /dev/null
+++ b/lib/openat-die.c
@@ -0,0 +1,6 @@
1/* Respond to a save- or restore-cwd failure.
2 This should never happen with Emacs. */
3#include <config.h>
4#include "openat.h"
5void openat_save_fail (int errnum) { abort (); }
6void openat_restore_fail (int errnum) { abort (); }
diff --git a/lib/openat-priv.h b/lib/openat-priv.h
new file mode 100644
index 00000000000..829cf7d0855
--- /dev/null
+++ b/lib/openat-priv.h
@@ -0,0 +1,64 @@
1/* Internals for openat-like functions.
2
3 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* written by Jim Meyering */
19
20#ifndef _GL_HEADER_OPENAT_PRIV
21#define _GL_HEADER_OPENAT_PRIV
22
23#include <errno.h>
24#include <limits.h>
25#include <stdlib.h>
26
27/* Maximum number of bytes that it is safe to allocate as a single
28 array on the stack, and that is known as a compile-time constant.
29 The assumption is that we'll touch the array very quickly, or a
30 temporary very near the array, provoking an out-of-memory trap. On
31 some operating systems, there is only one guard page for the stack,
32 and a page size can be as small as 4096 bytes. Subtract 64 in the
33 hope that this will let the compiler touch a nearby temporary and
34 provoke a trap. */
35#define SAFER_ALLOCA_MAX (4096 - 64)
36
37#define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX)
38
39#if defined PATH_MAX
40# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX)
41#elif defined _XOPEN_PATH_MAX
42# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX)
43#else
44# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024)
45#endif
46
47char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file);
48
49/* Trying to access a BUILD_PROC_NAME file will fail on systems without
50 /proc support, and even on systems *with* ProcFS support. Return
51 nonzero if the failure may be legitimate, e.g., because /proc is not
52 readable, or the particular .../fd/N directory is not present. */
53#define EXPECTED_ERRNO(Errno) \
54 ((Errno) == ENOTDIR || (Errno) == ENOENT \
55 || (Errno) == EPERM || (Errno) == EACCES \
56 || (Errno) == ENOSYS /* Solaris 8 */ \
57 || (Errno) == EOPNOTSUPP /* FreeBSD */)
58
59/* Wrapper function shared among linkat and renameat. */
60int at_func2 (int fd1, char const *file1,
61 int fd2, char const *file2,
62 int (*func) (char const *file1, char const *file2));
63
64#endif /* _GL_HEADER_OPENAT_PRIV */
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
new file mode 100644
index 00000000000..d7a68e26d0b
--- /dev/null
+++ b/lib/openat-proc.c
@@ -0,0 +1,110 @@
1/* Create /proc/self/fd-related names for subfiles of open directories.
2
3 Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#include <config.h>
21
22#include "openat-priv.h"
23
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <fcntl.h>
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h>
32
33#include "intprops.h"
34
35/* The results of open() in this file are not used with fchdir,
36 and we do not leak fds to any single-threaded code that could use stdio,
37 therefore save some unnecessary work in fchdir.c.
38 FIXME - if the kernel ever adds support for multi-thread safety for
39 avoiding standard fds, then we should use open_safer. */
40#undef open
41#undef close
42
43#define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s"
44
45#define PROC_SELF_FD_NAME_SIZE_BOUND(len) \
46 (sizeof PROC_SELF_FD_FORMAT - sizeof "%d%s" \
47 + INT_STRLEN_BOUND (int) + (len) + 1)
48
49
50/* Set BUF to the expansion of PROC_SELF_FD_FORMAT, using FD and FILE
51 respectively for %d and %s. If successful, return BUF if the
52 result fits in BUF, dynamically allocated memory otherwise. But
53 return NULL if /proc is not reliable, either because the operating
54 system support is lacking or because memory is low. */
55char *
56openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
57{
58 static int proc_status = 0;
59
60 /* Make sure the caller gets ENOENT when appropriate. */
61 if (!*file)
62 {
63 buf[0] = '\0';
64 return buf;
65 }
66
67 if (! proc_status)
68 {
69 /* Set PROC_STATUS to a positive value if /proc/self/fd is
70 reliable, and a negative value otherwise. Solaris 10
71 /proc/self/fd mishandles "..", and any file name might expand
72 to ".." after symbolic link expansion, so avoid /proc/self/fd
73 if it mishandles "..". Solaris 10 has openat, but this
74 problem is exhibited on code that built on Solaris 8 and
75 running on Solaris 10. */
76
77 int proc_self_fd = open ("/proc/self/fd",
78 O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
79 if (proc_self_fd < 0)
80 proc_status = -1;
81 else
82 {
83 /* Detect whether /proc/self/fd/%i/../fd exists, where %i is the
84 number of a file descriptor open on /proc/self/fd. On Linux,
85 that name resolves to /proc/self/fd, which was opened above.
86 However, on Solaris, it may resolve to /proc/self/fd/fd, which
87 cannot exist, since all names in /proc/self/fd are numeric. */
88 char dotdot_buf[PROC_SELF_FD_NAME_SIZE_BOUND (sizeof "../fd" - 1)];
89 sprintf (dotdot_buf, PROC_SELF_FD_FORMAT, proc_self_fd, "../fd");
90 proc_status = access (dotdot_buf, F_OK) ? -1 : 1;
91 close (proc_self_fd);
92 }
93 }
94
95 if (proc_status < 0)
96 return NULL;
97 else
98 {
99 size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file));
100 char *result = buf;
101 if (OPENAT_BUFFER_SIZE < bufsize)
102 {
103 result = malloc (bufsize);
104 if (! result)
105 return NULL;
106 }
107 sprintf (result, PROC_SELF_FD_FORMAT, fd, file);
108 return result;
109 }
110}
diff --git a/lib/openat.h b/lib/openat.h
new file mode 100644
index 00000000000..eb90990da1d
--- /dev/null
+++ b/lib/openat.h
@@ -0,0 +1,120 @@
1/* provide a replacement openat function
2 Copyright (C) 2004-2006, 2008-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* written by Jim Meyering */
18
19#ifndef _GL_HEADER_OPENAT
20#define _GL_HEADER_OPENAT
21
22#include <fcntl.h>
23
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <unistd.h>
27#include <stdbool.h>
28
29_GL_INLINE_HEADER_BEGIN
30
31#if !HAVE_OPENAT
32
33int openat_permissive (int fd, char const *file, int flags, mode_t mode,
34 int *cwd_errno);
35bool openat_needs_fchdir (void);
36
37#else
38
39# define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
40 openat (Fd, File, Flags, Mode)
41# define openat_needs_fchdir() false
42
43#endif
44
45_Noreturn void openat_restore_fail (int);
46_Noreturn void openat_save_fail (int);
47
48/* Using these function names makes application code
49 slightly more readable than it would be with
50 fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
51
52#if GNULIB_FCHOWNAT
53
54# ifndef FCHOWNAT_INLINE
55# define FCHOWNAT_INLINE _GL_INLINE
56# endif
57
58FCHOWNAT_INLINE int
59chownat (int fd, char const *file, uid_t owner, gid_t group)
60{
61 return fchownat (fd, file, owner, group, 0);
62}
63
64FCHOWNAT_INLINE int
65lchownat (int fd, char const *file, uid_t owner, gid_t group)
66{
67 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
68}
69
70#endif
71
72#if GNULIB_FCHMODAT
73
74# ifndef FCHMODAT_INLINE
75# define FCHMODAT_INLINE _GL_INLINE
76# endif
77
78FCHMODAT_INLINE int
79chmodat (int fd, char const *file, mode_t mode)
80{
81 return fchmodat (fd, file, mode, 0);
82}
83
84FCHMODAT_INLINE int
85lchmodat (int fd, char const *file, mode_t mode)
86{
87 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
88}
89
90#endif
91
92#if GNULIB_STATAT
93
94# ifndef STATAT_INLINE
95# define STATAT_INLINE _GL_INLINE
96# endif
97
98STATAT_INLINE int
99statat (int fd, char const *name, struct stat *st)
100{
101 return fstatat (fd, name, st, 0);
102}
103
104STATAT_INLINE int
105lstatat (int fd, char const *name, struct stat *st)
106{
107 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
108}
109
110#endif
111
112/* For now, there are no wrappers named laccessat or leuidaccessat,
113 since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
114 since access rights on symlinks are of limited utility. Likewise,
115 wrappers are not provided for accessat or euidaccessat, so as to
116 avoid dragging in -lgen on some platforms. */
117
118_GL_INLINE_HEADER_END
119
120#endif /* _GL_HEADER_OPENAT */
diff --git a/lib/pathmax.h b/lib/pathmax.h
index 03db7cb519b..a9ddc33d17f 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -1,5 +1,5 @@
1/* Define PATH_MAX somehow. Requires sys/types.h. 1/* Define PATH_MAX somehow. Requires sys/types.h.
2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2012 Free Software 2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
diff --git a/lib/pselect.c b/lib/pselect.c
index 1b6d099dccf..f4ea4883c39 100644
--- a/lib/pselect.c
+++ b/lib/pselect.c
@@ -1,6 +1,6 @@
1/* pselect - synchronous I/O multiplexing 1/* pselect - synchronous I/O multiplexing
2 2
3 Copyright 2011-2012 Free Software Foundation, Inc. 3 Copyright 2011-2013 Free Software Foundation, Inc.
4 4
5 This file is part of gnulib. 5 This file is part of gnulib.
6 6
diff --git a/lib/pthread_sigmask.c b/lib/pthread_sigmask.c
index 80ab24bf0b1..21919731ee4 100644
--- a/lib/pthread_sigmask.c
+++ b/lib/pthread_sigmask.c
@@ -1,5 +1,5 @@
1/* POSIX compatible signal blocking for threads. 1/* POSIX compatible signal blocking for threads.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc. 2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/putenv.c b/lib/putenv.c
index 3c0f7ead330..5f0fedaf9cc 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2012 Free Software 1/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2013 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 3
4 NOTE: The canonical source of this file is maintained with the GNU C 4 NOTE: The canonical source of this file is maintained with the GNU C
diff --git a/lib/readlink.c b/lib/readlink.c
index baac1322442..f83a1e0123f 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
1/* Stub for readlink(). 1/* Stub for readlink().
2 Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/readlinkat.c b/lib/readlinkat.c
new file mode 100644
index 00000000000..504e6ebbc49
--- /dev/null
+++ b/lib/readlinkat.c
@@ -0,0 +1,47 @@
1/* Read a symlink relative to an open directory.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* written by Eric Blake */
18
19#include <config.h>
20
21#include <unistd.h>
22
23/* Gnulib provides a readlink stub for mingw; use it for distinction
24 between EINVAL and ENOENT, rather than always failing with ENOSYS. */
25
26/* POSIX 2008 says that unlike readlink, readlinkat returns 0 for
27 success instead of the buffer length. But this would render
28 readlinkat worthless since readlink does not guarantee a
29 NUL-terminated buffer. Assume this was a bug in POSIX. */
30
31/* Read the contents of symlink FILE into buffer BUF of size LEN, in the
32 directory open on descriptor FD. If possible, do it without changing
33 the working directory. Otherwise, resort to using save_cwd/fchdir,
34 then readlink/restore_cwd. If either the save_cwd or the restore_cwd
35 fails, then give a diagnostic and exit nonzero. */
36
37#define AT_FUNC_NAME readlinkat
38#define AT_FUNC_F1 readlink
39#define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len
40#define AT_FUNC_POST_FILE_ARGS , buf, len
41#define AT_FUNC_RESULT ssize_t
42#include "at-func.c"
43#undef AT_FUNC_NAME
44#undef AT_FUNC_F1
45#undef AT_FUNC_POST_FILE_PARAM_DECLS
46#undef AT_FUNC_POST_FILE_ARGS
47#undef AT_FUNC_RESULT
diff --git a/lib/root-uid.h b/lib/root-uid.h
index 2379773c291..c75d88891ed 100644
--- a/lib/root-uid.h
+++ b/lib/root-uid.h
@@ -1,6 +1,6 @@
1/* The user ID that always has appropriate privileges in the POSIX sense. 1/* The user ID that always has appropriate privileges in the POSIX sense.
2 2
3 Copyright 2012 Free Software Foundation, Inc. 3 Copyright 2012-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
new file mode 100644
index 00000000000..b8dae34ca02
--- /dev/null
+++ b/lib/save-cwd.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define SAVE_CWD_INLINE _GL_EXTERN_INLINE
3#include "save-cwd.h"
diff --git a/lib/save-cwd.h b/lib/save-cwd.h
new file mode 100644
index 00000000000..bd0cd8d5707
--- /dev/null
+++ b/lib/save-cwd.h
@@ -0,0 +1,46 @@
1/* Do not save and restore the current working directory.
2
3 Copyright 2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Gnulib needs to save and restore the current working directory to
19 fully emulate functions like fstatat. But Emacs doesn't care what
20 the current working directory is; it always uses absolute file
21 names. This module replaces the Gnulib module by omitting the code
22 that Emacs does not need. */
23
24#ifndef SAVE_CWD_H
25#define SAVE_CWD_H 1
26
27_GL_INLINE_HEADER_BEGIN
28#ifndef SAVE_CWD_INLINE
29# define SAVE_CWD_INLINE _GL_INLINE
30#endif
31
32struct saved_cwd { int desc; };
33
34SAVE_CWD_INLINE int
35save_cwd (struct saved_cwd *cwd)
36{
37 cwd->desc = -1;
38 return 0;
39}
40
41SAVE_CWD_INLINE int restore_cwd (struct saved_cwd const *cwd) { return 0; }
42SAVE_CWD_INLINE void free_cwd (struct saved_cwd *cwd) { }
43
44_GL_INLINE_HEADER_END
45
46#endif
diff --git a/lib/sha1.c b/lib/sha1.c
index b9505dd9467..778389affc5 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -1,7 +1,7 @@
1/* sha1.c - Functions to compute SHA1 message digest of files or 1/* sha1.c - Functions to compute SHA1 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-1. 2 memory blocks according to the NIST specification FIPS-180-1.
3 3
4 Copyright (C) 2000-2001, 2003-2006, 2008-2012 Free Software Foundation, Inc. 4 Copyright (C) 2000-2001, 2003-2006, 2008-2013 Free Software Foundation, Inc.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
diff --git a/lib/sha1.h b/lib/sha1.h
index 0d9ced0298d..ddd386f9144 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -1,6 +1,6 @@
1/* Declarations of functions and data types used for SHA1 sum 1/* Declarations of functions and data types used for SHA1 sum
2 library functions. 2 library functions.
3 Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2012 Free Software 3 Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
diff --git a/lib/sha256.c b/lib/sha256.c
index 55273c6a3bc..4b2cee37fb5 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -1,7 +1,7 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or 1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2. 2 memory blocks according to the NIST specification FIPS-180-2.
3 3
4 Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc. 4 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
diff --git a/lib/sha256.h b/lib/sha256.h
index d69b83fc9fc..7e6252285bb 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -1,6 +1,6 @@
1/* Declarations of functions and data types used for SHA256 and SHA224 sum 1/* Declarations of functions and data types used for SHA256 and SHA224 sum
2 library functions. 2 library functions.
3 Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/sha512.c b/lib/sha512.c
index dfb67a305d8..79f11257474 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -1,7 +1,7 @@
1/* sha512.c - Functions to compute SHA512 and SHA384 message digest of files or 1/* sha512.c - Functions to compute SHA512 and SHA384 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2. 2 memory blocks according to the NIST specification FIPS-180-2.
3 3
4 Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc. 4 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
diff --git a/lib/sha512.h b/lib/sha512.h
index ddf91d6c726..2e78a5f9404 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -1,6 +1,6 @@
1/* Declarations of functions and data types used for SHA512 and SHA384 sum 1/* Declarations of functions and data types used for SHA512 and SHA384 sum
2 library functions. 2 library functions.
3 Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/sig2str.c b/lib/sig2str.c
index 2f5b21cc36f..8b36e2facf0 100644
--- a/lib/sig2str.c
+++ b/lib/sig2str.c
@@ -1,6 +1,6 @@
1/* sig2str.c -- convert between signal names and numbers 1/* sig2str.c -- convert between signal names and numbers
2 2
3 Copyright (C) 2002, 2004, 2006, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/sig2str.h b/lib/sig2str.h
index 75eff7d7c1a..d16be98c076 100644
--- a/lib/sig2str.h
+++ b/lib/sig2str.h
@@ -1,6 +1,6 @@
1/* sig2str.h -- convert between signal names and numbers 1/* sig2str.h -- convert between signal names and numbers
2 2
3 Copyright (C) 2002, 2005, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2005, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 8fb1ad119ad..54849504d77 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <signal.h>. 1/* A GNU-like <signal.h>.
2 2
3 Copyright (C) 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/stat-time.h b/lib/stat-time.h
index 74dd00aeb3e..2d3b5cd6514 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -1,6 +1,6 @@
1/* stat-related time functions. 1/* stat-related time functions.
2 2
3 Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/stat.c b/lib/stat.c
index c0bcb88320f..f888130d263 100644
--- a/lib/stat.c
+++ b/lib/stat.c
@@ -1,5 +1,5 @@
1/* Work around platform bugs in stat. 1/* Work around platform bugs in stat.
2 Copyright (C) 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index 8fba6943f69..c3a67321b0e 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C11 <stdalign.h>. 1/* A substitute for ISO C11 <stdalign.h>.
2 2
3 Copyright 2011-2012 Free Software Foundation, Inc. 3 Copyright 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/stdarg.in.h b/lib/stdarg.in.h
index 53104a61923..7484842dbd3 100644
--- a/lib/stdarg.in.h
+++ b/lib/stdarg.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <stdarg.h>. 1/* Substitute for and wrapper around <stdarg.h>.
2 Copyright (C) 2008-2012 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h
index 1f8caee4f2d..7c1577277fa 100644
--- a/lib/stdbool.in.h
+++ b/lib/stdbool.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2003, 2006-2012 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001. 2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 17fcaea2bfe..40f0536aaee 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -1,6 +1,6 @@
1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. 1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
2 2
3 Copyright (C) 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index e2a0eb19ac0..2db8b2e378b 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2002, 2004-2012 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2002, 2004-2013 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. 2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
@@ -39,7 +39,7 @@
39 Ideally we should test __BIONIC__ here, but it is only defined after 39 Ideally we should test __BIONIC__ here, but it is only defined after
40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */ 40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
41#if defined __ANDROID__ \ 41#if defined __ANDROID__ \
42 && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_ 42 && defined _SYS_TYPES_H_ && !defined __need_size_t
43# @INCLUDE_NEXT@ @NEXT_STDINT_H@ 43# @INCLUDE_NEXT@ @NEXT_STDINT_H@
44#else 44#else
45 45
diff --git a/lib/stdio.c b/lib/stdio.c
deleted file mode 100644
index e6ed82996b7..00000000000
--- a/lib/stdio.c
+++ /dev/null
@@ -1,3 +0,0 @@
1#include <config.h>
2#define _GL_STDIO_INLINE _GL_EXTERN_INLINE
3#include "stdio.h"
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index f3b52d28f6b..d6af99ca77d 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdio.h>. 1/* A GNU-like <stdio.h>.
2 2
3 Copyright (C) 2004, 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2007-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -46,11 +46,6 @@
46#ifndef _@GUARD_PREFIX@_STDIO_H 46#ifndef _@GUARD_PREFIX@_STDIO_H
47#define _@GUARD_PREFIX@_STDIO_H 47#define _@GUARD_PREFIX@_STDIO_H
48 48
49_GL_INLINE_HEADER_BEGIN
50#ifndef _GL_STDIO_INLINE
51# define _GL_STDIO_INLINE _GL_INLINE
52#endif
53
54/* Get va_list. Needed on many systems, including glibc 2.8. */ 49/* Get va_list. Needed on many systems, including glibc 2.8. */
55#include <stdarg.h> 50#include <stdarg.h>
56 51
@@ -580,21 +575,17 @@ _GL_CXXALIAS_RPL (fwrite, size_t,
580_GL_CXXALIAS_SYS (fwrite, size_t, 575_GL_CXXALIAS_SYS (fwrite, size_t,
581 (const void *ptr, size_t s, size_t n, FILE *stream)); 576 (const void *ptr, size_t s, size_t n, FILE *stream));
582 577
583/* Work around glibc bug 11959 578/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
584 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>, 579 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
585 which sometimes causes an unwanted diagnostic for fwrite calls. 580 which sometimes causes an unwanted diagnostic for fwrite calls.
586 This affects only function declaration attributes, so it's not 581 This affects only function declaration attributes under certain
587 needed for C++. */ 582 versions of gcc, and is not needed for C++. */
588# if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL 583# if (0 < __USE_FORTIFY_LEVEL \
589_GL_STDIO_INLINE size_t _GL_ARG_NONNULL ((1, 4)) 584 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
590rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream) 585 && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
591{ 586 && !defined __cplusplus)
592 size_t r = fwrite (ptr, s, n, stream);
593 (void) r;
594 return r;
595}
596# undef fwrite 587# undef fwrite
597# define fwrite rpl_fwrite 588# define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; })
598# endif 589# endif
599# endif 590# endif
600_GL_CXXALIASWARN (fwrite); 591_GL_CXXALIASWARN (fwrite);
@@ -1338,8 +1329,6 @@ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1338 "POSIX compliance"); 1329 "POSIX compliance");
1339#endif 1330#endif
1340 1331
1341_GL_INLINE_HEADER_END
1342
1343#endif /* _@GUARD_PREFIX@_STDIO_H */ 1332#endif /* _@GUARD_PREFIX@_STDIO_H */
1344#endif /* _@GUARD_PREFIX@_STDIO_H */ 1333#endif /* _@GUARD_PREFIX@_STDIO_H */
1345#endif 1334#endif
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 65558402bf3..c9552480e5d 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -20,8 +20,9 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined __need_malloc_and_calloc 23#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
24/* Special invocation convention inside glibc header files. */ 24/* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */
25 26
26#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 27#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
27 28
@@ -766,6 +767,22 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
766# endif 767# endif
767#endif 768#endif
768 769
770#if @GNULIB_SECURE_GETENV@
771/* Look up NAME in the environment, returning 0 in insecure situations. */
772# if !@HAVE_SECURE_GETENV@
773_GL_FUNCDECL_SYS (secure_getenv, char *,
774 (char const *name) _GL_ARG_NONNULL ((1)));
775# endif
776_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
777_GL_CXXALIASWARN (secure_getenv);
778#elif defined GNULIB_POSIXCHECK
779# undef secure_getenv
780# if HAVE_RAW_DECL_SECURE_GETENV
781_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
782 "use gnulib module secure_getenv for portability");
783# endif
784#endif
785
769#if @GNULIB_SETENV@ 786#if @GNULIB_SETENV@
770/* Set NAME to VALUE in the environment. 787/* Set NAME to VALUE in the environment.
771 If REPLACE is nonzero, overwrite an existing value. */ 788 If REPLACE is nonzero, overwrite an existing value. */
diff --git a/lib/strftime.c b/lib/strftime.c
index c7b8eb5ef7e..91d5d85cbcf 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2001, 2003-2007, 2009-2012 Free Software Foundation, Inc. 1/* Copyright (C) 1991-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc.
2 2
3 NOTE: The canonical source of this file is maintained with the GNU C Library. 3 NOTE: The canonical source of this file is maintained with the GNU C Library.
4 Bugs can be reported to bug-glibc@prep.ai.mit.edu. 4 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
@@ -26,7 +26,6 @@
26#else 26#else
27# include <config.h> 27# include <config.h>
28# if FPRINTFTIME 28# if FPRINTFTIME
29# include "ignore-value.h"
30# include "fprintftime.h" 29# include "fprintftime.h"
31# else 30# else
32# include "strftime.h" 31# include "strftime.h"
@@ -210,13 +209,12 @@ extern char *tzname[];
210 fwrite_uppcase (p, (s), _n); \ 209 fwrite_uppcase (p, (s), _n); \
211 else \ 210 else \
212 { \ 211 { \
213 /* We are ignoring the value of fwrite here, in spite of the \ 212 /* Ignore the value of fwrite. The caller can determine whether \
214 fact that technically, that may not be valid: the fwrite \ 213 an error occurred by inspecting ferror (P). All known fwrite \
215 specification in POSIX 2008 defers to that of fputc, which \ 214 implementations set the stream's error indicator when they \
216 is intended to be consistent with the one from ISO C, \ 215 fail due to ENOMEM etc., even though C11 and POSIX.1-2008 do \
217 which permits failure due to ENOMEM *without* setting the \ 216 not require this. */ \
218 stream's error indicator. */ \ 217 fwrite (s, _n, 1, p); \
219 ignore_value (fwrite ((s), _n, 1, p)); \
220 } \ 218 } \
221 } \ 219 } \
222 while (0) \ 220 while (0) \
diff --git a/lib/strftime.h b/lib/strftime.h
index d3b4cb28c52..a47e6d1e1f6 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -1,6 +1,6 @@
1/* declarations for strftime.c 1/* declarations for strftime.c
2 2
3 Copyright (C) 2002, 2004, 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2004, 2008-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/string.in.h b/lib/string.in.h
new file mode 100644
index 00000000000..d7a6c9c923e
--- /dev/null
+++ b/lib/string.in.h
@@ -0,0 +1,1029 @@
1/* A GNU-like <string.h>.
2
3 Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17
18#ifndef _@GUARD_PREFIX@_STRING_H
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_STRING_H@
27
28#ifndef _@GUARD_PREFIX@_STRING_H
29#define _@GUARD_PREFIX@_STRING_H
30
31/* NetBSD 5.0 mis-defines NULL. */
32#include <stddef.h>
33
34/* MirBSD defines mbslen as a macro. */
35#if @GNULIB_MBSLEN@ && defined __MirBSD__
36# include <wchar.h>
37#endif
38
39/* The __attribute__ feature is available in gcc versions 2.5 and later.
40 The attribute __pure__ was added in gcc 2.96. */
41#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
42# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
43#else
44# define _GL_ATTRIBUTE_PURE /* empty */
45#endif
46
47/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
48/* But in any case avoid namespace pollution on glibc systems. */
49#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
50 && ! defined __GLIBC__
51# include <unistd.h>
52#endif
53
54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55
56/* The definition of _GL_ARG_NONNULL is copied here. */
57
58/* The definition of _GL_WARN_ON_USE is copied here. */
59
60
61/* Find the index of the least-significant set bit. */
62#if @GNULIB_FFSL@
63# if !@HAVE_FFSL@
64_GL_FUNCDECL_SYS (ffsl, int, (long int i));
65# endif
66_GL_CXXALIAS_SYS (ffsl, int, (long int i));
67_GL_CXXALIASWARN (ffsl);
68#elif defined GNULIB_POSIXCHECK
69# undef ffsl
70# if HAVE_RAW_DECL_FFSL
71_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
72# endif
73#endif
74
75
76/* Find the index of the least-significant set bit. */
77#if @GNULIB_FFSLL@
78# if !@HAVE_FFSLL@
79_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
80# endif
81_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
82_GL_CXXALIASWARN (ffsll);
83#elif defined GNULIB_POSIXCHECK
84# undef ffsll
85# if HAVE_RAW_DECL_FFSLL
86_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
87# endif
88#endif
89
90
91/* Return the first instance of C within N bytes of S, or NULL. */
92#if @GNULIB_MEMCHR@
93# if @REPLACE_MEMCHR@
94# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
95# define memchr rpl_memchr
96# endif
97_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
98 _GL_ATTRIBUTE_PURE
99 _GL_ARG_NONNULL ((1)));
100_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
101# else
102# if ! @HAVE_MEMCHR@
103_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
104 _GL_ATTRIBUTE_PURE
105 _GL_ARG_NONNULL ((1)));
106# endif
107 /* On some systems, this function is defined as an overloaded function:
108 extern "C" { const void * std::memchr (const void *, int, size_t); }
109 extern "C++" { void * std::memchr (void *, int, size_t); } */
110_GL_CXXALIAS_SYS_CAST2 (memchr,
111 void *, (void const *__s, int __c, size_t __n),
112 void const *, (void const *__s, int __c, size_t __n));
113# endif
114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
116_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
117_GL_CXXALIASWARN1 (memchr, void const *,
118 (void const *__s, int __c, size_t __n));
119# else
120_GL_CXXALIASWARN (memchr);
121# endif
122#elif defined GNULIB_POSIXCHECK
123# undef memchr
124/* Assume memchr is always declared. */
125_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
126 "use gnulib module memchr for portability" );
127#endif
128
129/* Return the first occurrence of NEEDLE in HAYSTACK. */
130#if @GNULIB_MEMMEM@
131# if @REPLACE_MEMMEM@
132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133# define memmem rpl_memmem
134# endif
135_GL_FUNCDECL_RPL (memmem, void *,
136 (void const *__haystack, size_t __haystack_len,
137 void const *__needle, size_t __needle_len)
138 _GL_ATTRIBUTE_PURE
139 _GL_ARG_NONNULL ((1, 3)));
140_GL_CXXALIAS_RPL (memmem, void *,
141 (void const *__haystack, size_t __haystack_len,
142 void const *__needle, size_t __needle_len));
143# else
144# if ! @HAVE_DECL_MEMMEM@
145_GL_FUNCDECL_SYS (memmem, void *,
146 (void const *__haystack, size_t __haystack_len,
147 void const *__needle, size_t __needle_len)
148 _GL_ATTRIBUTE_PURE
149 _GL_ARG_NONNULL ((1, 3)));
150# endif
151_GL_CXXALIAS_SYS (memmem, void *,
152 (void const *__haystack, size_t __haystack_len,
153 void const *__needle, size_t __needle_len));
154# endif
155_GL_CXXALIASWARN (memmem);
156#elif defined GNULIB_POSIXCHECK
157# undef memmem
158# if HAVE_RAW_DECL_MEMMEM
159_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
160 "use gnulib module memmem-simple for portability, "
161 "and module memmem for speed" );
162# endif
163#endif
164
165/* Copy N bytes of SRC to DEST, return pointer to bytes after the
166 last written byte. */
167#if @GNULIB_MEMPCPY@
168# if ! @HAVE_MEMPCPY@
169_GL_FUNCDECL_SYS (mempcpy, void *,
170 (void *restrict __dest, void const *restrict __src,
171 size_t __n)
172 _GL_ARG_NONNULL ((1, 2)));
173# endif
174_GL_CXXALIAS_SYS (mempcpy, void *,
175 (void *restrict __dest, void const *restrict __src,
176 size_t __n));
177_GL_CXXALIASWARN (mempcpy);
178#elif defined GNULIB_POSIXCHECK
179# undef mempcpy
180# if HAVE_RAW_DECL_MEMPCPY
181_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
182 "use gnulib module mempcpy for portability");
183# endif
184#endif
185
186/* Search backwards through a block for a byte (specified as an int). */
187#if @GNULIB_MEMRCHR@
188# if ! @HAVE_DECL_MEMRCHR@
189_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
190 _GL_ATTRIBUTE_PURE
191 _GL_ARG_NONNULL ((1)));
192# endif
193 /* On some systems, this function is defined as an overloaded function:
194 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
195 extern "C++" { void * std::memrchr (void *, int, size_t); } */
196_GL_CXXALIAS_SYS_CAST2 (memrchr,
197 void *, (void const *, int, size_t),
198 void const *, (void const *, int, size_t));
199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
202_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
203# else
204_GL_CXXALIASWARN (memrchr);
205# endif
206#elif defined GNULIB_POSIXCHECK
207# undef memrchr
208# if HAVE_RAW_DECL_MEMRCHR
209_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
210 "use gnulib module memrchr for portability");
211# endif
212#endif
213
214/* Find the first occurrence of C in S. More efficient than
215 memchr(S,C,N), at the expense of undefined behavior if C does not
216 occur within N bytes. */
217#if @GNULIB_RAWMEMCHR@
218# if ! @HAVE_RAWMEMCHR@
219_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
220 _GL_ATTRIBUTE_PURE
221 _GL_ARG_NONNULL ((1)));
222# endif
223 /* On some systems, this function is defined as an overloaded function:
224 extern "C++" { const void * std::rawmemchr (const void *, int); }
225 extern "C++" { void * std::rawmemchr (void *, int); } */
226_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
227 void *, (void const *__s, int __c_in),
228 void const *, (void const *__s, int __c_in));
229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
232_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
233# else
234_GL_CXXALIASWARN (rawmemchr);
235# endif
236#elif defined GNULIB_POSIXCHECK
237# undef rawmemchr
238# if HAVE_RAW_DECL_RAWMEMCHR
239_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
240 "use gnulib module rawmemchr for portability");
241# endif
242#endif
243
244/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
245#if @GNULIB_STPCPY@
246# if ! @HAVE_STPCPY@
247_GL_FUNCDECL_SYS (stpcpy, char *,
248 (char *restrict __dst, char const *restrict __src)
249 _GL_ARG_NONNULL ((1, 2)));
250# endif
251_GL_CXXALIAS_SYS (stpcpy, char *,
252 (char *restrict __dst, char const *restrict __src));
253_GL_CXXALIASWARN (stpcpy);
254#elif defined GNULIB_POSIXCHECK
255# undef stpcpy
256# if HAVE_RAW_DECL_STPCPY
257_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
258 "use gnulib module stpcpy for portability");
259# endif
260#endif
261
262/* Copy no more than N bytes of SRC to DST, returning a pointer past the
263 last non-NUL byte written into DST. */
264#if @GNULIB_STPNCPY@
265# if @REPLACE_STPNCPY@
266# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
267# undef stpncpy
268# define stpncpy rpl_stpncpy
269# endif
270_GL_FUNCDECL_RPL (stpncpy, char *,
271 (char *restrict __dst, char const *restrict __src,
272 size_t __n)
273 _GL_ARG_NONNULL ((1, 2)));
274_GL_CXXALIAS_RPL (stpncpy, char *,
275 (char *restrict __dst, char const *restrict __src,
276 size_t __n));
277# else
278# if ! @HAVE_STPNCPY@
279_GL_FUNCDECL_SYS (stpncpy, char *,
280 (char *restrict __dst, char const *restrict __src,
281 size_t __n)
282 _GL_ARG_NONNULL ((1, 2)));
283# endif
284_GL_CXXALIAS_SYS (stpncpy, char *,
285 (char *restrict __dst, char const *restrict __src,
286 size_t __n));
287# endif
288_GL_CXXALIASWARN (stpncpy);
289#elif defined GNULIB_POSIXCHECK
290# undef stpncpy
291# if HAVE_RAW_DECL_STPNCPY
292_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
293 "use gnulib module stpncpy for portability");
294# endif
295#endif
296
297#if defined GNULIB_POSIXCHECK
298/* strchr() does not work with multibyte strings if the locale encoding is
299 GB18030 and the character to be searched is a digit. */
300# undef strchr
301/* Assume strchr is always declared. */
302_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
303 "in some multibyte locales - "
304 "use mbschr if you care about internationalization");
305#endif
306
307/* Find the first occurrence of C in S or the final NUL byte. */
308#if @GNULIB_STRCHRNUL@
309# if @REPLACE_STRCHRNUL@
310# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
311# define strchrnul rpl_strchrnul
312# endif
313_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
314 _GL_ATTRIBUTE_PURE
315 _GL_ARG_NONNULL ((1)));
316_GL_CXXALIAS_RPL (strchrnul, char *,
317 (const char *str, int ch));
318# else
319# if ! @HAVE_STRCHRNUL@
320_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
321 _GL_ATTRIBUTE_PURE
322 _GL_ARG_NONNULL ((1)));
323# endif
324 /* On some systems, this function is defined as an overloaded function:
325 extern "C++" { const char * std::strchrnul (const char *, int); }
326 extern "C++" { char * std::strchrnul (char *, int); } */
327_GL_CXXALIAS_SYS_CAST2 (strchrnul,
328 char *, (char const *__s, int __c_in),
329 char const *, (char const *__s, int __c_in));
330# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
334_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
335# else
336_GL_CXXALIASWARN (strchrnul);
337# endif
338#elif defined GNULIB_POSIXCHECK
339# undef strchrnul
340# if HAVE_RAW_DECL_STRCHRNUL
341_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
342 "use gnulib module strchrnul for portability");
343# endif
344#endif
345
346/* Duplicate S, returning an identical malloc'd string. */
347#if @GNULIB_STRDUP@
348# if @REPLACE_STRDUP@
349# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
350# undef strdup
351# define strdup rpl_strdup
352# endif
353_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
355# else
356# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
357 /* strdup exists as a function and as a macro. Get rid of the macro. */
358# undef strdup
359# endif
360# if !(@HAVE_DECL_STRDUP@ || defined strdup)
361_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
362# endif
363_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
364# endif
365_GL_CXXALIASWARN (strdup);
366#elif defined GNULIB_POSIXCHECK
367# undef strdup
368# if HAVE_RAW_DECL_STRDUP
369_GL_WARN_ON_USE (strdup, "strdup is unportable - "
370 "use gnulib module strdup for portability");
371# endif
372#endif
373
374/* Append no more than N characters from SRC onto DEST. */
375#if @GNULIB_STRNCAT@
376# if @REPLACE_STRNCAT@
377# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
378# undef strncat
379# define strncat rpl_strncat
380# endif
381_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
382 _GL_ARG_NONNULL ((1, 2)));
383_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
384# else
385_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
386# endif
387_GL_CXXALIASWARN (strncat);
388#elif defined GNULIB_POSIXCHECK
389# undef strncat
390# if HAVE_RAW_DECL_STRNCAT
391_GL_WARN_ON_USE (strncat, "strncat is unportable - "
392 "use gnulib module strncat for portability");
393# endif
394#endif
395
396/* Return a newly allocated copy of at most N bytes of STRING. */
397#if @GNULIB_STRNDUP@
398# if @REPLACE_STRNDUP@
399# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
400# undef strndup
401# define strndup rpl_strndup
402# endif
403_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
404 _GL_ARG_NONNULL ((1)));
405_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
406# else
407# if ! @HAVE_DECL_STRNDUP@
408_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
409 _GL_ARG_NONNULL ((1)));
410# endif
411_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
412# endif
413_GL_CXXALIASWARN (strndup);
414#elif defined GNULIB_POSIXCHECK
415# undef strndup
416# if HAVE_RAW_DECL_STRNDUP
417_GL_WARN_ON_USE (strndup, "strndup is unportable - "
418 "use gnulib module strndup for portability");
419# endif
420#endif
421
422/* Find the length (number of bytes) of STRING, but scan at most
423 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
424 return MAXLEN. */
425#if @GNULIB_STRNLEN@
426# if @REPLACE_STRNLEN@
427# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
428# undef strnlen
429# define strnlen rpl_strnlen
430# endif
431_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
432 _GL_ATTRIBUTE_PURE
433 _GL_ARG_NONNULL ((1)));
434_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
435# else
436# if ! @HAVE_DECL_STRNLEN@
437_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
438 _GL_ATTRIBUTE_PURE
439 _GL_ARG_NONNULL ((1)));
440# endif
441_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
442# endif
443_GL_CXXALIASWARN (strnlen);
444#elif defined GNULIB_POSIXCHECK
445# undef strnlen
446# if HAVE_RAW_DECL_STRNLEN
447_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
448 "use gnulib module strnlen for portability");
449# endif
450#endif
451
452#if defined GNULIB_POSIXCHECK
453/* strcspn() assumes the second argument is a list of single-byte characters.
454 Even in this simple case, it does not work with multibyte strings if the
455 locale encoding is GB18030 and one of the characters to be searched is a
456 digit. */
457# undef strcspn
458/* Assume strcspn is always declared. */
459_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
460 "in multibyte locales - "
461 "use mbscspn if you care about internationalization");
462#endif
463
464/* Find the first occurrence in S of any character in ACCEPT. */
465#if @GNULIB_STRPBRK@
466# if ! @HAVE_STRPBRK@
467_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
468 _GL_ATTRIBUTE_PURE
469 _GL_ARG_NONNULL ((1, 2)));
470# endif
471 /* On some systems, this function is defined as an overloaded function:
472 extern "C" { const char * strpbrk (const char *, const char *); }
473 extern "C++" { char * strpbrk (char *, const char *); } */
474_GL_CXXALIAS_SYS_CAST2 (strpbrk,
475 char *, (char const *__s, char const *__accept),
476 const char *, (char const *__s, char const *__accept));
477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
480_GL_CXXALIASWARN1 (strpbrk, char const *,
481 (char const *__s, char const *__accept));
482# else
483_GL_CXXALIASWARN (strpbrk);
484# endif
485# if defined GNULIB_POSIXCHECK
486/* strpbrk() assumes the second argument is a list of single-byte characters.
487 Even in this simple case, it does not work with multibyte strings if the
488 locale encoding is GB18030 and one of the characters to be searched is a
489 digit. */
490# undef strpbrk
491_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
492 "in multibyte locales - "
493 "use mbspbrk if you care about internationalization");
494# endif
495#elif defined GNULIB_POSIXCHECK
496# undef strpbrk
497# if HAVE_RAW_DECL_STRPBRK
498_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
499 "use gnulib module strpbrk for portability");
500# endif
501#endif
502
503#if defined GNULIB_POSIXCHECK
504/* strspn() assumes the second argument is a list of single-byte characters.
505 Even in this simple case, it cannot work with multibyte strings. */
506# undef strspn
507/* Assume strspn is always declared. */
508_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
509 "in multibyte locales - "
510 "use mbsspn if you care about internationalization");
511#endif
512
513#if defined GNULIB_POSIXCHECK
514/* strrchr() does not work with multibyte strings if the locale encoding is
515 GB18030 and the character to be searched is a digit. */
516# undef strrchr
517/* Assume strrchr is always declared. */
518_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
519 "in some multibyte locales - "
520 "use mbsrchr if you care about internationalization");
521#endif
522
523/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
524 If one is found, overwrite it with a NUL, and advance *STRINGP
525 to point to the next char after it. Otherwise, set *STRINGP to NULL.
526 If *STRINGP was already NULL, nothing happens.
527 Return the old value of *STRINGP.
528
529 This is a variant of strtok() that is multithread-safe and supports
530 empty fields.
531
532 Caveat: It modifies the original string.
533 Caveat: These functions cannot be used on constant strings.
534 Caveat: The identity of the delimiting character is lost.
535 Caveat: It doesn't work with multibyte strings unless all of the delimiter
536 characters are ASCII characters < 0x30.
537
538 See also strtok_r(). */
539#if @GNULIB_STRSEP@
540# if ! @HAVE_STRSEP@
541_GL_FUNCDECL_SYS (strsep, char *,
542 (char **restrict __stringp, char const *restrict __delim)
543 _GL_ARG_NONNULL ((1, 2)));
544# endif
545_GL_CXXALIAS_SYS (strsep, char *,
546 (char **restrict __stringp, char const *restrict __delim));
547_GL_CXXALIASWARN (strsep);
548# if defined GNULIB_POSIXCHECK
549# undef strsep
550_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
551 "in multibyte locales - "
552 "use mbssep if you care about internationalization");
553# endif
554#elif defined GNULIB_POSIXCHECK
555# undef strsep
556# if HAVE_RAW_DECL_STRSEP
557_GL_WARN_ON_USE (strsep, "strsep is unportable - "
558 "use gnulib module strsep for portability");
559# endif
560#endif
561
562#if @GNULIB_STRSTR@
563# if @REPLACE_STRSTR@
564# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
565# define strstr rpl_strstr
566# endif
567_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
568 _GL_ATTRIBUTE_PURE
569 _GL_ARG_NONNULL ((1, 2)));
570_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
571# else
572 /* On some systems, this function is defined as an overloaded function:
573 extern "C++" { const char * strstr (const char *, const char *); }
574 extern "C++" { char * strstr (char *, const char *); } */
575_GL_CXXALIAS_SYS_CAST2 (strstr,
576 char *, (const char *haystack, const char *needle),
577 const char *, (const char *haystack, const char *needle));
578# endif
579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
582_GL_CXXALIASWARN1 (strstr, const char *,
583 (const char *haystack, const char *needle));
584# else
585_GL_CXXALIASWARN (strstr);
586# endif
587#elif defined GNULIB_POSIXCHECK
588/* strstr() does not work with multibyte strings if the locale encoding is
589 different from UTF-8:
590 POSIX says that it operates on "strings", and "string" in POSIX is defined
591 as a sequence of bytes, not of characters. */
592# undef strstr
593/* Assume strstr is always declared. */
594_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
595 "work correctly on character strings in most "
596 "multibyte locales - "
597 "use mbsstr if you care about internationalization, "
598 "or use strstr if you care about speed");
599#endif
600
601/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
602 comparison. */
603#if @GNULIB_STRCASESTR@
604# if @REPLACE_STRCASESTR@
605# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
606# define strcasestr rpl_strcasestr
607# endif
608_GL_FUNCDECL_RPL (strcasestr, char *,
609 (const char *haystack, const char *needle)
610 _GL_ATTRIBUTE_PURE
611 _GL_ARG_NONNULL ((1, 2)));
612_GL_CXXALIAS_RPL (strcasestr, char *,
613 (const char *haystack, const char *needle));
614# else
615# if ! @HAVE_STRCASESTR@
616_GL_FUNCDECL_SYS (strcasestr, char *,
617 (const char *haystack, const char *needle)
618 _GL_ATTRIBUTE_PURE
619 _GL_ARG_NONNULL ((1, 2)));
620# endif
621 /* On some systems, this function is defined as an overloaded function:
622 extern "C++" { const char * strcasestr (const char *, const char *); }
623 extern "C++" { char * strcasestr (char *, const char *); } */
624_GL_CXXALIAS_SYS_CAST2 (strcasestr,
625 char *, (const char *haystack, const char *needle),
626 const char *, (const char *haystack, const char *needle));
627# endif
628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
631_GL_CXXALIASWARN1 (strcasestr, const char *,
632 (const char *haystack, const char *needle));
633# else
634_GL_CXXALIASWARN (strcasestr);
635# endif
636#elif defined GNULIB_POSIXCHECK
637/* strcasestr() does not work with multibyte strings:
638 It is a glibc extension, and glibc implements it only for unibyte
639 locales. */
640# undef strcasestr
641# if HAVE_RAW_DECL_STRCASESTR
642_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
643 "strings in multibyte locales - "
644 "use mbscasestr if you care about "
645 "internationalization, or use c-strcasestr if you want "
646 "a locale independent function");
647# endif
648#endif
649
650/* Parse S into tokens separated by characters in DELIM.
651 If S is NULL, the saved pointer in SAVE_PTR is used as
652 the next starting point. For example:
653 char s[] = "-abc-=-def";
654 char *sp;
655 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
656 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
657 x = strtok_r(NULL, "=", &sp); // x = NULL
658 // s = "abc\0-def\0"
659
660 This is a variant of strtok() that is multithread-safe.
661
662 For the POSIX documentation for this function, see:
663 http://www.opengroup.org/susv3xsh/strtok.html
664
665 Caveat: It modifies the original string.
666 Caveat: These functions cannot be used on constant strings.
667 Caveat: The identity of the delimiting character is lost.
668 Caveat: It doesn't work with multibyte strings unless all of the delimiter
669 characters are ASCII characters < 0x30.
670
671 See also strsep(). */
672#if @GNULIB_STRTOK_R@
673# if @REPLACE_STRTOK_R@
674# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
675# undef strtok_r
676# define strtok_r rpl_strtok_r
677# endif
678_GL_FUNCDECL_RPL (strtok_r, char *,
679 (char *restrict s, char const *restrict delim,
680 char **restrict save_ptr)
681 _GL_ARG_NONNULL ((2, 3)));
682_GL_CXXALIAS_RPL (strtok_r, char *,
683 (char *restrict s, char const *restrict delim,
684 char **restrict save_ptr));
685# else
686# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
687# undef strtok_r
688# endif
689# if ! @HAVE_DECL_STRTOK_R@
690_GL_FUNCDECL_SYS (strtok_r, char *,
691 (char *restrict s, char const *restrict delim,
692 char **restrict save_ptr)
693 _GL_ARG_NONNULL ((2, 3)));
694# endif
695_GL_CXXALIAS_SYS (strtok_r, char *,
696 (char *restrict s, char const *restrict delim,
697 char **restrict save_ptr));
698# endif
699_GL_CXXALIASWARN (strtok_r);
700# if defined GNULIB_POSIXCHECK
701_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
702 "strings in multibyte locales - "
703 "use mbstok_r if you care about internationalization");
704# endif
705#elif defined GNULIB_POSIXCHECK
706# undef strtok_r
707# if HAVE_RAW_DECL_STRTOK_R
708_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
709 "use gnulib module strtok_r for portability");
710# endif
711#endif
712
713
714/* The following functions are not specified by POSIX. They are gnulib
715 extensions. */
716
717#if @GNULIB_MBSLEN@
718/* Return the number of multibyte characters in the character string STRING.
719 This considers multibyte characters, unlike strlen, which counts bytes. */
720# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
721# undef mbslen
722# endif
723# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
724# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
725# define mbslen rpl_mbslen
726# endif
727_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
728 _GL_ATTRIBUTE_PURE
729 _GL_ARG_NONNULL ((1)));
730_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
731# else
732_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
733 _GL_ATTRIBUTE_PURE
734 _GL_ARG_NONNULL ((1)));
735_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
736# endif
737_GL_CXXALIASWARN (mbslen);
738#endif
739
740#if @GNULIB_MBSNLEN@
741/* Return the number of multibyte characters in the character string starting
742 at STRING and ending at STRING + LEN. */
743_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
744 _GL_ATTRIBUTE_PURE
745 _GL_ARG_NONNULL ((1));
746#endif
747
748#if @GNULIB_MBSCHR@
749/* Locate the first single-byte character C in the character string STRING,
750 and return a pointer to it. Return NULL if C is not found in STRING.
751 Unlike strchr(), this function works correctly in multibyte locales with
752 encodings such as GB18030. */
753# if defined __hpux
754# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
755# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
756# endif
757_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
758 _GL_ATTRIBUTE_PURE
759 _GL_ARG_NONNULL ((1)));
760_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
761# else
762_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
763 _GL_ATTRIBUTE_PURE
764 _GL_ARG_NONNULL ((1)));
765_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
766# endif
767_GL_CXXALIASWARN (mbschr);
768#endif
769
770#if @GNULIB_MBSRCHR@
771/* Locate the last single-byte character C in the character string STRING,
772 and return a pointer to it. Return NULL if C is not found in STRING.
773 Unlike strrchr(), this function works correctly in multibyte locales with
774 encodings such as GB18030. */
775# if defined __hpux || defined __INTERIX
776# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
777# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
778# endif
779_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
780 _GL_ATTRIBUTE_PURE
781 _GL_ARG_NONNULL ((1)));
782_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
783# else
784_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
785 _GL_ATTRIBUTE_PURE
786 _GL_ARG_NONNULL ((1)));
787_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
788# endif
789_GL_CXXALIASWARN (mbsrchr);
790#endif
791
792#if @GNULIB_MBSSTR@
793/* Find the first occurrence of the character string NEEDLE in the character
794 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
795 Unlike strstr(), this function works correctly in multibyte locales with
796 encodings different from UTF-8. */
797_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
798 _GL_ATTRIBUTE_PURE
799 _GL_ARG_NONNULL ((1, 2));
800#endif
801
802#if @GNULIB_MBSCASECMP@
803/* Compare the character strings S1 and S2, ignoring case, returning less than,
804 equal to or greater than zero if S1 is lexicographically less than, equal to
805 or greater than S2.
806 Note: This function may, in multibyte locales, return 0 for strings of
807 different lengths!
808 Unlike strcasecmp(), this function works correctly in multibyte locales. */
809_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
810 _GL_ATTRIBUTE_PURE
811 _GL_ARG_NONNULL ((1, 2));
812#endif
813
814#if @GNULIB_MBSNCASECMP@
815/* Compare the initial segment of the character string S1 consisting of at most
816 N characters with the initial segment of the character string S2 consisting
817 of at most N characters, ignoring case, returning less than, equal to or
818 greater than zero if the initial segment of S1 is lexicographically less
819 than, equal to or greater than the initial segment of S2.
820 Note: This function may, in multibyte locales, return 0 for initial segments
821 of different lengths!
822 Unlike strncasecmp(), this function works correctly in multibyte locales.
823 But beware that N is not a byte count but a character count! */
824_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
825 _GL_ATTRIBUTE_PURE
826 _GL_ARG_NONNULL ((1, 2));
827#endif
828
829#if @GNULIB_MBSPCASECMP@
830/* Compare the initial segment of the character string STRING consisting of
831 at most mbslen (PREFIX) characters with the character string PREFIX,
832 ignoring case. If the two match, return a pointer to the first byte
833 after this prefix in STRING. Otherwise, return NULL.
834 Note: This function may, in multibyte locales, return non-NULL if STRING
835 is of smaller length than PREFIX!
836 Unlike strncasecmp(), this function works correctly in multibyte
837 locales. */
838_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
839 _GL_ATTRIBUTE_PURE
840 _GL_ARG_NONNULL ((1, 2));
841#endif
842
843#if @GNULIB_MBSCASESTR@
844/* Find the first occurrence of the character string NEEDLE in the character
845 string HAYSTACK, using case-insensitive comparison.
846 Note: This function may, in multibyte locales, return success even if
847 strlen (haystack) < strlen (needle) !
848 Unlike strcasestr(), this function works correctly in multibyte locales. */
849_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
850 _GL_ATTRIBUTE_PURE
851 _GL_ARG_NONNULL ((1, 2));
852#endif
853
854#if @GNULIB_MBSCSPN@
855/* Find the first occurrence in the character string STRING of any character
856 in the character string ACCEPT. Return the number of bytes from the
857 beginning of the string to this occurrence, or to the end of the string
858 if none exists.
859 Unlike strcspn(), this function works correctly in multibyte locales. */
860_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
861 _GL_ATTRIBUTE_PURE
862 _GL_ARG_NONNULL ((1, 2));
863#endif
864
865#if @GNULIB_MBSPBRK@
866/* Find the first occurrence in the character string STRING of any character
867 in the character string ACCEPT. Return the pointer to it, or NULL if none
868 exists.
869 Unlike strpbrk(), this function works correctly in multibyte locales. */
870# if defined __hpux
871# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
872# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
873# endif
874_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
875 _GL_ATTRIBUTE_PURE
876 _GL_ARG_NONNULL ((1, 2)));
877_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
878# else
879_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
880 _GL_ATTRIBUTE_PURE
881 _GL_ARG_NONNULL ((1, 2)));
882_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
883# endif
884_GL_CXXALIASWARN (mbspbrk);
885#endif
886
887#if @GNULIB_MBSSPN@
888/* Find the first occurrence in the character string STRING of any character
889 not in the character string REJECT. Return the number of bytes from the
890 beginning of the string to this occurrence, or to the end of the string
891 if none exists.
892 Unlike strspn(), this function works correctly in multibyte locales. */
893_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
894 _GL_ATTRIBUTE_PURE
895 _GL_ARG_NONNULL ((1, 2));
896#endif
897
898#if @GNULIB_MBSSEP@
899/* Search the next delimiter (multibyte character listed in the character
900 string DELIM) starting at the character string *STRINGP.
901 If one is found, overwrite it with a NUL, and advance *STRINGP to point
902 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
903 If *STRINGP was already NULL, nothing happens.
904 Return the old value of *STRINGP.
905
906 This is a variant of mbstok_r() that supports empty fields.
907
908 Caveat: It modifies the original string.
909 Caveat: These functions cannot be used on constant strings.
910 Caveat: The identity of the delimiting character is lost.
911
912 See also mbstok_r(). */
913_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
914 _GL_ARG_NONNULL ((1, 2));
915#endif
916
917#if @GNULIB_MBSTOK_R@
918/* Parse the character string STRING into tokens separated by characters in
919 the character string DELIM.
920 If STRING is NULL, the saved pointer in SAVE_PTR is used as
921 the next starting point. For example:
922 char s[] = "-abc-=-def";
923 char *sp;
924 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
925 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
926 x = mbstok_r(NULL, "=", &sp); // x = NULL
927 // s = "abc\0-def\0"
928
929 Caveat: It modifies the original string.
930 Caveat: These functions cannot be used on constant strings.
931 Caveat: The identity of the delimiting character is lost.
932
933 See also mbssep(). */
934_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
935 _GL_ARG_NONNULL ((2, 3));
936#endif
937
938/* Map any int, typically from errno, into an error message. */
939#if @GNULIB_STRERROR@
940# if @REPLACE_STRERROR@
941# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
942# undef strerror
943# define strerror rpl_strerror
944# endif
945_GL_FUNCDECL_RPL (strerror, char *, (int));
946_GL_CXXALIAS_RPL (strerror, char *, (int));
947# else
948_GL_CXXALIAS_SYS (strerror, char *, (int));
949# endif
950_GL_CXXALIASWARN (strerror);
951#elif defined GNULIB_POSIXCHECK
952# undef strerror
953/* Assume strerror is always declared. */
954_GL_WARN_ON_USE (strerror, "strerror is unportable - "
955 "use gnulib module strerror to guarantee non-NULL result");
956#endif
957
958/* Map any int, typically from errno, into an error message. Multithread-safe.
959 Uses the POSIX declaration, not the glibc declaration. */
960#if @GNULIB_STRERROR_R@
961# if @REPLACE_STRERROR_R@
962# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
963# undef strerror_r
964# define strerror_r rpl_strerror_r
965# endif
966_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
967 _GL_ARG_NONNULL ((2)));
968_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
969# else
970# if !@HAVE_DECL_STRERROR_R@
971_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
972 _GL_ARG_NONNULL ((2)));
973# endif
974_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
975# endif
976# if @HAVE_DECL_STRERROR_R@
977_GL_CXXALIASWARN (strerror_r);
978# endif
979#elif defined GNULIB_POSIXCHECK
980# undef strerror_r
981# if HAVE_RAW_DECL_STRERROR_R
982_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
983 "use gnulib module strerror_r-posix for portability");
984# endif
985#endif
986
987#if @GNULIB_STRSIGNAL@
988# if @REPLACE_STRSIGNAL@
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
990# define strsignal rpl_strsignal
991# endif
992_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
993_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
994# else
995# if ! @HAVE_DECL_STRSIGNAL@
996_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
997# endif
998/* Need to cast, because on Cygwin 1.5.x systems, the return type is
999 'const char *'. */
1000_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1001# endif
1002_GL_CXXALIASWARN (strsignal);
1003#elif defined GNULIB_POSIXCHECK
1004# undef strsignal
1005# if HAVE_RAW_DECL_STRSIGNAL
1006_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1007 "use gnulib module strsignal for portability");
1008# endif
1009#endif
1010
1011#if @GNULIB_STRVERSCMP@
1012# if !@HAVE_STRVERSCMP@
1013_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1014 _GL_ATTRIBUTE_PURE
1015 _GL_ARG_NONNULL ((1, 2)));
1016# endif
1017_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1018_GL_CXXALIASWARN (strverscmp);
1019#elif defined GNULIB_POSIXCHECK
1020# undef strverscmp
1021# if HAVE_RAW_DECL_STRVERSCMP
1022_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1023 "use gnulib module strverscmp for portability");
1024# endif
1025#endif
1026
1027
1028#endif /* _@GUARD_PREFIX@_STRING_H */
1029#endif /* _@GUARD_PREFIX@_STRING_H */
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index 4f5fdbb5f22..c9bd2ad3b1c 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -1,6 +1,6 @@
1/* Convert string representation of a number into an intmax_t value. 1/* Convert string representation of a number into an intmax_t value.
2 2
3 Copyright (C) 1999, 2001-2004, 2006, 2009-2012 Free Software Foundation, 3 Copyright (C) 1999, 2001-2004, 2006, 2009-2013 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/lib/strtol.c b/lib/strtol.c
index bf992a8c272..379eda8c11b 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -1,6 +1,6 @@
1/* Convert string representation of a number into an integer value. 1/* Convert string representation of a number into an integer value.
2 2
3 Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2012 Free Software 3 Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with the GNU C 6 NOTE: The canonical source of this file is maintained with the GNU C
diff --git a/lib/strtoll.c b/lib/strtoll.c
index fdfceb01371..bb424002c96 100644
--- a/lib/strtoll.c
+++ b/lib/strtoll.c
@@ -1,5 +1,5 @@
1/* Function to parse a 'long long int' from text. 1/* Function to parse a 'long long int' from text.
2 Copyright (C) 1995-1997, 1999, 2001, 2009-2012 Free Software Foundation, 2 Copyright (C) 1995-1997, 1999, 2001, 2009-2013 Free Software Foundation,
3 Inc. 3 Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
diff --git a/lib/strtoul.c b/lib/strtoul.c
index e99da41edc0..a0ca376cdac 100644
--- a/lib/strtoul.c
+++ b/lib/strtoul.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991, 1997, 2009-2012 Free Software Foundation, Inc. 1/* Copyright (C) 1991, 1997, 2009-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
diff --git a/lib/strtoull.c b/lib/strtoull.c
index 33c2c5d9afb..494cc2f2926 100644
--- a/lib/strtoull.c
+++ b/lib/strtoull.c
@@ -1,5 +1,5 @@
1/* Function to parse an 'unsigned long long int' from text. 1/* Function to parse an 'unsigned long long int' from text.
2 Copyright (C) 1995-1997, 1999, 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 1995-1997, 1999, 2009-2013 Free Software Foundation, Inc.
3 NOTE: The canonical source of this file is maintained with the GNU C 3 NOTE: The canonical source of this file is maintained with the GNU C
4 Library. Bugs can be reported to bug-glibc@gnu.org. 4 Library. Bugs can be reported to bug-glibc@gnu.org.
5 5
diff --git a/lib/symlink.c b/lib/symlink.c
index 642ca66b66c..d3c9f21bb78 100644
--- a/lib/symlink.c
+++ b/lib/symlink.c
@@ -1,5 +1,5 @@
1/* Stub for symlink(). 1/* Stub for symlink().
2 Copyright (C) 2009-2012 Free Software Foundation, Inc. 2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index ae8f90cae74..521ccef321d 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -1,5 +1,5 @@
1/* Substitute for <sys/select.h>. 1/* Substitute for <sys/select.h>.
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -19,14 +19,25 @@
19# endif 19# endif
20@PRAGMA_COLUMNS@ 20@PRAGMA_COLUMNS@
21 21
22/* On OSF/1, <sys/types.h> and <sys/time.h> include <sys/select.h>. 22/* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
23 both include <sys/select.h>.
23 Simply delegate to the system's header in this case. */ 24 Simply delegate to the system's header in this case. */
24#if @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TYPES_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H) && defined _OSF_SOURCE 25#if (@HAVE_SYS_SELECT_H@ \
26 && ((defined __osf__ && defined _SYS_TYPES_H_ && defined _OSF_SOURCE) \
27 || (defined __sun && defined _SYS_TYPES_H \
28 && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \
29 || defined __EXTENSIONS__))) \
30 && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H)
25 31
26# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H 32# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
27# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ 33# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
28 34
29#elif @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TIME_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H) && defined _OSF_SOURCE 35#elif (@HAVE_SYS_SELECT_H@ \
36 && ((defined __osf__ && defined _SYS_TIME_H_ && defined _OSF_SOURCE) \
37 || (defined __sun && defined _SYS_TIME_H \
38 && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \
39 || defined __EXTENSIONS__))) \
40 && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H)
30 41
31# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H 42# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
32# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ 43# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index ac05ddb5cec..acc36947e38 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,5 +1,5 @@
1/* Provide a more complete sys/stat header file. 1/* Provide a more complete sys/stat header file.
2 Copyright (C) 2005-2012 Free Software Foundation, Inc. 2 Copyright (C) 2005-2013 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -150,6 +150,10 @@
150# endif 150# endif
151#endif 151#endif
152 152
153#ifndef S_ISMPX /* AIX */
154# define S_ISMPX(m) 0
155#endif
156
153#ifndef S_ISNAM /* Xenix */ 157#ifndef S_ISNAM /* Xenix */
154# ifdef S_IFNAM 158# ifdef S_IFNAM
155# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) 159# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index d915cee467a..656c3f13ad2 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -1,6 +1,6 @@
1/* Provide a more complete sys/time.h. 1/* Provide a more complete sys/time.h.
2 2
3 Copyright (C) 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -17,37 +17,34 @@
17 17
18/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
19 19
20#ifndef _@GUARD_PREFIX@_SYS_TIME_H
21
20#if __GNUC__ >= 3 22#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 23@PRAGMA_SYSTEM_HEADER@
22#endif 24#endif
23@PRAGMA_COLUMNS@ 25@PRAGMA_COLUMNS@
24 26
25#if defined _@GUARD_PREFIX@_SYS_TIME_H 27/* The include_next requires a split double-inclusion guard. */
26 28#if @HAVE_SYS_TIME_H@
27/* Simply delegate to the system's header, without adding anything. */ 29# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
28# if @HAVE_SYS_TIME_H@ 30#endif
29# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
30# endif
31
32#else
33 31
34# define _@GUARD_PREFIX@_SYS_TIME_H 32#ifndef _@GUARD_PREFIX@_SYS_TIME_H
33#define _@GUARD_PREFIX@_SYS_TIME_H
35 34
36# if @HAVE_SYS_TIME_H@ 35#if ! @HAVE_SYS_TIME_H@
37# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ 36# include <time.h>
38# else 37#endif
39# include <time.h>
40# endif
41 38
42/* On native Windows with MSVC, get the 'struct timeval' type. 39/* On native Windows with MSVC, get the 'struct timeval' type.
43 Also, on native Windows with a 64-bit time_t, where we are overriding the 40 Also, on native Windows with a 64-bit time_t, where we are overriding the
44 'struct timeval' type, get all declarations of system functions whose 41 'struct timeval' type, get all declarations of system functions whose
45 signature contains 'struct timeval'. */ 42 signature contains 'struct timeval'. */
46# if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H 43#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
47# define _GL_INCLUDING_WINSOCK2_H 44# define _GL_INCLUDING_WINSOCK2_H
48# include <winsock2.h> 45# include <winsock2.h>
49# undef _GL_INCLUDING_WINSOCK2_H 46# undef _GL_INCLUDING_WINSOCK2_H
50# endif 47#endif
51 48
52/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 49/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
53 50
@@ -55,112 +52,112 @@
55 52
56/* The definition of _GL_WARN_ON_USE is copied here. */ 53/* The definition of _GL_WARN_ON_USE is copied here. */
57 54
58# ifdef __cplusplus 55#ifdef __cplusplus
59extern "C" { 56extern "C" {
60# endif 57#endif
61 58
62# if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ 59#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
63 60
64# if @REPLACE_STRUCT_TIMEVAL@ 61# if @REPLACE_STRUCT_TIMEVAL@
65# define timeval rpl_timeval 62# define timeval rpl_timeval
66# endif 63# endif
67 64
68# if !GNULIB_defined_struct_timeval 65# if !GNULIB_defined_struct_timeval
69struct timeval 66struct timeval
70{ 67{
71 time_t tv_sec; 68 time_t tv_sec;
72 long int tv_usec; 69 long int tv_usec;
73}; 70};
74# define GNULIB_defined_struct_timeval 1 71# define GNULIB_defined_struct_timeval 1
75# endif
76
77# endif 72# endif
78 73
79# ifdef __cplusplus 74#endif
75
76#ifdef __cplusplus
80} 77}
81# endif 78#endif
82 79
83# if @GNULIB_GETTIMEOFDAY@ 80#if @GNULIB_GETTIMEOFDAY@
84# if @REPLACE_GETTIMEOFDAY@ 81# if @REPLACE_GETTIMEOFDAY@
85# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 82# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
86# undef gettimeofday 83# undef gettimeofday
87# define gettimeofday rpl_gettimeofday 84# define gettimeofday rpl_gettimeofday
88# endif 85# endif
89_GL_FUNCDECL_RPL (gettimeofday, int, 86_GL_FUNCDECL_RPL (gettimeofday, int,
90 (struct timeval *restrict, void *restrict) 87 (struct timeval *restrict, void *restrict)
91 _GL_ARG_NONNULL ((1))); 88 _GL_ARG_NONNULL ((1)));
92_GL_CXXALIAS_RPL (gettimeofday, int, 89_GL_CXXALIAS_RPL (gettimeofday, int,
93 (struct timeval *restrict, void *restrict)); 90 (struct timeval *restrict, void *restrict));
94# else 91# else
95# if !@HAVE_GETTIMEOFDAY@ 92# if !@HAVE_GETTIMEOFDAY@
96_GL_FUNCDECL_SYS (gettimeofday, int, 93_GL_FUNCDECL_SYS (gettimeofday, int,
97 (struct timeval *restrict, void *restrict) 94 (struct timeval *restrict, void *restrict)
98 _GL_ARG_NONNULL ((1))); 95 _GL_ARG_NONNULL ((1)));
99# endif 96# endif
100/* Need to cast, because on glibc systems, by default, the second argument is 97/* Need to cast, because on glibc systems, by default, the second argument is
101 struct timezone *. */ 98 struct timezone *. */
102_GL_CXXALIAS_SYS_CAST (gettimeofday, int, 99_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
103 (struct timeval *restrict, void *restrict)); 100 (struct timeval *restrict, void *restrict));
104# endif 101# endif
105_GL_CXXALIASWARN (gettimeofday); 102_GL_CXXALIASWARN (gettimeofday);
106# elif defined GNULIB_POSIXCHECK 103#elif defined GNULIB_POSIXCHECK
107# undef gettimeofday 104# undef gettimeofday
108# if HAVE_RAW_DECL_GETTIMEOFDAY 105# if HAVE_RAW_DECL_GETTIMEOFDAY
109_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " 106_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
110 "use gnulib module gettimeofday for portability"); 107 "use gnulib module gettimeofday for portability");
111# endif
112# endif 108# endif
109#endif
113 110
114/* Hide some function declarations from <winsock2.h>. */ 111/* Hide some function declarations from <winsock2.h>. */
115 112
116# if defined _MSC_VER && @HAVE_WINSOCK2_H@ 113#if defined _MSC_VER && @HAVE_WINSOCK2_H@
117# if !defined _@GUARD_PREFIX@_UNISTD_H 114# if !defined _@GUARD_PREFIX@_UNISTD_H
118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 115# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
119# undef close 116# undef close
120# define close close_used_without_including_unistd_h 117# define close close_used_without_including_unistd_h
121# else 118# else
122 _GL_WARN_ON_USE (close, 119 _GL_WARN_ON_USE (close,
123 "close() used without including <unistd.h>"); 120 "close() used without including <unistd.h>");
124# endif 121# endif
125# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 122# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
126# undef gethostname 123# undef gethostname
127# define gethostname gethostname_used_without_including_unistd_h 124# define gethostname gethostname_used_without_including_unistd_h
128# else 125# else
129 _GL_WARN_ON_USE (gethostname, 126 _GL_WARN_ON_USE (gethostname,
130 "gethostname() used without including <unistd.h>"); 127 "gethostname() used without including <unistd.h>");
131# endif
132# endif 128# endif
133# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H 129# endif
134# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 130# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
135# undef socket 131# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
136# define socket socket_used_without_including_sys_socket_h 132# undef socket
137# undef connect 133# define socket socket_used_without_including_sys_socket_h
138# define connect connect_used_without_including_sys_socket_h 134# undef connect
139# undef accept 135# define connect connect_used_without_including_sys_socket_h
140# define accept accept_used_without_including_sys_socket_h 136# undef accept
141# undef bind 137# define accept accept_used_without_including_sys_socket_h
142# define bind bind_used_without_including_sys_socket_h 138# undef bind
143# undef getpeername 139# define bind bind_used_without_including_sys_socket_h
144# define getpeername getpeername_used_without_including_sys_socket_h 140# undef getpeername
145# undef getsockname 141# define getpeername getpeername_used_without_including_sys_socket_h
146# define getsockname getsockname_used_without_including_sys_socket_h 142# undef getsockname
147# undef getsockopt 143# define getsockname getsockname_used_without_including_sys_socket_h
148# define getsockopt getsockopt_used_without_including_sys_socket_h 144# undef getsockopt
149# undef listen 145# define getsockopt getsockopt_used_without_including_sys_socket_h
150# define listen listen_used_without_including_sys_socket_h 146# undef listen
151# undef recv 147# define listen listen_used_without_including_sys_socket_h
152# define recv recv_used_without_including_sys_socket_h 148# undef recv
153# undef send 149# define recv recv_used_without_including_sys_socket_h
154# define send send_used_without_including_sys_socket_h 150# undef send
155# undef recvfrom 151# define send send_used_without_including_sys_socket_h
156# define recvfrom recvfrom_used_without_including_sys_socket_h 152# undef recvfrom
157# undef sendto 153# define recvfrom recvfrom_used_without_including_sys_socket_h
158# define sendto sendto_used_without_including_sys_socket_h 154# undef sendto
159# undef setsockopt 155# define sendto sendto_used_without_including_sys_socket_h
160# define setsockopt setsockopt_used_without_including_sys_socket_h 156# undef setsockopt
161# undef shutdown 157# define setsockopt setsockopt_used_without_including_sys_socket_h
162# define shutdown shutdown_used_without_including_sys_socket_h 158# undef shutdown
163# else 159# define shutdown shutdown_used_without_including_sys_socket_h
160# else
164 _GL_WARN_ON_USE (socket, 161 _GL_WARN_ON_USE (socket,
165 "socket() used without including <sys/socket.h>"); 162 "socket() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (connect, 163 _GL_WARN_ON_USE (connect,
@@ -189,17 +186,18 @@ _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
189 "setsockopt() used without including <sys/socket.h>"); 186 "setsockopt() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (shutdown, 187 _GL_WARN_ON_USE (shutdown,
191 "shutdown() used without including <sys/socket.h>"); 188 "shutdown() used without including <sys/socket.h>");
192# endif
193# endif 189# endif
194# if !defined _@GUARD_PREFIX@_SYS_SELECT_H 190# endif
195# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 191# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
196# undef select 192# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
197# define select select_used_without_including_sys_select_h 193# undef select
198# else 194# define select select_used_without_including_sys_select_h
195# else
199 _GL_WARN_ON_USE (select, 196 _GL_WARN_ON_USE (select,
200 "select() used without including <sys/select.h>"); 197 "select() used without including <sys/select.h>");
201# endif
202# endif 198# endif
203# endif 199# endif
200#endif
204 201
205#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ 202#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
203#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 8139d98f6a6..d7da35623b1 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -1,6 +1,6 @@
1/* Provide a more complete sys/types.h. 1/* Provide a more complete sys/types.h.
2 2
3 Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/time.in.h b/lib/time.in.h
index 04cde057cf0..8ced7947445 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -1,6 +1,6 @@
1/* A more-standard <time.h>. 1/* A more-standard <time.h>.
2 2
3 Copyright (C) 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/time_r.c b/lib/time_r.c
index 74366a0f759..9866299856c 100644
--- a/lib/time_r.c
+++ b/lib/time_r.c
@@ -1,6 +1,6 @@
1/* Reentrant time functions like localtime_r. 1/* Reentrant time functions like localtime_r.
2 2
3 Copyright (C) 2003, 2006-2007, 2010-2012 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006-2007, 2010-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index 4e5c641ac12..6ce2c73064f 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -1,6 +1,6 @@
1/* Add two struct timespec values. 1/* Add two struct timespec values.
2 2
3 Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/timespec-sub.c b/lib/timespec-sub.c
index 7c4c781b7f6..97c9f9de88c 100644
--- a/lib/timespec-sub.c
+++ b/lib/timespec-sub.c
@@ -1,6 +1,6 @@
1/* Subtract two struct timespec values. 1/* Subtract two struct timespec values.
2 2
3 Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/timespec.h b/lib/timespec.h
index d0a2194f61d..d665e6ccf9a 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -1,6 +1,6 @@
1/* timespec -- System time interface 1/* timespec -- System time interface
2 2
3 Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2012 Free Software 3 Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/lib/u64.h b/lib/u64.h
index 6a7d370c12b..d8009ad3913 100644
--- a/lib/u64.h
+++ b/lib/u64.h
@@ -1,6 +1,6 @@
1/* uint64_t-like operations that work even on hosts lacking uint64_t 1/* uint64_t-like operations that work even on hosts lacking uint64_t
2 2
3 Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 6171f77ac71..675c7e6a552 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2012 Free Software Foundation, Inc. 2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -14,29 +14,13 @@
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 16
17#ifndef _@GUARD_PREFIX@_UNISTD_H
18
17#if __GNUC__ >= 3 19#if __GNUC__ >= 3
18@PRAGMA_SYSTEM_HEADER@ 20@PRAGMA_SYSTEM_HEADER@
19#endif 21#endif
20@PRAGMA_COLUMNS@ 22@PRAGMA_COLUMNS@
21 23
22/* Special invocation convention:
23 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24 but we need to ensure that both the system <unistd.h> and <winsock2.h>
25 are completely included before we replace gethostname. */
26#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28/* <unistd.h> is being indirectly included for the first time from
29 <winsock2.h>; avoid declaring any overrides. */
30# if @HAVE_UNISTD_H@
31# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
32# else
33# error unexpected; report this to bug-gnulib@gnu.org
34# endif
35# define _GL_WINSOCK2_H_WITNESS
36
37/* Normal invocation. */
38#elif !defined _@GUARD_PREFIX@_UNISTD_H
39
40/* The include_next requires a split double-inclusion guard. */ 24/* The include_next requires a split double-inclusion guard. */
41#if @HAVE_UNISTD_H@ 25#if @HAVE_UNISTD_H@
42# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ 26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
@@ -79,7 +63,9 @@
79/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ 63/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80/* But avoid namespace pollution on glibc systems. */ 64/* But avoid namespace pollution on glibc systems. */
81#ifndef __GLIBC__ 65#ifndef __GLIBC__
66# define __need_system_stdlib_h
82# include <stdlib.h> 67# include <stdlib.h>
68# undef __need_system_stdlib_h
83#endif 69#endif
84 70
85/* Native Windows platforms declare chdir, getcwd, rmdir in 71/* Native Windows platforms declare chdir, getcwd, rmdir in
@@ -124,6 +110,7 @@
124/* Get getopt(), optarg, optind, opterr, optopt. 110/* Get getopt(), optarg, optind, opterr, optopt.
125 But avoid namespace pollution on glibc systems. */ 111 But avoid namespace pollution on glibc systems. */
126#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT 112#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
113# define __need_getopt
127# include <getopt.h> 114# include <getopt.h>
128#endif 115#endif
129 116
diff --git a/lib/unsetenv.c b/lib/unsetenv.c
index ddbe9a4d293..c58c82f4f44 100644
--- a/lib/unsetenv.c
+++ b/lib/unsetenv.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992, 1995-2002, 2005-2012 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2002, 2005-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
@@ -14,12 +14,12 @@
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#include <config.h>
18
19/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 17/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
20 optimizes away the name == NULL test below. */ 18 optimizes away the name == NULL test below. */
21#define _GL_ARG_NONNULL(params) 19#define _GL_ARG_NONNULL(params)
22 20
21#include <config.h>
22
23/* Specification. */ 23/* Specification. */
24#include <stdlib.h> 24#include <stdlib.h>
25 25
diff --git a/lib/utimens.c b/lib/utimens.c
index f06918cc23e..87123605ba2 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -1,6 +1,6 @@
1/* Set file access and modification times. 1/* Set file access and modification times.
2 2
3 Copyright (C) 2003-2012 Free Software Foundation, Inc. 3 Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the 6 under the terms of the GNU General Public License as published by the
diff --git a/lib/utimens.h b/lib/utimens.h
index f765d102b77..82a72a7a451 100644
--- a/lib/utimens.h
+++ b/lib/utimens.h
@@ -1,6 +1,6 @@
1/* Set file access and modification times. 1/* Set file access and modification times.
2 2
3 Copyright 2012 Free Software Foundation, Inc. 3 Copyright 2012-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the 6 under the terms of the GNU General Public License as published by the
diff --git a/lib/verify.h b/lib/verify.h
index 0c320b19ad4..cb8e90b5427 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -1,6 +1,6 @@
1/* Compile-time assert-like macros. 1/* Compile-time assert-like macros.
2 2
3 Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index ad777d8dd79..a971c78ad35 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -1,6 +1,6 @@
1/* xalloc-oversized.h -- memory allocation size checking 1/* xalloc-oversized.h -- memory allocation size checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by