1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Use Gnulib's `sys_stat' module; update Gnulib.

* .x-sc_prohibit_S_IS_definition: New file.

* m4/gnulib-cache.m4: Add `sys_stat'.

* libguile/filesys.c: Remove `S_IS*' macro definitions for Ultrix and
  MinGW.
This commit is contained in:
Ludovic Courtès 2009-12-15 20:14:02 +01:00
parent 20ccae8dbb
commit 1cd4fffcde
95 changed files with 9327 additions and 9148 deletions

View file

@ -0,0 +1 @@
lib/*

26
build-aux/arg-nonnull.h Normal file
View file

@ -0,0 +1,26 @@
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL
# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else
# define _GL_ARG_NONNULL(params)
# endif
#endif

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Sign files and upload them. # Sign files and upload them.
scriptversion=2009-04-28.21; # UTC scriptversion=2009-11-29.20; # UTC
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
# #
@ -73,34 +73,28 @@ actual command line options. Use this to keep your defaults. Comments
(#) and empty lines in $conffile are allowed. (#) and empty lines in $conffile are allowed.
Examples: Examples:
1. Upload automake-1.8.2b.tar.gz and automake-1.8.2b.tar.bz2 to two sites: 1. Upload foobar-1.0.tar.gz to ftp.gnu.org:
gnupload --to sources.redhat.com:~ftp/pub/automake \\ gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz
--to alpha.gnu.org:automake \\
automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
2. Same as above, but also create symbolic links to automake-latest.tar.*: 2. Upload foobar-1.0.tar.gz and foobar-1.0.tar.xz to ftp.gnu.org:
gnupload --to sources.redhat.com:~ftp/pub/automake \\ gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz foobar-1.0.tar.xz
--to alpha.gnu.org:automake \\
3. Same as above, and also create symbolic links to foobar-latest.tar.*:
gnupload --to ftp.gnu.org:foobar \\
--symlink-regex \\ --symlink-regex \\
automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2 foobar-1.0.tar.gz foobar-1.0.tar.xz
3. Symlink automake-1.8.2b.tar.gz to automake-latest.tar.gz and 4. Upload foobar-0.9.90.tar.gz to two sites:
automake-1.8.2b.tar.bz2 to automake-latest.tar.bz2 on both sites: gnupload --to alpha.gnu.org:foobar \\
--to sources.redhat.com:~ftp/pub/foobar \\
foobar-0.9.90.tar.gz
gnupload --to sources.redhat.com:~ftp/pub/automake \\ 5. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz
--to alpha.gnu.org:automake \\ (the -- terminates the list of files to delete):
--symlink automake-1.8.2b.tar.gz automake-latest.tar.gz \\ gnupload --to alpha.gnu.org:foobar \\
automake-1.8.2b.tar.bz2 automake-latest.tar.bz2 --to sources.redhat.com:~ftp/pub/foobar \\
--delete oopsbar-0.9.91.tar.gz \\
4. Delete automake-1.8.2a.tar.gz and .bz2, remove symlink -- foobar-0.9.91.tar.gz
automake-latest.tar.gz and upload automake-1.8.2b.tar.gz:
gnupload --to sources.redhat.com:~ftp/pub/automake \\
--to alpha.gnu.org:automake \\
--delete automake-1.8.2a.tar.gz automake-1.8.2a.tar.bz2 \\
--rmsymlink automake-latest.tar.gz \\
-- \\
automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
Report bugs to <bug-automake@gnu.org>. Report bugs to <bug-automake@gnu.org>.
Send patches to <automake-patches@gnu.org>." Send patches to <automake-patches@gnu.org>."

View file

@ -1,3 +1,20 @@
/* A C macro for emitting link time warnings.
Copyright (C) 1995, 1997, 2000, 2002-2003, 2007, 2009 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* GL_LINK_WARNING("literal string") arranges to emit the literal string as /* GL_LINK_WARNING("literal string") arranges to emit the literal string as
a linker warning on most glibc systems. a linker warning on most glibc systems.
We use a linker warning rather than a preprocessor warning, because We use a linker warning rather than a preprocessor warning, because
@ -15,12 +32,12 @@
# define GL_LINK_WARNING2(file, line, message) \ # define GL_LINK_WARNING2(file, line, message) \
GL_LINK_WARNING3 (file ":" #line ": warning: " message) GL_LINK_WARNING3 (file ":" #line ": warning: " message)
# define GL_LINK_WARNING3(message) \ # define GL_LINK_WARNING3(message) \
({ static const char warning[sizeof (message)] \ ({ static const char warning[sizeof (message)] \
__attribute__ ((__unused__, \ __attribute__ ((__unused__, \
__section__ (".gnu.warning"), \ __section__ (".gnu.warning"), \
__aligned__ (1))) \ __aligned__ (1))) \
= message "\n"; \ = message "\n"; \
(void)0; \ (void)0; \
}) })
# else # else
# define GL_LINK_WARNING(message) ((void) 0) # define GL_LINK_WARNING(message) ((void) 0)

View file

@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program. # the same distribution terms as the rest of that program.
# #
# Generated by gnulib-tool. # Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string verify version-etc-fsf vsnprintf warnings # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
@ -69,13 +69,32 @@ EXTRA_DIST += $(top_srcdir)/build-aux/announce-gen
## end gnulib module announce-gen ## end gnulib module announce-gen
## begin gnulib module arg-nonnull
BUILT_SOURCES += arg-nonnull.h
# The arg-nonnull.h that gets inserted into generated .h files is the same as
# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h
$(AM_V_GEN)rm -f $@-t $@ && \
sed -n -e '/GL_ARG_NONNULL/,$$p' \
< $(top_srcdir)/build-aux/arg-nonnull.h \
> $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
ARG_NONNULL_H=arg-nonnull.h
EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h
## end gnulib module arg-nonnull
## begin gnulib module arpa_inet ## begin gnulib module arpa_inet
BUILT_SOURCES += $(ARPA_INET_H) BUILT_SOURCES += $(ARPA_INET_H)
# We need the following in order to create <arpa/inet.h> when the system # We need the following in order to create <arpa/inet.h> when the system
# doesn't have one. # doesn't have one.
arpa/inet.h: arpa_inet.in.h arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) arpa $(AM_V_at)$(MKDIR_P) arpa
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@ -88,6 +107,7 @@ arpa/inet.h: arpa_inet.in.h
-e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
-e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/arpa_inet.in.h; \ < $(srcdir)/arpa_inet.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -346,7 +366,7 @@ BUILT_SOURCES += $(ICONV_H)
# We need the following in order to create <iconv.h> when the system # We need the following in order to create <iconv.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
iconv.h: iconv.in.h iconv.h: iconv.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -356,6 +376,7 @@ iconv.h: iconv.in.h
-e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \ -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
-e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
-e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/iconv.in.h; \ < $(srcdir)/iconv.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -426,7 +447,18 @@ AM_CFLAGS += $(CFLAG_VISIBILITY)
## begin gnulib module link-warning ## begin gnulib module link-warning
LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h BUILT_SOURCES += link-warning.h
# The link-warning.h that gets inserted into generated .h files is the same as
# build-aux/link-warning.h, except that it has the copyright header cut off.
link-warning.h: $(top_srcdir)/build-aux/link-warning.h
$(AM_V_GEN)rm -f $@-t $@ && \
sed -n -e '/GL_LINK_WARNING/,$$p' \
< $(top_srcdir)/build-aux/link-warning.h \
> $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += link-warning.h link-warning.h-t
LINK_WARNING_H=link-warning.h
EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
@ -512,7 +544,7 @@ BUILT_SOURCES += $(LOCALE_H)
# We need the following in order to create <locale.h> when the system # We need the following in order to create <locale.h> when the system
# doesn't have one that provides all definitions. # doesn't have one that provides all definitions.
locale.h: locale.in.h locale.h: locale.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -521,6 +553,7 @@ locale.h: locale.in.h
-e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \ -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \
-e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
-e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/locale.in.h; \ < $(srcdir)/locale.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -790,7 +823,7 @@ BUILT_SOURCES += stdio.h
# We need the following in order to create <stdio.h> when the system # We need the following in order to create <stdio.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
stdio.h: stdio.in.h stdio.h: stdio.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -875,6 +908,7 @@ stdio.h: stdio.in.h
-e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/stdio.in.h; \ < $(srcdir)/stdio.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -892,7 +926,7 @@ BUILT_SOURCES += stdlib.h
# We need the following in order to create <stdlib.h> when the system # We need the following in order to create <stdlib.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
stdlib.h: stdlib.in.h stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -949,6 +983,7 @@ stdlib.h: stdlib.in.h
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
-e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/stdlib.in.h; \ < $(srcdir)/stdlib.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -1000,7 +1035,7 @@ BUILT_SOURCES += string.h
# We need the following in order to create <string.h> when the system # We need the following in order to create <string.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
string.h: string.in.h string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -1067,6 +1102,7 @@ string.h: string.in.h
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/string.in.h; \ < $(srcdir)/string.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -1082,7 +1118,7 @@ BUILT_SOURCES += strings.h
# We need the following in order to create <strings.h> when the system # We need the following in order to create <strings.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
strings.h: strings.in.h strings.h: strings.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -1091,6 +1127,7 @@ strings.h: strings.in.h
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/strings.in.h; \ < $(srcdir)/strings.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -1132,7 +1169,7 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
# We need the following in order to create <sys/socket.h> when the system # We need the following in order to create <sys/socket.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
sys/socket.h: sys_socket.in.h sys/socket.h: sys_socket.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys $(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@ -1162,6 +1199,7 @@ sys/socket.h: sys_socket.in.h
-e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
-e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_socket.in.h; \ < $(srcdir)/sys_socket.in.h; \
} > $@-t && \ } > $@-t && \
mv -f $@-t $@ mv -f $@-t $@
@ -1178,7 +1216,7 @@ BUILT_SOURCES += sys/stat.h
# We need the following in order to create <sys/stat.h> when the system # We need the following in order to create <sys/stat.h> when the system
# has one that is incomplete. # has one that is incomplete.
sys/stat.h: sys_stat.in.h sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys $(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@ -1218,6 +1256,7 @@ sys/stat.h: sys_stat.in.h
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
-e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_stat.in.h; \ < $(srcdir)/sys_stat.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -1234,7 +1273,7 @@ BUILT_SOURCES += time.h
# We need the following in order to create <time.h> when the system # We need the following in order to create <time.h> when the system
# doesn't have one that works with the given compiler. # doesn't have one that works with the given compiler.
time.h: time.in.h time.h: time.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -1247,6 +1286,7 @@ time.h: time.in.h
-e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
-e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/time.in.h; \ < $(srcdir)/time.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -1271,7 +1311,7 @@ BUILT_SOURCES += unistd.h
# We need the following in order to create an empty placeholder for # We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one. # <unistd.h> when the system doesn't have one.
unistd.h: unistd.in.h unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@ -1302,6 +1342,7 @@ unistd.h: unistd.in.h
-e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
-e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
-e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
-e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
-e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
-e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
-e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
@ -1332,6 +1373,7 @@ unistd.h: unistd.in.h
-e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
-e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
-e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
-e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
-e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
-e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
@ -1356,6 +1398,7 @@ unistd.h: unistd.in.h
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
-e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
-e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
-e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
@ -1367,6 +1410,7 @@ unistd.h: unistd.in.h
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/unistd.in.h; \ < $(srcdir)/unistd.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@
@ -1476,7 +1520,7 @@ BUILT_SOURCES += $(WCHAR_H)
# We need the following in order to create <wchar.h> when the system # We need the following in order to create <wchar.h> when the system
# version does not work standalone. # version does not work standalone.
wchar.h: wchar.in.h wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \ $(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@ -1519,6 +1563,7 @@ wchar.h: wchar.in.h
-e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/wchar.in.h; \ < $(srcdir)/wchar.in.h; \
} > $@-t && \ } > $@-t && \
mv $@-t $@ mv $@-t $@

View file

@ -1,6 +1,6 @@
/* A GNU-like <arpa/inet.h>. /* A GNU-like <arpa/inet.h>.
Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc. Copyright (C) 2005-2006, 2008-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
@ -38,6 +38,8 @@
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -60,7 +62,8 @@ extern "C" {
For more details, see the POSIX:2001 specification For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
extern const char *inet_ntop (int af, const void *restrict src, extern const char *inet_ntop (int af, const void *restrict src,
char *restrict dst, socklen_t cnt); char *restrict dst, socklen_t cnt)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef inet_ntop # undef inet_ntop
@ -72,13 +75,14 @@ extern const char *inet_ntop (int af, const void *restrict src,
#if @GNULIB_INET_PTON@ #if @GNULIB_INET_PTON@
# if !@HAVE_DECL_INET_PTON@ # if !@HAVE_DECL_INET_PTON@
extern int inet_pton (int af, const char *restrict src, void *restrict dst); extern int inet_pton (int af, const char *restrict src, void *restrict dst)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef inet_pton # undef inet_pton
# define inet_pton(af,src,dst) \ # define inet_pton(af,src,dst) \
(GL_LINK_WARNING ("inet_pton is unportable - " \ (GL_LINK_WARNING ("inet_pton is unportable - " \
"use gnulib module inet_pton for portability"), \ "use gnulib module inet_pton for portability"), \
inet_pton (af, src, dst)) inet_pton (af, src, dst))
#endif #endif

View file

@ -21,24 +21,24 @@
/* Given an unsigned 16-bit argument X, return the value corresponding to /* Given an unsigned 16-bit argument X, return the value corresponding to
X with reversed byte order. */ X with reversed byte order. */
#define bswap_16(x) ((((x) & 0x00FF) << 8) | \ #define bswap_16(x) ((((x) & 0x00FF) << 8) | \
(((x) & 0xFF00) >> 8)) (((x) & 0xFF00) >> 8))
/* Given an unsigned 32-bit argument X, return the value corresponding to /* Given an unsigned 32-bit argument X, return the value corresponding to
X with reversed byte order. */ X with reversed byte order. */
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \ #define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
(((x) & 0x0000FF00) << 8) | \ (((x) & 0x0000FF00) << 8) | \
(((x) & 0x00FF0000) >> 8) | \ (((x) & 0x00FF0000) >> 8) | \
(((x) & 0xFF000000) >> 24)) (((x) & 0xFF000000) >> 24))
/* Given an unsigned 64-bit argument X, return the value corresponding to /* Given an unsigned 64-bit argument X, return the value corresponding to
X with reversed byte order. */ X with reversed byte order. */
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \ #define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
(((x) & 0x000000000000FF00ULL) << 40) | \ (((x) & 0x000000000000FF00ULL) << 40) | \
(((x) & 0x0000000000FF0000ULL) << 24) | \ (((x) & 0x0000000000FF0000ULL) << 24) | \
(((x) & 0x00000000FF000000ULL) << 8) | \ (((x) & 0x00000000FF000000ULL) << 8) | \
(((x) & 0x000000FF00000000ULL) >> 8) | \ (((x) & 0x000000FF00000000ULL) >> 8) | \
(((x) & 0x0000FF0000000000ULL) >> 24) | \ (((x) & 0x0000FF0000000000ULL) >> 24) | \
(((x) & 0x00FF000000000000ULL) >> 40) | \ (((x) & 0x00FF000000000000ULL) >> 40) | \
(((x) & 0xFF00000000000000ULL) >> 56)) (((x) & 0xFF00000000000000ULL) >> 56))
#endif /* _GL_BYTESWAP_H */ #endif /* _GL_BYTESWAP_H */

View file

@ -40,7 +40,7 @@ c_strcasecmp (const char *s1, const char *s2)
c2 = c_tolower (*p2); c2 = c_tolower (*p2);
if (c1 == '\0') if (c1 == '\0')
break; break;
++p1; ++p1;
++p2; ++p2;

View file

@ -40,7 +40,7 @@ c_strncasecmp (const char *s1, const char *s2, size_t n)
c2 = c_tolower (*p2); c2 = c_tolower (*p2);
if (--n == 0 || c1 == '\0') if (--n == 0 || c1 == '\0')
break; break;
++p1; ++p1;
++p2; ++p2;

View file

@ -21,6 +21,10 @@
#if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC #if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
optimizes away the name == NULL test below. */
#define _GL_ARG_NONNULL(params)
/* Specification. */ /* Specification. */
#include <stdlib.h> #include <stdlib.h>
@ -94,9 +98,9 @@ __realpath (const char *name, char *resolved)
if (name == NULL) if (name == NULL)
{ {
/* As per Single Unix Specification V2 we must return an error if /* As per Single Unix Specification V2 we must return an error if
either parameter is a null pointer. We extend this to allow either parameter is a null pointer. We extend this to allow
the RESOLVED parameter to be NULL in case the we are expected to the RESOLVED parameter to be NULL in case the we are expected to
allocate the room for the return value. */ allocate the room for the return value. */
__set_errno (EINVAL); __set_errno (EINVAL);
return NULL; return NULL;
} }
@ -104,7 +108,7 @@ __realpath (const char *name, char *resolved)
if (name[0] == '\0') if (name[0] == '\0')
{ {
/* As per Single Unix Specification V2 we must return an error if /* As per Single Unix Specification V2 we must return an error if
the name argument points to an empty string. */ the name argument points to an empty string. */
__set_errno (ENOENT); __set_errno (ENOENT);
return NULL; return NULL;
} }
@ -121,12 +125,12 @@ __realpath (const char *name, char *resolved)
{ {
rpath = malloc (path_max); rpath = malloc (path_max);
if (rpath == NULL) if (rpath == NULL)
{ {
/* It's easier to set errno to ENOMEM than to rely on the /* It's easier to set errno to ENOMEM than to rely on the
'malloc-posix' gnulib module. */ 'malloc-posix' gnulib module. */
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
} }
else else
rpath = resolved; rpath = resolved;
@ -135,10 +139,10 @@ __realpath (const char *name, char *resolved)
if (name[0] != '/') if (name[0] != '/')
{ {
if (!__getcwd (rpath, path_max)) if (!__getcwd (rpath, path_max))
{ {
rpath[0] = '\0'; rpath[0] = '\0';
goto error; goto error;
} }
dest = strchr (rpath, '\0'); dest = strchr (rpath, '\0');
} }
else else
@ -146,7 +150,7 @@ __realpath (const char *name, char *resolved)
rpath[0] = '/'; rpath[0] = '/';
dest = rpath + 1; dest = rpath + 1;
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/') if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/')
*dest++ = '/'; *dest++ = '/';
} }
for (start = end = name; *start; start = end) for (start = end = name; *start; start = end)
@ -160,153 +164,153 @@ __realpath (const char *name, char *resolved)
/* Skip sequence of multiple path-separators. */ /* Skip sequence of multiple path-separators. */
while (*start == '/') while (*start == '/')
++start; ++start;
/* Find end of path component. */ /* Find end of path component. */
for (end = start; *end && *end != '/'; ++end) for (end = start; *end && *end != '/'; ++end)
/* Nothing. */; /* Nothing. */;
if (end - start == 0) if (end - start == 0)
break; break;
else if (end - start == 1 && start[0] == '.') else if (end - start == 1 && start[0] == '.')
/* nothing */; /* nothing */;
else if (end - start == 2 && start[0] == '.' && start[1] == '.') else if (end - start == 2 && start[0] == '.' && start[1] == '.')
{ {
/* Back up to previous component, ignore if at root already. */ /* Back up to previous component, ignore if at root already. */
if (dest > rpath + 1) if (dest > rpath + 1)
while ((--dest)[-1] != '/'); while ((--dest)[-1] != '/');
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
&& *dest == '/') && *dest == '/')
dest++; dest++;
} }
else else
{ {
size_t new_size; size_t new_size;
if (dest[-1] != '/') if (dest[-1] != '/')
*dest++ = '/'; *dest++ = '/';
if (dest + (end - start) >= rpath_limit) if (dest + (end - start) >= rpath_limit)
{ {
ptrdiff_t dest_offset = dest - rpath; ptrdiff_t dest_offset = dest - rpath;
char *new_rpath; char *new_rpath;
if (resolved) if (resolved)
{ {
__set_errno (ENAMETOOLONG); __set_errno (ENAMETOOLONG);
if (dest > rpath + 1) if (dest > rpath + 1)
dest--; dest--;
*dest = '\0'; *dest = '\0';
goto error; goto error;
} }
new_size = rpath_limit - rpath; new_size = rpath_limit - rpath;
if (end - start + 1 > path_max) if (end - start + 1 > path_max)
new_size += end - start + 1; new_size += end - start + 1;
else else
new_size += path_max; new_size += path_max;
new_rpath = (char *) realloc (rpath, new_size); new_rpath = (char *) realloc (rpath, new_size);
if (new_rpath == NULL) if (new_rpath == NULL)
{ {
/* It's easier to set errno to ENOMEM than to rely on the /* It's easier to set errno to ENOMEM than to rely on the
'realloc-posix' gnulib module. */ 'realloc-posix' gnulib module. */
errno = ENOMEM; errno = ENOMEM;
goto error; goto error;
} }
rpath = new_rpath; rpath = new_rpath;
rpath_limit = rpath + new_size; rpath_limit = rpath + new_size;
dest = rpath + dest_offset; dest = rpath + dest_offset;
} }
#ifdef _LIBC #ifdef _LIBC
dest = __mempcpy (dest, start, end - start); dest = __mempcpy (dest, start, end - start);
#else #else
memcpy (dest, start, end - start); memcpy (dest, start, end - start);
dest += end - start; dest += end - start;
#endif #endif
*dest = '\0'; *dest = '\0';
#ifdef _LIBC #ifdef _LIBC
if (__lxstat64 (_STAT_VER, rpath, &st) < 0) if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
#else #else
if (lstat (rpath, &st) < 0) if (lstat (rpath, &st) < 0)
#endif #endif
goto error; goto error;
if (S_ISLNK (st.st_mode)) if (S_ISLNK (st.st_mode))
{ {
char *buf; char *buf;
size_t len; size_t len;
if (++num_links > MAXSYMLINKS) if (++num_links > MAXSYMLINKS)
{ {
__set_errno (ELOOP); __set_errno (ELOOP);
goto error; goto error;
} }
buf = malloca (path_max); buf = malloca (path_max);
if (!buf) if (!buf)
{ {
errno = ENOMEM; errno = ENOMEM;
goto error; goto error;
} }
n = __readlink (rpath, buf, path_max - 1); n = __readlink (rpath, buf, path_max - 1);
if (n < 0) if (n < 0)
{ {
int saved_errno = errno; int saved_errno = errno;
freea (buf); freea (buf);
errno = saved_errno; errno = saved_errno;
goto error; goto error;
} }
buf[n] = '\0'; buf[n] = '\0';
if (!extra_buf) if (!extra_buf)
{ {
extra_buf = malloca (path_max); extra_buf = malloca (path_max);
if (!extra_buf) if (!extra_buf)
{ {
freea (buf); freea (buf);
errno = ENOMEM; errno = ENOMEM;
goto error; goto error;
} }
} }
len = strlen (end); len = strlen (end);
if ((long int) (n + len) >= path_max) if ((long int) (n + len) >= path_max)
{ {
freea (buf); freea (buf);
__set_errno (ENAMETOOLONG); __set_errno (ENAMETOOLONG);
goto error; goto error;
} }
/* Careful here, end may be a pointer into extra_buf... */ /* Careful here, end may be a pointer into extra_buf... */
memmove (&extra_buf[n], end, len + 1); memmove (&extra_buf[n], end, len + 1);
name = end = memcpy (extra_buf, buf, n); name = end = memcpy (extra_buf, buf, n);
if (buf[0] == '/') if (buf[0] == '/')
{ {
dest = rpath + 1; /* It's an absolute symlink */ dest = rpath + 1; /* It's an absolute symlink */
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/') if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/')
*dest++ = '/'; *dest++ = '/';
} }
else else
{ {
/* Back up to previous component, ignore if at root /* Back up to previous component, ignore if at root
already: */ already: */
if (dest > rpath + 1) if (dest > rpath + 1)
while ((--dest)[-1] != '/'); while ((--dest)[-1] != '/');
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
&& *dest == '/') && *dest == '/')
dest++; dest++;
} }
} }
else if (!S_ISDIR (st.st_mode) && *end != '\0') else if (!S_ISDIR (st.st_mode) && *end != '\0')
{ {
__set_errno (ENOTDIR); __set_errno (ENOTDIR);
goto error; goto error;
} }
} }
} }
if (dest > rpath + 1 && dest[-1] == '/') if (dest > rpath + 1 && dest[-1] == '/')
--dest; --dest;

1114
lib/config.charset Executable file → Normal file

File diff suppressed because it is too large Load diff

View file

@ -36,33 +36,33 @@ rpl_duplocale (locale_t locale)
if (locale == LC_GLOBAL_LOCALE) if (locale == LC_GLOBAL_LOCALE)
{ {
/* Create a copy of the locale by fetching the name of each locale /* Create a copy of the locale by fetching the name of each locale
category, starting with LC_CTYPE. */ category, starting with LC_CTYPE. */
static struct { int cat; int mask; } categories[] = static struct { int cat; int mask; } const categories[] =
{ {
{ LC_NUMERIC, LC_NUMERIC_MASK }, { LC_NUMERIC, LC_NUMERIC_MASK },
{ LC_TIME, LC_TIME_MASK }, { LC_TIME, LC_TIME_MASK },
{ LC_COLLATE, LC_COLLATE_MASK }, { LC_COLLATE, LC_COLLATE_MASK },
{ LC_MONETARY, LC_MONETARY_MASK }, { LC_MONETARY, LC_MONETARY_MASK },
{ LC_MESSAGES, LC_MESSAGES_MASK } { LC_MESSAGES, LC_MESSAGES_MASK }
#ifdef LC_PAPER #ifdef LC_PAPER
, { LC_PAPER, LC_PAPER_MASK } , { LC_PAPER, LC_PAPER_MASK }
#endif #endif
#ifdef LC_NAME #ifdef LC_NAME
, { LC_NAME, LC_NAME_MASK } , { LC_NAME, LC_NAME_MASK }
#endif #endif
#ifdef LC_ADDRESS #ifdef LC_ADDRESS
, { LC_ADDRESS, LC_ADDRESS_MASK } , { LC_ADDRESS, LC_ADDRESS_MASK }
#endif #endif
#ifdef LC_TELEPHONE #ifdef LC_TELEPHONE
, { LC_TELEPHONE, LC_TELEPHONE_MASK } , { LC_TELEPHONE, LC_TELEPHONE_MASK }
#endif #endif
#ifdef LC_MEASUREMENT #ifdef LC_MEASUREMENT
, { LC_MEASUREMENT, LC_MEASUREMENT_MASK } , { LC_MEASUREMENT, LC_MEASUREMENT_MASK }
#endif #endif
#ifdef LC_IDENTIFICATION #ifdef LC_IDENTIFICATION
, { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK } , { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK }
#endif #endif
}; };
const char *base_name; const char *base_name;
locale_t base_copy; locale_t base_copy;
unsigned int i; unsigned int i;
@ -70,28 +70,28 @@ rpl_duplocale (locale_t locale)
base_name = setlocale (LC_CTYPE, NULL); base_name = setlocale (LC_CTYPE, NULL);
base_copy = newlocale (LC_ALL_MASK, base_name, NULL); base_copy = newlocale (LC_ALL_MASK, base_name, NULL);
if (base_copy == NULL) if (base_copy == NULL)
return NULL; return NULL;
for (i = 0; i < SIZEOF (categories); i++) for (i = 0; i < SIZEOF (categories); i++)
{ {
int category = categories[i].cat; int category = categories[i].cat;
int category_mask = categories[i].mask; int category_mask = categories[i].mask;
const char *name = setlocale (category, NULL); const char *name = setlocale (category, NULL);
if (strcmp (name, base_name) != 0) if (strcmp (name, base_name) != 0)
{ {
locale_t copy = newlocale (category_mask, name, base_copy); locale_t copy = newlocale (category_mask, name, base_copy);
if (copy == NULL) if (copy == NULL)
{ {
int saved_errno = errno; int saved_errno = errno;
freelocale (base_copy); freelocale (base_copy);
errno = saved_errno; errno = saved_errno;
return NULL; return NULL;
} }
/* No need to call freelocale (base_copy) if copy != base_copy; /* No need to call freelocale (base_copy) if copy != base_copy;
the newlocale function already takes care of doing it. */ the newlocale function already takes care of doing it. */
base_copy = copy; base_copy = copy;
} }
} }
return base_copy; return base_copy;
} }

View file

@ -130,27 +130,27 @@ flock (int fd, int operation)
{ {
DWORD err = GetLastError (); DWORD err = GetLastError ();
switch (err) switch (err)
{ {
/* This means someone else is holding a lock. */ /* This means someone else is holding a lock. */
case ERROR_LOCK_VIOLATION: case ERROR_LOCK_VIOLATION:
errno = EAGAIN; errno = EAGAIN;
break; break;
/* Out of memory. */ /* Out of memory. */
case ERROR_NOT_ENOUGH_MEMORY: case ERROR_NOT_ENOUGH_MEMORY:
errno = ENOMEM; errno = ENOMEM;
break; break;
case ERROR_BAD_COMMAND: case ERROR_BAD_COMMAND:
errno = EINVAL; errno = EINVAL;
break; break;
/* Unlikely to be other errors, but at least don't lose the /* Unlikely to be other errors, but at least don't lose the
* error code. * error code.
*/ */
default: default:
errno = err; errno = err;
} }
return -1; return -1;
} }

View file

@ -65,12 +65,12 @@ full_rw (int fd, const void *buf, size_t count)
{ {
size_t n_rw = safe_rw (fd, ptr, count); size_t n_rw = safe_rw (fd, ptr, count);
if (n_rw == (size_t) -1) if (n_rw == (size_t) -1)
break; break;
if (n_rw == 0) if (n_rw == 0)
{ {
errno = ZERO_BYTE_TRANSFER_ERRNO; errno = ZERO_BYTE_TRANSFER_ERRNO;
break; break;
} }
total += n_rw; total += n_rw;
ptr += n_rw; ptr += n_rw;
count -= n_rw; count -= n_rw;

View file

@ -140,8 +140,8 @@ inline
#endif #endif
static const char * static const char *
pgettext_aux (const char *domain, pgettext_aux (const char *domain,
const char *msg_ctxt_id, const char *msgid, const char *msg_ctxt_id, const char *msgid,
int category) int category)
{ {
const char *translation = dcgettext (domain, msg_ctxt_id, category); const char *translation = dcgettext (domain, msg_ctxt_id, category);
if (translation == msg_ctxt_id) if (translation == msg_ctxt_id)
@ -159,9 +159,9 @@ inline
#endif #endif
static const char * static const char *
npgettext_aux (const char *domain, npgettext_aux (const char *domain,
const char *msg_ctxt_id, const char *msgid, const char *msg_ctxt_id, const char *msgid,
const char *msgid_plural, unsigned long int n, const char *msgid_plural, unsigned long int n,
int category) int category)
{ {
const char *translation = const char *translation =
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
@ -199,8 +199,8 @@ inline
#endif #endif
static const char * static const char *
dcpgettext_expr (const char *domain, dcpgettext_expr (const char *domain,
const char *msgctxt, const char *msgid, const char *msgctxt, const char *msgid,
int category) int category)
{ {
size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1; size_t msgid_len = strlen (msgid) + 1;
@ -222,10 +222,10 @@ dcpgettext_expr (const char *domain,
translation = dcgettext (domain, msg_ctxt_id, category); translation = dcgettext (domain, msg_ctxt_id, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf) if (msg_ctxt_id != buf)
free (msg_ctxt_id); free (msg_ctxt_id);
#endif #endif
if (translation != msg_ctxt_id) if (translation != msg_ctxt_id)
return translation; return translation;
} }
return msgid; return msgid;
} }
@ -244,9 +244,9 @@ inline
#endif #endif
static const char * static const char *
dcnpgettext_expr (const char *domain, dcnpgettext_expr (const char *domain,
const char *msgctxt, const char *msgid, const char *msgctxt, const char *msgid,
const char *msgid_plural, unsigned long int n, const char *msgid_plural, unsigned long int n,
int category) int category)
{ {
size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1; size_t msgid_len = strlen (msgid) + 1;
@ -268,10 +268,10 @@ dcnpgettext_expr (const char *domain,
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf) if (msg_ctxt_id != buf)
free (msg_ctxt_id); free (msg_ctxt_id);
#endif #endif
if (!(translation == msg_ctxt_id || translation == msgid_plural)) if (!(translation == msg_ctxt_id || translation == msgid_plural))
return translation; return translation;
} }
return (n == 1 ? msgid : msgid_plural); return (n == 1 ? msgid : msgid_plural);
} }

View file

@ -59,25 +59,25 @@ utf16be_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
{ {
ucs4_t wc = (s[0] << 8) + s[1]; ucs4_t wc = (s[0] << 8) + s[1];
if (wc >= 0xd800 && wc < 0xdc00) if (wc >= 0xd800 && wc < 0xdc00)
{ {
if (n >= 4) if (n >= 4)
{ {
ucs4_t wc2 = (s[2] << 8) + s[3]; ucs4_t wc2 = (s[2] << 8) + s[3];
if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) if (!(wc2 >= 0xdc00 && wc2 < 0xe000))
return RET_ILSEQ; return RET_ILSEQ;
*pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00);
return 4; return 4;
} }
} }
else if (wc >= 0xdc00 && wc < 0xe000) else if (wc >= 0xdc00 && wc < 0xe000)
{ {
return RET_ILSEQ; return RET_ILSEQ;
} }
else else
{ {
*pwc = wc; *pwc = wc;
return 2; return 2;
} }
} }
return RET_TOOFEW; return RET_TOOFEW;
} }
@ -88,31 +88,31 @@ utf16be_wctomb (unsigned char *r, ucs4_t wc, size_t n)
if (!(wc >= 0xd800 && wc < 0xe000)) if (!(wc >= 0xd800 && wc < 0xe000))
{ {
if (wc < 0x10000) if (wc < 0x10000)
{ {
if (n >= 2) if (n >= 2)
{ {
r[0] = (unsigned char) (wc >> 8); r[0] = (unsigned char) (wc >> 8);
r[1] = (unsigned char) wc; r[1] = (unsigned char) wc;
return 2; return 2;
} }
else else
return RET_TOOSMALL; return RET_TOOSMALL;
} }
else if (wc < 0x110000) else if (wc < 0x110000)
{ {
if (n >= 4) if (n >= 4)
{ {
ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10);
ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
r[0] = (unsigned char) (wc1 >> 8); r[0] = (unsigned char) (wc1 >> 8);
r[1] = (unsigned char) wc1; r[1] = (unsigned char) wc1;
r[2] = (unsigned char) (wc2 >> 8); r[2] = (unsigned char) (wc2 >> 8);
r[3] = (unsigned char) wc2; r[3] = (unsigned char) wc2;
return 4; return 4;
} }
else else
return RET_TOOSMALL; return RET_TOOSMALL;
} }
} }
return RET_ILUNI; return RET_ILUNI;
} }
@ -130,25 +130,25 @@ utf16le_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
{ {
ucs4_t wc = s[0] + (s[1] << 8); ucs4_t wc = s[0] + (s[1] << 8);
if (wc >= 0xd800 && wc < 0xdc00) if (wc >= 0xd800 && wc < 0xdc00)
{ {
if (n >= 4) if (n >= 4)
{ {
ucs4_t wc2 = s[2] + (s[3] << 8); ucs4_t wc2 = s[2] + (s[3] << 8);
if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) if (!(wc2 >= 0xdc00 && wc2 < 0xe000))
return RET_ILSEQ; return RET_ILSEQ;
*pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00);
return 4; return 4;
} }
} }
else if (wc >= 0xdc00 && wc < 0xe000) else if (wc >= 0xdc00 && wc < 0xe000)
{ {
return RET_ILSEQ; return RET_ILSEQ;
} }
else else
{ {
*pwc = wc; *pwc = wc;
return 2; return 2;
} }
} }
return RET_TOOFEW; return RET_TOOFEW;
} }
@ -159,31 +159,31 @@ utf16le_wctomb (unsigned char *r, ucs4_t wc, size_t n)
if (!(wc >= 0xd800 && wc < 0xe000)) if (!(wc >= 0xd800 && wc < 0xe000))
{ {
if (wc < 0x10000) if (wc < 0x10000)
{ {
if (n >= 2) if (n >= 2)
{ {
r[0] = (unsigned char) wc; r[0] = (unsigned char) wc;
r[1] = (unsigned char) (wc >> 8); r[1] = (unsigned char) (wc >> 8);
return 2; return 2;
} }
else else
return RET_TOOSMALL; return RET_TOOSMALL;
} }
else if (wc < 0x110000) else if (wc < 0x110000)
{ {
if (n >= 4) if (n >= 4)
{ {
ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10);
ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
r[0] = (unsigned char) wc1; r[0] = (unsigned char) wc1;
r[1] = (unsigned char) (wc1 >> 8); r[1] = (unsigned char) (wc1 >> 8);
r[2] = (unsigned char) wc2; r[2] = (unsigned char) wc2;
r[3] = (unsigned char) (wc2 >> 8); r[3] = (unsigned char) (wc2 >> 8);
return 4; return 4;
} }
else else
return RET_TOOSMALL; return RET_TOOSMALL;
} }
} }
return RET_ILUNI; return RET_ILUNI;
} }
@ -201,12 +201,12 @@ utf32be_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
{ {
ucs4_t wc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; ucs4_t wc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
{ {
*pwc = wc; *pwc = wc;
return 4; return 4;
} }
else else
return RET_ILSEQ; return RET_ILSEQ;
} }
return RET_TOOFEW; return RET_TOOFEW;
} }
@ -217,15 +217,15 @@ utf32be_wctomb (unsigned char *r, ucs4_t wc, size_t n)
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
{ {
if (n >= 4) if (n >= 4)
{ {
r[0] = 0; r[0] = 0;
r[1] = (unsigned char) (wc >> 16); r[1] = (unsigned char) (wc >> 16);
r[2] = (unsigned char) (wc >> 8); r[2] = (unsigned char) (wc >> 8);
r[3] = (unsigned char) wc; r[3] = (unsigned char) wc;
return 4; return 4;
} }
else else
return RET_TOOSMALL; return RET_TOOSMALL;
} }
return RET_ILUNI; return RET_ILUNI;
} }
@ -243,12 +243,12 @@ utf32le_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
{ {
ucs4_t wc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24); ucs4_t wc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24);
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
{ {
*pwc = wc; *pwc = wc;
return 4; return 4;
} }
else else
return RET_ILSEQ; return RET_ILSEQ;
} }
return RET_TOOFEW; return RET_TOOFEW;
} }
@ -259,15 +259,15 @@ utf32le_wctomb (unsigned char *r, ucs4_t wc, size_t n)
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
{ {
if (n >= 4) if (n >= 4)
{ {
r[0] = (unsigned char) wc; r[0] = (unsigned char) wc;
r[1] = (unsigned char) (wc >> 8); r[1] = (unsigned char) (wc >> 8);
r[2] = (unsigned char) (wc >> 16); r[2] = (unsigned char) (wc >> 16);
r[3] = 0; r[3] = 0;
return 4; return 4;
} }
else else
return RET_TOOSMALL; return RET_TOOSMALL;
} }
return RET_ILUNI; return RET_ILUNI;
} }
@ -276,173 +276,173 @@ utf32le_wctomb (unsigned char *r, ucs4_t wc, size_t n)
size_t size_t
rpl_iconv (iconv_t cd, rpl_iconv (iconv_t cd,
ICONV_CONST char **inbuf, size_t *inbytesleft, ICONV_CONST char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft) char **outbuf, size_t *outbytesleft)
#undef iconv #undef iconv
{ {
#if REPLACE_ICONV_UTF #if REPLACE_ICONV_UTF
switch ((uintptr_t) cd) switch ((uintptr_t) cd)
{ {
{ {
int (*xxx_wctomb) (unsigned char *, ucs4_t, size_t); int (*xxx_wctomb) (unsigned char *, ucs4_t, size_t);
case (uintptr_t) _ICONV_UTF8_UTF16BE: case (uintptr_t) _ICONV_UTF8_UTF16BE:
xxx_wctomb = utf16be_wctomb; xxx_wctomb = utf16be_wctomb;
goto loop_from_utf8; goto loop_from_utf8;
case (uintptr_t) _ICONV_UTF8_UTF16LE: case (uintptr_t) _ICONV_UTF8_UTF16LE:
xxx_wctomb = utf16le_wctomb; xxx_wctomb = utf16le_wctomb;
goto loop_from_utf8; goto loop_from_utf8;
case (uintptr_t) _ICONV_UTF8_UTF32BE: case (uintptr_t) _ICONV_UTF8_UTF32BE:
xxx_wctomb = utf32be_wctomb; xxx_wctomb = utf32be_wctomb;
goto loop_from_utf8; goto loop_from_utf8;
case (uintptr_t) _ICONV_UTF8_UTF32LE: case (uintptr_t) _ICONV_UTF8_UTF32LE:
xxx_wctomb = utf32le_wctomb; xxx_wctomb = utf32le_wctomb;
goto loop_from_utf8; goto loop_from_utf8;
loop_from_utf8: loop_from_utf8:
if (inbuf == NULL || *inbuf == NULL) if (inbuf == NULL || *inbuf == NULL)
return 0; return 0;
{ {
ICONV_CONST char *inptr = *inbuf; ICONV_CONST char *inptr = *inbuf;
size_t inleft = *inbytesleft; size_t inleft = *inbytesleft;
char *outptr = *outbuf; char *outptr = *outbuf;
size_t outleft = *outbytesleft; size_t outleft = *outbytesleft;
size_t res = 0; size_t res = 0;
while (inleft > 0) while (inleft > 0)
{ {
ucs4_t uc; ucs4_t uc;
int m = u8_mbtoucr (&uc, (const uint8_t *) inptr, inleft); int m = u8_mbtoucr (&uc, (const uint8_t *) inptr, inleft);
if (m <= 0) if (m <= 0)
{ {
if (m == -1) if (m == -1)
{ {
errno = EILSEQ; errno = EILSEQ;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
if (m == -2) if (m == -2)
{ {
errno = EINVAL; errno = EINVAL;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
abort (); abort ();
} }
else else
{ {
int n = xxx_wctomb ((uint8_t *) outptr, uc, outleft); int n = xxx_wctomb ((uint8_t *) outptr, uc, outleft);
if (n < 0) if (n < 0)
{ {
if (n == RET_ILUNI) if (n == RET_ILUNI)
{ {
errno = EILSEQ; errno = EILSEQ;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
if (n == RET_TOOSMALL) if (n == RET_TOOSMALL)
{ {
errno = E2BIG; errno = E2BIG;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
abort (); abort ();
} }
else else
{ {
inptr += m; inptr += m;
inleft -= m; inleft -= m;
outptr += n; outptr += n;
outleft -= n; outleft -= n;
} }
} }
} }
*inbuf = inptr; *inbuf = inptr;
*inbytesleft = inleft; *inbytesleft = inleft;
*outbuf = outptr; *outbuf = outptr;
*outbytesleft = outleft; *outbytesleft = outleft;
return res; return res;
} }
} }
{ {
int (*xxx_mbtowc) (ucs4_t *, const unsigned char *, size_t); int (*xxx_mbtowc) (ucs4_t *, const unsigned char *, size_t);
case (uintptr_t) _ICONV_UTF16BE_UTF8: case (uintptr_t) _ICONV_UTF16BE_UTF8:
xxx_mbtowc = utf16be_mbtowc; xxx_mbtowc = utf16be_mbtowc;
goto loop_to_utf8; goto loop_to_utf8;
case (uintptr_t) _ICONV_UTF16LE_UTF8: case (uintptr_t) _ICONV_UTF16LE_UTF8:
xxx_mbtowc = utf16le_mbtowc; xxx_mbtowc = utf16le_mbtowc;
goto loop_to_utf8; goto loop_to_utf8;
case (uintptr_t) _ICONV_UTF32BE_UTF8: case (uintptr_t) _ICONV_UTF32BE_UTF8:
xxx_mbtowc = utf32be_mbtowc; xxx_mbtowc = utf32be_mbtowc;
goto loop_to_utf8; goto loop_to_utf8;
case (uintptr_t) _ICONV_UTF32LE_UTF8: case (uintptr_t) _ICONV_UTF32LE_UTF8:
xxx_mbtowc = utf32le_mbtowc; xxx_mbtowc = utf32le_mbtowc;
goto loop_to_utf8; goto loop_to_utf8;
loop_to_utf8: loop_to_utf8:
if (inbuf == NULL || *inbuf == NULL) if (inbuf == NULL || *inbuf == NULL)
return 0; return 0;
{ {
ICONV_CONST char *inptr = *inbuf; ICONV_CONST char *inptr = *inbuf;
size_t inleft = *inbytesleft; size_t inleft = *inbytesleft;
char *outptr = *outbuf; char *outptr = *outbuf;
size_t outleft = *outbytesleft; size_t outleft = *outbytesleft;
size_t res = 0; size_t res = 0;
while (inleft > 0) while (inleft > 0)
{ {
ucs4_t uc; ucs4_t uc;
int m = xxx_mbtowc (&uc, (const uint8_t *) inptr, inleft); int m = xxx_mbtowc (&uc, (const uint8_t *) inptr, inleft);
if (m <= 0) if (m <= 0)
{ {
if (m == RET_ILSEQ) if (m == RET_ILSEQ)
{ {
errno = EILSEQ; errno = EILSEQ;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
if (m == RET_TOOFEW) if (m == RET_TOOFEW)
{ {
errno = EINVAL; errno = EINVAL;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
abort (); abort ();
} }
else else
{ {
int n = u8_uctomb ((uint8_t *) outptr, uc, outleft); int n = u8_uctomb ((uint8_t *) outptr, uc, outleft);
if (n < 0) if (n < 0)
{ {
if (n == -1) if (n == -1)
{ {
errno = EILSEQ; errno = EILSEQ;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
if (n == -2) if (n == -2)
{ {
errno = E2BIG; errno = E2BIG;
res = (size_t)(-1); res = (size_t)(-1);
break; break;
} }
abort (); abort ();
} }
else else
{ {
inptr += m; inptr += m;
inleft -= m; inleft -= m;
outptr += n; outptr += n;
outleft -= n; outleft -= n;
} }
} }
} }
*inbuf = inptr; *inbuf = inptr;
*inbytesleft = inleft; *inbytesleft = inleft;
*outbuf = outptr; *outbuf = outptr;
*outbytesleft = outleft; *outbytesleft = outleft;
return res; return res;
} }
} }
} }
#endif #endif

View file

@ -1,6 +1,6 @@
/* A GNU-like <iconv.h>. /* A GNU-like <iconv.h>.
Copyright (C) 2007-2008 Free Software Foundation, Inc. Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
@ -28,6 +28,8 @@
#ifndef _GL_ICONV_H #ifndef _GL_ICONV_H
#define _GL_ICONV_H #define _GL_ICONV_H
/* The definition of _GL_ARG_NONNULL is copied here. */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -37,7 +39,8 @@ extern "C" {
/* An iconv_open wrapper that supports the IANA standardized encoding names /* An iconv_open wrapper that supports the IANA standardized encoding names
("ISO-8859-1" etc.) as far as possible. */ ("ISO-8859-1" etc.) as far as possible. */
# define iconv_open rpl_iconv_open # define iconv_open rpl_iconv_open
extern iconv_t iconv_open (const char *tocode, const char *fromcode); extern iconv_t iconv_open (const char *tocode, const char *fromcode)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @REPLACE_ICONV_UTF@ #if @REPLACE_ICONV_UTF@
@ -56,8 +59,8 @@ extern iconv_t iconv_open (const char *tocode, const char *fromcode);
#if @REPLACE_ICONV@ #if @REPLACE_ICONV@
# define iconv rpl_iconv # define iconv rpl_iconv
extern size_t iconv (iconv_t cd, extern size_t iconv (iconv_t cd,
@ICONV_CONST@ char **inbuf, size_t *inbytesleft, @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft); char **outbuf, size_t *outbytesleft);
# define iconv_close rpl_iconv_close # define iconv_close rpl_iconv_close
extern int iconv_close (iconv_t cd); extern int iconv_close (iconv_t cd);
#endif #endif

View file

@ -67,33 +67,33 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
&& fromcode[3] == '-') && fromcode[3] == '-')
{ {
if (c_toupper (tocode[0]) == 'U' if (c_toupper (tocode[0]) == 'U'
&& c_toupper (tocode[1]) == 'T' && c_toupper (tocode[1]) == 'T'
&& c_toupper (tocode[2]) == 'F' && c_toupper (tocode[2]) == 'F'
&& tocode[3] == '-') && tocode[3] == '-')
{ {
if (strcmp (fromcode + 4, "8") == 0) if (strcmp (fromcode + 4, "8") == 0)
{ {
if (c_strcasecmp (tocode + 4, "16BE") == 0) if (c_strcasecmp (tocode + 4, "16BE") == 0)
return _ICONV_UTF8_UTF16BE; return _ICONV_UTF8_UTF16BE;
if (c_strcasecmp (tocode + 4, "16LE") == 0) if (c_strcasecmp (tocode + 4, "16LE") == 0)
return _ICONV_UTF8_UTF16LE; return _ICONV_UTF8_UTF16LE;
if (c_strcasecmp (tocode + 4, "32BE") == 0) if (c_strcasecmp (tocode + 4, "32BE") == 0)
return _ICONV_UTF8_UTF32BE; return _ICONV_UTF8_UTF32BE;
if (c_strcasecmp (tocode + 4, "32LE") == 0) if (c_strcasecmp (tocode + 4, "32LE") == 0)
return _ICONV_UTF8_UTF32LE; return _ICONV_UTF8_UTF32LE;
} }
else if (strcmp (tocode + 4, "8") == 0) else if (strcmp (tocode + 4, "8") == 0)
{ {
if (c_strcasecmp (fromcode + 4, "16BE") == 0) if (c_strcasecmp (fromcode + 4, "16BE") == 0)
return _ICONV_UTF16BE_UTF8; return _ICONV_UTF16BE_UTF8;
if (c_strcasecmp (fromcode + 4, "16LE") == 0) if (c_strcasecmp (fromcode + 4, "16LE") == 0)
return _ICONV_UTF16LE_UTF8; return _ICONV_UTF16LE_UTF8;
if (c_strcasecmp (fromcode + 4, "32BE") == 0) if (c_strcasecmp (fromcode + 4, "32BE") == 0)
return _ICONV_UTF32BE_UTF8; return _ICONV_UTF32BE_UTF8;
if (c_strcasecmp (fromcode + 4, "32LE") == 0) if (c_strcasecmp (fromcode + 4, "32LE") == 0)
return _ICONV_UTF32LE_UTF8; return _ICONV_UTF32LE_UTF8;
} }
} }
} }
#endif #endif
@ -116,20 +116,20 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
/* Convert the encodings to upper case, because /* Convert the encodings to upper case, because
1. in the arguments of iconv_open() on AIX, HP-UX, and OSF/1 the case 1. in the arguments of iconv_open() on AIX, HP-UX, and OSF/1 the case
matters, matters,
2. it makes searching in the table faster. */ 2. it makes searching in the table faster. */
{ {
const char *p = fromcode; const char *p = fromcode;
char *q = fromcode_upper; char *q = fromcode_upper;
while ((*q = c_toupper (*p)) != '\0') while ((*q = c_toupper (*p)) != '\0')
{ {
p++; p++;
q++; q++;
if (q == &fromcode_upper[SIZEOF (fromcode_upper)]) if (q == &fromcode_upper[SIZEOF (fromcode_upper)])
{ {
errno = EINVAL; errno = EINVAL;
return (iconv_t)(-1); return (iconv_t)(-1);
} }
} }
fromcode_upper_end = q; fromcode_upper_end = q;
} }
@ -139,13 +139,13 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
char *q = tocode_upper; char *q = tocode_upper;
while ((*q = c_toupper (*p)) != '\0') while ((*q = c_toupper (*p)) != '\0')
{ {
p++; p++;
q++; q++;
if (q == &tocode_upper[SIZEOF (tocode_upper)]) if (q == &tocode_upper[SIZEOF (tocode_upper)])
{ {
errno = EINVAL; errno = EINVAL;
return (iconv_t)(-1); return (iconv_t)(-1);
} }
} }
tocode_upper_end = q; tocode_upper_end = q;
} }

View file

@ -27,9 +27,9 @@ extern "C" {
/* Handling of unconvertible characters. */ /* Handling of unconvertible characters. */
enum iconv_ilseq_handler enum iconv_ilseq_handler
{ {
iconveh_error, /* return and set errno = EILSEQ */ iconveh_error, /* return and set errno = EILSEQ */
iconveh_question_mark, /* use one '?' per unconvertible character */ iconveh_question_mark, /* use one '?' per unconvertible character */
iconveh_escape_sequence /* use escape sequence \uxxxx or \Uxxxxxxxx */ iconveh_escape_sequence /* use escape sequence \uxxxx or \Uxxxxxxxx */
}; };

View file

@ -59,15 +59,15 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si
/* char * /* char *
* inet_ntop(af, src, dst, size) * inet_ntop(af, src, dst, size)
* convert a network format address to presentation format. * convert a network format address to presentation format.
* return: * return:
* pointer to presentation format address (`dst'), or NULL (see errno). * pointer to presentation format address (`dst'), or NULL (see errno).
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
const char * const char *
inet_ntop (int af, const void *restrict src, inet_ntop (int af, const void *restrict src,
char *restrict dst, socklen_t cnt) char *restrict dst, socklen_t cnt)
{ {
switch (af) switch (af)
{ {
@ -90,14 +90,14 @@ inet_ntop (int af, const void *restrict src,
/* const char * /* const char *
* inet_ntop4(src, dst, size) * inet_ntop4(src, dst, size)
* format an IPv4 address * format an IPv4 address
* return: * return:
* `dst' (as a const) * `dst' (as a const)
* notes: * notes:
* (1) uses no statics * (1) uses no statics
* (2) takes a u_char* not an in_addr as input * (2) takes a u_char* not an in_addr as input
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static const char * static const char *
inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
@ -122,9 +122,9 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
/* const char * /* const char *
* inet_ntop6(src, dst, size) * inet_ntop6(src, dst, size)
* convert IPv6 binary address into presentation (printable) format * convert IPv6 binary address into presentation (printable) format
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static const char * static const char *
inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
@ -157,26 +157,26 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{ {
if (words[i] == 0) if (words[i] == 0)
{ {
if (cur.base == -1) if (cur.base == -1)
cur.base = i, cur.len = 1; cur.base = i, cur.len = 1;
else else
cur.len++; cur.len++;
} }
else else
{ {
if (cur.base != -1) if (cur.base != -1)
{ {
if (best.base == -1 || cur.len > best.len) if (best.base == -1 || cur.len > best.len)
best = cur; best = cur;
cur.base = -1; cur.base = -1;
} }
} }
} }
if (cur.base != -1) if (cur.base != -1)
{ {
if (best.base == -1 || cur.len > best.len) if (best.base == -1 || cur.len > best.len)
best = cur; best = cur;
} }
if (best.base != -1 && best.len < 2) if (best.base != -1 && best.len < 2)
best.base = -1; best.base = -1;
@ -189,28 +189,28 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
{ {
/* Are we inside the best run of 0x00's? */ /* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base && i < (best.base + best.len)) if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{ {
if (i == best.base) if (i == best.base)
*tp++ = ':'; *tp++ = ':';
continue; continue;
} }
/* Are we following an initial run of 0x00s or any real hex? */ /* Are we following an initial run of 0x00s or any real hex? */
if (i != 0) if (i != 0)
*tp++ = ':'; *tp++ = ':';
/* Is this address an encapsulated IPv4? */ /* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 && if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{ {
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp))) if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
return (NULL); return (NULL);
tp += strlen (tp); tp += strlen (tp);
break; break;
} }
{ {
int len = sprintf (tp, "%x", words[i]); int len = sprintf (tp, "%x", words[i]);
if (len < 0) if (len < 0)
return NULL; return NULL;
tp += len; tp += len;
} }
} }
/* Was it a trailing run of 0x00's? */ /* Was it a trailing run of 0x00's? */

View file

@ -57,14 +57,14 @@ static int inet_pton6 (const char *src, unsigned char *dst);
/* int /* int
* inet_pton(af, src, dst) * inet_pton(af, src, dst)
* convert from presentation format (which usually means ASCII printable) * convert from presentation format (which usually means ASCII printable)
* to network format (which is usually some kind of binary format). * to network format (which is usually some kind of binary format).
* return: * return:
* 1 if the address was valid for the specified address family * 1 if the address was valid for the specified address family
* 0 if the address wasn't valid (`dst' is untouched in this case) * 0 if the address wasn't valid (`dst' is untouched in this case)
* -1 if some other error occurred (`dst' is untouched in this case, too) * -1 if some other error occurred (`dst' is untouched in this case, too)
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
int int
inet_pton (int af, const char *restrict src, void *restrict dst) inet_pton (int af, const char *restrict src, void *restrict dst)
@ -88,14 +88,14 @@ inet_pton (int af, const char *restrict src, void *restrict dst)
/* int /* int
* inet_pton4(src, dst) * inet_pton4(src, dst)
* like inet_aton() but without all the hexadecimal, octal (with the * like inet_aton() but without all the hexadecimal, octal (with the
* exception of 0) and shorthand. * exception of 0) and shorthand.
* return: * return:
* 1 if `src' is a valid dotted quad, else 0. * 1 if `src' is a valid dotted quad, else 0.
* notice: * notice:
* does not touch `dst' unless it's returning 1. * does not touch `dst' unless it's returning 1.
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static int static int
inet_pton4 (const char *restrict src, unsigned char *restrict dst) inet_pton4 (const char *restrict src, unsigned char *restrict dst)
@ -110,30 +110,30 @@ inet_pton4 (const char *restrict src, unsigned char *restrict dst)
{ {
if (ch >= '0' && ch <= '9') if (ch >= '0' && ch <= '9')
{ {
unsigned new = *tp * 10 + (ch - '0'); unsigned new = *tp * 10 + (ch - '0');
if (saw_digit && *tp == 0) if (saw_digit && *tp == 0)
return (0); return (0);
if (new > 255) if (new > 255)
return (0); return (0);
*tp = new; *tp = new;
if (!saw_digit) if (!saw_digit)
{ {
if (++octets > 4) if (++octets > 4)
return (0); return (0);
saw_digit = 1; saw_digit = 1;
} }
} }
else if (ch == '.' && saw_digit) else if (ch == '.' && saw_digit)
{ {
if (octets == 4) if (octets == 4)
return (0); return (0);
*++tp = 0; *++tp = 0;
saw_digit = 0; saw_digit = 0;
} }
else else
return (0); return (0);
} }
if (octets < 4) if (octets < 4)
return (0); return (0);
@ -145,16 +145,16 @@ inet_pton4 (const char *restrict src, unsigned char *restrict dst)
/* int /* int
* inet_pton6(src, dst) * inet_pton6(src, dst)
* convert presentation level address to network order binary form. * convert presentation level address to network order binary form.
* return: * return:
* 1 if `src' is a valid [RFC1884 2.2] address, else 0. * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
* notice: * notice:
* (1) does not touch `dst' unless it's returning 1. * (1) does not touch `dst' unless it's returning 1.
* (2) :: in a full address is silently ignored. * (2) :: in a full address is silently ignored.
* credit: * credit:
* inspired by Mark Andrews. * inspired by Mark Andrews.
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static int static int
inet_pton6 (const char *restrict src, unsigned char *restrict dst) inet_pton6 (const char *restrict src, unsigned char *restrict dst)
@ -181,49 +181,49 @@ inet_pton6 (const char *restrict src, unsigned char *restrict dst)
pch = strchr (xdigits, ch); pch = strchr (xdigits, ch);
if (pch != NULL) if (pch != NULL)
{ {
val <<= 4; val <<= 4;
val |= (pch - xdigits); val |= (pch - xdigits);
if (val > 0xffff) if (val > 0xffff)
return (0); return (0);
saw_xdigit = 1; saw_xdigit = 1;
continue; continue;
} }
if (ch == ':') if (ch == ':')
{ {
curtok = src; curtok = src;
if (!saw_xdigit) if (!saw_xdigit)
{ {
if (colonp) if (colonp)
return (0); return (0);
colonp = tp; colonp = tp;
continue; continue;
} }
else if (*src == '\0') else if (*src == '\0')
{ {
return (0); return (0);
} }
if (tp + NS_INT16SZ > endp) if (tp + NS_INT16SZ > endp)
return (0); return (0);
*tp++ = (u_char) (val >> 8) & 0xff; *tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff; *tp++ = (u_char) val & 0xff;
saw_xdigit = 0; saw_xdigit = 0;
val = 0; val = 0;
continue; continue;
} }
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4 (curtok, tp) > 0) inet_pton4 (curtok, tp) > 0)
{ {
tp += NS_INADDRSZ; tp += NS_INADDRSZ;
saw_xdigit = 0; saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */ break; /* '\0' was seen by inet_pton4(). */
} }
return (0); return (0);
} }
if (saw_xdigit) if (saw_xdigit)
{ {
if (tp + NS_INT16SZ > endp) if (tp + NS_INT16SZ > endp)
return (0); return (0);
*tp++ = (u_char) (val >> 8) & 0xff; *tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff; *tp++ = (u_char) val & 0xff;
} }
@ -237,12 +237,12 @@ inet_pton6 (const char *restrict src, unsigned char *restrict dst)
int i; int i;
if (tp == endp) if (tp == endp)
return (0); return (0);
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
{ {
endp[-i] = colonp[n - i]; endp[-i] = colonp[n - i];
colonp[n - i] = 0; colonp[n - i] = 0;
} }
tp = endp; tp = endp;
} }
if (tp != endp) if (tp != endp)

View file

@ -129,214 +129,214 @@ get_charset_aliases (void)
char *file_name; char *file_name;
/* Make it possible to override the charset.alias location. This is /* Make it possible to override the charset.alias location. This is
necessary for running the testsuite before "make install". */ necessary for running the testsuite before "make install". */
dir = getenv ("CHARSETALIASDIR"); dir = getenv ("CHARSETALIASDIR");
if (dir == NULL || dir[0] == '\0') if (dir == NULL || dir[0] == '\0')
dir = relocate (LIBDIR); dir = relocate (LIBDIR);
/* Concatenate dir and base into freshly allocated file_name. */ /* Concatenate dir and base into freshly allocated file_name. */
{ {
size_t dir_len = strlen (dir); size_t dir_len = strlen (dir);
size_t base_len = strlen (base); size_t base_len = strlen (base);
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
file_name = (char *) malloc (dir_len + add_slash + base_len + 1); file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
if (file_name != NULL) if (file_name != NULL)
{ {
memcpy (file_name, dir, dir_len); memcpy (file_name, dir, dir_len);
if (add_slash) if (add_slash)
file_name[dir_len] = DIRECTORY_SEPARATOR; file_name[dir_len] = DIRECTORY_SEPARATOR;
memcpy (file_name + dir_len + add_slash, base, base_len + 1); memcpy (file_name + dir_len + add_slash, base, base_len + 1);
} }
} }
if (file_name == NULL) if (file_name == NULL)
/* Out of memory. Treat the file as empty. */ /* Out of memory. Treat the file as empty. */
cp = ""; cp = "";
else else
{ {
int fd; int fd;
/* Open the file. Reject symbolic links on platforms that support /* Open the file. Reject symbolic links on platforms that support
O_NOFOLLOW. This is a security feature. Without it, an attacker O_NOFOLLOW. This is a security feature. Without it, an attacker
could retrieve parts of the contents (namely, the tail of the could retrieve parts of the contents (namely, the tail of the
first line that starts with "* ") of an arbitrary file by placing first line that starts with "* ") of an arbitrary file by placing
a symbolic link to that file under the name "charset.alias" in a symbolic link to that file under the name "charset.alias" in
some writable directory and defining the environment variable some writable directory and defining the environment variable
CHARSETALIASDIR to point to that directory. */ CHARSETALIASDIR to point to that directory. */
fd = open (file_name, fd = open (file_name,
O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
if (fd < 0) if (fd < 0)
/* File not found. Treat it as empty. */ /* File not found. Treat it as empty. */
cp = ""; cp = "";
else else
{ {
FILE *fp; FILE *fp;
fp = fdopen (fd, "r"); fp = fdopen (fd, "r");
if (fp == NULL) if (fp == NULL)
{ {
/* Out of memory. Treat the file as empty. */ /* Out of memory. Treat the file as empty. */
close (fd); close (fd);
cp = ""; cp = "";
} }
else else
{ {
/* Parse the file's contents. */ /* Parse the file's contents. */
char *res_ptr = NULL; char *res_ptr = NULL;
size_t res_size = 0; size_t res_size = 0;
for (;;) for (;;)
{ {
int c; int c;
char buf1[50+1]; char buf1[50+1];
char buf2[50+1]; char buf2[50+1];
size_t l1, l2; size_t l1, l2;
char *old_res_ptr; char *old_res_ptr;
c = getc (fp); c = getc (fp);
if (c == EOF) if (c == EOF)
break; break;
if (c == '\n' || c == ' ' || c == '\t') if (c == '\n' || c == ' ' || c == '\t')
continue; continue;
if (c == '#') if (c == '#')
{ {
/* Skip comment, to end of line. */ /* Skip comment, to end of line. */
do do
c = getc (fp); c = getc (fp);
while (!(c == EOF || c == '\n')); while (!(c == EOF || c == '\n'));
if (c == EOF) if (c == EOF)
break; break;
continue; continue;
} }
ungetc (c, fp); ungetc (c, fp);
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
break; break;
l1 = strlen (buf1); l1 = strlen (buf1);
l2 = strlen (buf2); l2 = strlen (buf2);
old_res_ptr = res_ptr; old_res_ptr = res_ptr;
if (res_size == 0) if (res_size == 0)
{ {
res_size = l1 + 1 + l2 + 1; res_size = l1 + 1 + l2 + 1;
res_ptr = (char *) malloc (res_size + 1); res_ptr = (char *) malloc (res_size + 1);
} }
else else
{ {
res_size += l1 + 1 + l2 + 1; res_size += l1 + 1 + l2 + 1;
res_ptr = (char *) realloc (res_ptr, res_size + 1); res_ptr = (char *) realloc (res_ptr, res_size + 1);
} }
if (res_ptr == NULL) if (res_ptr == NULL)
{ {
/* Out of memory. */ /* Out of memory. */
res_size = 0; res_size = 0;
if (old_res_ptr != NULL) if (old_res_ptr != NULL)
free (old_res_ptr); free (old_res_ptr);
break; break;
} }
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
strcpy (res_ptr + res_size - (l2 + 1), buf2); strcpy (res_ptr + res_size - (l2 + 1), buf2);
} }
fclose (fp); fclose (fp);
if (res_size == 0) if (res_size == 0)
cp = ""; cp = "";
else else
{ {
*(res_ptr + res_size) = '\0'; *(res_ptr + res_size) = '\0';
cp = res_ptr; cp = res_ptr;
} }
} }
} }
free (file_name); free (file_name);
} }
#else #else
# if defined DARWIN7 # if defined DARWIN7
/* To avoid the trouble of installing a file that is shared by many /* To avoid the trouble of installing a file that is shared by many
GNU packages -- many packaging systems have problems with this --, GNU packages -- many packaging systems have problems with this --,
simply inline the aliases here. */ simply inline the aliases here. */
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
"ISO8859-2" "\0" "ISO-8859-2" "\0" "ISO8859-2" "\0" "ISO-8859-2" "\0"
"ISO8859-4" "\0" "ISO-8859-4" "\0" "ISO8859-4" "\0" "ISO-8859-4" "\0"
"ISO8859-5" "\0" "ISO-8859-5" "\0" "ISO8859-5" "\0" "ISO-8859-5" "\0"
"ISO8859-7" "\0" "ISO-8859-7" "\0" "ISO8859-7" "\0" "ISO-8859-7" "\0"
"ISO8859-9" "\0" "ISO-8859-9" "\0" "ISO8859-9" "\0" "ISO-8859-9" "\0"
"ISO8859-13" "\0" "ISO-8859-13" "\0" "ISO8859-13" "\0" "ISO-8859-13" "\0"
"ISO8859-15" "\0" "ISO-8859-15" "\0" "ISO8859-15" "\0" "ISO-8859-15" "\0"
"KOI8-R" "\0" "KOI8-R" "\0" "KOI8-R" "\0" "KOI8-R" "\0"
"KOI8-U" "\0" "KOI8-U" "\0" "KOI8-U" "\0" "KOI8-U" "\0"
"CP866" "\0" "CP866" "\0" "CP866" "\0" "CP866" "\0"
"CP949" "\0" "CP949" "\0" "CP949" "\0" "CP949" "\0"
"CP1131" "\0" "CP1131" "\0" "CP1131" "\0" "CP1131" "\0"
"CP1251" "\0" "CP1251" "\0" "CP1251" "\0" "CP1251" "\0"
"eucCN" "\0" "GB2312" "\0" "eucCN" "\0" "GB2312" "\0"
"GB2312" "\0" "GB2312" "\0" "GB2312" "\0" "GB2312" "\0"
"eucJP" "\0" "EUC-JP" "\0" "eucJP" "\0" "EUC-JP" "\0"
"eucKR" "\0" "EUC-KR" "\0" "eucKR" "\0" "EUC-KR" "\0"
"Big5" "\0" "BIG5" "\0" "Big5" "\0" "BIG5" "\0"
"Big5HKSCS" "\0" "BIG5-HKSCS" "\0" "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
"GBK" "\0" "GBK" "\0" "GBK" "\0" "GBK" "\0"
"GB18030" "\0" "GB18030" "\0" "GB18030" "\0" "GB18030" "\0"
"SJIS" "\0" "SHIFT_JIS" "\0" "SJIS" "\0" "SHIFT_JIS" "\0"
"ARMSCII-8" "\0" "ARMSCII-8" "\0" "ARMSCII-8" "\0" "ARMSCII-8" "\0"
"PT154" "\0" "PT154" "\0" "PT154" "\0" "PT154" "\0"
/*"ISCII-DEV" "\0" "?" "\0"*/ /*"ISCII-DEV" "\0" "?" "\0"*/
"*" "\0" "UTF-8" "\0"; "*" "\0" "UTF-8" "\0";
# endif # endif
# if defined VMS # if defined VMS
/* To avoid the troubles of an extra file charset.alias_vms in the /* To avoid the troubles of an extra file charset.alias_vms in the
sources of many GNU packages, simply inline the aliases here. */ sources of many GNU packages, simply inline the aliases here. */
/* The list of encodings is taken from the OpenVMS 7.3-1 documentation /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
"Compaq C Run-Time Library Reference Manual for OpenVMS systems" "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
section 10.7 "Handling Different Character Sets". */ section 10.7 "Handling Different Character Sets". */
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
"ISO8859-2" "\0" "ISO-8859-2" "\0" "ISO8859-2" "\0" "ISO-8859-2" "\0"
"ISO8859-5" "\0" "ISO-8859-5" "\0" "ISO8859-5" "\0" "ISO-8859-5" "\0"
"ISO8859-7" "\0" "ISO-8859-7" "\0" "ISO8859-7" "\0" "ISO-8859-7" "\0"
"ISO8859-8" "\0" "ISO-8859-8" "\0" "ISO8859-8" "\0" "ISO-8859-8" "\0"
"ISO8859-9" "\0" "ISO-8859-9" "\0" "ISO8859-9" "\0" "ISO-8859-9" "\0"
/* Japanese */ /* Japanese */
"eucJP" "\0" "EUC-JP" "\0" "eucJP" "\0" "EUC-JP" "\0"
"SJIS" "\0" "SHIFT_JIS" "\0" "SJIS" "\0" "SHIFT_JIS" "\0"
"DECKANJI" "\0" "DEC-KANJI" "\0" "DECKANJI" "\0" "DEC-KANJI" "\0"
"SDECKANJI" "\0" "EUC-JP" "\0" "SDECKANJI" "\0" "EUC-JP" "\0"
/* Chinese */ /* Chinese */
"eucTW" "\0" "EUC-TW" "\0" "eucTW" "\0" "EUC-TW" "\0"
"DECHANYU" "\0" "DEC-HANYU" "\0" "DECHANYU" "\0" "DEC-HANYU" "\0"
"DECHANZI" "\0" "GB2312" "\0" "DECHANZI" "\0" "GB2312" "\0"
/* Korean */ /* Korean */
"DECKOREAN" "\0" "EUC-KR" "\0"; "DECKOREAN" "\0" "EUC-KR" "\0";
# endif # endif
# if defined WIN32_NATIVE || defined __CYGWIN__ # if defined WIN32_NATIVE || defined __CYGWIN__
/* To avoid the troubles of installing a separate file in the same /* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */ runtime, simply inline the aliases here. */
cp = "CP936" "\0" "GBK" "\0" cp = "CP936" "\0" "GBK" "\0"
"CP1361" "\0" "JOHAB" "\0" "CP1361" "\0" "JOHAB" "\0"
"CP20127" "\0" "ASCII" "\0" "CP20127" "\0" "ASCII" "\0"
"CP20866" "\0" "KOI8-R" "\0" "CP20866" "\0" "KOI8-R" "\0"
"CP20936" "\0" "GB2312" "\0" "CP20936" "\0" "GB2312" "\0"
"CP21866" "\0" "KOI8-RU" "\0" "CP21866" "\0" "KOI8-RU" "\0"
"CP28591" "\0" "ISO-8859-1" "\0" "CP28591" "\0" "ISO-8859-1" "\0"
"CP28592" "\0" "ISO-8859-2" "\0" "CP28592" "\0" "ISO-8859-2" "\0"
"CP28593" "\0" "ISO-8859-3" "\0" "CP28593" "\0" "ISO-8859-3" "\0"
"CP28594" "\0" "ISO-8859-4" "\0" "CP28594" "\0" "ISO-8859-4" "\0"
"CP28595" "\0" "ISO-8859-5" "\0" "CP28595" "\0" "ISO-8859-5" "\0"
"CP28596" "\0" "ISO-8859-6" "\0" "CP28596" "\0" "ISO-8859-6" "\0"
"CP28597" "\0" "ISO-8859-7" "\0" "CP28597" "\0" "ISO-8859-7" "\0"
"CP28598" "\0" "ISO-8859-8" "\0" "CP28598" "\0" "ISO-8859-8" "\0"
"CP28599" "\0" "ISO-8859-9" "\0" "CP28599" "\0" "ISO-8859-9" "\0"
"CP28605" "\0" "ISO-8859-15" "\0" "CP28605" "\0" "ISO-8859-15" "\0"
"CP38598" "\0" "ISO-8859-8" "\0" "CP38598" "\0" "ISO-8859-8" "\0"
"CP51932" "\0" "EUC-JP" "\0" "CP51932" "\0" "EUC-JP" "\0"
"CP51936" "\0" "GB2312" "\0" "CP51936" "\0" "GB2312" "\0"
"CP51949" "\0" "EUC-KR" "\0" "CP51949" "\0" "EUC-KR" "\0"
"CP51950" "\0" "EUC-TW" "\0" "CP51950" "\0" "EUC-TW" "\0"
"CP54936" "\0" "GB18030" "\0" "CP54936" "\0" "GB18030" "\0"
"CP65001" "\0" "UTF-8" "\0"; "CP65001" "\0" "UTF-8" "\0";
# endif # endif
#endif #endif
@ -369,7 +369,7 @@ locale_charset (void)
codeset = nl_langinfo (CODESET); codeset = nl_langinfo (CODESET);
# ifdef __CYGWIN__ # ifdef __CYGWIN__
/* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always
returns "US-ASCII". As long as this is not fixed, return the suffix returns "US-ASCII". As long as this is not fixed, return the suffix
of the locale name from the environment variables (if present) or of the locale name from the environment variables (if present) or
the codepage as a number. */ the codepage as a number. */
@ -380,36 +380,46 @@ locale_charset (void)
locale = getenv ("LC_ALL"); locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0') if (locale == NULL || locale[0] == '\0')
{ {
locale = getenv ("LC_CTYPE"); locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0') if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG"); locale = getenv ("LANG");
} }
if (locale != NULL && locale[0] != '\0') if (locale != NULL && locale[0] != '\0')
{ {
/* If the locale name contains an encoding after the dot, return /* If the locale name contains an encoding after the dot, return
it. */ it. */
const char *dot = strchr (locale, '.'); const char *dot = strchr (locale, '.');
if (dot != NULL) if (dot != NULL)
{ {
const char *modifier; const char *modifier;
dot++; dot++;
/* Look for the possible @... trailer and remove it, if any. */ /* Look for the possible @... trailer and remove it, if any. */
modifier = strchr (dot, '@'); modifier = strchr (dot, '@');
if (modifier == NULL) if (modifier == NULL)
return dot; return dot;
if (modifier - dot < sizeof (buf)) if (modifier - dot < sizeof (buf))
{ {
memcpy (buf, dot, modifier - dot); memcpy (buf, dot, modifier - dot);
buf [modifier - dot] = '\0'; buf [modifier - dot] = '\0';
return buf; return buf;
} }
} }
} }
/* Woe32 has a function returning the locale's codepage as a number. */ /* Woe32 has a function returning the locale's codepage as a number:
GetACP(). This encoding is used by Cygwin, unless the user has set
the environment variable CYGWIN=codepage:oem (which very few people
do).
Output directed to console windows needs to be converted (to
GetOEMCP() if the console is using a raster font, or to
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
this conversion transparently (see winsup/cygwin/fhandler_console.cc),
converting to GetConsoleOutputCP(). This leads to correct results,
except when SetConsoleOutputCP has been called and a raster font is
in use. */
sprintf (buf, "CP%u", GetACP ()); sprintf (buf, "CP%u", GetACP ());
codeset = buf; codeset = buf;
} }
@ -431,11 +441,11 @@ locale_charset (void)
{ {
locale = getenv ("LC_ALL"); locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0') if (locale == NULL || locale[0] == '\0')
{ {
locale = getenv ("LC_CTYPE"); locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0') if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG"); locale = getenv ("LANG");
} }
} }
/* On some old systems, one used to set locale = "iso8859_1". On others, /* On some old systems, one used to set locale = "iso8859_1". On others,
@ -449,7 +459,13 @@ locale_charset (void)
static char buf[2 + 10 + 1]; static char buf[2 + 10 + 1];
/* Woe32 has a function returning the locale's codepage as a number. */ /* Woe32 has a function returning the locale's codepage as a number:
GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
But in GUI programs and for output sent to files and pipes, GetACP()
encoding is the best bet. */
sprintf (buf, "CP%u", GetACP ()); sprintf (buf, "CP%u", GetACP ());
codeset = buf; codeset = buf;
@ -467,7 +483,7 @@ locale_charset (void)
{ {
locale = getenv ("LC_CTYPE"); locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0') if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG"); locale = getenv ("LANG");
} }
if (locale != NULL && locale[0] != '\0') if (locale != NULL && locale[0] != '\0')
{ {
@ -475,21 +491,21 @@ locale_charset (void)
const char *dot = strchr (locale, '.'); const char *dot = strchr (locale, '.');
if (dot != NULL) if (dot != NULL)
{ {
const char *modifier; const char *modifier;
dot++; dot++;
/* Look for the possible @... trailer and remove it, if any. */ /* Look for the possible @... trailer and remove it, if any. */
modifier = strchr (dot, '@'); modifier = strchr (dot, '@');
if (modifier == NULL) if (modifier == NULL)
return dot; return dot;
if (modifier - dot < sizeof (buf)) if (modifier - dot < sizeof (buf))
{ {
memcpy (buf, dot, modifier - dot); memcpy (buf, dot, modifier - dot);
buf [modifier - dot] = '\0'; buf [modifier - dot] = '\0';
return buf; return buf;
} }
} }
/* Resolve through the charset.alias file. */ /* Resolve through the charset.alias file. */
codeset = locale; codeset = locale;
@ -498,12 +514,12 @@ locale_charset (void)
{ {
/* OS/2 has a function returning the locale's codepage as a number. */ /* OS/2 has a function returning the locale's codepage as a number. */
if (DosQueryCp (sizeof (cp), cp, &cplen)) if (DosQueryCp (sizeof (cp), cp, &cplen))
codeset = ""; codeset = "";
else else
{ {
sprintf (buf, "CP%u", cp[0]); sprintf (buf, "CP%u", cp[0]);
codeset = buf; codeset = buf;
} }
} }
#endif #endif
@ -517,10 +533,10 @@ locale_charset (void)
*aliases != '\0'; *aliases != '\0';
aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
if (strcmp (codeset, aliases) == 0 if (strcmp (codeset, aliases) == 0
|| (aliases[0] == '*' && aliases[1] == '\0')) || (aliases[0] == '*' && aliases[1] == '\0'))
{ {
codeset = aliases + strlen (aliases) + 1; codeset = aliases + strlen (aliases) + 1;
break; break;
} }
/* Don't return an empty string. GNU libc and GNU libiconv interpret /* Don't return an empty string. GNU libc and GNU libiconv interpret

View file

@ -34,6 +34,8 @@
# include <xlocale.h> # include <xlocale.h>
#endif #endif
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
On systems that don't define it, use the same value as GNU libintl. */ On systems that don't define it, use the same value as GNU libintl. */
#if !defined LC_MESSAGES #if !defined LC_MESSAGES
@ -44,7 +46,7 @@
# if @REPLACE_DUPLOCALE@ # if @REPLACE_DUPLOCALE@
# undef duplocale # undef duplocale
# define duplocale rpl_duplocale # define duplocale rpl_duplocale
extern locale_t duplocale (locale_t locale); extern locale_t duplocale (locale_t locale) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef duplocale # undef duplocale

View file

@ -74,21 +74,21 @@ mmalloca (size_t n)
char *p = (char *) malloc (nplus); char *p = (char *) malloc (nplus);
if (p != NULL) if (p != NULL)
{ {
size_t slot; size_t slot;
p += HEADER_SIZE; p += HEADER_SIZE;
/* Put a magic number into the indicator word. */ /* Put a magic number into the indicator word. */
((int *) p)[-1] = MAGIC_NUMBER; ((int *) p)[-1] = MAGIC_NUMBER;
/* Enter p into the hash table. */ /* Enter p into the hash table. */
slot = (unsigned long) p % HASH_TABLE_SIZE; slot = (unsigned long) p % HASH_TABLE_SIZE;
((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot]; ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
mmalloca_results[slot] = p; mmalloca_results[slot] = p;
return p; return p;
} }
} }
/* Out of memory. */ /* Out of memory. */
return NULL; return NULL;
@ -109,28 +109,28 @@ freea (void *p)
if (p != NULL) if (p != NULL)
{ {
/* Attempt to quickly distinguish the mmalloca() result - which has /* Attempt to quickly distinguish the mmalloca() result - which has
a magic indicator word - and the alloca() result - which has an a magic indicator word - and the alloca() result - which has an
uninitialized indicator word. It is for this test that sa_increment uninitialized indicator word. It is for this test that sa_increment
additional bytes are allocated in the alloca() case. */ additional bytes are allocated in the alloca() case. */
if (((int *) p)[-1] == MAGIC_NUMBER) if (((int *) p)[-1] == MAGIC_NUMBER)
{ {
/* Looks like a mmalloca() result. To see whether it really is one, /* Looks like a mmalloca() result. To see whether it really is one,
perform a lookup in the hash table. */ perform a lookup in the hash table. */
size_t slot = (unsigned long) p % HASH_TABLE_SIZE; size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
void **chain = &mmalloca_results[slot]; void **chain = &mmalloca_results[slot];
for (; *chain != NULL;) for (; *chain != NULL;)
{ {
if (*chain == p) if (*chain == p)
{ {
/* Found it. Remove it from the hash table and free it. */ /* Found it. Remove it from the hash table and free it. */
char *p_begin = (char *) p - HEADER_SIZE; char *p_begin = (char *) p - HEADER_SIZE;
*chain = ((struct header *) p_begin)->next; *chain = ((struct header *) p_begin)->next;
free (p_begin); free (p_begin);
return; return;
} }
chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next; chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next;
} }
} }
/* At this point, we know it was not a mmalloca() result. */ /* At this point, we know it was not a mmalloca() result. */
} }
} }

View file

@ -54,7 +54,7 @@ extern "C" {
the function returns. Upon failure, it returns NULL. */ the function returns. Upon failure, it returns NULL. */
#if HAVE_ALLOCA #if HAVE_ALLOCA
# define malloca(N) \ # define malloca(N) \
((N) < 4032 - sa_increment \ ((N) < 4032 - sa_increment \
? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
: mmalloca (N)) : mmalloca (N))
#else #else
@ -122,10 +122,10 @@ enum
sa_alignment_longdouble = sa_alignof (long double), sa_alignment_longdouble = sa_alignof (long double),
sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
| (sa_alignment_longlong - 1) | (sa_alignment_longlong - 1)
#endif #endif
| (sa_alignment_longdouble - 1) | (sa_alignment_longdouble - 1)
) + 1, ) + 1,
/* The increment that guarantees room for a magic word must be >= sizeof (int) /* The increment that guarantees room for a magic word must be >= sizeof (int)
and a multiple of sa_alignment_max. */ and a multiple of sa_alignment_max. */
sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max

View file

@ -63,30 +63,30 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
switch (nstate) switch (nstate)
{ {
case 0: case 0:
p = s; p = s;
m = n; m = n;
break; break;
case 3: case 3:
buf[2] = pstate[3]; buf[2] = pstate[3];
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 2: case 2:
buf[1] = pstate[2]; buf[1] = pstate[2];
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 1: case 1:
buf[0] = pstate[1]; buf[0] = pstate[1];
p = buf; p = buf;
m = nstate; m = nstate;
buf[m++] = s[0]; buf[m++] = s[0];
if (n >= 2 && m < 4) if (n >= 2 && m < 4)
{ {
buf[m++] = s[1]; buf[m++] = s[1];
if (n >= 3 && m < 4) if (n >= 3 && m < 4)
buf[m++] = s[2]; buf[m++] = s[2];
} }
break; break;
default: default:
errno = EINVAL; errno = EINVAL;
return (size_t)(-1); return (size_t)(-1);
} }
/* Here m > 0. */ /* Here m > 0. */
@ -99,208 +99,208 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
int res = mbtowc (pwc, p, m); int res = mbtowc (pwc, p, m);
if (res >= 0) if (res >= 0)
{ {
if (pwc != NULL && ((*pwc == 0) != (res == 0))) if (pwc != NULL && ((*pwc == 0) != (res == 0)))
abort (); abort ();
if (nstate >= (res > 0 ? res : 1)) if (nstate >= (res > 0 ? res : 1))
abort (); abort ();
res -= nstate; res -= nstate;
pstate[0] = 0; pstate[0] = 0;
return res; return res;
} }
/* mbtowc does not distinguish between invalid and incomplete multibyte /* mbtowc does not distinguish between invalid and incomplete multibyte
sequences. But mbrtowc needs to make this distinction. sequences. But mbrtowc needs to make this distinction.
There are two possible approaches: There are two possible approaches:
- Use iconv() and its return value. - Use iconv() and its return value.
- Use built-in knowledge about the possible encodings. - Use built-in knowledge about the possible encodings.
Given the low quality of implementation of iconv() on the systems that Given the low quality of implementation of iconv() on the systems that
lack mbrtowc(), we use the second approach. lack mbrtowc(), we use the second approach.
The possible encodings are: The possible encodings are:
- 8-bit encodings, - 8-bit encodings,
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
- UTF-8. - UTF-8.
Use specialized code for each. */ Use specialized code for each. */
if (m >= 4 || m >= MB_CUR_MAX) if (m >= 4 || m >= MB_CUR_MAX)
goto invalid; goto invalid;
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */ /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
{ {
const char *encoding = locale_charset (); const char *encoding = locale_charset ();
if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
{ {
/* Cf. unistr/u8-mblen.c. */ /* Cf. unistr/u8-mblen.c. */
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if (c >= 0xc2) if (c >= 0xc2)
{ {
if (c < 0xe0) if (c < 0xe0)
{ {
if (m == 1) if (m == 1)
goto incomplete; goto incomplete;
} }
else if (c < 0xf0) else if (c < 0xf0)
{ {
if (m == 1) if (m == 1)
goto incomplete; goto incomplete;
if (m == 2) if (m == 2)
{ {
unsigned char c2 = (unsigned char) p[1]; unsigned char c2 = (unsigned char) p[1];
if ((c2 ^ 0x80) < 0x40 if ((c2 ^ 0x80) < 0x40
&& (c >= 0xe1 || c2 >= 0xa0) && (c >= 0xe1 || c2 >= 0xa0)
&& (c != 0xed || c2 < 0xa0)) && (c != 0xed || c2 < 0xa0))
goto incomplete; goto incomplete;
} }
} }
else if (c <= 0xf4) else if (c <= 0xf4)
{ {
if (m == 1) if (m == 1)
goto incomplete; goto incomplete;
else /* m == 2 || m == 3 */ else /* m == 2 || m == 3 */
{ {
unsigned char c2 = (unsigned char) p[1]; unsigned char c2 = (unsigned char) p[1];
if ((c2 ^ 0x80) < 0x40 if ((c2 ^ 0x80) < 0x40
&& (c >= 0xf1 || c2 >= 0x90) && (c >= 0xf1 || c2 >= 0x90)
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
{ {
if (m == 2) if (m == 2)
goto incomplete; goto incomplete;
else /* m == 3 */ else /* m == 3 */
{ {
unsigned char c3 = (unsigned char) p[2]; unsigned char c3 = (unsigned char) p[2];
if ((c3 ^ 0x80) < 0x40) if ((c3 ^ 0x80) < 0x40)
goto incomplete; goto incomplete;
} }
} }
} }
} }
} }
goto invalid; goto invalid;
} }
/* As a reference for this code, you can use the GNU libiconv /* As a reference for this code, you can use the GNU libiconv
implementation. Look for uses of the RET_TOOFEW macro. */ implementation. Look for uses of the RET_TOOFEW macro. */
if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
{ {
if (m == 1) if (m == 1)
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
goto incomplete; goto incomplete;
} }
if (m == 2) if (m == 2)
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if (c == 0x8f) if (c == 0x8f)
{ {
unsigned char c2 = (unsigned char) p[1]; unsigned char c2 = (unsigned char) p[1];
if (c2 >= 0xa1 && c2 < 0xff) if (c2 >= 0xa1 && c2 < 0xff)
goto incomplete; goto incomplete;
} }
} }
goto invalid; goto invalid;
} }
if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|| STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|| STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
{ {
if (m == 1) if (m == 1)
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if (c >= 0xa1 && c < 0xff) if (c >= 0xa1 && c < 0xff)
goto incomplete; goto incomplete;
} }
goto invalid; goto invalid;
} }
if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
{ {
if (m == 1) if (m == 1)
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if ((c >= 0xa1 && c < 0xff) || c == 0x8e) if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
goto incomplete; goto incomplete;
} }
else /* m == 2 || m == 3 */ else /* m == 2 || m == 3 */
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if (c == 0x8e) if (c == 0x8e)
goto incomplete; goto incomplete;
} }
goto invalid; goto invalid;
} }
if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
{ {
if (m == 1) if (m == 1)
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
goto incomplete; goto incomplete;
} }
else /* m == 2 || m == 3 */ else /* m == 2 || m == 3 */
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if (c >= 0x90 && c <= 0xe3) if (c >= 0x90 && c <= 0xe3)
{ {
unsigned char c2 = (unsigned char) p[1]; unsigned char c2 = (unsigned char) p[1];
if (c2 >= 0x30 && c2 <= 0x39) if (c2 >= 0x30 && c2 <= 0x39)
{ {
if (m == 2) if (m == 2)
goto incomplete; goto incomplete;
else /* m == 3 */ else /* m == 3 */
{ {
unsigned char c3 = (unsigned char) p[2]; unsigned char c3 = (unsigned char) p[2];
if (c3 >= 0x81 && c3 <= 0xfe) if (c3 >= 0x81 && c3 <= 0xfe)
goto incomplete; goto incomplete;
} }
} }
} }
} }
goto invalid; goto invalid;
} }
if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
{ {
if (m == 1) if (m == 1)
{ {
unsigned char c = (unsigned char) p[0]; unsigned char c = (unsigned char) p[0];
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|| (c >= 0xf0 && c <= 0xf9)) || (c >= 0xf0 && c <= 0xf9))
goto incomplete; goto incomplete;
} }
goto invalid; goto invalid;
} }
/* An unknown multibyte encoding. */ /* An unknown multibyte encoding. */
goto incomplete; goto incomplete;
} }
incomplete: incomplete:
{ {
size_t k = nstate; size_t k = nstate;
/* Here 0 <= k < m < 4. */ /* Here 0 <= k < m < 4. */
pstate[++k] = s[0]; pstate[++k] = s[0];
if (k < m) if (k < m)
{ {
pstate[++k] = s[1]; pstate[++k] = s[1];
if (k < m) if (k < m)
pstate[++k] = s[2]; pstate[++k] = s[2];
} }
if (k != m) if (k != m)
abort (); abort ();
} }
pstate[0] = m; pstate[0] = m;
return (size_t)(-2); return (size_t)(-2);
@ -341,25 +341,25 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
if (!mbsinit (ps)) if (!mbsinit (ps))
{ {
/* Parse the rest of the multibyte character byte for byte. */ /* Parse the rest of the multibyte character byte for byte. */
size_t count = 0; size_t count = 0;
for (; n > 0; s++, n--) for (; n > 0; s++, n--)
{ {
wchar_t wc; wchar_t wc;
size_t ret = mbrtowc (&wc, s, 1, ps); size_t ret = mbrtowc (&wc, s, 1, ps);
if (ret == (size_t)(-1)) if (ret == (size_t)(-1))
return (size_t)(-1); return (size_t)(-1);
count++; count++;
if (ret != (size_t)(-2)) if (ret != (size_t)(-2))
{ {
/* The multibyte character has been completed. */ /* The multibyte character has been completed. */
if (pwc != NULL) if (pwc != NULL)
*pwc = wc; *pwc = wc;
return (wc == 0 ? 0 : count); return (wc == 0 ? 0 : count);
} }
} }
return (size_t)(-2); return (size_t)(-2);
} }
} }
# endif # endif
@ -371,10 +371,10 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
if (ret != (size_t)(-1) && ret != (size_t)(-2)) if (ret != (size_t)(-1) && ret != (size_t)(-2))
{ {
if (pwc != NULL) if (pwc != NULL)
*pwc = wc; *pwc = wc;
if (wc == 0) if (wc == 0)
ret = 0; ret = 0;
} }
return ret; return ret;
} }

View file

@ -97,15 +97,15 @@ __memchr (void const *s, int c_in, size_t n)
repeated_one |= repeated_one << 31 << 1; repeated_one |= repeated_one << 31 << 1;
repeated_c |= repeated_c << 31 << 1; repeated_c |= repeated_c << 31 << 1;
if (8 < sizeof (longword)) if (8 < sizeof (longword))
{ {
size_t i; size_t i;
for (i = 64; i < sizeof (longword) * 8; i *= 2) for (i = 64; i < sizeof (longword) * 8; i *= 2)
{ {
repeated_one |= repeated_one << i; repeated_one |= repeated_one << i;
repeated_c |= repeated_c << i; repeated_c |= repeated_c << i;
} }
} }
} }
/* Instead of the traditional loop which tests each byte, we will test a /* Instead of the traditional loop which tests each byte, we will test a
@ -144,8 +144,8 @@ __memchr (void const *s, int c_in, size_t n)
longword longword1 = *longword_ptr ^ repeated_c; longword longword1 = *longword_ptr ^ repeated_c;
if ((((longword1 - repeated_one) & ~longword1) if ((((longword1 - repeated_one) & ~longword1)
& (repeated_one << 7)) != 0) & (repeated_one << 7)) != 0)
break; break;
longword_ptr++; longword_ptr++;
n -= sizeof (longword); n -= sizeof (longword);
} }
@ -162,7 +162,7 @@ __memchr (void const *s, int c_in, size_t n)
for (; n > 0; --n, ++char_ptr) for (; n > 0; --n, ++char_ptr)
{ {
if (*char_ptr == c) if (*char_ptr == c)
return (void *) char_ptr; return (void *) char_ptr;
} }
return NULL; return NULL;

View file

@ -28,7 +28,7 @@
# if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF # if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF
# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \ # define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
: pathconf ("/", _PC_PATH_MAX)) : pathconf ("/", _PC_PATH_MAX))
# endif # endif
/* Don't include sys/param.h if it already has been. */ /* Don't include sys/param.h if it already has been. */

View file

@ -43,146 +43,146 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
switch (ap->type) switch (ap->type)
{ {
case TYPE_SCHAR: case TYPE_SCHAR:
ap->a.a_schar = va_arg (args, /*signed char*/ int); ap->a.a_schar = va_arg (args, /*signed char*/ int);
break; break;
case TYPE_UCHAR: case TYPE_UCHAR:
ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
break; break;
case TYPE_SHORT: case TYPE_SHORT:
ap->a.a_short = va_arg (args, /*short*/ int); ap->a.a_short = va_arg (args, /*short*/ int);
break; break;
case TYPE_USHORT: case TYPE_USHORT:
ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
break; break;
case TYPE_INT: case TYPE_INT:
ap->a.a_int = va_arg (args, int); ap->a.a_int = va_arg (args, int);
break; break;
case TYPE_UINT: case TYPE_UINT:
ap->a.a_uint = va_arg (args, unsigned int); ap->a.a_uint = va_arg (args, unsigned int);
break; break;
case TYPE_LONGINT: case TYPE_LONGINT:
ap->a.a_longint = va_arg (args, long int); ap->a.a_longint = va_arg (args, long int);
break; break;
case TYPE_ULONGINT: case TYPE_ULONGINT:
ap->a.a_ulongint = va_arg (args, unsigned long int); ap->a.a_ulongint = va_arg (args, unsigned long int);
break; break;
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT: case TYPE_LONGLONGINT:
ap->a.a_longlongint = va_arg (args, long long int); ap->a.a_longlongint = va_arg (args, long long int);
break; break;
case TYPE_ULONGLONGINT: case TYPE_ULONGLONGINT:
ap->a.a_ulonglongint = va_arg (args, unsigned long long int); ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
break; break;
#endif #endif
case TYPE_DOUBLE: case TYPE_DOUBLE:
ap->a.a_double = va_arg (args, double); ap->a.a_double = va_arg (args, double);
break; break;
case TYPE_LONGDOUBLE: case TYPE_LONGDOUBLE:
ap->a.a_longdouble = va_arg (args, long double); ap->a.a_longdouble = va_arg (args, long double);
break; break;
case TYPE_CHAR: case TYPE_CHAR:
ap->a.a_char = va_arg (args, int); ap->a.a_char = va_arg (args, int);
break; break;
#if HAVE_WINT_T #if HAVE_WINT_T
case TYPE_WIDE_CHAR: case TYPE_WIDE_CHAR:
/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
default argument promotions", this is not the case in mingw32, default argument promotions", this is not the case in mingw32,
where wint_t is 'unsigned short'. */ where wint_t is 'unsigned short'. */
ap->a.a_wide_char = ap->a.a_wide_char =
(sizeof (wint_t) < sizeof (int) (sizeof (wint_t) < sizeof (int)
? (wint_t) va_arg (args, int) ? (wint_t) va_arg (args, int)
: va_arg (args, wint_t)); : va_arg (args, wint_t));
break; break;
#endif #endif
case TYPE_STRING: case TYPE_STRING:
ap->a.a_string = va_arg (args, const char *); ap->a.a_string = va_arg (args, const char *);
/* A null pointer is an invalid argument for "%s", but in practice /* A null pointer is an invalid argument for "%s", but in practice
it occurs quite frequently in printf statements that produce it occurs quite frequently in printf statements that produce
debug output. Use a fallback in this case. */ debug output. Use a fallback in this case. */
if (ap->a.a_string == NULL) if (ap->a.a_string == NULL)
ap->a.a_string = "(NULL)"; ap->a.a_string = "(NULL)";
break; break;
#if HAVE_WCHAR_T #if HAVE_WCHAR_T
case TYPE_WIDE_STRING: case TYPE_WIDE_STRING:
ap->a.a_wide_string = va_arg (args, const wchar_t *); ap->a.a_wide_string = va_arg (args, const wchar_t *);
/* A null pointer is an invalid argument for "%ls", but in practice /* A null pointer is an invalid argument for "%ls", but in practice
it occurs quite frequently in printf statements that produce it occurs quite frequently in printf statements that produce
debug output. Use a fallback in this case. */ debug output. Use a fallback in this case. */
if (ap->a.a_wide_string == NULL) if (ap->a.a_wide_string == NULL)
{ {
static const wchar_t wide_null_string[] = static const wchar_t wide_null_string[] =
{ {
(wchar_t)'(', (wchar_t)'(',
(wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
(wchar_t)')', (wchar_t)')',
(wchar_t)0 (wchar_t)0
}; };
ap->a.a_wide_string = wide_null_string; ap->a.a_wide_string = wide_null_string;
} }
break; break;
#endif #endif
case TYPE_POINTER: case TYPE_POINTER:
ap->a.a_pointer = va_arg (args, void *); ap->a.a_pointer = va_arg (args, void *);
break; break;
case TYPE_COUNT_SCHAR_POINTER: case TYPE_COUNT_SCHAR_POINTER:
ap->a.a_count_schar_pointer = va_arg (args, signed char *); ap->a.a_count_schar_pointer = va_arg (args, signed char *);
break; break;
case TYPE_COUNT_SHORT_POINTER: case TYPE_COUNT_SHORT_POINTER:
ap->a.a_count_short_pointer = va_arg (args, short *); ap->a.a_count_short_pointer = va_arg (args, short *);
break; break;
case TYPE_COUNT_INT_POINTER: case TYPE_COUNT_INT_POINTER:
ap->a.a_count_int_pointer = va_arg (args, int *); ap->a.a_count_int_pointer = va_arg (args, int *);
break; break;
case TYPE_COUNT_LONGINT_POINTER: case TYPE_COUNT_LONGINT_POINTER:
ap->a.a_count_longint_pointer = va_arg (args, long int *); ap->a.a_count_longint_pointer = va_arg (args, long int *);
break; break;
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
case TYPE_COUNT_LONGLONGINT_POINTER: case TYPE_COUNT_LONGLONGINT_POINTER:
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
break; break;
#endif #endif
#if ENABLE_UNISTDIO #if ENABLE_UNISTDIO
/* The unistdio extensions. */ /* The unistdio extensions. */
case TYPE_U8_STRING: case TYPE_U8_STRING:
ap->a.a_u8_string = va_arg (args, const uint8_t *); ap->a.a_u8_string = va_arg (args, const uint8_t *);
/* A null pointer is an invalid argument for "%U", but in practice /* A null pointer is an invalid argument for "%U", but in practice
it occurs quite frequently in printf statements that produce it occurs quite frequently in printf statements that produce
debug output. Use a fallback in this case. */ debug output. Use a fallback in this case. */
if (ap->a.a_u8_string == NULL) if (ap->a.a_u8_string == NULL)
{ {
static const uint8_t u8_null_string[] = static const uint8_t u8_null_string[] =
{ '(', 'N', 'U', 'L', 'L', ')', 0 }; { '(', 'N', 'U', 'L', 'L', ')', 0 };
ap->a.a_u8_string = u8_null_string; ap->a.a_u8_string = u8_null_string;
} }
break; break;
case TYPE_U16_STRING: case TYPE_U16_STRING:
ap->a.a_u16_string = va_arg (args, const uint16_t *); ap->a.a_u16_string = va_arg (args, const uint16_t *);
/* A null pointer is an invalid argument for "%lU", but in practice /* A null pointer is an invalid argument for "%lU", but in practice
it occurs quite frequently in printf statements that produce it occurs quite frequently in printf statements that produce
debug output. Use a fallback in this case. */ debug output. Use a fallback in this case. */
if (ap->a.a_u16_string == NULL) if (ap->a.a_u16_string == NULL)
{ {
static const uint16_t u16_null_string[] = static const uint16_t u16_null_string[] =
{ '(', 'N', 'U', 'L', 'L', ')', 0 }; { '(', 'N', 'U', 'L', 'L', ')', 0 };
ap->a.a_u16_string = u16_null_string; ap->a.a_u16_string = u16_null_string;
} }
break; break;
case TYPE_U32_STRING: case TYPE_U32_STRING:
ap->a.a_u32_string = va_arg (args, const uint32_t *); ap->a.a_u32_string = va_arg (args, const uint32_t *);
/* A null pointer is an invalid argument for "%llU", but in practice /* A null pointer is an invalid argument for "%llU", but in practice
it occurs quite frequently in printf statements that produce it occurs quite frequently in printf statements that produce
debug output. Use a fallback in this case. */ debug output. Use a fallback in this case. */
if (ap->a.a_u32_string == NULL) if (ap->a.a_u32_string == NULL)
{ {
static const uint32_t u32_null_string[] = static const uint32_t u32_null_string[] =
{ '(', 'N', 'U', 'L', 'L', ')', 0 }; { '(', 'N', 'U', 'L', 'L', ')', 0 };
ap->a.a_u32_string = u32_null_string; ap->a.a_u32_string = u32_null_string;
} }
break; break;
#endif #endif
default: default:
/* Unknown type. */ /* Unknown type. */
return -1; return -1;
} }
return 0; return 0;
} }

View file

@ -93,42 +93,42 @@ typedef struct
arg_type type; arg_type type;
union union
{ {
signed char a_schar; signed char a_schar;
unsigned char a_uchar; unsigned char a_uchar;
short a_short; short a_short;
unsigned short a_ushort; unsigned short a_ushort;
int a_int; int a_int;
unsigned int a_uint; unsigned int a_uint;
long int a_longint; long int a_longint;
unsigned long int a_ulongint; unsigned long int a_ulongint;
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
long long int a_longlongint; long long int a_longlongint;
unsigned long long int a_ulonglongint; unsigned long long int a_ulonglongint;
#endif #endif
float a_float; float a_float;
double a_double; double a_double;
long double a_longdouble; long double a_longdouble;
int a_char; int a_char;
#if HAVE_WINT_T #if HAVE_WINT_T
wint_t a_wide_char; wint_t a_wide_char;
#endif #endif
const char* a_string; const char* a_string;
#if HAVE_WCHAR_T #if HAVE_WCHAR_T
const wchar_t* a_wide_string; const wchar_t* a_wide_string;
#endif #endif
void* a_pointer; void* a_pointer;
signed char * a_count_schar_pointer; signed char * a_count_schar_pointer;
short * a_count_short_pointer; short * a_count_short_pointer;
int * a_count_int_pointer; int * a_count_int_pointer;
long int * a_count_longint_pointer; long int * a_count_longint_pointer;
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
long long int * a_count_longlongint_pointer; long long int * a_count_longlongint_pointer;
#endif #endif
#if ENABLE_UNISTDIO #if ENABLE_UNISTDIO
/* The unistdio extensions. */ /* The unistdio extensions. */
const uint8_t * a_u8_string; const uint8_t * a_u8_string;
const uint16_t * a_u16_string; const uint16_t * a_u16_string;
const uint32_t * a_u32_string; const uint32_t * a_u32_string;
#endif #endif
} }
a; a;

View file

@ -80,10 +80,10 @@ STATIC
int int
PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
{ {
const CHAR_T *cp = format; /* pointer into format */ const CHAR_T *cp = format; /* pointer into format */
size_t arg_posn = 0; /* number of regular arguments consumed */ size_t arg_posn = 0; /* number of regular arguments consumed */
size_t d_allocated; /* allocated elements of d->dir */ size_t d_allocated; /* allocated elements of d->dir */
size_t a_allocated; /* allocated elements of a->arg */ size_t a_allocated; /* allocated elements of a->arg */
size_t max_width_length = 0; size_t max_width_length = 0;
size_t max_precision_length = 0; size_t max_precision_length = 0;
@ -99,501 +99,501 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
a->arg = NULL; a->arg = NULL;
#define REGISTER_ARG(_index_,_type_) \ #define REGISTER_ARG(_index_,_type_) \
{ \ { \
size_t n = (_index_); \ size_t n = (_index_); \
if (n >= a_allocated) \ if (n >= a_allocated) \
{ \ { \
size_t memory_size; \ size_t memory_size; \
argument *memory; \ argument *memory; \
\ \
a_allocated = xtimes (a_allocated, 2); \ a_allocated = xtimes (a_allocated, 2); \
if (a_allocated <= n) \ if (a_allocated <= n) \
a_allocated = xsum (n, 1); \ a_allocated = xsum (n, 1); \
memory_size = xtimes (a_allocated, sizeof (argument)); \ memory_size = xtimes (a_allocated, sizeof (argument)); \
if (size_overflow_p (memory_size)) \ if (size_overflow_p (memory_size)) \
/* Overflow, would lead to out of memory. */ \ /* Overflow, would lead to out of memory. */ \
goto out_of_memory; \ goto out_of_memory; \
memory = (argument *) (a->arg \ memory = (argument *) (a->arg \
? realloc (a->arg, memory_size) \ ? realloc (a->arg, memory_size) \
: malloc (memory_size)); \ : malloc (memory_size)); \
if (memory == NULL) \ if (memory == NULL) \
/* Out of memory. */ \ /* Out of memory. */ \
goto out_of_memory; \ goto out_of_memory; \
a->arg = memory; \ a->arg = memory; \
} \ } \
while (a->count <= n) \ while (a->count <= n) \
a->arg[a->count++].type = TYPE_NONE; \ a->arg[a->count++].type = TYPE_NONE; \
if (a->arg[n].type == TYPE_NONE) \ if (a->arg[n].type == TYPE_NONE) \
a->arg[n].type = (_type_); \ a->arg[n].type = (_type_); \
else if (a->arg[n].type != (_type_)) \ else if (a->arg[n].type != (_type_)) \
/* Ambiguous type for positional argument. */ \ /* Ambiguous type for positional argument. */ \
goto error; \ goto error; \
} }
while (*cp != '\0') while (*cp != '\0')
{ {
CHAR_T c = *cp++; CHAR_T c = *cp++;
if (c == '%') if (c == '%')
{ {
size_t arg_index = ARG_NONE; size_t arg_index = ARG_NONE;
DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
/* Initialize the next directive. */ /* Initialize the next directive. */
dp->dir_start = cp - 1; dp->dir_start = cp - 1;
dp->flags = 0; dp->flags = 0;
dp->width_start = NULL; dp->width_start = NULL;
dp->width_end = NULL; dp->width_end = NULL;
dp->width_arg_index = ARG_NONE; dp->width_arg_index = ARG_NONE;
dp->precision_start = NULL; dp->precision_start = NULL;
dp->precision_end = NULL; dp->precision_end = NULL;
dp->precision_arg_index = ARG_NONE; dp->precision_arg_index = ARG_NONE;
dp->arg_index = ARG_NONE; dp->arg_index = ARG_NONE;
/* Test for positional argument. */ /* Test for positional argument. */
if (*cp >= '0' && *cp <= '9') if (*cp >= '0' && *cp <= '9')
{ {
const CHAR_T *np; const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++) for (np = cp; *np >= '0' && *np <= '9'; np++)
; ;
if (*np == '$') if (*np == '$')
{ {
size_t n = 0; size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++) for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0'); n = xsum (xtimes (n, 10), *np - '0');
if (n == 0) if (n == 0)
/* Positional argument 0. */ /* Positional argument 0. */
goto error; goto error;
if (size_overflow_p (n)) if (size_overflow_p (n))
/* n too large, would lead to out of memory later. */ /* n too large, would lead to out of memory later. */
goto error; goto error;
arg_index = n - 1; arg_index = n - 1;
cp = np + 1; cp = np + 1;
} }
} }
/* Read the flags. */ /* Read the flags. */
for (;;) for (;;)
{ {
if (*cp == '\'') if (*cp == '\'')
{ {
dp->flags |= FLAG_GROUP; dp->flags |= FLAG_GROUP;
cp++; cp++;
} }
else if (*cp == '-') else if (*cp == '-')
{ {
dp->flags |= FLAG_LEFT; dp->flags |= FLAG_LEFT;
cp++; cp++;
} }
else if (*cp == '+') else if (*cp == '+')
{ {
dp->flags |= FLAG_SHOWSIGN; dp->flags |= FLAG_SHOWSIGN;
cp++; cp++;
} }
else if (*cp == ' ') else if (*cp == ' ')
{ {
dp->flags |= FLAG_SPACE; dp->flags |= FLAG_SPACE;
cp++; cp++;
} }
else if (*cp == '#') else if (*cp == '#')
{ {
dp->flags |= FLAG_ALT; dp->flags |= FLAG_ALT;
cp++; cp++;
} }
else if (*cp == '0') else if (*cp == '0')
{ {
dp->flags |= FLAG_ZERO; dp->flags |= FLAG_ZERO;
cp++; cp++;
} }
else else
break; break;
} }
/* Parse the field width. */ /* Parse the field width. */
if (*cp == '*') if (*cp == '*')
{ {
dp->width_start = cp; dp->width_start = cp;
cp++; cp++;
dp->width_end = cp; dp->width_end = cp;
if (max_width_length < 1) if (max_width_length < 1)
max_width_length = 1; max_width_length = 1;
/* Test for positional argument. */ /* Test for positional argument. */
if (*cp >= '0' && *cp <= '9') if (*cp >= '0' && *cp <= '9')
{ {
const CHAR_T *np; const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++) for (np = cp; *np >= '0' && *np <= '9'; np++)
; ;
if (*np == '$') if (*np == '$')
{ {
size_t n = 0; size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++) for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0'); n = xsum (xtimes (n, 10), *np - '0');
if (n == 0) if (n == 0)
/* Positional argument 0. */ /* Positional argument 0. */
goto error; goto error;
if (size_overflow_p (n)) if (size_overflow_p (n))
/* n too large, would lead to out of memory later. */ /* n too large, would lead to out of memory later. */
goto error; goto error;
dp->width_arg_index = n - 1; dp->width_arg_index = n - 1;
cp = np + 1; cp = np + 1;
} }
} }
if (dp->width_arg_index == ARG_NONE) if (dp->width_arg_index == ARG_NONE)
{ {
dp->width_arg_index = arg_posn++; dp->width_arg_index = arg_posn++;
if (dp->width_arg_index == ARG_NONE) if (dp->width_arg_index == ARG_NONE)
/* arg_posn wrapped around. */ /* arg_posn wrapped around. */
goto error; goto error;
} }
REGISTER_ARG (dp->width_arg_index, TYPE_INT); REGISTER_ARG (dp->width_arg_index, TYPE_INT);
} }
else if (*cp >= '0' && *cp <= '9') else if (*cp >= '0' && *cp <= '9')
{ {
size_t width_length; size_t width_length;
dp->width_start = cp; dp->width_start = cp;
for (; *cp >= '0' && *cp <= '9'; cp++) for (; *cp >= '0' && *cp <= '9'; cp++)
; ;
dp->width_end = cp; dp->width_end = cp;
width_length = dp->width_end - dp->width_start; width_length = dp->width_end - dp->width_start;
if (max_width_length < width_length) if (max_width_length < width_length)
max_width_length = width_length; max_width_length = width_length;
} }
/* Parse the precision. */ /* Parse the precision. */
if (*cp == '.') if (*cp == '.')
{ {
cp++; cp++;
if (*cp == '*') if (*cp == '*')
{ {
dp->precision_start = cp - 1; dp->precision_start = cp - 1;
cp++; cp++;
dp->precision_end = cp; dp->precision_end = cp;
if (max_precision_length < 2) if (max_precision_length < 2)
max_precision_length = 2; max_precision_length = 2;
/* Test for positional argument. */ /* Test for positional argument. */
if (*cp >= '0' && *cp <= '9') if (*cp >= '0' && *cp <= '9')
{ {
const CHAR_T *np; const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++) for (np = cp; *np >= '0' && *np <= '9'; np++)
; ;
if (*np == '$') if (*np == '$')
{ {
size_t n = 0; size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++) for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0'); n = xsum (xtimes (n, 10), *np - '0');
if (n == 0) if (n == 0)
/* Positional argument 0. */ /* Positional argument 0. */
goto error; goto error;
if (size_overflow_p (n)) if (size_overflow_p (n))
/* n too large, would lead to out of memory /* n too large, would lead to out of memory
later. */ later. */
goto error; goto error;
dp->precision_arg_index = n - 1; dp->precision_arg_index = n - 1;
cp = np + 1; cp = np + 1;
} }
} }
if (dp->precision_arg_index == ARG_NONE) if (dp->precision_arg_index == ARG_NONE)
{ {
dp->precision_arg_index = arg_posn++; dp->precision_arg_index = arg_posn++;
if (dp->precision_arg_index == ARG_NONE) if (dp->precision_arg_index == ARG_NONE)
/* arg_posn wrapped around. */ /* arg_posn wrapped around. */
goto error; goto error;
} }
REGISTER_ARG (dp->precision_arg_index, TYPE_INT); REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
} }
else else
{ {
size_t precision_length; size_t precision_length;
dp->precision_start = cp - 1; dp->precision_start = cp - 1;
for (; *cp >= '0' && *cp <= '9'; cp++) for (; *cp >= '0' && *cp <= '9'; cp++)
; ;
dp->precision_end = cp; dp->precision_end = cp;
precision_length = dp->precision_end - dp->precision_start; precision_length = dp->precision_end - dp->precision_start;
if (max_precision_length < precision_length) if (max_precision_length < precision_length)
max_precision_length = precision_length; max_precision_length = precision_length;
} }
} }
{ {
arg_type type; arg_type type;
/* Parse argument type/size specifiers. */ /* Parse argument type/size specifiers. */
{ {
int flags = 0; int flags = 0;
for (;;) for (;;)
{ {
if (*cp == 'h') if (*cp == 'h')
{ {
flags |= (1 << (flags & 1)); flags |= (1 << (flags & 1));
cp++; cp++;
} }
else if (*cp == 'L') else if (*cp == 'L')
{ {
flags |= 4; flags |= 4;
cp++; cp++;
} }
else if (*cp == 'l') else if (*cp == 'l')
{ {
flags += 8; flags += 8;
cp++; cp++;
} }
else if (*cp == 'j') else if (*cp == 'j')
{ {
if (sizeof (intmax_t) > sizeof (long)) if (sizeof (intmax_t) > sizeof (long))
{ {
/* intmax_t = long long */ /* intmax_t = long long */
flags += 16; flags += 16;
} }
else if (sizeof (intmax_t) > sizeof (int)) else if (sizeof (intmax_t) > sizeof (int))
{ {
/* intmax_t = long */ /* intmax_t = long */
flags += 8; flags += 8;
} }
cp++; cp++;
} }
else if (*cp == 'z' || *cp == 'Z') else if (*cp == 'z' || *cp == 'Z')
{ {
/* 'z' is standardized in ISO C 99, but glibc uses 'Z' /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
because the warning facility in gcc-2.95.2 understands because the warning facility in gcc-2.95.2 understands
only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
if (sizeof (size_t) > sizeof (long)) if (sizeof (size_t) > sizeof (long))
{ {
/* size_t = long long */ /* size_t = long long */
flags += 16; flags += 16;
} }
else if (sizeof (size_t) > sizeof (int)) else if (sizeof (size_t) > sizeof (int))
{ {
/* size_t = long */ /* size_t = long */
flags += 8; flags += 8;
} }
cp++; cp++;
} }
else if (*cp == 't') else if (*cp == 't')
{ {
if (sizeof (ptrdiff_t) > sizeof (long)) if (sizeof (ptrdiff_t) > sizeof (long))
{ {
/* ptrdiff_t = long long */ /* ptrdiff_t = long long */
flags += 16; flags += 16;
} }
else if (sizeof (ptrdiff_t) > sizeof (int)) else if (sizeof (ptrdiff_t) > sizeof (int))
{ {
/* ptrdiff_t = long */ /* ptrdiff_t = long */
flags += 8; flags += 8;
} }
cp++; cp++;
} }
#if defined __APPLE__ && defined __MACH__ #if defined __APPLE__ && defined __MACH__
/* On MacOS X 10.3, PRIdMAX is defined as "qd". /* On MacOS X 10.3, PRIdMAX is defined as "qd".
We cannot change it to "lld" because PRIdMAX must also We cannot change it to "lld" because PRIdMAX must also
be understood by the system's printf routines. */ be understood by the system's printf routines. */
else if (*cp == 'q') else if (*cp == 'q')
{ {
if (64 / 8 > sizeof (long)) if (64 / 8 > sizeof (long))
{ {
/* int64_t = long long */ /* int64_t = long long */
flags += 16; flags += 16;
} }
else else
{ {
/* int64_t = long */ /* int64_t = long */
flags += 8; flags += 8;
} }
cp++; cp++;
} }
#endif #endif
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* On native Win32, PRIdMAX is defined as "I64d". /* On native Win32, PRIdMAX is defined as "I64d".
We cannot change it to "lld" because PRIdMAX must also We cannot change it to "lld" because PRIdMAX must also
be understood by the system's printf routines. */ be understood by the system's printf routines. */
else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
{ {
if (64 / 8 > sizeof (long)) if (64 / 8 > sizeof (long))
{ {
/* __int64 = long long */ /* __int64 = long long */
flags += 16; flags += 16;
} }
else else
{ {
/* __int64 = long */ /* __int64 = long */
flags += 8; flags += 8;
} }
cp += 3; cp += 3;
} }
#endif #endif
else else
break; break;
} }
/* Read the conversion character. */ /* Read the conversion character. */
c = *cp++; c = *cp++;
switch (c) switch (c)
{ {
case 'd': case 'i': case 'd': case 'i':
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */ /* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4)) if (flags >= 16 || (flags & 4))
type = TYPE_LONGLONGINT; type = TYPE_LONGLONGINT;
else else
#endif #endif
/* If 'long long' exists and is the same as 'long', we parse /* If 'long long' exists and is the same as 'long', we parse
"lld" into TYPE_LONGINT. */ "lld" into TYPE_LONGINT. */
if (flags >= 8) if (flags >= 8)
type = TYPE_LONGINT; type = TYPE_LONGINT;
else if (flags & 2) else if (flags & 2)
type = TYPE_SCHAR; type = TYPE_SCHAR;
else if (flags & 1) else if (flags & 1)
type = TYPE_SHORT; type = TYPE_SHORT;
else else
type = TYPE_INT; type = TYPE_INT;
break; break;
case 'o': case 'u': case 'x': case 'X': case 'o': case 'u': case 'x': case 'X':
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */ /* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4)) if (flags >= 16 || (flags & 4))
type = TYPE_ULONGLONGINT; type = TYPE_ULONGLONGINT;
else else
#endif #endif
/* If 'unsigned long long' exists and is the same as /* If 'unsigned long long' exists and is the same as
'unsigned long', we parse "llu" into TYPE_ULONGINT. */ 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
if (flags >= 8) if (flags >= 8)
type = TYPE_ULONGINT; type = TYPE_ULONGINT;
else if (flags & 2) else if (flags & 2)
type = TYPE_UCHAR; type = TYPE_UCHAR;
else if (flags & 1) else if (flags & 1)
type = TYPE_USHORT; type = TYPE_USHORT;
else else
type = TYPE_UINT; type = TYPE_UINT;
break; break;
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
case 'a': case 'A': case 'a': case 'A':
if (flags >= 16 || (flags & 4)) if (flags >= 16 || (flags & 4))
type = TYPE_LONGDOUBLE; type = TYPE_LONGDOUBLE;
else else
type = TYPE_DOUBLE; type = TYPE_DOUBLE;
break; break;
case 'c': case 'c':
if (flags >= 8) if (flags >= 8)
#if HAVE_WINT_T #if HAVE_WINT_T
type = TYPE_WIDE_CHAR; type = TYPE_WIDE_CHAR;
#else #else
goto error; goto error;
#endif #endif
else else
type = TYPE_CHAR; type = TYPE_CHAR;
break; break;
#if HAVE_WINT_T #if HAVE_WINT_T
case 'C': case 'C':
type = TYPE_WIDE_CHAR; type = TYPE_WIDE_CHAR;
c = 'c'; c = 'c';
break; break;
#endif #endif
case 's': case 's':
if (flags >= 8) if (flags >= 8)
#if HAVE_WCHAR_T #if HAVE_WCHAR_T
type = TYPE_WIDE_STRING; type = TYPE_WIDE_STRING;
#else #else
goto error; goto error;
#endif #endif
else else
type = TYPE_STRING; type = TYPE_STRING;
break; break;
#if HAVE_WCHAR_T #if HAVE_WCHAR_T
case 'S': case 'S':
type = TYPE_WIDE_STRING; type = TYPE_WIDE_STRING;
c = 's'; c = 's';
break; break;
#endif #endif
case 'p': case 'p':
type = TYPE_POINTER; type = TYPE_POINTER;
break; break;
case 'n': case 'n':
#if HAVE_LONG_LONG_INT #if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */ /* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4)) if (flags >= 16 || (flags & 4))
type = TYPE_COUNT_LONGLONGINT_POINTER; type = TYPE_COUNT_LONGLONGINT_POINTER;
else else
#endif #endif
/* If 'long long' exists and is the same as 'long', we parse /* If 'long long' exists and is the same as 'long', we parse
"lln" into TYPE_COUNT_LONGINT_POINTER. */ "lln" into TYPE_COUNT_LONGINT_POINTER. */
if (flags >= 8) if (flags >= 8)
type = TYPE_COUNT_LONGINT_POINTER; type = TYPE_COUNT_LONGINT_POINTER;
else if (flags & 2) else if (flags & 2)
type = TYPE_COUNT_SCHAR_POINTER; type = TYPE_COUNT_SCHAR_POINTER;
else if (flags & 1) else if (flags & 1)
type = TYPE_COUNT_SHORT_POINTER; type = TYPE_COUNT_SHORT_POINTER;
else else
type = TYPE_COUNT_INT_POINTER; type = TYPE_COUNT_INT_POINTER;
break; break;
#if ENABLE_UNISTDIO #if ENABLE_UNISTDIO
/* The unistdio extensions. */ /* The unistdio extensions. */
case 'U': case 'U':
if (flags >= 16) if (flags >= 16)
type = TYPE_U32_STRING; type = TYPE_U32_STRING;
else if (flags >= 8) else if (flags >= 8)
type = TYPE_U16_STRING; type = TYPE_U16_STRING;
else else
type = TYPE_U8_STRING; type = TYPE_U8_STRING;
break; break;
#endif #endif
case '%': case '%':
type = TYPE_NONE; type = TYPE_NONE;
break; break;
default: default:
/* Unknown conversion character. */ /* Unknown conversion character. */
goto error; goto error;
} }
} }
if (type != TYPE_NONE) if (type != TYPE_NONE)
{ {
dp->arg_index = arg_index; dp->arg_index = arg_index;
if (dp->arg_index == ARG_NONE) if (dp->arg_index == ARG_NONE)
{ {
dp->arg_index = arg_posn++; dp->arg_index = arg_posn++;
if (dp->arg_index == ARG_NONE) if (dp->arg_index == ARG_NONE)
/* arg_posn wrapped around. */ /* arg_posn wrapped around. */
goto error; goto error;
} }
REGISTER_ARG (dp->arg_index, type); REGISTER_ARG (dp->arg_index, type);
} }
dp->conversion = c; dp->conversion = c;
dp->dir_end = cp; dp->dir_end = cp;
} }
d->count++; d->count++;
if (d->count >= d_allocated) if (d->count >= d_allocated)
{ {
size_t memory_size; size_t memory_size;
DIRECTIVE *memory; DIRECTIVE *memory;
d_allocated = xtimes (d_allocated, 2); d_allocated = xtimes (d_allocated, 2);
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
if (size_overflow_p (memory_size)) if (size_overflow_p (memory_size))
/* Overflow, would lead to out of memory. */ /* Overflow, would lead to out of memory. */
goto out_of_memory; goto out_of_memory;
memory = (DIRECTIVE *) realloc (d->dir, memory_size); memory = (DIRECTIVE *) realloc (d->dir, memory_size);
if (memory == NULL) if (memory == NULL)
/* Out of memory. */ /* Out of memory. */
goto out_of_memory; goto out_of_memory;
d->dir = memory; d->dir = memory;
} }
} }
#if CHAR_T_ONLY_ASCII #if CHAR_T_ONLY_ASCII
else if (!c_isascii (c)) else if (!c_isascii (c))
{ {
/* Non-ASCII character. Not supported. */ /* Non-ASCII character. Not supported. */
goto error; goto error;
} }
#endif #endif
} }
d->dir[d->count].dir_start = cp; d->dir[d->count].dir_start = cp;

View file

@ -26,15 +26,15 @@
/* Flags */ /* Flags */
#define FLAG_GROUP 1 /* ' flag */ #define FLAG_GROUP 1 /* ' flag */
#define FLAG_LEFT 2 /* - flag */ #define FLAG_LEFT 2 /* - flag */
#define FLAG_SHOWSIGN 4 /* + flag */ #define FLAG_SHOWSIGN 4 /* + flag */
#define FLAG_SPACE 8 /* space flag */ #define FLAG_SPACE 8 /* space flag */
#define FLAG_ALT 16 /* # flag */ #define FLAG_ALT 16 /* # flag */
#define FLAG_ZERO 32 #define FLAG_ZERO 32
/* arg_index value indicating that no argument is consumed. */ /* arg_index value indicating that no argument is consumed. */
#define ARG_NONE (~(size_t)0) #define ARG_NONE (~(size_t)0)
/* xxx_directive: A parsed directive. /* xxx_directive: A parsed directive.
xxx_directives: A parsed format string. */ xxx_directives: A parsed format string. */
@ -163,10 +163,10 @@ extern int
u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
extern int extern int
u16_printf_parse (const uint16_t *format, u16_directives *d, u16_printf_parse (const uint16_t *format, u16_directives *d,
arguments *a); arguments *a);
extern int extern int
u32_printf_parse (const uint32_t *format, u32_directives *d, u32_printf_parse (const uint32_t *format, u32_directives *d,
arguments *a); arguments *a);
#else #else
# ifdef STATIC # ifdef STATIC
STATIC STATIC

View file

@ -44,8 +44,8 @@ extern char **environ;
/* This lock protects against simultaneous modifications of `environ'. */ /* This lock protects against simultaneous modifications of `environ'. */
# include <bits/libc-lock.h> # include <bits/libc-lock.h>
__libc_lock_define_initialized (static, envlock) __libc_lock_define_initialized (static, envlock)
# define LOCK __libc_lock_lock (envlock) # define LOCK __libc_lock_lock (envlock)
# define UNLOCK __libc_lock_unlock (envlock) # define UNLOCK __libc_lock_unlock (envlock)
#else #else
# define LOCK # define LOCK
# define UNLOCK # define UNLOCK
@ -71,13 +71,13 @@ _unsetenv (const char *name)
while (*ep != NULL) while (*ep != NULL)
if (!strncmp (*ep, name, len) && (*ep)[len] == '=') if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
{ {
/* Found it. Remove this pointer by moving later ones back. */ /* Found it. Remove this pointer by moving later ones back. */
char **dp = ep; char **dp = ep;
do do
dp[0] = dp[1]; dp[0] = dp[1];
while (*dp++); while (*dp++);
/* Continue the loop in case NAME appears again. */ /* Continue the loop in case NAME appears again. */
} }
else else
++ep; ++ep;
@ -106,7 +106,7 @@ putenv (char *string)
size = 0; size = 0;
for (ep = environ; *ep != NULL; ++ep) for (ep = environ; *ep != NULL; ++ep)
if (!strncmp (*ep, string, name_end - string) && if (!strncmp (*ep, string, name_end - string) &&
(*ep)[name_end - string] == '=') (*ep)[name_end - string] == '=')
break; break;
else else
++size; ++size;
@ -116,9 +116,9 @@ putenv (char *string)
static char **last_environ = NULL; static char **last_environ = NULL;
char **new_environ = (char **) malloc ((size + 2) * sizeof (char *)); char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
if (new_environ == NULL) if (new_environ == NULL)
return -1; return -1;
(void) memcpy ((void *) new_environ, (void *) environ, (void) memcpy ((void *) new_environ, (void *) environ,
size * sizeof (char *)); size * sizeof (char *));
new_environ[size] = (char *) string; new_environ[size] = (char *) string;
new_environ[size + 1] = NULL; new_environ[size + 1] = NULL;
free (last_environ); free (last_environ);

View file

@ -66,12 +66,12 @@ safe_rw (int fd, void const *buf, size_t count)
ssize_t result = rw (fd, buf, count); ssize_t result = rw (fd, buf, count);
if (0 <= result) if (0 <= result)
return result; return result;
else if (IS_EINTR (errno)) else if (IS_EINTR (errno))
continue; continue;
else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count) else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
count = BUGGY_READ_MAXIMUM; count = BUGGY_READ_MAXIMUM;
else else
return result; return result;
} }
} }

View file

@ -55,10 +55,10 @@ rpl_stat (char const *name, struct stat *st)
{ {
size_t len = strlen (name); size_t len = strlen (name);
if (ISSLASH (name[len - 1])) if (ISSLASH (name[len - 1]))
{ {
errno = ENOTDIR; errno = ENOTDIR;
return -1; return -1;
} }
} }
#endif /* REPLACE_FUNC_STAT_FILE */ #endif /* REPLACE_FUNC_STAT_FILE */
#if REPLACE_FUNC_STAT_DIR #if REPLACE_FUNC_STAT_DIR

View file

@ -102,8 +102,8 @@
((signed) \ ((signed) \
? ~ _STDINT_MIN (signed, bits, zero) \ ? ~ _STDINT_MIN (signed, bits, zero) \
: /* The expression for the unsigned case. The subtraction of (signed) \ : /* The expression for the unsigned case. The subtraction of (signed) \
is a nop in the unsigned case and avoids "signed integer overflow" \ is a nop in the unsigned case and avoids "signed integer overflow" \
warnings in the signed case. */ \ warnings in the signed case. */ \
((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
/* 7.18.1.1. Exact-width integer types */ /* 7.18.1.1. Exact-width integer types */
@ -454,10 +454,10 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
#undef SIG_ATOMIC_MAX #undef SIG_ATOMIC_MAX
#define SIG_ATOMIC_MIN \ #define SIG_ATOMIC_MIN \
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
0@SIG_ATOMIC_T_SUFFIX@) 0@SIG_ATOMIC_T_SUFFIX@)
#define SIG_ATOMIC_MAX \ #define SIG_ATOMIC_MAX \
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
0@SIG_ATOMIC_T_SUFFIX@) 0@SIG_ATOMIC_T_SUFFIX@)
/* size_t limit */ /* size_t limit */

View file

@ -39,27 +39,27 @@
# include <windows.h> # include <windows.h>
# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ # define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
if (ferror (stream)) \ if (ferror (stream)) \
return (EXPRESSION); \ return (EXPRESSION); \
else \ else \
{ \ { \
RETTYPE ret; \ RETTYPE ret; \
SetLastError (0); \ SetLastError (0); \
ret = (EXPRESSION); \ ret = (EXPRESSION); \
if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \ if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \
{ \ { \
int fd = fileno (stream); \ int fd = fileno (stream); \
if (fd >= 0 \ if (fd >= 0 \
&& GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\ && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
{ \ { \
/* Try to raise signal SIGPIPE. */ \ /* Try to raise signal SIGPIPE. */ \
raise (SIGPIPE); \ raise (SIGPIPE); \
/* If it is currently blocked or ignored, change errno from \ /* If it is currently blocked or ignored, change errno from \
EINVAL to EPIPE. */ \ EINVAL to EPIPE. */ \
errno = EPIPE; \ errno = EPIPE; \
} \ } \
} \ } \
return ret; \ return ret; \
} }
# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ # if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */

View file

@ -63,6 +63,8 @@
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -74,7 +76,7 @@ extern "C" {
# endif # endif
# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@ # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
extern int dprintf (int fd, const char *format, ...) extern int dprintf (int fd, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3))); __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef dprintf # undef dprintf
@ -88,7 +90,7 @@ extern int dprintf (int fd, const char *format, ...)
# if @REPLACE_FCLOSE@ # if @REPLACE_FCLOSE@
# define fclose rpl_fclose # define fclose rpl_fclose
/* Close STREAM and its underlying file descriptor. */ /* Close STREAM and its underlying file descriptor. */
extern int fclose (FILE *stream); extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fclose # undef fclose
@ -123,7 +125,8 @@ extern int fclose (FILE *stream);
# if @REPLACE_FOPEN@ # if @REPLACE_FOPEN@
# undef fopen # undef fopen
# define fopen rpl_fopen # define fopen rpl_fopen
extern FILE * fopen (const char *filename, const char *mode); extern FILE * fopen (const char *filename, const char *mode)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fopen # undef fopen
@ -137,12 +140,14 @@ extern FILE * fopen (const char *filename, const char *mode);
# if @REPLACE_FPRINTF@ # if @REPLACE_FPRINTF@
# define fprintf rpl_fprintf # define fprintf rpl_fprintf
extern int fprintf (FILE *fp, const char *format, ...) extern int fprintf (FILE *fp, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3))); __attribute__ ((__format__ (__printf__, 2, 3)))
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define fprintf rpl_fprintf # define fprintf rpl_fprintf
extern int fprintf (FILE *fp, const char *format, ...) extern int fprintf (FILE *fp, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3))); __attribute__ ((__format__ (__printf__, 2, 3)))
_GL_ARG_NONNULL ((1, 2));
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fprintf # undef fprintf
# define fprintf \ # define fprintf \
@ -163,7 +168,7 @@ extern int fprintf (FILE *fp, const char *format, ...)
was before the write calls. When discarding pending input, the file was before the write calls. When discarding pending input, the file
position is advanced to match the end of the previously read input. position is advanced to match the end of the previously read input.
Return 0 if successful. Upon error, return -1 and set errno. */ Return 0 if successful. Upon error, return -1 and set errno. */
extern int fpurge (FILE *gl_stream); extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fpurge # undef fpurge
@ -176,20 +181,21 @@ extern int fprintf (FILE *fp, const char *format, ...)
#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fputc # undef fputc
# define fputc rpl_fputc # define fputc rpl_fputc
extern int fputc (int c, FILE *stream); extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
#endif #endif
#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fputs # undef fputs
# define fputs rpl_fputs # define fputs rpl_fputs
extern int fputs (const char *string, FILE *stream); extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_FREOPEN@ #if @GNULIB_FREOPEN@
# if @REPLACE_FREOPEN@ # if @REPLACE_FREOPEN@
# undef freopen # undef freopen
# define freopen rpl_freopen # define freopen rpl_freopen
extern FILE * freopen (const char *filename, const char *mode, FILE *stream); extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef freopen # undef freopen
@ -200,7 +206,7 @@ extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
#endif #endif
#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@ #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
extern int rpl_fseek (FILE *fp, long offset, int whence); extern int rpl_fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
# undef fseek # undef fseek
# if defined GNULIB_POSIXCHECK # if defined GNULIB_POSIXCHECK
# define fseek(f,o,w) \ # define fseek(f,o,w) \
@ -226,7 +232,7 @@ extern int rpl_fseek (FILE *fp, long offset, int whence);
/* Provide fseek, fseeko functions that are aware of a preceding /* Provide fseek, fseeko functions that are aware of a preceding
fflush(), and which detect pipes. */ fflush(), and which detect pipes. */
# define fseeko rpl_fseeko # define fseeko rpl_fseeko
extern int fseeko (FILE *fp, off_t offset, int whence); extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
# if !@GNULIB_FSEEK@ # if !@GNULIB_FSEEK@
# undef fseek # undef fseek
# define fseek(f,o,w) \ # define fseek(f,o,w) \
@ -245,7 +251,7 @@ extern int fseeko (FILE *fp, off_t offset, int whence);
#endif #endif
#if @GNULIB_FTELL@ && @REPLACE_FTELL@ #if @GNULIB_FTELL@ && @REPLACE_FTELL@
extern long rpl_ftell (FILE *fp); extern long rpl_ftell (FILE *fp) _GL_ARG_NONNULL ((1));
# undef ftell # undef ftell
# if GNULIB_POSIXCHECK # if GNULIB_POSIXCHECK
# define ftell(f) \ # define ftell(f) \
@ -269,7 +275,7 @@ extern long rpl_ftell (FILE *fp);
#if @GNULIB_FTELLO@ #if @GNULIB_FTELLO@
# if @REPLACE_FTELLO@ # if @REPLACE_FTELLO@
# define ftello rpl_ftello # define ftello rpl_ftello
extern off_t ftello (FILE *fp); extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
# if !@GNULIB_FTELL@ # if !@GNULIB_FTELL@
# undef ftell # undef ftell
# define ftell(f) \ # define ftell(f) \
@ -290,7 +296,8 @@ extern off_t ftello (FILE *fp);
#if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fwrite # undef fwrite
# define fwrite rpl_fwrite # define fwrite rpl_fwrite
extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream); extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
_GL_ARG_NONNULL ((1, 4));
#endif #endif
#if @GNULIB_GETDELIM@ #if @GNULIB_GETDELIM@
@ -302,13 +309,14 @@ extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
Return the number of bytes read and stored at *LINEPTR (not including the Return the number of bytes read and stored at *LINEPTR (not including the
NUL terminator), or -1 on error or EOF. */ NUL terminator), or -1 on error or EOF. */
extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
FILE *stream); FILE *stream)
_GL_ARG_NONNULL ((1, 2, 4));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef getdelim # undef getdelim
# define getdelim(l, s, d, f) \ # define getdelim(l, s, d, f) \
(GL_LINK_WARNING ("getdelim is unportable - " \ (GL_LINK_WARNING ("getdelim is unportable - " \
"use gnulib module getdelim for portability"), \ "use gnulib module getdelim for portability"), \
getdelim (l, s, d, f)) getdelim (l, s, d, f))
#endif #endif
@ -324,13 +332,14 @@ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
bytes of space. It is realloc'd as necessary. bytes of space. It is realloc'd as necessary.
Return the number of bytes read and stored at *LINEPTR (not including the Return the number of bytes read and stored at *LINEPTR (not including the
NUL terminator), or -1 on error or EOF. */ NUL terminator), or -1 on error or EOF. */
extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
_GL_ARG_NONNULL ((1, 2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef getline # undef getline
# define getline(l, s, f) \ # define getline(l, s, f) \
(GL_LINK_WARNING ("getline is unportable - " \ (GL_LINK_WARNING ("getline is unportable - " \
"use gnulib module getline for portability"), \ "use gnulib module getline for portability"), \
getline (l, s, f)) getline (l, s, f))
#endif #endif
@ -347,10 +356,10 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
memory allocation error, call obstack_alloc_failed_handler. Upon memory allocation error, call obstack_alloc_failed_handler. Upon
other error, return -1. */ other error, return -1. */
extern int obstack_printf (struct obstack *obs, const char *format, ...) extern int obstack_printf (struct obstack *obs, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3))); __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
extern int obstack_vprintf (struct obstack *obs, const char *format, extern int obstack_vprintf (struct obstack *obs, const char *format,
va_list args) va_list args)
__attribute__ ((__format__ (__printf__, 2, 0))); __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
# endif # endif
#endif #endif
@ -374,7 +383,8 @@ extern void perror (const char *string);
# if @REPLACE_POPEN@ # if @REPLACE_POPEN@
# undef popen # undef popen
# define popen rpl_popen # define popen rpl_popen
extern FILE *popen (const char *cmd, const char *mode); extern FILE *popen (const char *cmd, const char *mode)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef popen # undef popen
@ -389,13 +399,13 @@ extern FILE *popen (const char *cmd, const char *mode);
/* Don't break __attribute__((format(printf,M,N))). */ /* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__ # define printf __printf__
extern int printf (const char *format, ...) extern int printf (const char *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2))); __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
# endif # endif
#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
/* Don't break __attribute__((format(printf,M,N))). */ /* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__ # define printf __printf__
extern int printf (const char *format, ...) extern int printf (const char *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2))); __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef printf # undef printf
# define printf \ # define printf \
@ -415,7 +425,7 @@ extern int printf (const char *format, ...)
#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef putc # undef putc
# define putc rpl_fputc # define putc rpl_fputc
extern int putc (int c, FILE *stream); extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
#endif #endif
#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
@ -427,18 +437,18 @@ extern int putchar (int c);
#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef puts # undef puts
# define puts rpl_puts # define puts rpl_puts
extern int puts (const char *string); extern int puts (const char *string) _GL_ARG_NONNULL ((1));
#endif #endif
#if @GNULIB_REMOVE@ #if @GNULIB_REMOVE@
# if @REPLACE_REMOVE@ # if @REPLACE_REMOVE@
# undef remove # undef remove
# define remove rpl_remove # define remove rpl_remove
extern int remove (const char *name); extern int remove (const char *name) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef remove # undef remove
# define remove(n) \ # define remove(n) \
(GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \ (GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \
"use gnulib module remove for more portability"), \ "use gnulib module remove for more portability"), \
remove (n)) remove (n))
@ -448,11 +458,12 @@ extern int remove (const char *name);
# if @REPLACE_RENAME@ # if @REPLACE_RENAME@
# undef rename # undef rename
# define rename rpl_rename # define rename rpl_rename
extern int rename (const char *old, const char *new); extern int rename (const char *old_filename, const char *new_filename)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef rename # undef rename
# define rename(o,n) \ # define rename(o,n) \
(GL_LINK_WARNING ("rename is buggy on some platforms - " \ (GL_LINK_WARNING ("rename is buggy on some platforms - " \
"use gnulib module rename for more portability"), \ "use gnulib module rename for more portability"), \
rename (o, n)) rename (o, n))
@ -464,11 +475,12 @@ extern int rename (const char *old, const char *new);
# define renameat rpl_renameat # define renameat rpl_renameat
# endif # endif
# if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@ # if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
extern int renameat (int fd1, char const *file1, int fd2, char const *file2); extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
_GL_ARG_NONNULL ((2, 4));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef renameat # undef renameat
# define renameat(d1,f1,d2,f2) \ # define renameat(d1,f1,d2,f2) \
(GL_LINK_WARNING ("renameat is not portable - " \ (GL_LINK_WARNING ("renameat is not portable - " \
"use gnulib module renameat for portability"), \ "use gnulib module renameat for portability"), \
renameat (d1, f1, d2, f2)) renameat (d1, f1, d2, f2))
@ -480,7 +492,8 @@ extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
# endif # endif
# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
extern int snprintf (char *str, size_t size, const char *format, ...) extern int snprintf (char *str, size_t size, const char *format, ...)
__attribute__ ((__format__ (__printf__, 3, 4))); __attribute__ ((__format__ (__printf__, 3, 4)))
_GL_ARG_NONNULL ((3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef snprintf # undef snprintf
@ -494,7 +507,8 @@ extern int snprintf (char *str, size_t size, const char *format, ...)
# if @REPLACE_SPRINTF@ # if @REPLACE_SPRINTF@
# define sprintf rpl_sprintf # define sprintf rpl_sprintf
extern int sprintf (char *str, const char *format, ...) extern int sprintf (char *str, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3))); __attribute__ ((__format__ (__printf__, 2, 3)))
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef sprintf # undef sprintf
@ -516,9 +530,9 @@ extern int sprintf (char *str, const char *format, ...)
*RESULT and return the number of resulting bytes, excluding the trailing *RESULT and return the number of resulting bytes, excluding the trailing
NUL. Upon memory allocation error, or some other error, return -1. */ NUL. Upon memory allocation error, or some other error, return -1. */
extern int asprintf (char **result, const char *format, ...) extern int asprintf (char **result, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3))); __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
extern int vasprintf (char **result, const char *format, va_list args) extern int vasprintf (char **result, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0))); __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
# endif # endif
#endif #endif
@ -528,7 +542,7 @@ extern int sprintf (char *str, const char *format, ...)
# endif # endif
# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@ # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
extern int vdprintf (int fd, const char *format, va_list args) extern int vdprintf (int fd, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0))); __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef vdprintf # undef vdprintf
@ -542,12 +556,14 @@ extern int vdprintf (int fd, const char *format, va_list args)
# if @REPLACE_VFPRINTF@ # if @REPLACE_VFPRINTF@
# define vfprintf rpl_vfprintf # define vfprintf rpl_vfprintf
extern int vfprintf (FILE *fp, const char *format, va_list args) extern int vfprintf (FILE *fp, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0))); __attribute__ ((__format__ (__printf__, 2, 0)))
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define vfprintf rpl_vfprintf # define vfprintf rpl_vfprintf
extern int vfprintf (FILE *fp, const char *format, va_list args) extern int vfprintf (FILE *fp, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0))); __attribute__ ((__format__ (__printf__, 2, 0)))
_GL_ARG_NONNULL ((1, 2));
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef vfprintf # undef vfprintf
# define vfprintf(s,f,a) \ # define vfprintf(s,f,a) \
@ -561,12 +577,12 @@ extern int vfprintf (FILE *fp, const char *format, va_list args)
# if @REPLACE_VPRINTF@ # if @REPLACE_VPRINTF@
# define vprintf rpl_vprintf # define vprintf rpl_vprintf
extern int vprintf (const char *format, va_list args) extern int vprintf (const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 1, 0))); __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
# endif # endif
#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define vprintf rpl_vprintf # define vprintf rpl_vprintf
extern int vprintf (const char *format, va_list args) extern int vprintf (const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 1, 0))); __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef vprintf # undef vprintf
# define vprintf(f,a) \ # define vprintf(f,a) \
@ -582,7 +598,8 @@ extern int vprintf (const char *format, va_list args)
# endif # endif
# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
extern int vsnprintf (char *str, size_t size, const char *format, va_list args) extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 3, 0))); __attribute__ ((__format__ (__printf__, 3, 0)))
_GL_ARG_NONNULL ((3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef vsnprintf # undef vsnprintf
@ -596,7 +613,8 @@ extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
# if @REPLACE_VSPRINTF@ # if @REPLACE_VSPRINTF@
# define vsprintf rpl_vsprintf # define vsprintf rpl_vsprintf
extern int vsprintf (char *str, const char *format, va_list args) extern int vsprintf (char *str, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0))); __attribute__ ((__format__ (__printf__, 2, 0)))
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef vsprintf # undef vsprintf

View file

@ -56,18 +56,20 @@
#if !@HAVE_STRUCT_RANDOM_DATA@ #if !@HAVE_STRUCT_RANDOM_DATA@
struct random_data struct random_data
{ {
int32_t *fptr; /* Front pointer. */ int32_t *fptr; /* Front pointer. */
int32_t *rptr; /* Rear pointer. */ int32_t *rptr; /* Rear pointer. */
int32_t *state; /* Array of state values. */ int32_t *state; /* Array of state values. */
int rand_type; /* Type of random number generator. */ int rand_type; /* Type of random number generator. */
int rand_deg; /* Degree of random number generator. */ int rand_deg; /* Degree of random number generator. */
int rand_sep; /* Distance between front and rear. */ int rand_sep; /* Distance between front and rear. */
int32_t *end_ptr; /* Pointer behind state table. */ int32_t *end_ptr; /* Pointer behind state table. */
}; };
#endif #endif
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */ /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
#ifndef EXIT_SUCCESS #ifndef EXIT_SUCCESS
@ -91,7 +93,7 @@ extern "C" {
# if !@HAVE_ATOLL@ # if !@HAVE_ATOLL@
/* Parse a signed decimal integer. /* Parse a signed decimal integer.
Returns the value of the integer. Errors are not detected. */ Returns the value of the integer. Errors are not detected. */
extern long long atoll (const char *string); extern long long atoll (const char *string) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef atoll # undef atoll
@ -120,7 +122,7 @@ extern void * calloc (size_t nmemb, size_t size);
# define canonicalize_file_name rpl_canonicalize_file_name # define canonicalize_file_name rpl_canonicalize_file_name
# endif # endif
# if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@ # if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@
extern char *canonicalize_file_name (const char *name); extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef canonicalize_file_name # undef canonicalize_file_name
@ -136,7 +138,7 @@ extern char *canonicalize_file_name (const char *name);
The three numbers are the load average of the last 1 minute, the last 5 The three numbers are the load average of the last 1 minute, the last 5
minutes, and the last 15 minutes, respectively. minutes, and the last 15 minutes, respectively.
LOADAVG is an array of NELEM numbers. */ LOADAVG is an array of NELEM numbers. */
extern int getloadavg (double loadavg[], int nelem); extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef getloadavg # undef getloadavg
@ -159,7 +161,8 @@ extern int getloadavg (double loadavg[], int nelem);
For more details see the POSIX:2001 specification. For more details see the POSIX:2001 specification.
http://www.opengroup.org/susv3xsh/getsubopt.html */ http://www.opengroup.org/susv3xsh/getsubopt.html */
# if !@HAVE_GETSUBOPT@ # if !@HAVE_GETSUBOPT@
extern int getsubopt (char **optionp, char *const *tokens, char **valuep); extern int getsubopt (char **optionp, char *const *tokens, char **valuep)
_GL_ARG_NONNULL ((1, 2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef getsubopt # undef getsubopt
@ -190,7 +193,7 @@ extern void * malloc (size_t size);
they are replaced with a string that makes the directory name unique. they are replaced with a string that makes the directory name unique.
Returns TEMPLATE, or a null pointer if it cannot get a unique name. Returns TEMPLATE, or a null pointer if it cannot get a unique name.
The directory is created mode 700. */ The directory is created mode 700. */
extern char * mkdtemp (char * /*template*/); extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkdtemp # undef mkdtemp
@ -214,7 +217,7 @@ extern char * mkdtemp (char * /*template*/);
implementation. implementation.
Returns the open file descriptor if successful, otherwise -1 and errno Returns the open file descriptor if successful, otherwise -1 and errno
set. */ set. */
extern int mkostemp (char * /*template*/, int /*flags*/); extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkostemp # undef mkostemp
@ -239,7 +242,8 @@ extern int mkostemp (char * /*template*/, int /*flags*/);
implementation. implementation.
Returns the open file descriptor if successful, otherwise -1 and errno Returns the open file descriptor if successful, otherwise -1 and errno
set. */ set. */
extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/); extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkostemps # undef mkostemps
@ -261,7 +265,7 @@ extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
Returns the open file descriptor if successful, otherwise -1 and errno Returns the open file descriptor if successful, otherwise -1 and errno
set. */ set. */
# define mkstemp rpl_mkstemp # define mkstemp rpl_mkstemp
extern int mkstemp (char * /*template*/); extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
# else # else
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
# include <unistd.h> # include <unistd.h>
@ -286,7 +290,8 @@ extern int mkstemp (char * /*template*/);
implementation. implementation.
Returns the open file descriptor if successful, otherwise -1 and errno Returns the open file descriptor if successful, otherwise -1 and errno
set. */ set. */
extern int mkstemps (char * /*template*/, int /*suffixlen*/); extern int mkstemps (char * /*template*/, int /*suffixlen*/)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkstemps # undef mkstemps
@ -300,7 +305,7 @@ extern int mkstemps (char * /*template*/, int /*suffixlen*/);
# if @REPLACE_PUTENV@ # if @REPLACE_PUTENV@
# undef putenv # undef putenv
# define putenv rpl_putenv # define putenv rpl_putenv
extern int putenv (char *string); extern int putenv (char *string) _GL_ARG_NONNULL ((1));
# endif # endif
#endif #endif
@ -311,30 +316,34 @@ extern int putenv (char *string);
# define RAND_MAX 2147483647 # define RAND_MAX 2147483647
# endif # endif
int srandom_r (unsigned int seed, struct random_data *rand_state); int srandom_r (unsigned int seed, struct random_data *rand_state)
_GL_ARG_NONNULL ((2));
int initstate_r (unsigned int seed, char *buf, size_t buf_size, int initstate_r (unsigned int seed, char *buf, size_t buf_size,
struct random_data *rand_state); struct random_data *rand_state)
int setstate_r (char *arg_state, struct random_data *rand_state); _GL_ARG_NONNULL ((2, 4));
int random_r (struct random_data *buf, int32_t *result); int setstate_r (char *arg_state, struct random_data *rand_state)
_GL_ARG_NONNULL ((1, 2));
int random_r (struct random_data *buf, int32_t *result)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef random_r # undef random_r
# define random_r(b,r) \ # define random_r(b,r) \
(GL_LINK_WARNING ("random_r is unportable - " \ (GL_LINK_WARNING ("random_r is unportable - " \
"use gnulib module random_r for portability"), \ "use gnulib module random_r for portability"), \
random_r (b,r)) random_r (b,r))
# undef initstate_r # undef initstate_r
# define initstate_r(s,b,sz,r) \ # define initstate_r(s,b,sz,r) \
(GL_LINK_WARNING ("initstate_r is unportable - " \ (GL_LINK_WARNING ("initstate_r is unportable - " \
"use gnulib module random_r for portability"), \ "use gnulib module random_r for portability"), \
initstate_r (s,b,sz,r)) initstate_r (s,b,sz,r))
# undef srandom_r # undef srandom_r
# define srandom_r(s,r) \ # define srandom_r(s,r) \
(GL_LINK_WARNING ("srandom_r is unportable - " \ (GL_LINK_WARNING ("srandom_r is unportable - " \
"use gnulib module random_r for portability"), \ "use gnulib module random_r for portability"), \
srandom_r (s,r)) srandom_r (s,r))
# undef setstate_r # undef setstate_r
# define setstate_r(a,r) \ # define setstate_r(a,r) \
(GL_LINK_WARNING ("setstate_r is unportable - " \ (GL_LINK_WARNING ("setstate_r is unportable - " \
"use gnulib module random_r for portability"), \ "use gnulib module random_r for portability"), \
setstate_r (a,r)) setstate_r (a,r))
@ -359,7 +368,7 @@ extern void * realloc (void *ptr, size_t size);
# define realpath rpl_realpath # define realpath rpl_realpath
# endif # endif
# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@ # if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
extern char *realpath (const char *name, char *resolved); extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef realpath # undef realpath
@ -373,7 +382,7 @@ extern char *realpath (const char *name, char *resolved);
# if !@HAVE_RPMATCH@ # if !@HAVE_RPMATCH@
/* Test a user response to a question. /* Test a user response to a question.
Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
extern int rpmatch (const char *response); extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef rpmatch # undef rpmatch
@ -391,7 +400,8 @@ extern int rpmatch (const char *response);
# if !@HAVE_SETENV@ || @REPLACE_SETENV@ # if !@HAVE_SETENV@ || @REPLACE_SETENV@
/* Set NAME to VALUE in the environment. /* Set NAME to VALUE in the environment.
If REPLACE is nonzero, overwrite an existing value. */ If REPLACE is nonzero, overwrite an existing value. */
extern int setenv (const char *name, const char *value, int replace); extern int setenv (const char *name, const char *value, int replace)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef setenv # undef setenv
@ -407,7 +417,7 @@ extern int setenv (const char *name, const char *value, int replace);
# endif # endif
# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@ # if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
/* Parse a double from STRING, updating ENDP if appropriate. */ /* Parse a double from STRING, updating ENDP if appropriate. */
extern double strtod (const char *str, char **endp); extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strtod # undef strtod
@ -427,7 +437,8 @@ extern double strtod (const char *str, char **endp);
stored in *ENDPTR. stored in *ENDPTR.
Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
to ERANGE. */ to ERANGE. */
extern long long strtoll (const char *string, char **endptr, int base); extern long long strtoll (const char *string, char **endptr, int base)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strtoll # undef strtoll
@ -447,7 +458,8 @@ extern long long strtoll (const char *string, char **endptr, int base);
stored in *ENDPTR. stored in *ENDPTR.
Upon overflow, the return value is ULLONG_MAX, and errno is set to Upon overflow, the return value is ULLONG_MAX, and errno is set to
ERANGE. */ ERANGE. */
extern unsigned long long strtoull (const char *string, char **endptr, int base); extern unsigned long long strtoull (const char *string, char **endptr, int base)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strtoull # undef strtoull
@ -464,7 +476,7 @@ extern unsigned long long strtoull (const char *string, char **endptr, int base)
# endif # endif
# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@ # if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
/* Remove the variable NAME from the environment. */ /* Remove the variable NAME from the environment. */
extern int unsetenv (const char *name); extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef unsetenv # undef unsetenv

View file

@ -46,7 +46,7 @@ strcasecmp (const char *s1, const char *s2)
c2 = TOLOWER (*p2); c2 = TOLOWER (*p2);
if (c1 == '\0') if (c1 == '\0')
break; break;
++p1; ++p1;
++p2; ++p2;

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,7 @@ extern "C" {
use UTC instead. Use __NS as the number of nanoseconds in the use UTC instead. Use __NS as the number of nanoseconds in the
%N directive. */ %N directive. */
size_t nstrftime (char *, size_t, char const *, struct tm const *, size_t nstrftime (char *, size_t, char const *, struct tm const *,
int __utc, int __ns); int __utc, int __ns);
#ifdef __cplusplus #ifdef __cplusplus
} }

File diff suppressed because it is too large Load diff

View file

@ -54,7 +54,7 @@ typedef struct
set. */ set. */
extern int extern int
iconveh_open (const char *to_codeset, const char *from_codeset, iconveh_open (const char *to_codeset, const char *from_codeset,
iconveh_t *cdp); iconveh_t *cdp);
/* Close a conversion descriptor created by iconveh_open(). /* Close a conversion descriptor created by iconveh_open().
Return value: 0 if successful, otherwise -1 and errno set. */ Return value: 0 if successful, otherwise -1 and errno set. */
@ -78,10 +78,10 @@ extern int
unchanged if no dynamic memory allocation was necessary. */ unchanged if no dynamic memory allocation was necessary. */
extern int extern int
mem_cd_iconveh (const char *src, size_t srclen, mem_cd_iconveh (const char *src, size_t srclen,
const iconveh_t *cd, const iconveh_t *cd,
enum iconv_ilseq_handler handler, enum iconv_ilseq_handler handler,
size_t *offsets, size_t *offsets,
char **resultp, size_t *lengthp); char **resultp, size_t *lengthp);
/* Convert an entire string from one encoding to another, using iconv. /* Convert an entire string from one encoding to another, using iconv.
The original string is the NUL-terminated string starting at SRC. The original string is the NUL-terminated string starting at SRC.
@ -94,8 +94,8 @@ extern int
successful, otherwise NULL and errno set. */ successful, otherwise NULL and errno set. */
extern char * extern char *
str_cd_iconveh (const char *src, str_cd_iconveh (const char *src,
const iconveh_t *cd, const iconveh_t *cd,
enum iconv_ilseq_handler handler); enum iconv_ilseq_handler handler);
#endif #endif
@ -114,10 +114,10 @@ extern char *
unchanged if no dynamic memory allocation was necessary. */ unchanged if no dynamic memory allocation was necessary. */
extern int extern int
mem_iconveh (const char *src, size_t srclen, mem_iconveh (const char *src, size_t srclen,
const char *from_codeset, const char *to_codeset, const char *from_codeset, const char *to_codeset,
enum iconv_ilseq_handler handler, enum iconv_ilseq_handler handler,
size_t *offsets, size_t *offsets,
char **resultp, size_t *lengthp); char **resultp, size_t *lengthp);
/* Convert an entire string from one encoding to another, using iconv. /* Convert an entire string from one encoding to another, using iconv.
The original string is the NUL-terminated string starting at SRC. The original string is the NUL-terminated string starting at SRC.
@ -128,8 +128,8 @@ extern int
successful, otherwise NULL and errno set. */ successful, otherwise NULL and errno set. */
extern char * extern char *
str_iconveh (const char *src, str_iconveh (const char *src,
const char *from_codeset, const char *to_codeset, const char *from_codeset, const char *to_codeset,
enum iconv_ilseq_handler handler); enum iconv_ilseq_handler handler);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -45,6 +45,8 @@
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -56,7 +58,7 @@ extern "C" {
# if @REPLACE_MEMCHR@ # if @REPLACE_MEMCHR@
# define memchr rpl_memchr # define memchr rpl_memchr
extern void *memchr (void const *__s, int __c, size_t __n) extern void *memchr (void const *__s, int __c, size_t __n)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef memchr # undef memchr
@ -73,8 +75,8 @@ extern void *memchr (void const *__s, int __c, size_t __n)
# endif # endif
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@ # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
extern void *memmem (void const *__haystack, size_t __haystack_len, extern void *memmem (void const *__haystack, size_t __haystack_len,
void const *__needle, size_t __needle_len) void const *__needle, size_t __needle_len)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef memmem # undef memmem
@ -90,7 +92,8 @@ extern void *memmem (void const *__haystack, size_t __haystack_len,
#if @GNULIB_MEMPCPY@ #if @GNULIB_MEMPCPY@
# if ! @HAVE_MEMPCPY@ # if ! @HAVE_MEMPCPY@
extern void *mempcpy (void *restrict __dest, void const *restrict __src, extern void *mempcpy (void *restrict __dest, void const *restrict __src,
size_t __n); size_t __n)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mempcpy # undef mempcpy
@ -104,7 +107,7 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src,
#if @GNULIB_MEMRCHR@ #if @GNULIB_MEMRCHR@
# if ! @HAVE_DECL_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@
extern void *memrchr (void const *, int, size_t) extern void *memrchr (void const *, int, size_t)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef memrchr # undef memrchr
@ -120,7 +123,7 @@ extern void *memrchr (void const *, int, size_t)
#if @GNULIB_RAWMEMCHR@ #if @GNULIB_RAWMEMCHR@
# if ! @HAVE_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@
extern void *rawmemchr (void const *__s, int __c_in) extern void *rawmemchr (void const *__s, int __c_in)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef rawmemchr # undef rawmemchr
@ -133,7 +136,8 @@ extern void *rawmemchr (void const *__s, int __c_in)
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
#if @GNULIB_STPCPY@ #if @GNULIB_STPCPY@
# if ! @HAVE_STPCPY@ # if ! @HAVE_STPCPY@
extern char *stpcpy (char *restrict __dst, char const *restrict __src); extern char *stpcpy (char *restrict __dst, char const *restrict __src)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef stpcpy # undef stpcpy
@ -149,7 +153,8 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src);
# if ! @HAVE_STPNCPY@ # if ! @HAVE_STPNCPY@
# define stpncpy gnu_stpncpy # define stpncpy gnu_stpncpy
extern char *stpncpy (char *restrict __dst, char const *restrict __src, extern char *stpncpy (char *restrict __dst, char const *restrict __src,
size_t __n); size_t __n)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef stpncpy # undef stpncpy
@ -174,7 +179,7 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
#if @GNULIB_STRCHRNUL@ #if @GNULIB_STRCHRNUL@
# if ! @HAVE_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@
extern char *strchrnul (char const *__s, int __c_in) extern char *strchrnul (char const *__s, int __c_in)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strchrnul # undef strchrnul
@ -191,7 +196,7 @@ extern char *strchrnul (char const *__s, int __c_in)
# define strdup rpl_strdup # define strdup rpl_strdup
# endif # endif
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@ # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
extern char *strdup (char const *__s); extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strdup # undef strdup
@ -208,7 +213,7 @@ extern char *strdup (char const *__s);
# define strndup rpl_strndup # define strndup rpl_strndup
# endif # endif
# if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@ # if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
extern char *strndup (char const *__string, size_t __n); extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strndup # undef strndup
@ -224,7 +229,7 @@ extern char *strndup (char const *__string, size_t __n);
#if @GNULIB_STRNLEN@ #if @GNULIB_STRNLEN@
# if ! @HAVE_DECL_STRNLEN@ # if ! @HAVE_DECL_STRNLEN@
extern size_t strnlen (char const *__string, size_t __maxlen) extern size_t strnlen (char const *__string, size_t __maxlen)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strnlen # undef strnlen
@ -251,7 +256,7 @@ extern size_t strnlen (char const *__string, size_t __maxlen)
#if @GNULIB_STRPBRK@ #if @GNULIB_STRPBRK@
# if ! @HAVE_STRPBRK@ # if ! @HAVE_STRPBRK@
extern char *strpbrk (char const *__s, char const *__accept) extern char *strpbrk (char const *__s, char const *__accept)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif # endif
# if defined GNULIB_POSIXCHECK # if defined GNULIB_POSIXCHECK
/* strpbrk() assumes the second argument is a list of single-byte characters. /* strpbrk() assumes the second argument is a list of single-byte characters.
@ -313,7 +318,8 @@ extern char *strpbrk (char const *__s, char const *__accept)
See also strtok_r(). */ See also strtok_r(). */
#if @GNULIB_STRSEP@ #if @GNULIB_STRSEP@
# if ! @HAVE_STRSEP@ # if ! @HAVE_STRSEP@
extern char *strsep (char **restrict __stringp, char const *restrict __delim); extern char *strsep (char **restrict __stringp, char const *restrict __delim)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
# if defined GNULIB_POSIXCHECK # if defined GNULIB_POSIXCHECK
# undef strsep # undef strsep
@ -334,8 +340,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
#if @GNULIB_STRSTR@ #if @GNULIB_STRSTR@
# if @REPLACE_STRSTR@ # if @REPLACE_STRSTR@
# define strstr rpl_strstr # define strstr rpl_strstr
char *strstr (const char *haystack, const char *needle) extern char *strstr (const char *haystack, const char *needle)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
/* strstr() does not work with multibyte strings if the locale encoding is /* strstr() does not work with multibyte strings if the locale encoding is
@ -360,7 +366,7 @@ char *strstr (const char *haystack, const char *needle)
# endif # endif
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@ # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
extern char *strcasestr (const char *haystack, const char *needle) extern char *strcasestr (const char *haystack, const char *needle)
__attribute__ ((__pure__)); __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
/* strcasestr() does not work with multibyte strings: /* strcasestr() does not work with multibyte strings:
@ -379,12 +385,12 @@ extern char *strcasestr (const char *haystack, const char *needle)
/* Parse S into tokens separated by characters in DELIM. /* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example: the next starting point. For example:
char s[] = "-abc-=-def"; char s[] = "-abc-=-def";
char *sp; char *sp;
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
x = strtok_r(NULL, "=", &sp); // x = NULL x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0" // s = "abc\0-def\0"
This is a variant of strtok() that is multithread-safe. This is a variant of strtok() that is multithread-safe.
@ -407,7 +413,8 @@ extern char *strcasestr (const char *haystack, const char *needle)
# endif # endif
# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@ # if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
extern char *strtok_r (char *restrict s, char const *restrict delim, extern char *strtok_r (char *restrict s, char const *restrict delim,
char **restrict save_ptr); char **restrict save_ptr)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
# if defined GNULIB_POSIXCHECK # if defined GNULIB_POSIXCHECK
# undef strtok_r # undef strtok_r
@ -432,13 +439,13 @@ extern char *strtok_r (char *restrict s, char const *restrict delim,
#if @GNULIB_MBSLEN@ #if @GNULIB_MBSLEN@
/* Return the number of multibyte characters in the character string STRING. /* Return the number of multibyte characters in the character string STRING.
This considers multibyte characters, unlike strlen, which counts bytes. */ This considers multibyte characters, unlike strlen, which counts bytes. */
extern size_t mbslen (const char *string); extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
#endif #endif
#if @GNULIB_MBSNLEN@ #if @GNULIB_MBSNLEN@
/* Return the number of multibyte characters in the character string starting /* Return the number of multibyte characters in the character string starting
at STRING and ending at STRING + LEN. */ at STRING and ending at STRING + LEN. */
extern size_t mbsnlen (const char *string, size_t len); extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
#endif #endif
#if @GNULIB_MBSCHR@ #if @GNULIB_MBSCHR@
@ -447,7 +454,7 @@ extern size_t mbsnlen (const char *string, size_t len);
Unlike strchr(), this function works correctly in multibyte locales with Unlike strchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */ encodings such as GB18030. */
# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
extern char * mbschr (const char *string, int c); extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
#endif #endif
#if @GNULIB_MBSRCHR@ #if @GNULIB_MBSRCHR@
@ -456,7 +463,7 @@ extern char * mbschr (const char *string, int c);
Unlike strrchr(), this function works correctly in multibyte locales with Unlike strrchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */ encodings such as GB18030. */
# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
extern char * mbsrchr (const char *string, int c); extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
#endif #endif
#if @GNULIB_MBSSTR@ #if @GNULIB_MBSSTR@
@ -464,7 +471,8 @@ extern char * mbsrchr (const char *string, int c);
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
Unlike strstr(), this function works correctly in multibyte locales with Unlike strstr(), this function works correctly in multibyte locales with
encodings different from UTF-8. */ encodings different from UTF-8. */
extern char * mbsstr (const char *haystack, const char *needle); extern char * mbsstr (const char *haystack, const char *needle)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSCASECMP@ #if @GNULIB_MBSCASECMP@
@ -474,7 +482,8 @@ extern char * mbsstr (const char *haystack, const char *needle);
Note: This function may, in multibyte locales, return 0 for strings of Note: This function may, in multibyte locales, return 0 for strings of
different lengths! different lengths!
Unlike strcasecmp(), this function works correctly in multibyte locales. */ Unlike strcasecmp(), this function works correctly in multibyte locales. */
extern int mbscasecmp (const char *s1, const char *s2); extern int mbscasecmp (const char *s1, const char *s2)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSNCASECMP@ #if @GNULIB_MBSNCASECMP@
@ -487,7 +496,8 @@ extern int mbscasecmp (const char *s1, const char *s2);
of different lengths! of different lengths!
Unlike strncasecmp(), this function works correctly in multibyte locales. Unlike strncasecmp(), this function works correctly in multibyte locales.
But beware that N is not a byte count but a character count! */ But beware that N is not a byte count but a character count! */
extern int mbsncasecmp (const char *s1, const char *s2, size_t n); extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSPCASECMP@ #if @GNULIB_MBSPCASECMP@
@ -500,7 +510,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
smaller length than PREFIX! smaller length than PREFIX!
Unlike strncasecmp(), this function works correctly in multibyte Unlike strncasecmp(), this function works correctly in multibyte
locales. */ locales. */
extern char * mbspcasecmp (const char *string, const char *prefix); extern char * mbspcasecmp (const char *string, const char *prefix)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSCASESTR@ #if @GNULIB_MBSCASESTR@
@ -509,7 +520,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix);
Note: This function may, in multibyte locales, return success even if Note: This function may, in multibyte locales, return success even if
strlen (haystack) < strlen (needle) ! strlen (haystack) < strlen (needle) !
Unlike strcasestr(), this function works correctly in multibyte locales. */ Unlike strcasestr(), this function works correctly in multibyte locales. */
extern char * mbscasestr (const char *haystack, const char *needle); extern char * mbscasestr (const char *haystack, const char *needle)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSCSPN@ #if @GNULIB_MBSCSPN@
@ -518,7 +530,8 @@ extern char * mbscasestr (const char *haystack, const char *needle);
beginning of the string to this occurrence, or to the end of the string beginning of the string to this occurrence, or to the end of the string
if none exists. if none exists.
Unlike strcspn(), this function works correctly in multibyte locales. */ Unlike strcspn(), this function works correctly in multibyte locales. */
extern size_t mbscspn (const char *string, const char *accept); extern size_t mbscspn (const char *string, const char *accept)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSPBRK@ #if @GNULIB_MBSPBRK@
@ -527,7 +540,8 @@ extern size_t mbscspn (const char *string, const char *accept);
exists. exists.
Unlike strpbrk(), this function works correctly in multibyte locales. */ Unlike strpbrk(), this function works correctly in multibyte locales. */
# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
extern char * mbspbrk (const char *string, const char *accept); extern char * mbspbrk (const char *string, const char *accept)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSSPN@ #if @GNULIB_MBSSPN@
@ -536,7 +550,8 @@ extern char * mbspbrk (const char *string, const char *accept);
beginning of the string to this occurrence, or to the end of the string beginning of the string to this occurrence, or to the end of the string
if none exists. if none exists.
Unlike strspn(), this function works correctly in multibyte locales. */ Unlike strspn(), this function works correctly in multibyte locales. */
extern size_t mbsspn (const char *string, const char *reject); extern size_t mbsspn (const char *string, const char *reject)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSSEP@ #if @GNULIB_MBSSEP@
@ -554,7 +569,8 @@ extern size_t mbsspn (const char *string, const char *reject);
Caveat: The identity of the delimiting character is lost. Caveat: The identity of the delimiting character is lost.
See also mbstok_r(). */ See also mbstok_r(). */
extern char * mbssep (char **stringp, const char *delim); extern char * mbssep (char **stringp, const char *delim)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if @GNULIB_MBSTOK_R@ #if @GNULIB_MBSTOK_R@
@ -562,19 +578,20 @@ extern char * mbssep (char **stringp, const char *delim);
the character string DELIM. the character string DELIM.
If STRING is NULL, the saved pointer in SAVE_PTR is used as If STRING is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example: the next starting point. For example:
char s[] = "-abc-=-def"; char s[] = "-abc-=-def";
char *sp; char *sp;
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
x = mbstok_r(NULL, "=", &sp); // x = NULL x = mbstok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0" // s = "abc\0-def\0"
Caveat: It modifies the original string. Caveat: It modifies the original string.
Caveat: These functions cannot be used on constant strings. Caveat: These functions cannot be used on constant strings.
Caveat: The identity of the delimiting character is lost. Caveat: The identity of the delimiting character is lost.
See also mbssep(). */ See also mbssep(). */
extern char * mbstok_r (char *string, const char *delim, char **save_ptr); extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
_GL_ARG_NONNULL ((2, 3));
#endif #endif
/* Map any int, typically from errno, into an error message. */ /* Map any int, typically from errno, into an error message. */
@ -609,7 +626,7 @@ extern char *strsignal (int __sig);
#if @GNULIB_STRVERSCMP@ #if @GNULIB_STRVERSCMP@
# if !@HAVE_STRVERSCMP@ # if !@HAVE_STRVERSCMP@
extern int strverscmp (const char *, const char *); extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef strverscmp # undef strverscmp

View file

@ -1,6 +1,6 @@
/* A substitute <strings.h>. /* A substitute <strings.h>.
Copyright (C) 2007-2008 Free Software Foundation, Inc. Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
@ -31,6 +31,8 @@
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -42,7 +44,8 @@ extern "C" {
than S2. than S2.
Note: This function does not work in multibyte locales. */ Note: This function does not work in multibyte locales. */
#if ! @HAVE_STRCASECMP@ #if ! @HAVE_STRCASECMP@
extern int strcasecmp (char const *s1, char const *s2); extern int strcasecmp (char const *s1, char const *s2)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if defined GNULIB_POSIXCHECK #if defined GNULIB_POSIXCHECK
/* strcasecmp() does not work with multibyte strings: /* strcasecmp() does not work with multibyte strings:
@ -64,7 +67,8 @@ extern int strcasecmp (char const *s1, char const *s2);
lexicographically less than, equal to or greater than S2. lexicographically less than, equal to or greater than S2.
Note: This function cannot work correctly in multibyte locales. */ Note: This function cannot work correctly in multibyte locales. */
#if ! @HAVE_DECL_STRNCASECMP@ #if ! @HAVE_DECL_STRNCASECMP@
extern int strncasecmp (char const *s1, char const *s2, size_t n); extern int strncasecmp (char const *s1, char const *s2, size_t n)
_GL_ARG_NONNULL ((1, 2));
#endif #endif
#if defined GNULIB_POSIXCHECK #if defined GNULIB_POSIXCHECK
/* strncasecmp() does not work with multibyte strings: /* strncasecmp() does not work with multibyte strings:

View file

@ -46,7 +46,7 @@ strncasecmp (const char *s1, const char *s2, size_t n)
c2 = TOLOWER (*p2); c2 = TOLOWER (*p2);
if (--n == 0 || c1 == '\0') if (--n == 0 || c1 == '\0')
break; break;
++p1; ++p1;
++p2; ++p2;

View file

@ -49,7 +49,7 @@ extern int flock (int fd, int operation);
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef flock # undef flock
# define flock(fd,op) \ # define flock(fd,op) \
(GL_LINK_WARNING ("flock is unportable - " \ (GL_LINK_WARNING ("flock is unportable - " \
"use gnulib module flock for portability"), \ "use gnulib module flock for portability"), \
flock ((fd), (op))) flock ((fd), (op)))

View file

@ -43,6 +43,8 @@
#ifndef _GL_SYS_SOCKET_H #ifndef _GL_SYS_SOCKET_H
#define _GL_SYS_SOCKET_H #define _GL_SYS_SOCKET_H
/* The definition of _GL_ARG_NONNULL is copied here. */
#if !@HAVE_SA_FAMILY_T@ #if !@HAVE_SA_FAMILY_T@
typedef unsigned short sa_family_t; typedef unsigned short sa_family_t;
#endif #endif
@ -54,10 +56,10 @@ typedef unsigned short sa_family_t;
# define __ss_aligntype unsigned long int # define __ss_aligntype unsigned long int
# define _SS_SIZE 256 # define _SS_SIZE 256
# define _SS_PADSIZE \ # define _SS_PADSIZE \
(_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
? sizeof (sa_family_t) \ ? sizeof (sa_family_t) \
: alignof (__ss_aligntype)) \ : alignof (__ss_aligntype)) \
+ sizeof (__ss_aligntype))) + sizeof (__ss_aligntype)))
struct sockaddr_storage struct sockaddr_storage
{ {
@ -177,7 +179,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
# if @GNULIB_SOCKET@ # if @GNULIB_SOCKET@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef socket # undef socket
# define socket rpl_socket # define socket rpl_socket
extern int rpl_socket (int, int, int protocol); extern int rpl_socket (int, int, int protocol);
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
@ -194,8 +196,8 @@ extern int rpl_socket (int, int, int protocol);
# if @GNULIB_CONNECT@ # if @GNULIB_CONNECT@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef connect # undef connect
# define connect rpl_connect # define connect rpl_connect
extern int rpl_connect (int, struct sockaddr *, int); extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef connect # undef connect
@ -211,7 +213,7 @@ extern int rpl_connect (int, struct sockaddr *, int);
# if @GNULIB_ACCEPT@ # if @GNULIB_ACCEPT@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef accept # undef accept
# define accept rpl_accept # define accept rpl_accept
extern int rpl_accept (int, struct sockaddr *, int *); extern int rpl_accept (int, struct sockaddr *, int *);
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
@ -228,8 +230,8 @@ extern int rpl_accept (int, struct sockaddr *, int *);
# if @GNULIB_BIND@ # if @GNULIB_BIND@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef bind # undef bind
# define bind rpl_bind # define bind rpl_bind
extern int rpl_bind (int, struct sockaddr *, int); extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef bind # undef bind
@ -245,8 +247,9 @@ extern int rpl_bind (int, struct sockaddr *, int);
# if @GNULIB_GETPEERNAME@ # if @GNULIB_GETPEERNAME@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef getpeername # undef getpeername
# define getpeername rpl_getpeername # define getpeername rpl_getpeername
extern int rpl_getpeername (int, struct sockaddr *, int *); extern int rpl_getpeername (int, struct sockaddr *, int *)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef getpeername # undef getpeername
@ -262,8 +265,9 @@ extern int rpl_getpeername (int, struct sockaddr *, int *);
# if @GNULIB_GETSOCKNAME@ # if @GNULIB_GETSOCKNAME@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef getsockname # undef getsockname
# define getsockname rpl_getsockname # define getsockname rpl_getsockname
extern int rpl_getsockname (int, struct sockaddr *, int *); extern int rpl_getsockname (int, struct sockaddr *, int *)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef getsockname # undef getsockname
@ -279,8 +283,9 @@ extern int rpl_getsockname (int, struct sockaddr *, int *);
# if @GNULIB_GETSOCKOPT@ # if @GNULIB_GETSOCKOPT@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef getsockopt # undef getsockopt
# define getsockopt rpl_getsockopt # define getsockopt rpl_getsockopt
extern int rpl_getsockopt (int, int, int, void *, socklen_t *); extern int rpl_getsockopt (int, int, int, void *, socklen_t *)
_GL_ARG_NONNULL ((4, 5));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef getsockopt # undef getsockopt
@ -296,7 +301,7 @@ extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
# if @GNULIB_LISTEN@ # if @GNULIB_LISTEN@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef listen # undef listen
# define listen rpl_listen # define listen rpl_listen
extern int rpl_listen (int, int); extern int rpl_listen (int, int);
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
@ -313,8 +318,8 @@ extern int rpl_listen (int, int);
# if @GNULIB_RECV@ # if @GNULIB_RECV@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef recv # undef recv
# define recv rpl_recv # define recv rpl_recv
extern int rpl_recv (int, void *, int, int); extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef recv # undef recv
@ -330,8 +335,8 @@ extern int rpl_recv (int, void *, int, int);
# if @GNULIB_SEND@ # if @GNULIB_SEND@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef send # undef send
# define send rpl_send # define send rpl_send
extern int rpl_send (int, const void *, int, int); extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef send # undef send
@ -347,8 +352,9 @@ extern int rpl_send (int, const void *, int, int);
# if @GNULIB_RECVFROM@ # if @GNULIB_RECVFROM@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef recvfrom # undef recvfrom
# define recvfrom rpl_recvfrom # define recvfrom rpl_recvfrom
extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *); extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *)
_GL_ARG_NONNULL ((2));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef recvfrom # undef recvfrom
@ -364,8 +370,9 @@ extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
# if @GNULIB_SENDTO@ # if @GNULIB_SENDTO@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef sendto # undef sendto
# define sendto rpl_sendto # define sendto rpl_sendto
extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int); extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int)
_GL_ARG_NONNULL ((2));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef sendto # undef sendto
@ -381,8 +388,9 @@ extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
# if @GNULIB_SETSOCKOPT@ # if @GNULIB_SETSOCKOPT@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef setsockopt # undef setsockopt
# define setsockopt rpl_setsockopt # define setsockopt rpl_setsockopt
extern int rpl_setsockopt (int, int, int, const void *, socklen_t); extern int rpl_setsockopt (int, int, int, const void *, socklen_t)
_GL_ARG_NONNULL ((4));
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
# undef setsockopt # undef setsockopt
@ -398,7 +406,7 @@ extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
# if @GNULIB_SHUTDOWN@ # if @GNULIB_SHUTDOWN@
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef shutdown # undef shutdown
# define shutdown rpl_shutdown # define shutdown rpl_shutdown
extern int rpl_shutdown (int, int); extern int rpl_shutdown (int, int);
# endif # endif
# elif @HAVE_WINSOCK2_H@ # elif @HAVE_WINSOCK2_H@
@ -414,7 +422,7 @@ extern int rpl_shutdown (int, int);
# if @HAVE_WINSOCK2_H@ # if @HAVE_WINSOCK2_H@
# undef select # undef select
# define select select_used_without_including_sys_select_h # define select select_used_without_including_sys_select_h
# endif # endif
# ifdef __cplusplus # ifdef __cplusplus
@ -437,7 +445,7 @@ extern "C" {
# define accept4 rpl_accept4 # define accept4 rpl_accept4
# endif # endif
extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
int flags); int flags);
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef accept4 # undef accept4
# define accept4(s,a,l,f) \ # define accept4(s,a,l,f) \

View file

@ -49,6 +49,8 @@
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). */ headers that may declare mkdir(). */
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
@ -295,7 +297,8 @@ extern "C" {
#if @GNULIB_FCHMODAT@ #if @GNULIB_FCHMODAT@
# if !@HAVE_FCHMODAT@ # if !@HAVE_FCHMODAT@
extern int fchmodat (int fd, char const *file, mode_t mode, int flag); extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fchmodat # undef fchmodat
@ -308,7 +311,7 @@ extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
#if @REPLACE_FSTAT@ #if @REPLACE_FSTAT@
# define fstat rpl_fstat # define fstat rpl_fstat
extern int fstat (int fd, struct stat *buf); extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
#endif #endif
@ -318,7 +321,8 @@ extern int fstat (int fd, struct stat *buf);
# define fstatat rpl_fstatat # define fstatat rpl_fstatat
# endif # endif
# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@ # if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
extern int fstatat (int fd, char const *name, struct stat *st, int flags); extern int fstatat (int fd, char const *name, struct stat *st, int flags)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fstatat # undef fstatat
@ -360,7 +364,7 @@ extern int futimens (int fd, struct timespec const times[2]);
# define lchmod chmod # define lchmod chmod
# endif # endif
# if 0 /* assume already declared */ # if 0 /* assume already declared */
extern int lchmod (const char *filename, mode_t mode); extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef lchmod # undef lchmod
@ -379,13 +383,14 @@ extern int lchmod (const char *filename, mode_t mode);
# elif @REPLACE_LSTAT@ # elif @REPLACE_LSTAT@
# undef lstat # undef lstat
# define lstat rpl_lstat # define lstat rpl_lstat
extern int rpl_lstat (const char *name, struct stat *buf); extern int rpl_lstat (const char *name, struct stat *buf)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef lstat # undef lstat
# define lstat(p,b) \ # define lstat(p,b) \
(GL_LINK_WARNING ("lstat is unportable - " \ (GL_LINK_WARNING ("lstat is unportable - " \
"use gnulib module lstat for portability"), \ "use gnulib module lstat for portability"), \
lstat (p, b)) lstat (p, b))
#endif #endif
@ -393,7 +398,7 @@ extern int rpl_lstat (const char *name, struct stat *buf);
#if @REPLACE_MKDIR@ #if @REPLACE_MKDIR@
# undef mkdir # undef mkdir
# define mkdir rpl_mkdir # define mkdir rpl_mkdir
extern int mkdir (char const *name, mode_t mode); extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
#else #else
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Additionally, it declares _mkdir (and depending on compile flags, an Additionally, it declares _mkdir (and depending on compile flags, an
@ -413,7 +418,8 @@ rpl_mkdir (char const *name, mode_t mode)
#if @GNULIB_MKDIRAT@ #if @GNULIB_MKDIRAT@
# if !@HAVE_MKDIRAT@ # if !@HAVE_MKDIRAT@
extern int mkdirat (int fd, char const *file, mode_t mode); extern int mkdirat (int fd, char const *file, mode_t mode)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkdirat # undef mkdirat
@ -430,7 +436,7 @@ extern int mkdirat (int fd, char const *file, mode_t mode);
# define mkfifo rpl_mkfifo # define mkfifo rpl_mkfifo
# endif # endif
# if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@ # if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
int mkfifo (char const *file, mode_t mode); extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkfifo # undef mkfifo
@ -443,11 +449,12 @@ int mkfifo (char const *file, mode_t mode);
#if @GNULIB_MKFIFOAT@ #if @GNULIB_MKFIFOAT@
# if !@HAVE_MKFIFOAT@ # if !@HAVE_MKFIFOAT@
int mkfifoat (int fd, char const *file, mode_t mode); extern int mkfifoat (int fd, char const *file, mode_t mode)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mkfifoat # undef mkfifoat
# define mkfifoat(d,n,m) \ # define mkfifoat(d,n,m) \
(GL_LINK_WARNING ("mkfifoat is not portable - " \ (GL_LINK_WARNING ("mkfifoat is not portable - " \
"use gnulib module mkfifoat for portability"), \ "use gnulib module mkfifoat for portability"), \
mkfifoat (d, n, m)) mkfifoat (d, n, m))
@ -460,7 +467,8 @@ int mkfifoat (int fd, char const *file, mode_t mode);
# define mknod rpl_mknod # define mknod rpl_mknod
# endif # endif
# if !@HAVE_MKNOD@ || @REPLACE_MKNOD@ # if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
int mknod (char const *file, mode_t mode, dev_t dev); extern int mknod (char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mknod # undef mknod
@ -473,11 +481,12 @@ int mknod (char const *file, mode_t mode, dev_t dev);
#if @GNULIB_MKNODAT@ #if @GNULIB_MKNODAT@
# if !@HAVE_MKNODAT@ # if !@HAVE_MKNODAT@
int mknodat (int fd, char const *file, mode_t mode, dev_t dev); extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mknodat # undef mknodat
# define mknodat(f,n,m,d) \ # define mknodat(f,n,m,d) \
(GL_LINK_WARNING ("mknodat is not portable - " \ (GL_LINK_WARNING ("mknodat is not portable - " \
"use gnulib module mkfifoat for portability"), \ "use gnulib module mkfifoat for portability"), \
mknodat (f, n, m, d)) mknodat (f, n, m, d))
@ -499,13 +508,13 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
# else /* !_LARGE_FILES */ # else /* !_LARGE_FILES */
# define stat(name, st) rpl_stat (name, st) # define stat(name, st) rpl_stat (name, st)
# endif /* !_LARGE_FILES */ # endif /* !_LARGE_FILES */
extern int stat (const char *name, struct stat *buf); extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef stat # undef stat
# define stat(p,b) \ # define stat(p,b) \
(GL_LINK_WARNING ("stat is unportable - " \ (GL_LINK_WARNING ("stat is unportable - " \
"use gnulib module stat for portability"), \ "use gnulib module stat for portability"), \
stat (p, b)) stat (p, b))
#endif #endif
@ -517,7 +526,8 @@ extern int stat (const char *name, struct stat *buf);
# endif # endif
# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@ # if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
extern int utimensat (int fd, char const *name, extern int utimensat (int fd, char const *name,
struct timespec const times[2], int flag); struct timespec const times[2], int flag)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef utimensat # undef utimensat

View file

@ -40,6 +40,8 @@
/* NetBSD 5.0 mis-defines NULL. */ /* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h> #include <stddef.h>
/* The definition of _GL_ARG_NONNULL is copied here. */
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
# endif # endif
@ -66,13 +68,14 @@ struct timespec
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */ <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
# if @REPLACE_NANOSLEEP@ # if @REPLACE_NANOSLEEP@
# define nanosleep rpl_nanosleep # define nanosleep rpl_nanosleep
int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp); extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
_GL_ARG_NONNULL ((1));
# endif # endif
/* Return the 'time_t' representation of TP and normalize TP. */ /* Return the 'time_t' representation of TP and normalize TP. */
# if @REPLACE_MKTIME@ # if @REPLACE_MKTIME@
# define mktime rpl_mktime # define mktime rpl_mktime
extern time_t mktime (struct tm *__tp); extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
# endif # endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
@ -83,10 +86,12 @@ extern time_t mktime (struct tm *__tp);
# define localtime_r rpl_localtime_r # define localtime_r rpl_localtime_r
# undef gmtime_r # undef gmtime_r
# define gmtime_r rpl_gmtime_r # define gmtime_r rpl_gmtime_r
struct tm *localtime_r (time_t const *restrict __timer, extern struct tm *localtime_r (time_t const *restrict __timer,
struct tm *restrict __result); struct tm *restrict __result)
struct tm *gmtime_r (time_t const *restrict __timer, _GL_ARG_NONNULL ((1, 2));
struct tm *restrict __result); extern struct tm *gmtime_r (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
@ -95,15 +100,17 @@ struct tm *gmtime_r (time_t const *restrict __timer,
# if @REPLACE_STRPTIME@ # if @REPLACE_STRPTIME@
# undef strptime # undef strptime
# define strptime rpl_strptime # define strptime rpl_strptime
char *strptime (char const *restrict __buf, char const *restrict __format, extern char *strptime (char const *restrict __buf,
struct tm *restrict __tm); char const *restrict __format,
struct tm *restrict __tm)
_GL_ARG_NONNULL ((1, 2, 3));
# endif # endif
/* Convert TM to a time_t value, assuming UTC. */ /* Convert TM to a time_t value, assuming UTC. */
# if @REPLACE_TIMEGM@ # if @REPLACE_TIMEGM@
# undef timegm # undef timegm
# define timegm rpl_timegm # define timegm rpl_timegm
time_t timegm (struct tm *__tm); extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
# endif # endif
/* Encourage applications to avoid unsafe functions that can overrun /* Encourage applications to avoid unsafe functions that can overrun

View file

@ -59,43 +59,45 @@
# include <winsock2.h> # include <winsock2.h>
# if !defined _GL_SYS_SOCKET_H # if !defined _GL_SYS_SOCKET_H
# undef socket # undef socket
# define socket socket_used_without_including_sys_socket_h # define socket socket_used_without_including_sys_socket_h
# undef connect # undef connect
# define connect connect_used_without_including_sys_socket_h # define connect connect_used_without_including_sys_socket_h
# undef accept # undef accept
# define accept accept_used_without_including_sys_socket_h # define accept accept_used_without_including_sys_socket_h
# undef bind # undef bind
# define bind bind_used_without_including_sys_socket_h # define bind bind_used_without_including_sys_socket_h
# undef getpeername # undef getpeername
# define getpeername getpeername_used_without_including_sys_socket_h # define getpeername getpeername_used_without_including_sys_socket_h
# undef getsockname # undef getsockname
# define getsockname getsockname_used_without_including_sys_socket_h # define getsockname getsockname_used_without_including_sys_socket_h
# undef getsockopt # undef getsockopt
# define getsockopt getsockopt_used_without_including_sys_socket_h # define getsockopt getsockopt_used_without_including_sys_socket_h
# undef listen # undef listen
# define listen listen_used_without_including_sys_socket_h # define listen listen_used_without_including_sys_socket_h
# undef recv # undef recv
# define recv recv_used_without_including_sys_socket_h # define recv recv_used_without_including_sys_socket_h
# undef send # undef send
# define send send_used_without_including_sys_socket_h # define send send_used_without_including_sys_socket_h
# undef recvfrom # undef recvfrom
# define recvfrom recvfrom_used_without_including_sys_socket_h # define recvfrom recvfrom_used_without_including_sys_socket_h
# undef sendto # undef sendto
# define sendto sendto_used_without_including_sys_socket_h # define sendto sendto_used_without_including_sys_socket_h
# undef setsockopt # undef setsockopt
# define setsockopt setsockopt_used_without_including_sys_socket_h # define setsockopt setsockopt_used_without_including_sys_socket_h
# undef shutdown # undef shutdown
# define shutdown shutdown_used_without_including_sys_socket_h # define shutdown shutdown_used_without_including_sys_socket_h
# endif # endif
# if !defined _GL_SYS_SELECT_H # if !defined _GL_SYS_SELECT_H
# undef select # undef select
# define select select_used_without_including_sys_select_h # define select select_used_without_including_sys_select_h
# endif # endif
# endif # endif
#endif #endif
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* OS/2 EMX lacks these macros. */ /* OS/2 EMX lacks these macros. */
#ifndef STDIN_FILENO #ifndef STDIN_FILENO
@ -135,7 +137,8 @@ extern "C" {
Return 0 if successful, otherwise -1 and errno set. Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/chown.html>. */ <http://www.opengroup.org/susv3xsh/chown.html>. */
extern int chown (const char *file, uid_t uid, gid_t gid); extern int chown (const char *file, uid_t uid, gid_t gid)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef chown # undef chown
@ -239,7 +242,7 @@ extern char **environ;
# if !@HAVE_EUIDACCESS@ # if !@HAVE_EUIDACCESS@
/* Like access(), except that it uses the effective user id and group id of /* Like access(), except that it uses the effective user id and group id of
the current process. */ the current process. */
extern int euidaccess (const char *filename, int mode); extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef euidaccess # undef euidaccess
@ -252,11 +255,12 @@ extern int euidaccess (const char *filename, int mode);
#if @GNULIB_FACCESSAT@ #if @GNULIB_FACCESSAT@
# if !@HAVE_FACCESSAT@ # if !@HAVE_FACCESSAT@
int faccessat (int fd, char const *file, int mode, int flag); extern int faccessat (int fd, char const *file, int mode, int flag)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef faccessat # undef faccessat
# define faccessat(d,n,m,f) \ # define faccessat(d,n,m,f) \
(GL_LINK_WARNING ("faccessat is not portable - " \ (GL_LINK_WARNING ("faccessat is not portable - " \
"use gnulib module faccessat for portability"), \ "use gnulib module faccessat for portability"), \
faccessat (d, n, m, f)) faccessat (d, n, m, f))
@ -273,7 +277,8 @@ int faccessat (int fd, char const *file, int mode, int flag);
extern int fchdir (int /*fd*/); extern int fchdir (int /*fd*/);
/* Gnulib internal hooks needed to maintain the fchdir metadata. */ /* Gnulib internal hooks needed to maintain the fchdir metadata. */
extern int _gl_register_fd (int fd, const char *filename); extern int _gl_register_fd (int fd, const char *filename)
_GL_ARG_NONNULL ((2));
extern void _gl_unregister_fd (int fd); extern void _gl_unregister_fd (int fd);
extern int _gl_register_dup (int oldfd, int newfd); extern int _gl_register_dup (int oldfd, int newfd);
extern const char *_gl_directory_name (int fd); extern const char *_gl_directory_name (int fd);
@ -294,11 +299,12 @@ extern const char *_gl_directory_name (int fd);
# define fchownat rpl_fchownat # define fchownat rpl_fchownat
# endif # endif
# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@ # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef fchownat # undef fchownat
# define fchownat(d,n,o,g,f) \ # define fchownat(d,n,o,g,f) \
(GL_LINK_WARNING ("fchownat is not portable - " \ (GL_LINK_WARNING ("fchownat is not portable - " \
"use gnulib module openat for portability"), \ "use gnulib module openat for portability"), \
fchownat (d, n, o, g, f)) fchownat (d, n, o, g, f))
@ -378,7 +384,7 @@ extern char * getcwd (char *buf, size_t size);
If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
Return 0 if successful, otherwise set errno and return -1. */ Return 0 if successful, otherwise set errno and return -1. */
# if !@HAVE_GETDOMAINNAME@ # if !@HAVE_GETDOMAINNAME@
extern int getdomainname(char *name, size_t len); extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef getdomainname # undef getdomainname
@ -439,7 +445,7 @@ int getgroups (int n, gid_t *groups);
# define gethostname rpl_gethostname # define gethostname rpl_gethostname
# endif # endif
# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@ # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
extern int gethostname(char *name, size_t len); extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
# endif # endif
#elif @UNISTD_H_HAVE_WINSOCK2_H@ #elif @UNISTD_H_HAVE_WINSOCK2_H@
# undef gethostname # undef gethostname
@ -464,7 +470,7 @@ extern int gethostname(char *name, size_t len);
See <http://www.opengroup.org/susv3xsh/getlogin.html>. See <http://www.opengroup.org/susv3xsh/getlogin.html>.
*/ */
# if !@HAVE_DECL_GETLOGIN_R@ # if !@HAVE_DECL_GETLOGIN_R@
extern int getlogin_r (char *name, size_t size); extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef getlogin_r # undef getlogin_r
@ -574,7 +580,8 @@ extern void endusershell (void);
Return 0 if successful, otherwise -1 and errno set. Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/lchown.html>. */ <http://www.opengroup.org/susv3xsh/lchown.html>. */
extern int lchown (char const *file, uid_t owner, gid_t group); extern int lchown (char const *file, uid_t owner, gid_t group)
_GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef lchown # undef lchown
@ -594,7 +601,8 @@ extern int lchown (char const *file, uid_t owner, gid_t group);
See POSIX:2001 specification See POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/link.html>. */ <http://www.opengroup.org/susv3xsh/link.html>. */
# if !@HAVE_LINK@ || @REPLACE_LINK@ # if !@HAVE_LINK@ || @REPLACE_LINK@
extern int link (const char *path1, const char *path2); extern int link (const char *path1, const char *path2)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef link # undef link
@ -614,11 +622,12 @@ extern int link (const char *path1, const char *path2);
Return 0 if successful, otherwise -1 and errno set. */ Return 0 if successful, otherwise -1 and errno set. */
# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@ # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
extern int linkat (int fd1, const char *path1, int fd2, const char *path2, extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
int flag); int flag)
_GL_ARG_NONNULL ((2, 4));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef linkat # undef linkat
# define link(f1,path1,f2,path2,f) \ # define link(f1,path1,f2,path2,f) \
(GL_LINK_WARNING ("linkat is unportable - " \ (GL_LINK_WARNING ("linkat is unportable - " \
"use gnulib module linkat for portability"), \ "use gnulib module linkat for portability"), \
linkat (f1, path1, f2, path2,f)) linkat (f1, path1, f2, path2,f))
@ -654,7 +663,7 @@ extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
# if @HAVE_PIPE2@ # if @HAVE_PIPE2@
# define pipe2 rpl_pipe2 # define pipe2 rpl_pipe2
# endif # endif
extern int pipe2 (int fd[2], int flags); extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef pipe2 # undef pipe2
# define pipe2(f,o) \ # define pipe2(f,o) \
@ -664,6 +673,27 @@ extern int pipe2 (int fd[2], int flags);
#endif #endif
#if @GNULIB_PREAD@
# if @REPLACE_PREAD@
# define pread rpl_pread
# endif
/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
Return the number of bytes placed into BUF if successful, otherwise
set errno and return -1. 0 indicates EOF. See the POSIX:2001
specification <http://www.opengroup.org/susv3xsh/pread.html>. */
# if !@HAVE_PREAD@ || @REPLACE_PREAD@
extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
_GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef pread
# define pread(f,b,s,o) \
(GL_LINK_WARNING ("pread is unportable - " \
"use gnulib module pread for portability"), \
pread (f, b, s, o))
#endif
#if @GNULIB_READLINK@ #if @GNULIB_READLINK@
# if @REPLACE_READLINK@ # if @REPLACE_READLINK@
# define readlink rpl_readlink # define readlink rpl_readlink
@ -674,7 +704,8 @@ extern int pipe2 (int fd[2], int flags);
See the POSIX:2001 specification See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/readlink.html>. */ <http://www.opengroup.org/susv3xsh/readlink.html>. */
# if !@HAVE_READLINK@ || @REPLACE_READLINK@ # if !@HAVE_READLINK@ || @REPLACE_READLINK@
extern ssize_t readlink (const char *file, char *buf, size_t bufsize); extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef readlink # undef readlink
@ -687,11 +718,12 @@ extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
#if @GNULIB_READLINKAT@ #if @GNULIB_READLINKAT@
# if !@HAVE_READLINKAT@ # if !@HAVE_READLINKAT@
ssize_t readlinkat (int fd, char const *file, char *buf, size_t len); extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
_GL_ARG_NONNULL ((2, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef readlinkat # undef readlinkat
# define readlinkat(d,n,b,l) \ # define readlinkat(d,n,b,l) \
(GL_LINK_WARNING ("readlinkat is not portable - " \ (GL_LINK_WARNING ("readlinkat is not portable - " \
"use gnulib module symlinkat for portability"), \ "use gnulib module symlinkat for portability"), \
readlinkat (d, n, b, l)) readlinkat (d, n, b, l))
@ -702,7 +734,7 @@ ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
# if @REPLACE_RMDIR@ # if @REPLACE_RMDIR@
# define rmdir rpl_rmdir # define rmdir rpl_rmdir
/* Remove the directory DIR. */ /* Remove the directory DIR. */
extern int rmdir (char const *name); extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef rmdir # undef rmdir
@ -740,11 +772,12 @@ extern unsigned int sleep (unsigned int n);
# define symlink rpl_symlink # define symlink rpl_symlink
# endif # endif
# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@ # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
int symlink (char const *contents, char const *file); extern int symlink (char const *contents, char const *file)
_GL_ARG_NONNULL ((1, 2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef symlink # undef symlink
# define symlink(c,n) \ # define symlink(c,n) \
(GL_LINK_WARNING ("symlink is not portable - " \ (GL_LINK_WARNING ("symlink is not portable - " \
"use gnulib module symlink for portability"), \ "use gnulib module symlink for portability"), \
symlink (c, n)) symlink (c, n))
@ -753,11 +786,12 @@ int symlink (char const *contents, char const *file);
#if @GNULIB_SYMLINKAT@ #if @GNULIB_SYMLINKAT@
# if !@HAVE_SYMLINKAT@ # if !@HAVE_SYMLINKAT@
int symlinkat (char const *contents, int fd, char const *file); extern int symlinkat (char const *contents, int fd, char const *file)
_GL_ARG_NONNULL ((1, 3));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef symlinkat # undef symlinkat
# define symlinkat(c,d,n) \ # define symlinkat(c,d,n) \
(GL_LINK_WARNING ("symlinkat is not portable - " \ (GL_LINK_WARNING ("symlinkat is not portable - " \
"use gnulib module symlinkat for portability"), \ "use gnulib module symlinkat for portability"), \
symlinkat (c, d, n)) symlinkat (c, d, n))
@ -768,7 +802,7 @@ int symlinkat (char const *contents, int fd, char const *file);
# if @REPLACE_UNLINK@ # if @REPLACE_UNLINK@
# undef unlink # undef unlink
# define unlink rpl_unlink # define unlink rpl_unlink
extern int unlink (char const *file); extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef unlink # undef unlink
@ -785,7 +819,7 @@ extern int unlink (char const *file);
# define unlinkat rpl_unlinkat # define unlinkat rpl_unlinkat
# endif # endif
# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@ # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
extern int unlinkat (int fd, char const *file, int flag); extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef unlinkat # undef unlinkat
@ -823,7 +857,8 @@ extern int usleep (useconds_t n);
<http://www.opengroup.org/susv3xsh/write.html>. */ <http://www.opengroup.org/susv3xsh/write.html>. */
# undef write # undef write
# define write rpl_write # define write rpl_write
extern ssize_t write (int fd, const void *buf, size_t count); extern ssize_t write (int fd, const void *buf, size_t count)
_GL_ARG_NONNULL ((2));
#endif #endif

View file

@ -81,32 +81,32 @@ extern const uint32_t *
/* Convert an UTF-8 string to an UTF-16 string. */ /* Convert an UTF-8 string to an UTF-16 string. */
extern uint16_t * extern uint16_t *
u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf, u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf,
size_t *lengthp); size_t *lengthp);
/* Convert an UTF-8 string to an UCS-4 string. */ /* Convert an UTF-8 string to an UCS-4 string. */
extern uint32_t * extern uint32_t *
u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf, u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf,
size_t *lengthp); size_t *lengthp);
/* Convert an UTF-16 string to an UTF-8 string. */ /* Convert an UTF-16 string to an UTF-8 string. */
extern uint8_t * extern uint8_t *
u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf, u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf,
size_t *lengthp); size_t *lengthp);
/* Convert an UTF-16 string to an UCS-4 string. */ /* Convert an UTF-16 string to an UCS-4 string. */
extern uint32_t * extern uint32_t *
u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf, u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf,
size_t *lengthp); size_t *lengthp);
/* Convert an UCS-4 string to an UTF-8 string. */ /* Convert an UCS-4 string to an UTF-8 string. */
extern uint8_t * extern uint8_t *
u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf, u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf,
size_t *lengthp); size_t *lengthp);
/* Convert an UCS-4 string to an UTF-16 string. */ /* Convert an UCS-4 string to an UTF-16 string. */
extern uint16_t * extern uint16_t *
u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf, u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf,
size_t *lengthp); size_t *lengthp);
/* Elementary string functions. */ /* Elementary string functions. */
@ -351,12 +351,12 @@ u32_uctomb (uint32_t *s, ucs4_t uc, int n)
if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000)) if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
{ {
if (n > 0) if (n > 0)
{ {
*s = uc; *s = uc;
return 1; return 1;
} }
else else
return -2; return -2;
} }
else else
return -1; return -1;

View file

@ -30,124 +30,124 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
if (c >= 0xc2) if (c >= 0xc2)
{ {
if (c < 0xe0) if (c < 0xe0)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40) if ((s[1] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x1f) << 6) *puc = ((unsigned int) (c & 0x1f) << 6)
| (unsigned int) (s[1] ^ 0x80); | (unsigned int) (s[1] ^ 0x80);
return 2; return 2;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf0) else if (c < 0xf0)
{ {
if (n >= 3) if (n >= 3)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || s[1] >= 0xa0) && (c >= 0xe1 || s[1] >= 0xa0)
&& (c != 0xed || s[1] < 0xa0)) && (c != 0xed || s[1] < 0xa0))
{ {
*puc = ((unsigned int) (c & 0x0f) << 12) *puc = ((unsigned int) (c & 0x0f) << 12)
| ((unsigned int) (s[1] ^ 0x80) << 6) | ((unsigned int) (s[1] ^ 0x80) << 6)
| (unsigned int) (s[2] ^ 0x80); | (unsigned int) (s[2] ^ 0x80);
return 3; return 3;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf8) else if (c < 0xf8)
{ {
if (n >= 4) if (n >= 4)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40
&& (c >= 0xf1 || s[1] >= 0x90) && (c >= 0xf1 || s[1] >= 0x90)
#if 1 #if 1
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif #endif
) )
{ {
*puc = ((unsigned int) (c & 0x07) << 18) *puc = ((unsigned int) (c & 0x07) << 18)
| ((unsigned int) (s[1] ^ 0x80) << 12) | ((unsigned int) (s[1] ^ 0x80) << 12)
| ((unsigned int) (s[2] ^ 0x80) << 6) | ((unsigned int) (s[2] ^ 0x80) << 6)
| (unsigned int) (s[3] ^ 0x80); | (unsigned int) (s[3] ^ 0x80);
return 4; return 4;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#if 0 #if 0
else if (c < 0xfc) else if (c < 0xfc)
{ {
if (n >= 5) if (n >= 5)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (c >= 0xf9 || s[1] >= 0x88)) && (c >= 0xf9 || s[1] >= 0x88))
{ {
*puc = ((unsigned int) (c & 0x03) << 24) *puc = ((unsigned int) (c & 0x03) << 24)
| ((unsigned int) (s[1] ^ 0x80) << 18) | ((unsigned int) (s[1] ^ 0x80) << 18)
| ((unsigned int) (s[2] ^ 0x80) << 12) | ((unsigned int) (s[2] ^ 0x80) << 12)
| ((unsigned int) (s[3] ^ 0x80) << 6) | ((unsigned int) (s[3] ^ 0x80) << 6)
| (unsigned int) (s[4] ^ 0x80); | (unsigned int) (s[4] ^ 0x80);
return 5; return 5;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xfe) else if (c < 0xfe)
{ {
if (n >= 6) if (n >= 6)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (s[5] ^ 0x80) < 0x40 && (s[5] ^ 0x80) < 0x40
&& (c >= 0xfd || s[1] >= 0x84)) && (c >= 0xfd || s[1] >= 0x84))
{ {
*puc = ((unsigned int) (c & 0x01) << 30) *puc = ((unsigned int) (c & 0x01) << 30)
| ((unsigned int) (s[1] ^ 0x80) << 24) | ((unsigned int) (s[1] ^ 0x80) << 24)
| ((unsigned int) (s[2] ^ 0x80) << 18) | ((unsigned int) (s[2] ^ 0x80) << 18)
| ((unsigned int) (s[3] ^ 0x80) << 12) | ((unsigned int) (s[3] ^ 0x80) << 12)
| ((unsigned int) (s[4] ^ 0x80) << 6) | ((unsigned int) (s[4] ^ 0x80) << 6)
| (unsigned int) (s[5] ^ 0x80); | (unsigned int) (s[5] ^ 0x80);
return 6; return 6;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#endif #endif
} }
/* invalid multibyte character */ /* invalid multibyte character */

View file

@ -30,134 +30,134 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
if (c >= 0xc2) if (c >= 0xc2)
{ {
if (c < 0xe0) if (c < 0xe0)
{ {
if (n >= 2) if (n >= 2)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40) if ((s[1] ^ 0x80) < 0x40)
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x1f) << 6) *puc = ((unsigned int) (c & 0x1f) << 6)
| (unsigned int) (s[1] ^ 0x80); | (unsigned int) (s[1] ^ 0x80);
return 2; return 2;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf0) else if (c < 0xf0)
{ {
if (n >= 3) if (n >= 3)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || s[1] >= 0xa0) && (c >= 0xe1 || s[1] >= 0xa0)
&& (c != 0xed || s[1] < 0xa0)) && (c != 0xed || s[1] < 0xa0))
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x0f) << 12) *puc = ((unsigned int) (c & 0x0f) << 12)
| ((unsigned int) (s[1] ^ 0x80) << 6) | ((unsigned int) (s[1] ^ 0x80) << 6)
| (unsigned int) (s[2] ^ 0x80); | (unsigned int) (s[2] ^ 0x80);
return 3; return 3;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf8) else if (c < 0xf8)
{ {
if (n >= 4) if (n >= 4)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40
&& (c >= 0xf1 || s[1] >= 0x90) && (c >= 0xf1 || s[1] >= 0x90)
#if 1 #if 1
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif #endif
) )
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x07) << 18) *puc = ((unsigned int) (c & 0x07) << 18)
| ((unsigned int) (s[1] ^ 0x80) << 12) | ((unsigned int) (s[1] ^ 0x80) << 12)
| ((unsigned int) (s[2] ^ 0x80) << 6) | ((unsigned int) (s[2] ^ 0x80) << 6)
| (unsigned int) (s[3] ^ 0x80); | (unsigned int) (s[3] ^ 0x80);
return 4; return 4;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#if 0 #if 0
else if (c < 0xfc) else if (c < 0xfc)
{ {
if (n >= 5) if (n >= 5)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (c >= 0xf9 || s[1] >= 0x88)) && (c >= 0xf9 || s[1] >= 0x88))
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x03) << 24) *puc = ((unsigned int) (c & 0x03) << 24)
| ((unsigned int) (s[1] ^ 0x80) << 18) | ((unsigned int) (s[1] ^ 0x80) << 18)
| ((unsigned int) (s[2] ^ 0x80) << 12) | ((unsigned int) (s[2] ^ 0x80) << 12)
| ((unsigned int) (s[3] ^ 0x80) << 6) | ((unsigned int) (s[3] ^ 0x80) << 6)
| (unsigned int) (s[4] ^ 0x80); | (unsigned int) (s[4] ^ 0x80);
return 5; return 5;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xfe) else if (c < 0xfe)
{ {
if (n >= 6) if (n >= 6)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (s[5] ^ 0x80) < 0x40 && (s[5] ^ 0x80) < 0x40
&& (c >= 0xfd || s[1] >= 0x84)) && (c >= 0xfd || s[1] >= 0x84))
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x01) << 30) *puc = ((unsigned int) (c & 0x01) << 30)
| ((unsigned int) (s[1] ^ 0x80) << 24) | ((unsigned int) (s[1] ^ 0x80) << 24)
| ((unsigned int) (s[2] ^ 0x80) << 18) | ((unsigned int) (s[2] ^ 0x80) << 18)
| ((unsigned int) (s[3] ^ 0x80) << 12) | ((unsigned int) (s[3] ^ 0x80) << 12)
| ((unsigned int) (s[4] ^ 0x80) << 6) | ((unsigned int) (s[4] ^ 0x80) << 6)
| (unsigned int) (s[5] ^ 0x80); | (unsigned int) (s[5] ^ 0x80);
return 6; return 6;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#endif #endif
} }
/* invalid multibyte character */ /* invalid multibyte character */

View file

@ -41,134 +41,134 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
else if (c >= 0xc2) else if (c >= 0xc2)
{ {
if (c < 0xe0) if (c < 0xe0)
{ {
if (n >= 2) if (n >= 2)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40) if ((s[1] ^ 0x80) < 0x40)
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x1f) << 6) *puc = ((unsigned int) (c & 0x1f) << 6)
| (unsigned int) (s[1] ^ 0x80); | (unsigned int) (s[1] ^ 0x80);
return 2; return 2;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf0) else if (c < 0xf0)
{ {
if (n >= 3) if (n >= 3)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || s[1] >= 0xa0) && (c >= 0xe1 || s[1] >= 0xa0)
&& (c != 0xed || s[1] < 0xa0)) && (c != 0xed || s[1] < 0xa0))
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x0f) << 12) *puc = ((unsigned int) (c & 0x0f) << 12)
| ((unsigned int) (s[1] ^ 0x80) << 6) | ((unsigned int) (s[1] ^ 0x80) << 6)
| (unsigned int) (s[2] ^ 0x80); | (unsigned int) (s[2] ^ 0x80);
return 3; return 3;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf8) else if (c < 0xf8)
{ {
if (n >= 4) if (n >= 4)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40
&& (c >= 0xf1 || s[1] >= 0x90) && (c >= 0xf1 || s[1] >= 0x90)
#if 1 #if 1
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif #endif
) )
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x07) << 18) *puc = ((unsigned int) (c & 0x07) << 18)
| ((unsigned int) (s[1] ^ 0x80) << 12) | ((unsigned int) (s[1] ^ 0x80) << 12)
| ((unsigned int) (s[2] ^ 0x80) << 6) | ((unsigned int) (s[2] ^ 0x80) << 6)
| (unsigned int) (s[3] ^ 0x80); | (unsigned int) (s[3] ^ 0x80);
return 4; return 4;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#if 0 #if 0
else if (c < 0xfc) else if (c < 0xfc)
{ {
if (n >= 5) if (n >= 5)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (c >= 0xf9 || s[1] >= 0x88)) && (c >= 0xf9 || s[1] >= 0x88))
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x03) << 24) *puc = ((unsigned int) (c & 0x03) << 24)
| ((unsigned int) (s[1] ^ 0x80) << 18) | ((unsigned int) (s[1] ^ 0x80) << 18)
| ((unsigned int) (s[2] ^ 0x80) << 12) | ((unsigned int) (s[2] ^ 0x80) << 12)
| ((unsigned int) (s[3] ^ 0x80) << 6) | ((unsigned int) (s[3] ^ 0x80) << 6)
| (unsigned int) (s[4] ^ 0x80); | (unsigned int) (s[4] ^ 0x80);
return 5; return 5;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xfe) else if (c < 0xfe)
{ {
if (n >= 6) if (n >= 6)
{ {
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (s[5] ^ 0x80) < 0x40 && (s[5] ^ 0x80) < 0x40
&& (c >= 0xfd || s[1] >= 0x84)) && (c >= 0xfd || s[1] >= 0x84))
#endif #endif
{ {
*puc = ((unsigned int) (c & 0x01) << 30) *puc = ((unsigned int) (c & 0x01) << 30)
| ((unsigned int) (s[1] ^ 0x80) << 24) | ((unsigned int) (s[1] ^ 0x80) << 24)
| ((unsigned int) (s[2] ^ 0x80) << 18) | ((unsigned int) (s[2] ^ 0x80) << 18)
| ((unsigned int) (s[3] ^ 0x80) << 12) | ((unsigned int) (s[3] ^ 0x80) << 12)
| ((unsigned int) (s[4] ^ 0x80) << 6) | ((unsigned int) (s[4] ^ 0x80) << 6)
| (unsigned int) (s[5] ^ 0x80); | (unsigned int) (s[5] ^ 0x80);
return 6; return 6;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#endif #endif
} }
/* invalid multibyte character */ /* invalid multibyte character */

View file

@ -40,124 +40,124 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
else if (c >= 0xc2) else if (c >= 0xc2)
{ {
if (c < 0xe0) if (c < 0xe0)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40) if ((s[1] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x1f) << 6) *puc = ((unsigned int) (c & 0x1f) << 6)
| (unsigned int) (s[1] ^ 0x80); | (unsigned int) (s[1] ^ 0x80);
return 2; return 2;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf0) else if (c < 0xf0)
{ {
if (n >= 3) if (n >= 3)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || s[1] >= 0xa0) && (c >= 0xe1 || s[1] >= 0xa0)
&& (c != 0xed || s[1] < 0xa0)) && (c != 0xed || s[1] < 0xa0))
{ {
*puc = ((unsigned int) (c & 0x0f) << 12) *puc = ((unsigned int) (c & 0x0f) << 12)
| ((unsigned int) (s[1] ^ 0x80) << 6) | ((unsigned int) (s[1] ^ 0x80) << 6)
| (unsigned int) (s[2] ^ 0x80); | (unsigned int) (s[2] ^ 0x80);
return 3; return 3;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xf8) else if (c < 0xf8)
{ {
if (n >= 4) if (n >= 4)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40
&& (c >= 0xf1 || s[1] >= 0x90) && (c >= 0xf1 || s[1] >= 0x90)
#if 1 #if 1
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif #endif
) )
{ {
*puc = ((unsigned int) (c & 0x07) << 18) *puc = ((unsigned int) (c & 0x07) << 18)
| ((unsigned int) (s[1] ^ 0x80) << 12) | ((unsigned int) (s[1] ^ 0x80) << 12)
| ((unsigned int) (s[2] ^ 0x80) << 6) | ((unsigned int) (s[2] ^ 0x80) << 6)
| (unsigned int) (s[3] ^ 0x80); | (unsigned int) (s[3] ^ 0x80);
return 4; return 4;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#if 0 #if 0
else if (c < 0xfc) else if (c < 0xfc)
{ {
if (n >= 5) if (n >= 5)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (c >= 0xf9 || s[1] >= 0x88)) && (c >= 0xf9 || s[1] >= 0x88))
{ {
*puc = ((unsigned int) (c & 0x03) << 24) *puc = ((unsigned int) (c & 0x03) << 24)
| ((unsigned int) (s[1] ^ 0x80) << 18) | ((unsigned int) (s[1] ^ 0x80) << 18)
| ((unsigned int) (s[2] ^ 0x80) << 12) | ((unsigned int) (s[2] ^ 0x80) << 12)
| ((unsigned int) (s[3] ^ 0x80) << 6) | ((unsigned int) (s[3] ^ 0x80) << 6)
| (unsigned int) (s[4] ^ 0x80); | (unsigned int) (s[4] ^ 0x80);
return 5; return 5;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
else if (c < 0xfe) else if (c < 0xfe)
{ {
if (n >= 6) if (n >= 6)
{ {
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
&& (s[5] ^ 0x80) < 0x40 && (s[5] ^ 0x80) < 0x40
&& (c >= 0xfd || s[1] >= 0x84)) && (c >= 0xfd || s[1] >= 0x84))
{ {
*puc = ((unsigned int) (c & 0x01) << 30) *puc = ((unsigned int) (c & 0x01) << 30)
| ((unsigned int) (s[1] ^ 0x80) << 24) | ((unsigned int) (s[1] ^ 0x80) << 24)
| ((unsigned int) (s[2] ^ 0x80) << 18) | ((unsigned int) (s[2] ^ 0x80) << 18)
| ((unsigned int) (s[3] ^ 0x80) << 12) | ((unsigned int) (s[3] ^ 0x80) << 12)
| ((unsigned int) (s[4] ^ 0x80) << 6) | ((unsigned int) (s[4] ^ 0x80) << 6)
| (unsigned int) (s[5] ^ 0x80); | (unsigned int) (s[5] ^ 0x80);
return 6; return 6;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return n; return n;
} }
} }
#endif #endif
} }
/* invalid multibyte character */ /* invalid multibyte character */

View file

@ -33,250 +33,250 @@ u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n)
else if (c >= 0xc2) else if (c >= 0xc2)
{ {
if (c < 0xe0) if (c < 0xe0)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40) if ((s[1] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x1f) << 6) *puc = ((unsigned int) (c & 0x1f) << 6)
| (unsigned int) (s[1] ^ 0x80); | (unsigned int) (s[1] ^ 0x80);
return 2; return 2;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
else if (c < 0xf0) else if (c < 0xf0)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40
&& (c >= 0xe1 || s[1] >= 0xa0) && (c >= 0xe1 || s[1] >= 0xa0)
&& (c != 0xed || s[1] < 0xa0)) && (c != 0xed || s[1] < 0xa0))
{ {
if (n >= 3) if (n >= 3)
{ {
if ((s[2] ^ 0x80) < 0x40) if ((s[2] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x0f) << 12) *puc = ((unsigned int) (c & 0x0f) << 12)
| ((unsigned int) (s[1] ^ 0x80) << 6) | ((unsigned int) (s[1] ^ 0x80) << 6)
| (unsigned int) (s[2] ^ 0x80); | (unsigned int) (s[2] ^ 0x80);
return 3; return 3;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
else if (c < 0xf8) else if (c < 0xf8)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40
&& (c >= 0xf1 || s[1] >= 0x90) && (c >= 0xf1 || s[1] >= 0x90)
#if 1 #if 1
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif #endif
) )
{ {
if (n >= 3) if (n >= 3)
{ {
if ((s[2] ^ 0x80) < 0x40) if ((s[2] ^ 0x80) < 0x40)
{ {
if (n >= 4) if (n >= 4)
{ {
if ((s[3] ^ 0x80) < 0x40) if ((s[3] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x07) << 18) *puc = ((unsigned int) (c & 0x07) << 18)
| ((unsigned int) (s[1] ^ 0x80) << 12) | ((unsigned int) (s[1] ^ 0x80) << 12)
| ((unsigned int) (s[2] ^ 0x80) << 6) | ((unsigned int) (s[2] ^ 0x80) << 6)
| (unsigned int) (s[3] ^ 0x80); | (unsigned int) (s[3] ^ 0x80);
return 4; return 4;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
#if 0 #if 0
else if (c < 0xfc) else if (c < 0xfc)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40
&& (c >= 0xf9 || s[1] >= 0x88)) && (c >= 0xf9 || s[1] >= 0x88))
{ {
if (n >= 3) if (n >= 3)
{ {
if ((s[2] ^ 0x80) < 0x40) if ((s[2] ^ 0x80) < 0x40)
{ {
if (n >= 4) if (n >= 4)
{ {
if ((s[3] ^ 0x80) < 0x40) if ((s[3] ^ 0x80) < 0x40)
{ {
if (n >= 5) if (n >= 5)
{ {
if ((s[4] ^ 0x80) < 0x40) if ((s[4] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x03) << 24) *puc = ((unsigned int) (c & 0x03) << 24)
| ((unsigned int) (s[1] ^ 0x80) << 18) | ((unsigned int) (s[1] ^ 0x80) << 18)
| ((unsigned int) (s[2] ^ 0x80) << 12) | ((unsigned int) (s[2] ^ 0x80) << 12)
| ((unsigned int) (s[3] ^ 0x80) << 6) | ((unsigned int) (s[3] ^ 0x80) << 6)
| (unsigned int) (s[4] ^ 0x80); | (unsigned int) (s[4] ^ 0x80);
return 5; return 5;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
else if (c < 0xfe) else if (c < 0xfe)
{ {
if (n >= 2) if (n >= 2)
{ {
if ((s[1] ^ 0x80) < 0x40 if ((s[1] ^ 0x80) < 0x40
&& (c >= 0xfd || s[1] >= 0x84)) && (c >= 0xfd || s[1] >= 0x84))
{ {
if (n >= 3) if (n >= 3)
{ {
if ((s[2] ^ 0x80) < 0x40) if ((s[2] ^ 0x80) < 0x40)
{ {
if (n >= 4) if (n >= 4)
{ {
if ((s[3] ^ 0x80) < 0x40) if ((s[3] ^ 0x80) < 0x40)
{ {
if (n >= 5) if (n >= 5)
{ {
if ((s[4] ^ 0x80) < 0x40) if ((s[4] ^ 0x80) < 0x40)
{ {
if (n >= 6) if (n >= 6)
{ {
if ((s[5] ^ 0x80) < 0x40) if ((s[5] ^ 0x80) < 0x40)
{ {
*puc = ((unsigned int) (c & 0x01) << 30) *puc = ((unsigned int) (c & 0x01) << 30)
| ((unsigned int) (s[1] ^ 0x80) << 24) | ((unsigned int) (s[1] ^ 0x80) << 24)
| ((unsigned int) (s[2] ^ 0x80) << 18) | ((unsigned int) (s[2] ^ 0x80) << 18)
| ((unsigned int) (s[3] ^ 0x80) << 12) | ((unsigned int) (s[3] ^ 0x80) << 12)
| ((unsigned int) (s[4] ^ 0x80) << 6) | ((unsigned int) (s[4] ^ 0x80) << 6)
| (unsigned int) (s[5] ^ 0x80); | (unsigned int) (s[5] ^ 0x80);
return 6; return 6;
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
/* invalid multibyte character */ /* invalid multibyte character */
} }
else else
{ {
/* incomplete multibyte character */ /* incomplete multibyte character */
*puc = 0xfffd; *puc = 0xfffd;
return -2; return -2;
} }
} }
#endif #endif
} }
/* invalid multibyte character */ /* invalid multibyte character */

View file

@ -29,65 +29,65 @@ u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start)
uint8_t c_1 = s[-1]; uint8_t c_1 = s[-1];
if (c_1 < 0x80) if (c_1 < 0x80)
{ {
*puc = c_1; *puc = c_1;
return s - 1; return s - 1;
} }
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((c_1 ^ 0x80) < 0x40) if ((c_1 ^ 0x80) < 0x40)
#endif #endif
if (s - 1 != start) if (s - 1 != start)
{ {
uint8_t c_2 = s[-2]; uint8_t c_2 = s[-2];
if (c_2 >= 0xc2 && c_2 < 0xe0) if (c_2 >= 0xc2 && c_2 < 0xe0)
{ {
*puc = ((unsigned int) (c_2 & 0x1f) << 6) *puc = ((unsigned int) (c_2 & 0x1f) << 6)
| (unsigned int) (c_1 ^ 0x80); | (unsigned int) (c_1 ^ 0x80);
return s - 2; return s - 2;
} }
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((c_2 ^ 0x80) < 0x40) if ((c_2 ^ 0x80) < 0x40)
#endif #endif
if (s - 2 != start) if (s - 2 != start)
{ {
uint8_t c_3 = s[-3]; uint8_t c_3 = s[-3];
if (c_3 >= 0xe0 && c_3 < 0xf0 if (c_3 >= 0xe0 && c_3 < 0xf0
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
&& (c_3 >= 0xe1 || c_2 >= 0xa0) && (c_3 >= 0xe1 || c_2 >= 0xa0)
&& (c_3 != 0xed || c_2 < 0xa0) && (c_3 != 0xed || c_2 < 0xa0)
#endif #endif
) )
{ {
*puc = ((unsigned int) (c_3 & 0x0f) << 12) *puc = ((unsigned int) (c_3 & 0x0f) << 12)
| ((unsigned int) (c_2 ^ 0x80) << 6) | ((unsigned int) (c_2 ^ 0x80) << 6)
| (unsigned int) (c_1 ^ 0x80); | (unsigned int) (c_1 ^ 0x80);
return s - 3; return s - 3;
} }
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
if ((c_3 ^ 0x80) < 0x40) if ((c_3 ^ 0x80) < 0x40)
#endif #endif
if (s - 3 != start) if (s - 3 != start)
{ {
uint8_t c_4 = s[-4]; uint8_t c_4 = s[-4];
if (c_4 >= 0xf0 && c_4 < 0xf8 if (c_4 >= 0xf0 && c_4 < 0xf8
#if CONFIG_UNICODE_SAFETY #if CONFIG_UNICODE_SAFETY
&& (c_4 >= 0xf1 || c_3 >= 0x90) && (c_4 >= 0xf1 || c_3 >= 0x90)
&& (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90)) && (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90))
#endif #endif
) )
{ {
*puc = ((unsigned int) (c_4 & 0x07) << 18) *puc = ((unsigned int) (c_4 & 0x07) << 18)
| ((unsigned int) (c_3 ^ 0x80) << 12) | ((unsigned int) (c_3 ^ 0x80) << 12)
| ((unsigned int) (c_2 ^ 0x80) << 6) | ((unsigned int) (c_2 ^ 0x80) << 6)
| (unsigned int) (c_1 ^ 0x80); | (unsigned int) (c_1 ^ 0x80);
return s - 4; return s - 4;
} }
} }
} }
} }
} }
return NULL; return NULL;
} }

View file

@ -33,9 +33,9 @@ u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n)
else if (uc < 0x10000) else if (uc < 0x10000)
{ {
if (uc < 0xd800 || uc >= 0xe000) if (uc < 0xd800 || uc >= 0xe000)
count = 3; count = 3;
else else
return -1; return -1;
} }
#if 0 #if 0
else if (uc < 0x200000) else if (uc < 0x200000)

View file

@ -33,10 +33,10 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
if (uc < 0x80) if (uc < 0x80)
{ {
if (n > 0) if (n > 0)
{ {
s[0] = uc; s[0] = uc;
return 1; return 1;
} }
/* else return -2, below. */ /* else return -2, below. */
} }
else else
@ -44,43 +44,43 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
int count; int count;
if (uc < 0x800) if (uc < 0x800)
count = 2; count = 2;
else if (uc < 0x10000) else if (uc < 0x10000)
{ {
if (uc < 0xd800 || uc >= 0xe000) if (uc < 0xd800 || uc >= 0xe000)
count = 3; count = 3;
else else
return -1; return -1;
} }
#if 0 #if 0
else if (uc < 0x200000) else if (uc < 0x200000)
count = 4; count = 4;
else if (uc < 0x4000000) else if (uc < 0x4000000)
count = 5; count = 5;
else if (uc <= 0x7fffffff) else if (uc <= 0x7fffffff)
count = 6; count = 6;
#else #else
else if (uc < 0x110000) else if (uc < 0x110000)
count = 4; count = 4;
#endif #endif
else else
return -1; return -1;
if (n >= count) if (n >= count)
{ {
switch (count) /* note: code falls through cases! */ switch (count) /* note: code falls through cases! */
{ {
#if 0 #if 0
case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000;
case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000;
#endif #endif
case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
/*case 1:*/ s[0] = uc; /*case 1:*/ s[0] = uc;
} }
return count; return count;
} }
} }
return -2; return -2;
} }

File diff suppressed because it is too large Load diff

View file

@ -110,8 +110,8 @@
#if 4 <= __GNUC__ #if 4 <= __GNUC__
# define verify(R) \ # define verify(R) \
extern int (* verify_function__ (void)) \ extern int (* verify_function__ (void)) \
[__builtin_constant_p (R) && (R) ? 1 : -1] [__builtin_constant_p (R) && (R) ? 1 : -1]
#endif #endif
* In C++, any struct definition inside sizeof is invalid. * In C++, any struct definition inside sizeof is invalid.

View file

@ -32,6 +32,12 @@
#include "gettext.h" #include "gettext.h"
#define _(msgid) gettext (msgid) #define _(msgid) gettext (msgid)
/* If you use AM_INIT_AUTOMAKE's no-define option,
PACKAGE is not defined. Use PACKAGE_TARNAME instead. */
#if ! defined PACKAGE && defined PACKAGE_TARNAME
# define PACKAGE PACKAGE_TARNAME
#endif
enum { COPYRIGHT_YEAR = 2009 }; enum { COPYRIGHT_YEAR = 2009 };
/* The three functions below display the --version information the /* The three functions below display the --version information the
@ -54,9 +60,9 @@ enum { COPYRIGHT_YEAR = 2009 };
number of elements in the array. */ number of elements in the array. */
void void
version_etc_arn (FILE *stream, version_etc_arn (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, const char *version,
const char * const * authors, size_t n_authors) const char * const * authors, size_t n_authors)
{ {
if (command_name) if (command_name)
fprintf (stream, "%s (%s) %s\n", command_name, package, version); fprintf (stream, "%s (%s) %s\n", command_name, package, version);
@ -66,7 +72,7 @@ version_etc_arn (FILE *stream,
#ifdef PACKAGE_PACKAGER #ifdef PACKAGE_PACKAGER
# ifdef PACKAGE_PACKAGER_VERSION # ifdef PACKAGE_PACKAGER_VERSION
fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER, fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER,
PACKAGE_PACKAGER_VERSION); PACKAGE_PACKAGER_VERSION);
# else # else
fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER); fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER);
# endif # endif
@ -84,7 +90,7 @@ This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n\ There is NO WARRANTY, to the extent permitted by law.\n\
\n\ \n\
"), "),
stream); stream);
switch (n_authors) switch (n_authors)
{ {
@ -102,66 +108,66 @@ There is NO WARRANTY, to the extent permitted by law.\n\
case 3: case 3:
/* TRANSLATORS: Each %s denotes an author name. */ /* TRANSLATORS: Each %s denotes an author name. */
fprintf (stream, _("Written by %s, %s, and %s.\n"), fprintf (stream, _("Written by %s, %s, and %s.\n"),
authors[0], authors[1], authors[2]); authors[0], authors[1], authors[2]);
break; break;
case 4: case 4:
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"),
authors[0], authors[1], authors[2], authors[3]); authors[0], authors[1], authors[2], authors[3]);
break; break;
case 5: case 5:
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4]); authors[0], authors[1], authors[2], authors[3], authors[4]);
break; break;
case 6: case 6:
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4], authors[0], authors[1], authors[2], authors[3], authors[4],
authors[5]); authors[5]);
break; break;
case 7: case 7:
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4], authors[0], authors[1], authors[2], authors[3], authors[4],
authors[5], authors[6]); authors[5], authors[6]);
break; break;
case 8: case 8:
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("\ fprintf (stream, _("\
Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4], authors[0], authors[1], authors[2], authors[3], authors[4],
authors[5], authors[6], authors[7]); authors[5], authors[6], authors[7]);
break; break;
case 9: case 9:
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("\ fprintf (stream, _("\
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4], authors[0], authors[1], authors[2], authors[3], authors[4],
authors[5], authors[6], authors[7], authors[8]); authors[5], authors[6], authors[7], authors[8]);
break; break;
default: default:
/* 10 or more authors. Use an abbreviation, since the human reader /* 10 or more authors. Use an abbreviation, since the human reader
will probably not want to read the entire list anyway. */ will probably not want to read the entire list anyway. */
/* TRANSLATORS: Each %s denotes an author name. /* TRANSLATORS: Each %s denotes an author name.
You can use line breaks, estimating that each author name occupies You can use line breaks, estimating that each author name occupies
ca. 16 screen columns and that a screen line has ca. 80 columns. */ ca. 16 screen columns and that a screen line has ca. 80 columns. */
fprintf (stream, _("\ fprintf (stream, _("\
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4], authors[0], authors[1], authors[2], authors[3], authors[4],
authors[5], authors[6], authors[7], authors[8]); authors[5], authors[6], authors[7], authors[8]);
break; break;
} }
} }
@ -172,8 +178,8 @@ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
Author names are given in the NULL-terminated array AUTHORS. */ Author names are given in the NULL-terminated array AUTHORS. */
void void
version_etc_ar (FILE *stream, version_etc_ar (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, const char * const * authors) const char *version, const char * const * authors)
{ {
size_t n_authors; size_t n_authors;
@ -188,19 +194,19 @@ version_etc_ar (FILE *stream,
Author names are given in the NULL-terminated va_list AUTHORS. */ Author names are given in the NULL-terminated va_list AUTHORS. */
void void
version_etc_va (FILE *stream, version_etc_va (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, va_list authors) const char *version, va_list authors)
{ {
size_t n_authors; size_t n_authors;
const char *authtab[10]; const char *authtab[10];
for (n_authors = 0; for (n_authors = 0;
n_authors < 10 n_authors < 10
&& (authtab[n_authors] = va_arg (authors, const char *)) != NULL; && (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
n_authors++) n_authors++)
; ;
version_etc_arn (stream, command_name, package, version, version_etc_arn (stream, command_name, package, version,
authtab, n_authors); authtab, n_authors);
} }
@ -219,8 +225,8 @@ version_etc_va (FILE *stream,
NULL argument at the end. */ NULL argument at the end. */
void void
version_etc (FILE *stream, version_etc (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, /* const char *author1, ...*/ ...) const char *version, /* const char *author1, ...*/ ...)
{ {
va_list authors; va_list authors;
@ -239,14 +245,14 @@ emit_bug_reporting_address (void)
printf (_("\nReport bugs to: %s\n"), PACKAGE_BUGREPORT); printf (_("\nReport bugs to: %s\n"), PACKAGE_BUGREPORT);
#ifdef PACKAGE_PACKAGER_BUG_REPORTS #ifdef PACKAGE_PACKAGER_BUG_REPORTS
printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER, printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER,
PACKAGE_PACKAGER_BUG_REPORTS); PACKAGE_PACKAGER_BUG_REPORTS);
#endif #endif
#ifdef PACKAGE_URL #ifdef PACKAGE_URL
printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
#else #else
printf (_("%s home page: <http://www.gnu.org/software/%s/>\n"), printf (_("%s home page: <http://www.gnu.org/software/%s/>\n"),
PACKAGE_NAME, PACKAGE_TARNAME); PACKAGE_NAME, PACKAGE);
#endif #endif
fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"), fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
stdout); stdout);
} }

View file

@ -50,26 +50,26 @@ extern const char version_etc_copyright[];
/* N_AUTHORS names are supplied in array AUTHORS. */ /* N_AUTHORS names are supplied in array AUTHORS. */
extern void version_etc_arn (FILE *stream, extern void version_etc_arn (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, const char *version,
const char * const * authors, size_t n_authors); const char * const * authors, size_t n_authors);
/* Names are passed in the NULL-terminated array AUTHORS. */ /* Names are passed in the NULL-terminated array AUTHORS. */
extern void version_etc_ar (FILE *stream, extern void version_etc_ar (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, const char * const * authors); const char *version, const char * const * authors);
/* Names are passed in the NULL-terminated va_list. */ /* Names are passed in the NULL-terminated va_list. */
extern void version_etc_va (FILE *stream, extern void version_etc_va (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, va_list authors); const char *version, va_list authors);
/* Names are passed as separate arguments, with an additional /* Names are passed as separate arguments, with an additional
NULL argument at the end. */ NULL argument at the end. */
extern void version_etc (FILE *stream, extern void version_etc (FILE *stream,
const char *command_name, const char *package, const char *command_name, const char *package,
const char *version, const char *version,
/* const char *author1, ..., NULL */ ...) /* const char *author1, ..., NULL */ ...)
ATTRIBUTE_SENTINEL; ATTRIBUTE_SENTINEL;
/* Display the usual `Report bugs to' stanza */ /* Display the usual `Report bugs to' stanza */

View file

@ -52,11 +52,11 @@ vsnprintf (char *str, size_t size, const char *format, va_list args)
if (output != str) if (output != str)
{ {
if (size) if (size)
{ {
size_t pruned_len = (len < size ? len : size - 1); size_t pruned_len = (len < size ? len : size - 1);
memcpy (str, output, pruned_len); memcpy (str, output, pruned_len);
str[pruned_len] = '\0'; str[pruned_len] = '\0';
} }
free (output); free (output);
} }

View file

@ -74,6 +74,8 @@
/* The definition of GL_LINK_WARNING is copied here. */ /* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -197,7 +199,8 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
# define mbsrtowcs rpl_mbsrtowcs # define mbsrtowcs rpl_mbsrtowcs
# endif # endif
# if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@ # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps); extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mbsrtowcs # undef mbsrtowcs
@ -215,7 +218,8 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t
# define mbsnrtowcs rpl_mbsnrtowcs # define mbsnrtowcs rpl_mbsnrtowcs
# endif # endif
# if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@ # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps); extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef mbsnrtowcs # undef mbsnrtowcs
@ -251,7 +255,8 @@ extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
# define wcsrtombs rpl_wcsrtombs # define wcsrtombs rpl_wcsrtombs
# endif # endif
# if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@ # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps); extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef wcsrtombs # undef wcsrtombs
@ -269,7 +274,8 @@ extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t
# define wcsnrtombs rpl_wcsnrtombs # define wcsnrtombs rpl_wcsnrtombs
# endif # endif
# if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@ # if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@
extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps); extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
_GL_ARG_NONNULL ((2));
# endif # endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef wcsnrtombs # undef wcsnrtombs

View file

@ -46,14 +46,14 @@ rpl_write (int fd, const void *buf, size_t count)
if (ret < 0) if (ret < 0)
{ {
if (GetLastError () == ERROR_NO_DATA if (GetLastError () == ERROR_NO_DATA
&& GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE) && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)
{ {
/* Try to raise signal SIGPIPE. */ /* Try to raise signal SIGPIPE. */
raise (SIGPIPE); raise (SIGPIPE);
/* If it is currently blocked or ignored, change errno from EINVAL /* If it is currently blocked or ignored, change errno from EINVAL
to EPIPE. */ to EPIPE. */
errno = EPIPE; errno = EPIPE;
} }
} }
return ret; return ret;
} }

View file

@ -115,69 +115,6 @@
# endif # endif
#endif #endif
/* Ultrix has S_IFSOCK, but no S_ISSOCK. Ipe! */
#if defined (S_IFSOCK) && ! defined (S_ISSOCK)
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
#endif
/* The MinGW gcc does not define the S_ISSOCK macro. Any other native Windows
compiler like BorlandC or MSVC has none of these macros defined. */
#ifdef __MINGW32__
# ifdef _S_IFIFO
# undef _S_IFIFO
# endif
# ifdef _S_IFCHR
# undef _S_IFCHR
# endif
# ifdef _S_IFBLK
# undef _S_IFBLK
# endif
# ifdef _S_IFDIR
# undef _S_IFDIR
# endif
# ifdef _S_IFREG
# undef _S_IFREG
# endif
# ifdef _S_IFSOCK
# undef _S_IFSOCK
# endif
# define _S_IFIFO 0x1000 /* FIFO */
# define _S_IFCHR 0x2000 /* Character */
# define _S_IFBLK 0x3000 /* Block */
# define _S_IFDIR 0x4000 /* Directory */
# define _S_IFREG 0x8000 /* Regular */
# define _S_IFSOCK 0xC000 /* Socket */
# ifdef S_ISBLK
# undef S_ISBLK
# endif
# ifdef S_ISFIFO
# undef S_ISFIFO
# endif
# ifdef S_ISCHR
# undef S_ISCHR
# endif
# ifdef S_ISDIR
# undef S_ISDIR
# endif
# ifdef S_ISREG
# undef S_ISREG
# endif
# ifdef S_ISSOCK
# undef S_ISSOCK
# endif
# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK)
# define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO)
# define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR)
# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG)
# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK)
#endif /* __MINGW32__ */
/* Some more definitions for the native Windows port. */ /* Some more definitions for the native Windows port. */
#ifdef __MINGW32__ #ifdef __MINGW32__
# define mkdir(path, mode) mkdir (path) # define mkdir(path, mode) mkdir (path)

View file

@ -14,31 +14,31 @@ AC_DEFUN([gl_AC_DOS],
[ [
AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos], AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
[ [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__ #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
neither MSDOS nor Windows neither MSDOS nor Windows
#endif]])], #endif]])],
[ac_cv_win_or_dos=yes], [ac_cv_win_or_dos=yes],
[ac_cv_win_or_dos=no]) [ac_cv_win_or_dos=no])
]) ])
if test x"$ac_cv_win_or_dos" = xyes; then if test x"$ac_cv_win_or_dos" = xyes; then
ac_fs_accepts_drive_letter_prefix=1 ac_fs_accepts_drive_letter_prefix=1
ac_fs_backslash_is_file_name_separator=1 ac_fs_backslash_is_file_name_separator=1
AC_CACHE_CHECK([whether drive letter can start relative path], AC_CACHE_CHECK([whether drive letter can start relative path],
[ac_cv_drive_letter_can_be_relative], [ac_cv_drive_letter_can_be_relative],
[ [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#if defined __CYGWIN__ #if defined __CYGWIN__
drive letters are always absolute drive letters are always absolute
#endif]])], #endif]])],
[ac_cv_drive_letter_can_be_relative=yes], [ac_cv_drive_letter_can_be_relative=yes],
[ac_cv_drive_letter_can_be_relative=no]) [ac_cv_drive_letter_can_be_relative=no])
]) ])
if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
ac_fs_drive_letter_can_be_relative=1 ac_fs_drive_letter_can_be_relative=1
else else
ac_fs_drive_letter_can_be_relative=0 ac_fs_drive_letter_can_be_relative=0
fi fi
else else
ac_fs_accepts_drive_letter_prefix=0 ac_fs_accepts_drive_letter_prefix=0

View file

@ -9,27 +9,27 @@ AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root], AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
[ if test x"$cross_compiling" = xyes ; then [ if test x"$cross_compiling" = xyes ; then
# When cross-compiling, there is no way to tell whether // is special # When cross-compiling, there is no way to tell whether // is special
# short of a list of hosts. However, the only known hosts to date # short of a list of hosts. However, the only known hosts to date
# that have a distinct // are Apollo DomainOS (too old to port to), # that have a distinct // are Apollo DomainOS (too old to port to),
# Cygwin, and z/OS. If anyone knows of another system for which // has # Cygwin, and z/OS. If anyone knows of another system for which // has
# special semantics and is distinct from /, please report it to # special semantics and is distinct from /, please report it to
# <bug-gnulib@gnu.org>. # <bug-gnulib@gnu.org>.
case $host in case $host in
*-cygwin | i370-ibm-openedition) *-cygwin | i370-ibm-openedition)
gl_cv_double_slash_root=yes ;; gl_cv_double_slash_root=yes ;;
*) *)
# Be optimistic and assume that / and // are the same when we # Be optimistic and assume that / and // are the same when we
# don't know. # don't know.
gl_cv_double_slash_root='unknown, assuming no' ;; gl_cv_double_slash_root='unknown, assuming no' ;;
esac esac
else else
set x `ls -di / // 2>/dev/null` set x `ls -di / // 2>/dev/null`
if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
gl_cv_double_slash_root=no gl_cv_double_slash_root=no
else else
gl_cv_double_slash_root=yes gl_cv_double_slash_root=yes
fi fi
fi]) fi])
if test "$gl_cv_double_slash_root" = yes; then if test "$gl_cv_double_slash_root" = yes; then
AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1], AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],

View file

@ -74,8 +74,8 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
[ac_cv_safe_to_define___extensions__], [ac_cv_safe_to_define___extensions__],
[AC_COMPILE_IFELSE( [AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[ [AC_LANG_PROGRAM([[
# define __EXTENSIONS__ 1 # define __EXTENSIONS__ 1
]AC_INCLUDES_DEFAULT])], ]AC_INCLUDES_DEFAULT])],
[ac_cv_safe_to_define___extensions__=yes], [ac_cv_safe_to_define___extensions__=yes],
[ac_cv_safe_to_define___extensions__=no])]) [ac_cv_safe_to_define___extensions__=no])])
test $ac_cv_safe_to_define___extensions__ = yes && test $ac_cv_safe_to_define___extensions__ = yes &&

View file

@ -26,53 +26,53 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
[AC_RUN_IFELSE( [AC_RUN_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[#include <sys/types.h> [[#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#ifndef O_NOATIME #ifndef O_NOATIME
#define O_NOATIME 0 #define O_NOATIME 0
#endif #endif
#ifndef O_NOFOLLOW #ifndef O_NOFOLLOW
#define O_NOFOLLOW 0 #define O_NOFOLLOW 0
#endif #endif
static int const constants[] = static int const constants[] =
{ {
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
}; };
]], ]],
[[ [[
int status = !constants; int status = !constants;
{ {
static char const sym[] = "conftest.sym"; static char const sym[] = "conftest.sym";
if (symlink (".", sym) != 0 if (symlink (".", sym) != 0
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
status |= 32; status |= 32;
unlink (sym); unlink (sym);
} }
{ {
static char const file[] = "confdefs.h"; static char const file[] = "confdefs.h";
int fd = open (file, O_RDONLY | O_NOATIME); int fd = open (file, O_RDONLY | O_NOATIME);
char c; char c;
struct stat st0, st1; struct stat st0, st1;
if (fd < 0 if (fd < 0
|| fstat (fd, &st0) != 0 || fstat (fd, &st0) != 0
|| sleep (1) != 0 || sleep (1) != 0
|| read (fd, &c, 1) != 1 || read (fd, &c, 1) != 1
|| close (fd) != 0 || close (fd) != 0
|| stat (file, &st1) != 0 || stat (file, &st1) != 0
|| st0.st_atime != st1.st_atime) || st0.st_atime != st1.st_atime)
status |= 64; status |= 64;
} }
return status;]])], return status;]])],
[gl_cv_header_working_fcntl_h=yes], [gl_cv_header_working_fcntl_h=yes],
[case $? in #( [case $? in #(
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
*) gl_cv_header_working_fcntl_h='no';; *) gl_cv_header_working_fcntl_h='no';;
esac], esac],
[gl_cv_header_working_fcntl_h=cross-compiling])]) [gl_cv_header_working_fcntl_h=cross-compiling])])
case $gl_cv_header_working_fcntl_h in #( case $gl_cv_header_working_fcntl_h in #(

View file

@ -12,16 +12,16 @@ AC_DEFUN([gl_GLIBC21],
AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer], AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
[ac_cv_gnu_library_2_1], [ac_cv_gnu_library_2_1],
[AC_EGREP_CPP([Lucky GNU user], [AC_EGREP_CPP([Lucky GNU user],
[ [
#include <features.h> #include <features.h>
#ifdef __GNU_LIBRARY__ #ifdef __GNU_LIBRARY__
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
Lucky GNU user Lucky GNU user
#endif #endif
#endif #endif
], ],
[ac_cv_gnu_library_2_1=yes], [ac_cv_gnu_library_2_1=yes],
[ac_cv_gnu_library_2_1=no]) [ac_cv_gnu_library_2_1=no])
] ]
) )
AC_SUBST([GLIBC21]) AC_SUBST([GLIBC21])

View file

@ -15,7 +15,7 @@
# Specification in the form of a command-line invocation: # Specification in the form of a command-line invocation:
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string verify version-etc-fsf vsnprintf warnings # gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
# Specification in the form of a few gnulib-tool.m4 macro invocations: # Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([]) gl_LOCAL_DIR([])
@ -52,6 +52,7 @@ gl_MODULES([
strftime strftime
striconveh striconveh
string string
sys_stat
verify verify
version-etc-fsf version-etc-fsf
vsnprintf vsnprintf

View file

@ -70,13 +70,13 @@ AC_DEFUN([AC_C_RESTRICT],
for ac_kw in __restrict __restrict__ _Restrict restrict; do for ac_kw in __restrict __restrict__ _Restrict restrict; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM( AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[typedef int * int_ptr; [[typedef int * int_ptr;
int foo (int_ptr $ac_kw ip) { int foo (int_ptr $ac_kw ip) {
return ip[0]; return ip[0];
}]], }]],
[[int s[1]; [[int s[1];
int * $ac_kw t = s; int * $ac_kw t = s;
t[0] = 0; t[0] = 0;
return foo(t)]])], return foo(t)]])],
[ac_cv_c_restrict=$ac_kw]) [ac_cv_c_restrict=$ac_kw])
test "$ac_cv_c_restrict" != no && break test "$ac_cv_c_restrict" != no && break
done done

View file

@ -179,7 +179,7 @@ AC_DEFUN([gl_INIT],
if test -n "$gl_LIBOBJS"; then if test -n "$gl_LIBOBJS"; then
# Remove the extension. # Remove the extension.
sed_drop_objext='s/\.o$//;s/\.obj$//' sed_drop_objext='s/\.o$//;s/\.obj$//'
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
gl_libobjs="$gl_libobjs $i.$ac_objext" gl_libobjs="$gl_libobjs $i.$ac_objext"
gl_ltlibobjs="$gl_ltlibobjs $i.lo" gl_ltlibobjs="$gl_ltlibobjs $i.lo"
done done
@ -218,7 +218,7 @@ AC_DEFUN([gl_INIT],
if test -n "$gltests_LIBOBJS"; then if test -n "$gltests_LIBOBJS"; then
# Remove the extension. # Remove the extension.
sed_drop_objext='s/\.o$//;s/\.obj$//' sed_drop_objext='s/\.o$//;s/\.obj$//'
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
gltests_libobjs="$gltests_libobjs $i.$ac_objext" gltests_libobjs="$gltests_libobjs $i.$ac_objext"
gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
done done
@ -286,6 +286,7 @@ AC_DEFUN([gltests_LIBSOURCES], [
# gnulib-tool and may be removed by future gnulib-tool invocations. # gnulib-tool and may be removed by future gnulib-tool invocations.
AC_DEFUN([gl_FILE_LIST], [ AC_DEFUN([gl_FILE_LIST], [
build-aux/announce-gen build-aux/announce-gen
build-aux/arg-nonnull.h
build-aux/config.rpath build-aux/config.rpath
build-aux/gendocs.sh build-aux/gendocs.sh
build-aux/gitlog-to-changelog build-aux/gitlog-to-changelog

View file

@ -90,8 +90,8 @@ int main ()
outptr = buf; outptr = buf;
outbytesleft = sizeof (buf); outbytesleft = sizeof (buf);
res = iconv (cd, res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytesleft, (ICONV_CONST char **) &inptr, &inbytesleft,
&outptr, &outbytesleft); &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0); ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + (sizeof (expected) - 1)); ASSERT (outptr == buf + (sizeof (expected) - 1));
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0); ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
@ -117,8 +117,8 @@ int main ()
outptr = buf; outptr = buf;
outbytesleft = sizeof (buf); outbytesleft = sizeof (buf);
res = iconv (cd, res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytesleft, (ICONV_CONST char **) &inptr, &inbytesleft,
&outptr, &outbytesleft); &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0); ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + (sizeof (expected) - 1)); ASSERT (outptr == buf + (sizeof (expected) - 1));
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0); ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
@ -144,8 +144,8 @@ int main ()
outptr = buf; outptr = buf;
outbytesleft = sizeof (buf); outbytesleft = sizeof (buf);
res = iconv (cd, res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytesleft, (ICONV_CONST char **) &inptr, &inbytesleft,
&outptr, &outbytesleft); &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0); ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + (sizeof (expected) - 1)); ASSERT (outptr == buf + (sizeof (expected) - 1));
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0); ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
@ -171,8 +171,8 @@ int main ()
outptr = buf; outptr = buf;
outbytesleft = sizeof (buf); outbytesleft = sizeof (buf);
res = iconv (cd, res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytesleft, (ICONV_CONST char **) &inptr, &inbytesleft,
&outptr, &outbytesleft); &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0); ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + (sizeof (expected) - 1)); ASSERT (outptr == buf + (sizeof (expected) - 1));
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0); ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
@ -199,8 +199,8 @@ int main ()
outptr = buf; outptr = buf;
outbytesleft = sizeof (buf); outbytesleft = sizeof (buf);
res = iconv (cd, res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytesleft, (ICONV_CONST char **) &inptr, &inbytesleft,
&outptr, &outbytesleft); &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0); ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + (sizeof (expected) - 1)); ASSERT (outptr == buf + (sizeof (expected) - 1));
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0); ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);

View file

@ -109,11 +109,11 @@ EOF
# be # be
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
# That way, a header file with the following line: # That way, a header file with the following line:
# #@INCLUDE_NEXT@ @NEXT_FOO_H@ # #@INCLUDE_NEXT@ @NEXT_FOO_H@
# or # or
# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ # #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
# behaves (after sed substitution) as if it contained # behaves (after sed substitution) as if it contained
# #include_next <foo.h> # #include_next <foo.h>
# even if the compiler does not support include_next. # even if the compiler does not support include_next.
# The three "///" are to pacify Sun C 5.8, which otherwise would say # The three "///" are to pacify Sun C 5.8, which otherwise would say
# "warning: #include of /usr/include/... may be non-portable". # "warning: #include of /usr/include/... may be non-portable".
@ -129,46 +129,46 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
m4_foreach_w([gl_HEADER_NAME], [$1], m4_foreach_w([gl_HEADER_NAME], [$1],
[AS_VAR_PUSHDEF([gl_next_header], [AS_VAR_PUSHDEF([gl_next_header],
[gl_cv_next_]m4_defn([gl_HEADER_NAME])) [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
if test $gl_cv_have_include_next = yes; then if test $gl_cv_have_include_next = yes; then
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
else else
AC_CACHE_CHECK( AC_CACHE_CHECK(
[absolute name of <]m4_defn([gl_HEADER_NAME])[>], [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
m4_defn([gl_next_header]), m4_defn([gl_next_header]),
[AS_VAR_PUSHDEF([gl_header_exists], [AS_VAR_PUSHDEF([gl_header_exists],
[ac_cv_header_]m4_defn([gl_HEADER_NAME])) [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
if test AS_VAR_GET(gl_header_exists) = yes; then if test AS_VAR_GET(gl_header_exists) = yes; then
AC_LANG_CONFTEST( AC_LANG_CONFTEST(
[AC_LANG_SOURCE( [AC_LANG_SOURCE(
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
)]) )])
dnl AIX "xlc -E" and "cc -E" omit #line directives for header files dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
dnl that contain only a #include of other header files and no dnl that contain only a #include of other header files and no
dnl non-comment tokens of their own. This leads to a failure to dnl non-comment tokens of their own. This leads to a failure to
dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h> dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
dnl and others. The workaround is to force preservation of comments dnl and others. The workaround is to force preservation of comments
dnl through option -C. This ensures all necessary #line directives dnl through option -C. This ensures all necessary #line directives
dnl are present. GCC supports option -C as well. dnl are present. GCC supports option -C as well.
case "$host_os" in case "$host_os" in
aix*) gl_absname_cpp="$ac_cpp -C" ;; aix*) gl_absname_cpp="$ac_cpp -C" ;;
*) gl_absname_cpp="$ac_cpp" ;; *) gl_absname_cpp="$ac_cpp" ;;
esac esac
dnl eval is necessary to expand gl_absname_cpp. dnl eval is necessary to expand gl_absname_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval, dnl Ultrix and Pyramid sh refuse to redirect output of eval,
dnl so use subshell. dnl so use subshell.
AS_VAR_SET([gl_next_header], AS_VAR_SET([gl_next_header],
['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{ sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1# s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
s#^/[^/]#//&# s#^/[^/]#//&#
p p
q q
}'`'"']) }'`'"'])
else else
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
fi fi
AS_VAR_POPDEF([gl_header_exists])]) AS_VAR_POPDEF([gl_header_exists])])
fi fi
AC_SUBST( AC_SUBST(
AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),

View file

@ -27,7 +27,7 @@ AC_DEFUN([gl_LD_VERSION_SCRIPT],
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
cat > conftest.map <<EOF cat > conftest.map <<EOF
VERS_1 { VERS_1 {
global: sym; global: sym;
}; };
VERS_2 { VERS_2 {

View file

@ -59,7 +59,7 @@ if test "$GCC" = yes; then
# Canonicalize the path of ld # Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done done
test -z "$LD" && LD="$ac_prog" test -z "$LD" && LD="$ac_prog"
;; ;;
@ -89,9 +89,9 @@ AC_CACHE_VAL([acl_cv_path_LD],
# Break only if it was the GNU/non-GNU ld that we prefer. # Break only if it was the GNU/non-GNU ld that we prefer.
case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
*GNU* | *'with BFD'*) *GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break ;; test "$with_gnu_ld" != no && break ;;
*) *)
test "$with_gnu_ld" != yes && break ;; test "$with_gnu_ld" != yes && break ;;
esac esac
fi fi
done done

View file

@ -20,30 +20,30 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
[AC_LINK_IFELSE( [AC_LINK_IFELSE(
[_AC_TYPE_LONG_LONG_SNIPPET], [_AC_TYPE_LONG_LONG_SNIPPET],
[dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
dnl If cross compiling, assume the bug isn't important, since dnl If cross compiling, assume the bug isn't important, since
dnl nobody cross compiles for this platform as far as we know. dnl nobody cross compiles for this platform as far as we know.
AC_RUN_IFELSE( AC_RUN_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[@%:@include <limits.h> [[@%:@include <limits.h>
@%:@ifndef LLONG_MAX @%:@ifndef LLONG_MAX
@%:@ define HALF \ @%:@ define HALF \
(1LL << (sizeof (long long int) * CHAR_BIT - 2)) (1LL << (sizeof (long long int) * CHAR_BIT - 2))
@%:@ define LLONG_MAX (HALF - 1 + HALF) @%:@ define LLONG_MAX (HALF - 1 + HALF)
@%:@endif]], @%:@endif]],
[[long long int n = 1; [[long long int n = 1;
int i; int i;
for (i = 0; ; i++) for (i = 0; ; i++)
{ {
long long int m = n << i; long long int m = n << i;
if (m >> i != n) if (m >> i != n)
return 1; return 1;
if (LLONG_MAX / 2 < m) if (LLONG_MAX / 2 < m)
break; break;
} }
return 0;]])], return 0;]])],
[ac_cv_type_long_long_int=yes], [ac_cv_type_long_long_int=yes],
[ac_cv_type_long_long_int=no], [ac_cv_type_long_long_int=no],
[ac_cv_type_long_long_int=yes])], [ac_cv_type_long_long_int=yes])],
[ac_cv_type_long_long_int=no])]) [ac_cv_type_long_long_int=no])])
if test $ac_cv_type_long_long_int = yes; then if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], [1], AC_DEFINE([HAVE_LONG_LONG_INT], [1],
@ -83,24 +83,24 @@ AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
[ [
AC_LANG_PROGRAM( AC_LANG_PROGRAM(
[[/* For now, do not test the preprocessor; as of 2007 there are too many [[/* For now, do not test the preprocessor; as of 2007 there are too many
implementations with broken preprocessors. Perhaps this can implementations with broken preprocessors. Perhaps this can
be revisited in 2012. In the meantime, code should not expect be revisited in 2012. In the meantime, code should not expect
#if to work with literals wider than 32 bits. */ #if to work with literals wider than 32 bits. */
/* Test literals. */ /* Test literals. */
long long int ll = 9223372036854775807ll; long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL; long long int nll = -9223372036854775807LL;
unsigned long long int ull = 18446744073709551615ULL; unsigned long long int ull = 18446744073709551615ULL;
/* Test constant expressions. */ /* Test constant expressions. */
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
? 1 : -1)]; ? 1 : -1)];
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
? 1 : -1)]; ? 1 : -1)];
int i = 63;]], int i = 63;]],
[[/* Test availability of runtime routines for shift and division. */ [[/* Test availability of runtime routines for shift and division. */
long long int llmax = 9223372036854775807ll; long long int llmax = 9223372036854775807ll;
unsigned long long int ullmax = 18446744073709551615ull; unsigned long long int ullmax = 18446744073709551615ull;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
| (llmax / ll) | (llmax % ll) | (llmax / ll) | (llmax % ll)
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
| (ullmax / ull) | (ullmax % ull));]]) | (ullmax / ull) | (ullmax % ull));]])
]) ])

View file

@ -18,17 +18,17 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t], AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
[AC_COMPILE_IFELSE( [AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT[ [AC_INCLUDES_DEFAULT[
# include <wchar.h>]], # include <wchar.h>]],
[[mbstate_t x; return sizeof x;]])], [[mbstate_t x; return sizeof x;]])],
[ac_cv_type_mbstate_t=yes], [ac_cv_type_mbstate_t=yes],
[ac_cv_type_mbstate_t=no])]) [ac_cv_type_mbstate_t=no])])
if test $ac_cv_type_mbstate_t = yes; then if test $ac_cv_type_mbstate_t = yes; then
AC_DEFINE([HAVE_MBSTATE_T], [1], AC_DEFINE([HAVE_MBSTATE_T], [1],
[Define to 1 if <wchar.h> declares mbstate_t.]) [Define to 1 if <wchar.h> declares mbstate_t.])
else else
AC_DEFINE([mbstate_t], [int], AC_DEFINE([mbstate_t], [int],
[Define to a type if <wchar.h> does not define.]) [Define to a type if <wchar.h> does not define.])
fi fi
]) ])

View file

@ -53,11 +53,11 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
{ {
int pagesize = getpagesize (); int pagesize = getpagesize ();
char *two_pages = char *two_pages =
(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
flags, fd, 0); flags, fd, 0);
if (two_pages != (char *)(-1) if (two_pages != (char *)(-1)
&& mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
fence = two_pages + pagesize; fence = two_pages + pagesize;
} }
#endif #endif
if (fence) if (fence)

View file

@ -28,11 +28,11 @@ AC_DEFUN([gl_FUNC_PUTENV],
return 1; return 1;
return 0; return 0;
]])], ]])],
gl_cv_func_svid_putenv=yes, gl_cv_func_svid_putenv=yes,
gl_cv_func_svid_putenv=no, gl_cv_func_svid_putenv=no,
dnl When crosscompiling, assume putenv is broken. dnl When crosscompiling, assume putenv is broken.
gl_cv_func_svid_putenv=no) gl_cv_func_svid_putenv=no)
]) ])
if test $gl_cv_func_svid_putenv = no; then if test $gl_cv_func_svid_putenv = no; then
REPLACE_PUTENV=1 REPLACE_PUTENV=1

View file

@ -20,30 +20,30 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
AC_CHECK_TYPE([socklen_t], , AC_CHECK_TYPE([socklen_t], ,
[AC_MSG_CHECKING([for socklen_t equivalent]) [AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([gl_cv_socklen_t_equiv], AC_CACHE_VAL([gl_cv_socklen_t_equiv],
[# Systems have either "struct sockaddr *" or [# Systems have either "struct sockaddr *" or
# "void *" as the second argument to getpeername # "void *" as the second argument to getpeername
gl_cv_socklen_t_equiv= gl_cv_socklen_t_equiv=
for arg2 in "struct sockaddr" void; do for arg2 in "struct sockaddr" void; do
for t in int size_t "unsigned int" "long int" "unsigned long int"; do for t in int size_t "unsigned int" "long int" "unsigned long int"; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM( AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <sys/types.h> [[#include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
int getpeername (int, $arg2 *, $t *);]], int getpeername (int, $arg2 *, $t *);]],
[[$t len; [[$t len;
getpeername (0, 0, &len);]])], getpeername (0, 0, &len);]])],
[gl_cv_socklen_t_equiv="$t"]) [gl_cv_socklen_t_equiv="$t"])
test "$gl_cv_socklen_t_equiv" != "" && break test "$gl_cv_socklen_t_equiv" != "" && break
done done
test "$gl_cv_socklen_t_equiv" != "" && break test "$gl_cv_socklen_t_equiv" != "" && break
done done
]) ])
if test "$gl_cv_socklen_t_equiv" = ""; then if test "$gl_cv_socklen_t_equiv" = ""; then
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
fi fi
AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
[type to use in place of socklen_t if not defined])], [type to use in place of socklen_t if not defined])],
[#include <sys/types.h> [#include <sys/types.h>
#if HAVE_SYS_SOCKET_H #if HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>

View file

@ -38,77 +38,77 @@ AC_DEFUN([AC_HEADER_STDBOOL],
[AC_CACHE_CHECK([for stdbool.h that conforms to C99], [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
[ac_cv_header_stdbool_h], [ac_cv_header_stdbool_h],
[AC_TRY_COMPILE( [AC_TRY_COMPILE(
[ [
#include <stdbool.h> #include <stdbool.h>
#ifndef bool #ifndef bool
"error: bool is not defined" "error: bool is not defined"
#endif #endif
#ifndef false #ifndef false
"error: false is not defined" "error: false is not defined"
#endif #endif
#if false #if false
"error: false is not 0" "error: false is not 0"
#endif #endif
#ifndef true #ifndef true
"error: true is not defined" "error: true is not defined"
#endif #endif
#if true != 1 #if true != 1
"error: true is not 1" "error: true is not 1"
#endif #endif
#ifndef __bool_true_false_are_defined #ifndef __bool_true_false_are_defined
"error: __bool_true_false_are_defined is not defined" "error: __bool_true_false_are_defined is not defined"
#endif #endif
struct s { _Bool s: 1; _Bool t; } s; struct s { _Bool s: 1; _Bool t; } s;
char a[true == 1 ? 1 : -1]; char a[true == 1 ? 1 : -1];
char b[false == 0 ? 1 : -1]; char b[false == 0 ? 1 : -1];
char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1];
char d[(bool) 0.5 == true ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1];
bool e = &s; bool e = &s;
char f[(_Bool) 0.0 == false ? 1 : -1]; char f[(_Bool) 0.0 == false ? 1 : -1];
char g[true]; char g[true];
char h[sizeof (_Bool)]; char h[sizeof (_Bool)];
char i[sizeof s.t]; char i[sizeof s.t];
enum { j = false, k = true, l = false * true, m = true * 256 }; enum { j = false, k = true, l = false * true, m = true * 256 };
_Bool n[m]; _Bool n[m];
char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char o[sizeof n == m * sizeof n[0] ? 1 : -1];
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
#if defined __xlc__ || defined __GNUC__ #if defined __xlc__ || defined __GNUC__
/* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
reported by James Lemley on 2005-10-05; see reported by James Lemley on 2005-10-05; see
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
This test is not quite right, since xlc is allowed to This test is not quite right, since xlc is allowed to
reject this program, as the initializer for xlcbug is reject this program, as the initializer for xlcbug is
not one of the forms that C requires support for. not one of the forms that C requires support for.
However, doing the test right would require a run-time However, doing the test right would require a run-time
test, and that would make cross-compilation harder. test, and that would make cross-compilation harder.
Let us hope that IBM fixes the xlc bug, and also adds Let us hope that IBM fixes the xlc bug, and also adds
support for this kind of constant expression. In the support for this kind of constant expression. In the
meantime, this test will reject xlc, which is OK, since meantime, this test will reject xlc, which is OK, since
our stdbool.h substitute should suffice. We also test our stdbool.h substitute should suffice. We also test
this with GCC, where it should work, to detect more this with GCC, where it should work, to detect more
quickly whether someone messes up the test in the quickly whether someone messes up the test in the
future. */ future. */
char digs[] = "0123456789"; char digs[] = "0123456789";
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
#endif #endif
/* Catch a bug in an HP-UX C compiler. See /* Catch a bug in an HP-UX C compiler. See
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
*/ */
_Bool q = true; _Bool q = true;
_Bool *pq = &q; _Bool *pq = &q;
], ],
[ [
*pq |= q; *pq |= q;
*pq |= ! q; *pq |= ! q;
/* Refer to every declared value, to avoid compiler optimizations. */ /* Refer to every declared value, to avoid compiler optimizations. */
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ !m + !n + !o + !p + !q + !pq); + !m + !n + !o + !p + !q + !pq);
], ],
[ac_cv_header_stdbool_h=yes], [ac_cv_header_stdbool_h=yes],
[ac_cv_header_stdbool_h=no])]) [ac_cv_header_stdbool_h=no])])
AC_CHECK_TYPES([_Bool]) AC_CHECK_TYPES([_Bool])
if test $ac_cv_header_stdbool_h = yes; then if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.]) AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])

View file

@ -396,12 +396,12 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
case $glsuf in case $glsuf in
'') gltype1='int';; '') gltype1='int';;
l) gltype1='long int';; l) gltype1='long int';;
ll) gltype1='long long int';; ll) gltype1='long long int';;
i64) gltype1='__int64';; i64) gltype1='__int64';;
u) gltype1='unsigned int';; u) gltype1='unsigned int';;
ul) gltype1='unsigned long int';; ul) gltype1='unsigned long int';;
ull) gltype1='unsigned long long int';; ull) gltype1='unsigned long long int';;
ui64)gltype1='unsigned __int64';; ui64)gltype1='unsigned __int64';;
esac esac
AC_COMPILE_IFELSE( AC_COMPILE_IFELSE(

View file

@ -140,6 +140,6 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
choke me choke me
# endif # endif
#endif]])], #endif]])],
[gl_cv_var_stdin_large_offset=yes], [gl_cv_var_stdin_large_offset=yes],
[gl_cv_var_stdin_large_offset=no])]) [gl_cv_var_stdin_large_offset=no])])
]) ])

View file

@ -66,31 +66,31 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
dnl Assume proper GNU behavior unless another module says otherwise. dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR]) HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
]) ])

View file

@ -45,9 +45,9 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
[gl_cv_sys_struct_timespec_in_time_h], [gl_cv_sys_struct_timespec_in_time_h],
[AC_COMPILE_IFELSE( [AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[#include <time.h> [[#include <time.h>
]], ]],
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])], [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
[gl_cv_sys_struct_timespec_in_time_h=yes], [gl_cv_sys_struct_timespec_in_time_h=yes],
[gl_cv_sys_struct_timespec_in_time_h=no])]) [gl_cv_sys_struct_timespec_in_time_h=no])])
@ -59,12 +59,12 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
AC_CACHE_CHECK([for struct timespec in <sys/time.h>], AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
[gl_cv_sys_struct_timespec_in_sys_time_h], [gl_cv_sys_struct_timespec_in_sys_time_h],
[AC_COMPILE_IFELSE( [AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[#include <sys/time.h> [[#include <sys/time.h>
]], ]],
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])], [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
[gl_cv_sys_struct_timespec_in_sys_time_h=yes], [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
[gl_cv_sys_struct_timespec_in_sys_time_h=no])]) [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
fi fi

View file

@ -56,6 +56,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT]) GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
@ -87,6 +88,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_LINK=1; AC_SUBST([HAVE_LINK]) HAVE_LINK=1; AC_SUBST([HAVE_LINK])
HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
@ -111,6 +113,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])

View file

@ -11,8 +11,8 @@ m4_define([gl_VERSION_ETC_FLAG],
AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1], [$2])], AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1], [$2])],
[dnl [dnl
case $withval in case $withval in
yes|no) ;; yes|no) ;;
*) AC_DEFINE_UNQUOTED(AS_TR_CPP([PACKAGE_$1]), ["$withval"], [$2]) ;; *) AC_DEFINE_UNQUOTED(AS_TR_CPP([PACKAGE_$1]), ["$withval"], [$2]) ;;
esac esac
]) ])
]) ])
@ -20,11 +20,11 @@ m4_define([gl_VERSION_ETC_FLAG],
AC_DEFUN([gl_VERSION_ETC], AC_DEFUN([gl_VERSION_ETC],
[dnl [dnl
gl_VERSION_ETC_FLAG([packager], gl_VERSION_ETC_FLAG([packager],
[String identifying the packager of this software]) [String identifying the packager of this software])
gl_VERSION_ETC_FLAG([packager-version], gl_VERSION_ETC_FLAG([packager-version],
[Packager-specific version information]) [Packager-specific version information])
gl_VERSION_ETC_FLAG([packager-bug-reports], gl_VERSION_ETC_FLAG([packager-bug-reports],
[Packager info for bug reports (URL/e-mail/...)]) [Packager info for bug reports (URL/e-mail/...)])
if test "X$with_packager" = "X" && \ if test "X$with_packager" = "X" && \
test "X$with_packager_version$with_packager_bug_reports" != "X" test "X$with_packager_version$with_packager_bug_reports" != "X"
then then

View file

@ -33,7 +33,7 @@ AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
CPPFLAGS="${CPPFLAGS} $1" CPPFLAGS="${CPPFLAGS} $1"
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])], AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
[AS_VAR_SET([gl_Warn], [yes])], [AS_VAR_SET([gl_Warn], [yes])],
[AS_VAR_SET([gl_Warn], [no])]) [AS_VAR_SET([gl_Warn], [no])])
CPPFLAGS="$save_CPPFLAGS" CPPFLAGS="$save_CPPFLAGS"
]) ])
AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl

View file

@ -77,6 +77,11 @@ else
url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE) url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
endif endif
# Override this in cfg.mk if you are using a different format in your
# NEWS file.
today = $(shell date +%Y-%m-%d)
news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
# Prevent programs like 'sort' from considering distinct strings to be equal. # Prevent programs like 'sort' from considering distinct strings to be equal.
# Doing it here saves us from having to set LC_ALL elsewhere in this file. # Doing it here saves us from having to set LC_ALL elsewhere in this file.
export LC_ALL = C export LC_ALL = C
@ -568,13 +573,12 @@ sc_makefile_check:
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \ $$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
news-date-check: NEWS news-check: NEWS
today=`date +%Y-%m-%d`; \ if head $(srcdir)/NEWS | grep -E $(news-check-regexp) \
if head $(srcdir)/NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
>/dev/null; then \ >/dev/null; then \
:; \ :; \
else \ else \
echo "version or today's date is not in NEWS" 1>&2; \ echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
exit 1; \ exit 1; \
fi fi
@ -678,17 +682,6 @@ vc-diff-check:
rm vc-diffs; \ rm vc-diffs; \
fi fi
# Use this to make sure we don't run these programs when building
# from a virgin tgz file, below.
null_AM_MAKEFLAGS = \
ACLOCAL=false \
AUTOCONF=false \
AUTOMAKE=false \
AUTOHEADER=false \
MAKEINFO=false
built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
rel-files = $(DIST_ARCHIVES) rel-files = $(DIST_ARCHIVES)
gnulib_dir ?= $(srcdir)/gnulib gnulib_dir ?= $(srcdir)/gnulib
@ -754,15 +747,24 @@ alpha beta stable: $(local-check) writable-files no-submodule-changes
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|| : || :
$(MAKE) vc-diff-check $(MAKE) vc-diff-check
$(MAKE) news-date-check $(MAKE) news-check
$(MAKE) distcheck $(MAKE) distcheck
$(MAKE) dist XZ_OPT=-9ev $(MAKE) dist XZ_OPT=-9ev
$(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir) $(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
# Override this in cfg.mk if you follow different procedures.
release-prep-hook ?= release-prep
.PHONY: release-prep
release-prep:
case $$RELEASE_TYPE in alpha|beta|stable) ;; \
*) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
$(MAKE) -s announcement > /tmp/announce-$(my_distdir)
if test -d $(release_archive_dir); then \ if test -d $(release_archive_dir); then \
ln $(rel-files) $(release_archive_dir); \ ln $(rel-files) $(release_archive_dir); \
chmod a-w $(rel-files); \ chmod a-w $(rel-files); \
fi fi
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
echo $(VERSION) > $(prev_version_file) echo $(VERSION) > $(prev_version_file)
$(MAKE) update-NEWS-hash $(MAKE) update-NEWS-hash
perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS