summaryrefslogtreecommitdiff
path: root/lib/gl
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2010-01-26 15:39:52 +0100
committerSimon Josefsson <simon@josefsson.org>2010-01-26 15:39:52 +0100
commitd8d94c27e1c30a7a09fbfa77bdfd995e2307a7f6 (patch)
tree0b1ee6da324163860b2a2ea7a23c8946a59031ac /lib/gl
parentba4d206c53fdd9f6c1b19c2ae571054b5765c5f2 (diff)
downloadgnutls-d8d94c27e1c30a7a09fbfa77bdfd995e2307a7f6.tar.gz
Update gnulib files.
Diffstat (limited to 'lib/gl')
-rw-r--r--lib/gl/Makefile.am125
-rw-r--r--lib/gl/alignof.h2
-rw-r--r--lib/gl/alloca.in.h4
-rw-r--r--lib/gl/asnprintf.c2
-rw-r--r--lib/gl/asprintf.c3
-rw-r--r--lib/gl/byteswap.in.h24
-rw-r--r--lib/gl/c-ctype.c2
-rw-r--r--lib/gl/c-ctype.h2
-rw-r--r--lib/gl/close-hook.c4
-rw-r--r--lib/gl/close-hook.h2
-rw-r--r--lib/gl/errno.in.h2
-rw-r--r--lib/gl/float+.h2
-rw-r--r--lib/gl/float.in.h2
-rw-r--r--lib/gl/fseeko.c53
-rw-r--r--lib/gl/gettext.h13
-rw-r--r--lib/gl/lseek.c2
-rw-r--r--lib/gl/m4/00gnulib.m42
-rw-r--r--lib/gl/m4/alloca.m43
-rw-r--r--lib/gl/m4/byteswap.m42
-rw-r--r--lib/gl/m4/codeset.m42
-rw-r--r--lib/gl/m4/errno_h.m42
-rw-r--r--lib/gl/m4/extensions.m422
-rw-r--r--lib/gl/m4/float_h.m42
-rw-r--r--lib/gl/m4/fseeko.m412
-rw-r--r--lib/gl/m4/func.m42
-rw-r--r--lib/gl/m4/gettext.m42
-rw-r--r--lib/gl/m4/glibc2.m410
-rw-r--r--lib/gl/m4/glibc21.m410
-rw-r--r--lib/gl/m4/gnulib-cache.m42
-rw-r--r--lib/gl/m4/gnulib-common.m435
-rw-r--r--lib/gl/m4/gnulib-comp.m412
-rw-r--r--lib/gl/m4/gnulib-tool.m42
-rw-r--r--lib/gl/m4/iconv.m425
-rw-r--r--lib/gl/m4/include_next.m480
-rw-r--r--lib/gl/m4/intdiv0.m42
-rw-r--r--lib/gl/m4/intl.m42
-rw-r--r--lib/gl/m4/intldir.m42
-rw-r--r--lib/gl/m4/intlmacosx.m42
-rw-r--r--lib/gl/m4/intmax.m42
-rw-r--r--lib/gl/m4/intmax_t.m43
-rw-r--r--lib/gl/m4/inttypes-pri.m42
-rw-r--r--lib/gl/m4/inttypes_h.m42
-rw-r--r--lib/gl/m4/lcmessage.m43
-rw-r--r--lib/gl/m4/ld-output-def.m42
-rw-r--r--lib/gl/m4/ld-version-script.m44
-rw-r--r--lib/gl/m4/lib-ld.m48
-rw-r--r--lib/gl/m4/lib-link.m42
-rw-r--r--lib/gl/m4/lib-prefix.m42
-rw-r--r--lib/gl/m4/lock.m42
-rw-r--r--lib/gl/m4/longlong.m466
-rw-r--r--lib/gl/m4/lseek.m422
-rw-r--r--lib/gl/m4/malloc.m42
-rw-r--r--lib/gl/m4/memchr.m410
-rw-r--r--lib/gl/m4/memmem.m431
-rw-r--r--lib/gl/m4/minmax.m42
-rw-r--r--lib/gl/m4/mmap-anon.m42
-rw-r--r--lib/gl/m4/multiarch.m42
-rw-r--r--lib/gl/m4/netdb_h.m45
-rw-r--r--lib/gl/m4/nls.m43
-rw-r--r--lib/gl/m4/po.m42
-rw-r--r--lib/gl/m4/printf-posix.m42
-rw-r--r--lib/gl/m4/printf.m42
-rw-r--r--lib/gl/m4/progtest.m42
-rw-r--r--lib/gl/m4/read-file.m43
-rw-r--r--lib/gl/m4/realloc.m42
-rw-r--r--lib/gl/m4/size_max.m42
-rw-r--r--lib/gl/m4/snprintf.m42
-rw-r--r--lib/gl/m4/sockets.m42
-rw-r--r--lib/gl/m4/socklen.m428
-rw-r--r--lib/gl/m4/sockpfaf.m42
-rw-r--r--lib/gl/m4/stdbool.m4140
-rw-r--r--lib/gl/m4/stddef_h.m42
-rw-r--r--lib/gl/m4/stdint.m414
-rw-r--r--lib/gl/m4/stdint_h.m42
-rw-r--r--lib/gl/m4/stdio_h.m418
-rw-r--r--lib/gl/m4/stdlib_h.m421
-rw-r--r--lib/gl/m4/strcase.m42
-rw-r--r--lib/gl/m4/string_h.m468
-rw-r--r--lib/gl/m4/strings_h.m48
-rw-r--r--lib/gl/m4/strverscmp.m42
-rw-r--r--lib/gl/m4/sys_socket_h.m416
-rw-r--r--lib/gl/m4/sys_stat_h.m49
-rw-r--r--lib/gl/m4/threadlib.m42
-rw-r--r--lib/gl/m4/time_h.m420
-rw-r--r--lib/gl/m4/time_r.m43
-rw-r--r--lib/gl/m4/uintmax_t.m42
-rw-r--r--lib/gl/m4/ungetc.m432
-rw-r--r--lib/gl/m4/unistd_h.m432
-rw-r--r--lib/gl/m4/vasnprintf.m42
-rw-r--r--lib/gl/m4/vasprintf.m43
-rw-r--r--lib/gl/m4/visibility.m42
-rw-r--r--lib/gl/m4/vsnprintf.m42
-rw-r--r--lib/gl/m4/wchar.m4103
-rw-r--r--lib/gl/m4/wchar_t.m42
-rw-r--r--lib/gl/m4/wint_t.m42
-rw-r--r--lib/gl/m4/xsize.m42
-rw-r--r--lib/gl/memchr.c26
-rw-r--r--lib/gl/memmem.c10
-rw-r--r--lib/gl/minmax.h3
-rw-r--r--lib/gl/netdb.in.h88
-rw-r--r--lib/gl/override/lib/gettext.h.diff24
-rw-r--r--lib/gl/printf-args.c211
-rw-r--r--lib/gl/printf-args.h55
-rw-r--r--lib/gl/printf-parse.c940
-rw-r--r--lib/gl/printf-parse.h21
-rw-r--r--lib/gl/read-file.c52
-rw-r--r--lib/gl/read-file.h2
-rw-r--r--lib/gl/realloc.c5
-rw-r--r--lib/gl/size_max.h2
-rw-r--r--lib/gl/snprintf.c12
-rw-r--r--lib/gl/sockets.c36
-rw-r--r--lib/gl/sockets.h2
-rw-r--r--lib/gl/stdbool.in.h2
-rw-r--r--lib/gl/stddef.in.h2
-rw-r--r--lib/gl/stdint.in.h10
-rw-r--r--lib/gl/stdio-impl.h44
-rw-r--r--lib/gl/stdio-write.c42
-rw-r--r--lib/gl/stdio.in.h475
-rw-r--r--lib/gl/stdlib.in.h282
-rw-r--r--lib/gl/str-two-way.h362
-rw-r--r--lib/gl/strcasecmp.c4
-rw-r--r--lib/gl/string.in.h348
-rw-r--r--lib/gl/strings.in.h43
-rw-r--r--lib/gl/strncasecmp.c4
-rw-r--r--lib/gl/strverscmp.c7
-rw-r--r--lib/gl/sys_socket.in.h192
-rw-r--r--lib/gl/sys_stat.in.h136
-rw-r--r--lib/gl/tests/Makefile.am91
-rw-r--r--lib/gl/tests/dummy.c2
-rw-r--r--lib/gl/tests/intprops.h14
-rw-r--r--lib/gl/tests/test-alloca-opt.c2
-rw-r--r--lib/gl/tests/test-byteswap.c17
-rw-r--r--lib/gl/tests/test-c-ctype.c636
-rw-r--r--lib/gl/tests/test-errno.c2
-rw-r--r--lib/gl/tests/test-fseeko.c28
-rw-r--r--lib/gl/tests/test-func.c20
-rw-r--r--lib/gl/tests/test-memchr.c65
-rw-r--r--lib/gl/tests/test-netdb.c2
-rw-r--r--lib/gl/tests/test-read-file.c70
-rw-r--r--lib/gl/tests/test-snprintf.c46
-rw-r--r--lib/gl/tests/test-stdbool.c2
-rw-r--r--lib/gl/tests/test-stddef.c2
-rw-r--r--lib/gl/tests/test-stdint.c2
-rw-r--r--lib/gl/tests/test-stdio.c9
-rw-r--r--lib/gl/tests/test-stdlib.c2
-rw-r--r--lib/gl/tests/test-string.c2
-rw-r--r--lib/gl/tests/test-strings.c2
-rw-r--r--lib/gl/tests/test-strverscmp.c20
-rw-r--r--lib/gl/tests/test-sys_socket.c2
-rw-r--r--lib/gl/tests/test-sys_stat.c2
-rw-r--r--lib/gl/tests/test-time.c2
-rw-r--r--lib/gl/tests/test-unistd.c2
-rw-r--r--lib/gl/tests/test-vasnprintf.c23
-rw-r--r--lib/gl/tests/test-vasprintf.c18
-rw-r--r--lib/gl/tests/test-vsnprintf.c46
-rw-r--r--lib/gl/tests/test-wchar.c2
-rw-r--r--lib/gl/tests/verify.h6
-rw-r--r--lib/gl/tests/zerosize-ptr.h10
-rw-r--r--lib/gl/time.in.h27
-rw-r--r--lib/gl/time_r.c2
-rw-r--r--lib/gl/unistd.in.h482
-rw-r--r--lib/gl/vasnprintf.c8060
-rw-r--r--lib/gl/vasnprintf.h17
-rw-r--r--lib/gl/vasprintf.c2
-rw-r--r--lib/gl/vsnprintf.c12
-rw-r--r--lib/gl/w32sock.h3
-rw-r--r--lib/gl/wchar.in.h121
-rw-r--r--lib/gl/xsize.h2
168 files changed, 7486 insertions, 7049 deletions
diff --git a/lib/gl/Makefile.am b/lib/gl/Makefile.am
index 090f724774..8bb9f26f79 100644
--- a/lib/gl/Makefile.am
+++ b/lib/gl/Makefile.am
@@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2009 Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
@@ -64,6 +64,30 @@ EXTRA_DIST += alloca.in.h
## end gnulib module alloca-opt
+## begin gnulib module arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+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 byteswap
BUILT_SOURCES += $(BYTESWAP_H)
@@ -182,14 +206,6 @@ EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
## end gnulib module havelib
-## begin gnulib module link-warning
-
-LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
-
-EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
-
-## end gnulib module link-warning
-
## begin gnulib module lseek
@@ -229,7 +245,7 @@ BUILT_SOURCES += $(NETDB_H)
# We need the following in order to create <netdb.h> when the system
# doesn't have one that works with the given compiler.
-netdb.h: netdb.in.h
+netdb.h: netdb.in.h $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -242,6 +258,7 @@ netdb.h: netdb.in.h
-e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
-e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
-e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/netdb.in.h; \
} > $@-t && \
mv $@-t $@
@@ -381,7 +398,7 @@ BUILT_SOURCES += stdio.h
# We need the following in order to create <stdio.h> when the system
# doesn't have one that works with the given compiler.
-stdio.h: stdio.in.h
+stdio.h: stdio.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -427,7 +444,8 @@ stdio.h: stdio.in.h
-e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
-e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
-e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
- -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
+ < $(srcdir)/stdio.in.h | \
+ sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
-e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
-e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
-e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
@@ -465,8 +483,8 @@ stdio.h: stdio.in.h
-e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
-e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
- < $(srcdir)/stdio.in.h; \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += stdio.h stdio.h-t
@@ -483,7 +501,7 @@ BUILT_SOURCES += stdlib.h
# We need the following in order to create <stdlib.h> when the system
# doesn't have one that works with the given compiler.
-stdlib.h: stdlib.in.h
+stdlib.h: stdlib.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -536,9 +554,11 @@ stdlib.h: stdlib.in.h
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
+ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
- -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/stdlib.in.h; \
} > $@-t && \
mv $@-t $@
@@ -563,7 +583,7 @@ BUILT_SOURCES += string.h
# We need the following in order to create <string.h> when the system
# doesn't have one that works with the given compiler.
-string.h: string.in.h
+string.h: string.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -602,6 +622,8 @@ string.h: string.in.h
-e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
-e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
-e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
+ < $(srcdir)/string.in.h | \
+ sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
-e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
-e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
-e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
@@ -629,7 +651,8 @@ string.h: string.in.h
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_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_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
< $(srcdir)/string.in.h; \
} > $@-t && \
mv $@-t $@
@@ -645,7 +668,7 @@ BUILT_SOURCES += strings.h
# We need the following in order to create <strings.h> when the system
# doesn't have one that works with the given compiler.
-strings.h: strings.in.h
+strings.h: strings.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -653,7 +676,8 @@ strings.h: strings.in.h
-e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/strings.in.h; \
} > $@-t && \
mv $@-t $@
@@ -674,11 +698,11 @@ EXTRA_liblgnu_la_SOURCES += strverscmp.c
## begin gnulib module sys_socket
-BUILT_SOURCES += $(SYS_SOCKET_H)
+BUILT_SOURCES += sys/socket.h
# We need the following in order to create <sys/socket.h> when the system
# doesn't have one that works with the given compiler.
-sys/socket.h: sys_socket.in.h
+sys/socket.h: sys_socket.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -707,7 +731,8 @@ sys/socket.h: sys_socket.in.h
-e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
-e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
-e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/sys_socket.in.h; \
} > $@-t && \
mv -f $@-t $@
@@ -724,7 +749,7 @@ BUILT_SOURCES += sys/stat.h
# We need the following in order to create <sys/stat.h> when the system
# has one that is incomplete.
-sys/stat.h: sys_stat.in.h
+sys/stat.h: sys_stat.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -763,7 +788,8 @@ sys/stat.h: sys_stat.in.h
-e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
-e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/sys_stat.in.h; \
} > $@-t && \
mv $@-t $@
@@ -780,7 +806,7 @@ BUILT_SOURCES += time.h
# We need the following in order to create <time.h> when the system
# 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 $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -793,6 +819,7 @@ time.h: time.in.h
-e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|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 '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/time.in.h; \
} > $@-t && \
mv $@-t $@
@@ -817,7 +844,7 @@ BUILT_SOURCES += unistd.h
# We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one.
-unistd.h: unistd.in.h
+unistd.h: unistd.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@@ -840,6 +867,7 @@ unistd.h: unistd.in.h
-e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
-e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \
-e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
+ -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \
-e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
-e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
-e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
@@ -848,6 +876,7 @@ unistd.h: unistd.in.h
-e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
-e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|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_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
-e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
@@ -858,8 +887,10 @@ unistd.h: unistd.in.h
-e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
-e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
-e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
+ -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \
-e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
- -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
+ < $(srcdir)/unistd.in.h | \
+ sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
-e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
-e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
-e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
@@ -871,18 +902,21 @@ unistd.h: unistd.in.h
-e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
-e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
-e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
+ -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
-e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
-e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
-e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
-e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|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_READLINKAT''@|$(HAVE_READLINKAT)|g' \
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
-e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
-e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
-e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
+ -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
@@ -900,16 +934,19 @@ unistd.h: unistd.in.h
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
-e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|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_RMDIR''@|$(REPLACE_RMDIR)|g' \
+ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
-e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
+ -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
-e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|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 '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
- < $(srcdir)/unistd.in.h; \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += unistd.h unistd.h-t
@@ -945,13 +982,32 @@ EXTRA_liblgnu_la_SOURCES += vsnprintf.c
## end gnulib module vsnprintf
+## begin gnulib module warn-on-use
+
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ sed -n -e '/^.ifndef/,$$p' \
+ < $(top_srcdir)/build-aux/warn-on-use.h \
+ > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+EXTRA_DIST += $(top_srcdir)/build-aux/warn-on-use.h
+
+## end gnulib module warn-on-use
+
## begin gnulib module wchar
-BUILT_SOURCES += $(WCHAR_H)
+BUILT_SOURCES += wchar.h
# We need the following in order to create <wchar.h> when the system
# version does not work standalone.
-wchar.h: wchar.in.h
+wchar.h: wchar.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -993,7 +1049,8 @@ wchar.h: wchar.in.h
-e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
-e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/wchar.in.h; \
} > $@-t && \
mv $@-t $@
diff --git a/lib/gl/alignof.h b/lib/gl/alignof.h
index e492dbc035..d65dd648b2 100644
--- a/lib/gl/alignof.h
+++ b/lib/gl/alignof.h
@@ -1,5 +1,5 @@
/* Determine alignment of types.
- Copyright (C) 2003-2004, 2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2006, 2009-2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/alloca.in.h b/lib/gl/alloca.in.h
index 38b20c3973..cdb7366cdf 100644
--- a/lib/gl/alloca.in.h
+++ b/lib/gl/alloca.in.h
@@ -1,7 +1,7 @@
/* Memory allocation on the stack.
- Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
- Foundation, Inc.
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
+ Inc.
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
diff --git a/lib/gl/asnprintf.c b/lib/gl/asnprintf.c
index bf989a89a2..75f519bc34 100644
--- a/lib/gl/asnprintf.c
+++ b/lib/gl/asnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009, 2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/asprintf.c b/lib/gl/asprintf.c
index 2df1d4b0ec..5e74dd0daa 100644
--- a/lib/gl/asprintf.c
+++ b/lib/gl/asprintf.c
@@ -1,5 +1,6 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation,
+ Inc.
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
diff --git a/lib/gl/byteswap.in.h b/lib/gl/byteswap.in.h
index fd63ce1756..f245fbdc49 100644
--- a/lib/gl/byteswap.in.h
+++ b/lib/gl/byteswap.in.h
@@ -1,5 +1,5 @@
/* byteswap.h - Byte swapping
- Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
This program is free software: you can redistribute it and/or modify
@@ -21,24 +21,24 @@
/* Given an unsigned 16-bit argument X, return the value corresponding to
X with reversed byte order. */
#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
X with reversed byte order. */
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
- (((x) & 0x0000FF00) << 8) | \
- (((x) & 0x00FF0000) >> 8) | \
- (((x) & 0xFF000000) >> 24))
+ (((x) & 0x0000FF00) << 8) | \
+ (((x) & 0x00FF0000) >> 8) | \
+ (((x) & 0xFF000000) >> 24))
/* Given an unsigned 64-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
- (((x) & 0x000000000000FF00ULL) << 40) | \
- (((x) & 0x0000000000FF0000ULL) << 24) | \
- (((x) & 0x00000000FF000000ULL) << 8) | \
- (((x) & 0x000000FF00000000ULL) >> 8) | \
- (((x) & 0x0000FF0000000000ULL) >> 24) | \
- (((x) & 0x00FF000000000000ULL) >> 40) | \
- (((x) & 0xFF00000000000000ULL) >> 56))
+ (((x) & 0x000000000000FF00ULL) << 40) | \
+ (((x) & 0x0000000000FF0000ULL) << 24) | \
+ (((x) & 0x00000000FF000000ULL) << 8) | \
+ (((x) & 0x000000FF00000000ULL) >> 8) | \
+ (((x) & 0x0000FF0000000000ULL) >> 24) | \
+ (((x) & 0x00FF000000000000ULL) >> 40) | \
+ (((x) & 0xFF00000000000000ULL) >> 56))
#endif /* _GL_BYTESWAP_H */
diff --git a/lib/gl/c-ctype.c b/lib/gl/c-ctype.c
index 1c685c549d..9da8e58131 100644
--- a/lib/gl/c-ctype.c
+++ b/lib/gl/c-ctype.c
@@ -1,6 +1,6 @@
/* Character handling in C locale.
- Copyright 2000-2003, 2006 Free Software Foundation, Inc.
+ Copyright 2000-2003, 2006, 2009-2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/c-ctype.h b/lib/gl/c-ctype.h
index 2bce9d105c..5ac5dd25e7 100644
--- a/lib/gl/c-ctype.h
+++ b/lib/gl/c-ctype.h
@@ -5,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
- Copyright (C) 2000-2003, 2006, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2006, 2008-2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/close-hook.c b/lib/gl/close-hook.c
index 045dcf7210..34ef8763db 100644
--- a/lib/gl/close-hook.c
+++ b/lib/gl/close-hook.c
@@ -1,5 +1,5 @@
/* Hook for making the close() function extensible.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
@@ -66,7 +66,7 @@ register_close_hook (close_hook_fn hook, struct close_hook *link)
{
/* The link is already in use. */
if (link->private_fn != hook)
- abort ();
+ abort ();
}
}
diff --git a/lib/gl/close-hook.h b/lib/gl/close-hook.h
index 483d69c8da..cda7742ee0 100644
--- a/lib/gl/close-hook.h
+++ b/lib/gl/close-hook.h
@@ -1,5 +1,5 @@
/* Hook for making the close() function extensible.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/errno.in.h b/lib/gl/errno.in.h
index f87c55d293..579348cc3b 100644
--- a/lib/gl/errno.in.h
+++ b/lib/gl/errno.in.h
@@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
- Copyright (C) 2008-2009 Free Software Foundation, Inc.
+ Copyright (C) 2008-2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/float+.h b/lib/gl/float+.h
index f0c0c18966..3167ebf121 100644
--- a/lib/gl/float+.h
+++ b/lib/gl/float+.h
@@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/gl/float.in.h b/lib/gl/float.in.h
index 1600d05afc..dc1f6ce6db 100644
--- a/lib/gl/float.in.h
+++ b/lib/gl/float.in.h
@@ -1,6 +1,6 @@
/* A correct <float.h>.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/fseeko.c b/lib/gl/fseeko.c
index f9550a1695..cca32a56d9 100644
--- a/lib/gl/fseeko.c
+++ b/lib/gl/fseeko.c
@@ -1,5 +1,5 @@
/* An fseeko() function that, together with fflush(), is POSIX compliant.
- Copyright (C) 2007-2009 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
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
@@ -50,10 +50,10 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
if ((fp->_flags & __SL64) == 0)
{
/* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
- mode; but has an fseeko that requires 64-bit mode. */
+ mode; but has an fseeko that requires 64-bit mode. */
FILE *tmp = fopen ("/dev/null", "r");
if (!tmp)
- return -1;
+ return -1;
fp->_flags |= __SL64;
fp->_seek64 = tmp->_seek64;
fclose (tmp);
@@ -62,8 +62,8 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
if (fp_->_p == fp_->_bf._base
&& fp_->_r == 0
&& fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
- ? fp_->_bf._size
- : 0)
+ ? fp_->_bf._size
+ : 0)
&& fp_ub._base == NULL)
#elif defined __EMX__ /* emx+gcc */
if (fp->_ptr == fp->_buffer
@@ -77,7 +77,7 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
if (((fp->__modeflags & __FLAG_WRITING) == 0
|| fp->__bufpos == fp->__bufstart)
&& ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
- || fp->__bufpos == fp->__bufread))
+ || fp->__bufpos == fp->__bufread))
#elif defined __QNX__ /* QNX */
if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
&& fp->_Rback == fp->_Back + sizeof (fp->_Back)
@@ -92,25 +92,42 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
#endif
{
/* We get here when an fflush() call immediately preceded this one. We
- know there are no buffers.
- POSIX requires us to modify the file descriptor's position.
- But we cannot position beyond end of file here. */
+ know there are no buffers.
+ POSIX requires us to modify the file descriptor's position.
+ But we cannot position beyond end of file here. */
off_t pos =
- lseek (fileno (fp),
- whence == SEEK_END && offset > 0 ? 0 : offset,
- whence);
+ lseek (fileno (fp),
+ whence == SEEK_END && offset > 0 ? 0 : offset,
+ whence);
if (pos == -1)
- {
+ {
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
- fp_->_flags &= ~__SOFF;
+ fp_->_flags &= ~__SOFF;
#endif
- return -1;
- }
+ return -1;
+ }
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags &= ~_IO_EOF_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
+# if defined __CYGWIN__
+ /* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
+# else
+ /* fp_->_offset is an fpos_t. */
+ {
+ /* Use a union, since on NetBSD, the compilation flags
+ determine whether fpos_t is typedef'd to off_t or a struct
+ containing a single off_t member. */
+ union
+ {
+ fpos_t f;
+ off_t o;
+ } u;
+ u.o = pos;
+ fp_->_offset = u.f;
+ }
+# endif
fp_->_flags |= __SOFF;
fp_->_flags &= ~__SEOF;
#elif defined __EMX__ /* emx+gcc */
@@ -122,9 +139,9 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
fp->__eof = 0;
#endif
/* If we were not requested to position beyond end of file, we're
- done. */
+ done. */
if (!(whence == SEEK_END && offset > 0))
- return 0;
+ return 0;
}
return fseeko (fp, offset, whence);
}
diff --git a/lib/gl/gettext.h b/lib/gl/gettext.h
index 56d4a21302..7dfb7233f2 100644
--- a/lib/gl/gettext.h
+++ b/lib/gl/gettext.h
@@ -1,5 +1,6 @@
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software
+ Foundation, Inc.
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
@@ -140,8 +141,8 @@ inline
#endif
static const char *
pgettext_aux (const char *domain,
- const char *msg_ctxt_id, const char *msgid,
- int category)
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
{
const char *translation = dcgettext (domain, msg_ctxt_id, category);
if (translation == msg_ctxt_id)
@@ -159,9 +160,9 @@ inline
#endif
static const char *
npgettext_aux (const char *domain,
- const char *msg_ctxt_id, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
{
const char *translation =
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
diff --git a/lib/gl/lseek.c b/lib/gl/lseek.c
index feec8310bd..601efa357f 100644
--- a/lib/gl/lseek.c
+++ b/lib/gl/lseek.c
@@ -1,5 +1,5 @@
/* An lseek() function that detects pipes.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/m4/00gnulib.m4 b/lib/gl/m4/00gnulib.m4
index d4d04d1530..301469b31c 100644
--- a/lib/gl/m4/00gnulib.m4
+++ b/lib/gl/m4/00gnulib.m4
@@ -1,5 +1,5 @@
# 00gnulib.m4 serial 2
-dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/alloca.m4 b/lib/gl/m4/alloca.m4
index 4b978e137c..f3ee34380c 100644
--- a/lib/gl/m4/alloca.m4
+++ b/lib/gl/m4/alloca.m4
@@ -1,5 +1,6 @@
# alloca.m4 serial 9
-dnl Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation,
+dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/byteswap.m4 b/lib/gl/m4/byteswap.m4
index ad13f22867..2afd6a2a4e 100644
--- a/lib/gl/m4/byteswap.m4
+++ b/lib/gl/m4/byteswap.m4
@@ -1,5 +1,5 @@
# byteswap.m4 serial 3
-dnl Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/codeset.m4 b/lib/gl/m4/codeset.m4
index 413217bd4a..a53c04260c 100644
--- a/lib/gl/m4/codeset.m4
+++ b/lib/gl/m4/codeset.m4
@@ -1,5 +1,5 @@
# codeset.m4 serial 4 (gettext-0.18)
-dnl Copyright (C) 2000-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/errno_h.m4 b/lib/gl/m4/errno_h.m4
index 4ce1ccbd9f..d02a039363 100644
--- a/lib/gl/m4/errno_h.m4
+++ b/lib/gl/m4/errno_h.m4
@@ -1,5 +1,5 @@
# errno_h.m4 serial 6
-dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/extensions.m4 b/lib/gl/m4/extensions.m4
index ba6d5e190f..7d9458a8d6 100644
--- a/lib/gl/m4/extensions.m4
+++ b/lib/gl/m4/extensions.m4
@@ -1,7 +1,7 @@
-# serial 8 -*- Autoconf -*-
+# serial 9 -*- Autoconf -*-
# Enable extensions on systems that normally disable them.
-# Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -12,6 +12,20 @@
# enough in this area it's likely we'll need to redefine
# AC_USE_SYSTEM_EXTENSIONS for quite some time.
+# If autoconf reports a warning
+# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+# the fix is
+# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
+# but always AC_REQUIREd,
+# 2) to ensure that for each occurrence of
+# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+# or
+# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+# the corresponding gnulib module description has 'extensions' among
+# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
+# invocation occurs in gl_EARLY, not in gl_INIT.
+
# AC_USE_SYSTEM_EXTENSIONS
# ------------------------
# Enable extensions on systems that normally disable them,
@@ -74,8 +88,8 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
[ac_cv_safe_to_define___extensions__],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
-# define __EXTENSIONS__ 1
- ]AC_INCLUDES_DEFAULT])],
+# define __EXTENSIONS__ 1
+ ]AC_INCLUDES_DEFAULT])],
[ac_cv_safe_to_define___extensions__=yes],
[ac_cv_safe_to_define___extensions__=no])])
test $ac_cv_safe_to_define___extensions__ = yes &&
diff --git a/lib/gl/m4/float_h.m4 b/lib/gl/m4/float_h.m4
index d36e3a46ca..a74a0d957f 100644
--- a/lib/gl/m4/float_h.m4
+++ b/lib/gl/m4/float_h.m4
@@ -1,5 +1,5 @@
# float_h.m4 serial 3
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/fseeko.m4 b/lib/gl/m4/fseeko.m4
index a370648e9f..5f7f97729c 100644
--- a/lib/gl/m4/fseeko.m4
+++ b/lib/gl/m4/fseeko.m4
@@ -1,5 +1,5 @@
-# fseeko.m4 serial 6
-dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
+# fseeko.m4 serial 7
+dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -17,12 +17,10 @@ AC_DEFUN([gl_FUNC_FSEEKO],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
]], [fseeko (stdin, 0, 0);])],
- [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
+ [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
])
- if test $gl_cv_func_fseeko = no; then
- HAVE_FSEEKO=0
- gl_REPLACE_FSEEKO
- elif test $gl_cv_var_stdin_large_offset = no; then
+ if test $gl_cv_func_fseeko = no \
+ || test $gl_cv_var_stdin_large_offset = no; then
gl_REPLACE_FSEEKO
fi
])
diff --git a/lib/gl/m4/func.m4 b/lib/gl/m4/func.m4
index d02bce8a8b..698c5281da 100644
--- a/lib/gl/m4/func.m4
+++ b/lib/gl/m4/func.m4
@@ -1,5 +1,5 @@
# func.m4 serial 2
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/gettext.m4 b/lib/gl/m4/gettext.m4
index d90c85008a..d6dc3fe25c 100644
--- a/lib/gl/m4/gettext.m4
+++ b/lib/gl/m4/gettext.m4
@@ -1,5 +1,5 @@
# gettext.m4 serial 62 (gettext-0.18)
-dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/glibc2.m4 b/lib/gl/m4/glibc2.m4
index fe58a0f326..f148c12c45 100644
--- a/lib/gl/m4/glibc2.m4
+++ b/lib/gl/m4/glibc2.m4
@@ -1,5 +1,5 @@
# glibc2.m4 serial 2
-dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -12,16 +12,16 @@ AC_DEFUN([gt_GLIBC2],
AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer],
[ac_cv_gnu_library_2],
[AC_EGREP_CPP([Lucky GNU user],
- [
+ [
#include <features.h>
#ifdef __GNU_LIBRARY__
#if (__GLIBC__ >= 2)
Lucky GNU user
#endif
#endif
- ],
- [ac_cv_gnu_library_2=yes],
- [ac_cv_gnu_library_2=no])
+ ],
+ [ac_cv_gnu_library_2=yes],
+ [ac_cv_gnu_library_2=no])
]
)
AC_SUBST([GLIBC2])
diff --git a/lib/gl/m4/glibc21.m4 b/lib/gl/m4/glibc21.m4
index 93fbf47459..68ada9d4d5 100644
--- a/lib/gl/m4/glibc21.m4
+++ b/lib/gl/m4/glibc21.m4
@@ -1,5 +1,5 @@
# glibc21.m4 serial 4
-dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -12,16 +12,16 @@ AC_DEFUN([gl_GLIBC21],
AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
[ac_cv_gnu_library_2_1],
[AC_EGREP_CPP([Lucky GNU user],
- [
+ [
#include <features.h>
#ifdef __GNU_LIBRARY__
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
Lucky GNU user
#endif
#endif
- ],
- [ac_cv_gnu_library_2_1=yes],
- [ac_cv_gnu_library_2_1=no])
+ ],
+ [ac_cv_gnu_library_2_1=yes],
+ [ac_cv_gnu_library_2_1=no])
]
)
AC_SUBST([GLIBC21])
diff --git a/lib/gl/m4/gnulib-cache.m4 b/lib/gl/m4/gnulib-cache.m4
index de6f4c74a4..5129198896 100644
--- a/lib/gl/m4/gnulib-cache.m4
+++ b/lib/gl/m4/gnulib-cache.m4
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2009 Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
diff --git a/lib/gl/m4/gnulib-common.m4 b/lib/gl/m4/gnulib-common.m4
index c8fda20330..b7812a8962 100644
--- a/lib/gl/m4/gnulib-common.m4
+++ b/lib/gl/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
-# gnulib-common.m4 serial 11
-dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
+# gnulib-common.m4 serial 12
+dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -23,14 +23,17 @@ AC_DEFUN([gl_COMMON_BODY], [
# define __GNUC_STDC_INLINE__ 1
#endif])
AH_VERBATIM([unused_parameter],
-[/* Define as a marker that can be attached to function parameter declarations
- for parameters that are not used. This helps to reduce warnings, such as
- from GCC -Wunused-parameter. */
+[/* Define as a marker that can be attached to declarations that might not
+ be used. This helps to reduce warnings, such as from
+ GCC -Wunused-parameter. */
#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-# define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
+# define _GL_UNUSED __attribute__ ((__unused__))
#else
-# define _UNUSED_PARAMETER_
+# define _GL_UNUSED
#endif
+/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
+ is a misnomer outside of parameter lists. */
+#define _UNUSED_PARAMETER_ _GL_UNUSED
])
])
@@ -49,6 +52,14 @@ m4_ifndef([m4_foreach_w],
[m4_define([m4_foreach_w],
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
+# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
+# ----------------------------------------------------
+# Backport of autoconf-2.63b's macro.
+# Remove this macro when we can assume autoconf >= 2.64.
+m4_ifndef([AS_VAR_IF],
+[m4_define([AS_VAR_IF],
+[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
+
# AC_PROG_MKDIR_P
# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
# Remove this macro when we can assume autoconf >= 2.60.
@@ -70,13 +81,13 @@ AC_DEFUN([AC_C_RESTRICT],
for ac_kw in __restrict __restrict__ _Restrict restrict; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[typedef int * int_ptr;
- int foo (int_ptr $ac_kw ip) {
- return ip[0];
+ int foo (int_ptr $ac_kw ip) {
+ return ip[0];
}]],
[[int s[1];
- int * $ac_kw t = s;
- t[0] = 0;
- return foo(t)]])],
+ int * $ac_kw t = s;
+ t[0] = 0;
+ return foo(t)]])],
[ac_cv_c_restrict=$ac_kw])
test "$ac_cv_c_restrict" != no && break
done
diff --git a/lib/gl/m4/gnulib-comp.m4 b/lib/gl/m4/gnulib-comp.m4
index e6389f0df3..4186f4cb79 100644
--- a/lib/gl/m4/gnulib-comp.m4
+++ b/lib/gl/m4/gnulib-comp.m4
@@ -1,5 +1,5 @@
# DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2009 Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
@@ -121,7 +121,7 @@ AC_DEFUN([lgl_INIT],
if test -n "$lgl_LIBOBJS"; then
# Remove the extension.
sed_drop_objext='s/\.o$//;s/\.obj$//'
- for i in `for i in $lgl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
+ for i in `for i in $lgl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
lgl_libobjs="$lgl_libobjs $i.$ac_objext"
lgl_ltlibobjs="$lgl_ltlibobjs $i.lo"
done
@@ -164,7 +164,7 @@ AC_DEFUN([lgl_INIT],
if test -n "$lgltests_LIBOBJS"; then
# Remove the extension.
sed_drop_objext='s/\.o$//;s/\.obj$//'
- for i in `for i in $lgltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
+ for i in `for i in $lgltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
lgltests_libobjs="$lgltests_libobjs $i.$ac_objext"
lgltests_ltlibobjs="$lgltests_ltlibobjs $i.lo"
done
@@ -233,8 +233,9 @@ AC_DEFUN([lgltests_LIBSOURCES], [
# This macro records the list of files which have been installed by
# gnulib-tool and may be removed by future gnulib-tool invocations.
AC_DEFUN([lgl_FILE_LIST], [
+ build-aux/arg-nonnull.h
build-aux/config.rpath
- build-aux/link-warning.h
+ build-aux/warn-on-use.h
lib/alignof.h
lib/alloca.in.h
lib/asnprintf.c
@@ -364,10 +365,13 @@ AC_DEFUN([lgl_FILE_LIST], [
m4/vasprintf.m4
m4/visibility.m4
m4/vsnprintf.m4
+ m4/warn-on-use.m4
m4/wchar.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/xsize.m4
+ tests/macros.h
+ tests/signature.h
tests/test-alloca-opt.c
tests/test-byteswap.c
tests/test-c-ctype.c
diff --git a/lib/gl/m4/gnulib-tool.m4 b/lib/gl/m4/gnulib-tool.m4
index 4438d48869..69e7733b99 100644
--- a/lib/gl/m4/gnulib-tool.m4
+++ b/lib/gl/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
# gnulib-tool.m4 serial 2
-dnl Copyright (C) 2004-2005 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2005, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/iconv.m4 b/lib/gl/m4/iconv.m4
index ce21b0b878..f46ff14215 100644
--- a/lib/gl/m4/iconv.m4
+++ b/lib/gl/m4/iconv.m4
@@ -1,5 +1,5 @@
-# iconv.m4 serial AM8 (gettext-0.18)
-dnl Copyright (C) 2000-2002, 2007-2009 Free Software Foundation, Inc.
+# iconv.m4 serial 9 (gettext-0.18)
+dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -58,7 +58,7 @@ AC_DEFUN([AM_ICONV_LINK],
])
if test "$am_cv_func_iconv" = yes; then
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
- dnl This tests against bugs in AIX 5.1 and HP-UX 11.11.
+ dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10.
am_save_LIBS="$LIBS"
if test $am_cv_lib_iconv = yes; then
LIBS="$LIBS $LIBICONV"
@@ -87,6 +87,25 @@ int main ()
return 1;
}
}
+ /* Test against Solaris 10 bug: Failures are not distinguishable from
+ successful returns. */
+ {
+ iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
+ if (cd_ascii_to_88591 != (iconv_t)(-1))
+ {
+ static const char input[] = "\263";
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_ascii_to_88591,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if (res == 0)
+ return 1;
+ }
+ }
#if 0 /* This bug could be worked around by the caller. */
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
{
diff --git a/lib/gl/m4/include_next.m4 b/lib/gl/m4/include_next.m4
index 5e22ded936..c7e0672f60 100644
--- a/lib/gl/m4/include_next.m4
+++ b/lib/gl/m4/include_next.m4
@@ -1,5 +1,5 @@
# include_next.m4 serial 14
-dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -109,11 +109,11 @@ EOF
# be
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
# That way, a header file with the following line:
-# #@INCLUDE_NEXT@ @NEXT_FOO_H@
+# #@INCLUDE_NEXT@ @NEXT_FOO_H@
# 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
-# #include_next <foo.h>
+# #include_next <foo.h>
# even if the compiler does not support include_next.
# The three "///" are to pacify Sun C 5.8, which otherwise would say
# "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],
[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
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
else
AC_CACHE_CHECK(
- [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
- m4_defn([gl_next_header]),
- [AS_VAR_PUSHDEF([gl_header_exists],
- [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
- if test AS_VAR_GET(gl_header_exists) = yes; then
- AC_LANG_CONFTEST(
- [AC_LANG_SOURCE(
- [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
- )])
- 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 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 and others. The workaround is to force preservation of comments
- dnl through option -C. This ensures all necessary #line directives
- dnl are present. GCC supports option -C as well.
- case "$host_os" in
- aix*) gl_absname_cpp="$ac_cpp -C" ;;
- *) gl_absname_cpp="$ac_cpp" ;;
- esac
- dnl eval is necessary to expand gl_absname_cpp.
- dnl Ultrix and Pyramid sh refuse to redirect output of eval,
- dnl so use subshell.
- AS_VAR_SET([gl_next_header],
- ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
- sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
- s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
- s#^/[^/]#//&#
- p
- q
- }'`'"'])
- else
- AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
- fi
- AS_VAR_POPDEF([gl_header_exists])])
+ [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
+ m4_defn([gl_next_header]),
+ [AS_VAR_PUSHDEF([gl_header_exists],
+ [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
+ if test AS_VAR_GET(gl_header_exists) = yes; then
+ AC_LANG_CONFTEST(
+ [AC_LANG_SOURCE(
+ [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
+ )])
+ 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 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 and others. The workaround is to force preservation of comments
+ dnl through option -C. This ensures all necessary #line directives
+ dnl are present. GCC supports option -C as well.
+ case "$host_os" in
+ aix*) gl_absname_cpp="$ac_cpp -C" ;;
+ *) gl_absname_cpp="$ac_cpp" ;;
+ esac
+ dnl eval is necessary to expand gl_absname_cpp.
+ dnl Ultrix and Pyramid sh refuse to redirect output of eval,
+ dnl so use subshell.
+ AS_VAR_SET([gl_next_header],
+ ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+ sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
+ s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
+ s#^/[^/]#//&#
+ p
+ q
+ }'`'"'])
+ else
+ AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+ fi
+ AS_VAR_POPDEF([gl_header_exists])])
fi
AC_SUBST(
AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
diff --git a/lib/gl/m4/intdiv0.m4 b/lib/gl/m4/intdiv0.m4
index 29e6e0aa16..289c4df5ed 100644
--- a/lib/gl/m4/intdiv0.m4
+++ b/lib/gl/m4/intdiv0.m4
@@ -1,5 +1,5 @@
# intdiv0.m4 serial 3 (gettext-0.18)
-dnl Copyright (C) 2002, 2007-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/intl.m4 b/lib/gl/m4/intl.m4
index 934408bb90..5e17fea9f1 100644
--- a/lib/gl/m4/intl.m4
+++ b/lib/gl/m4/intl.m4
@@ -1,5 +1,5 @@
# intl.m4 serial 8 (gettext-0.17)
-dnl Copyright (C) 1995-2007 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2007, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/intldir.m4 b/lib/gl/m4/intldir.m4
index 0980e6f286..744c0bc713 100644
--- a/lib/gl/m4/intldir.m4
+++ b/lib/gl/m4/intldir.m4
@@ -1,5 +1,5 @@
# intldir.m4 serial 2 (gettext-0.18)
-dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/intlmacosx.m4 b/lib/gl/m4/intlmacosx.m4
index c24837c429..dd91025962 100644
--- a/lib/gl/m4/intlmacosx.m4
+++ b/lib/gl/m4/intlmacosx.m4
@@ -1,5 +1,5 @@
# intlmacosx.m4 serial 3 (gettext-0.18)
-dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/intmax.m4 b/lib/gl/m4/intmax.m4
index a3785e9989..74aaaf5ed6 100644
--- a/lib/gl/m4/intmax.m4
+++ b/lib/gl/m4/intmax.m4
@@ -1,5 +1,5 @@
# intmax.m4 serial 5 (gettext-0.18)
-dnl Copyright (C) 2002-2005, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2005, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/intmax_t.m4 b/lib/gl/m4/intmax_t.m4
index 264cb57184..975caac506 100644
--- a/lib/gl/m4/intmax_t.m4
+++ b/lib/gl/m4/intmax_t.m4
@@ -1,5 +1,6 @@
# intmax_t.m4 serial 7
-dnl Copyright (C) 1997-2004, 2006-2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2004, 2006-2007, 2009-2010 Free Software Foundation,
+dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/inttypes-pri.m4 b/lib/gl/m4/inttypes-pri.m4
index 98fec7bcf6..718a4f4e19 100644
--- a/lib/gl/m4/inttypes-pri.m4
+++ b/lib/gl/m4/inttypes-pri.m4
@@ -1,5 +1,5 @@
# inttypes-pri.m4 serial 6 (gettext-0.18)
-dnl Copyright (C) 1997-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2002, 2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/inttypes_h.m4 b/lib/gl/m4/inttypes_h.m4
index f4ca16021c..782d77ed8b 100644
--- a/lib/gl/m4/inttypes_h.m4
+++ b/lib/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
# inttypes_h.m4 serial 9
-dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/lcmessage.m4 b/lib/gl/m4/lcmessage.m4
index fa8e4167ac..1a705431a9 100644
--- a/lib/gl/m4/lcmessage.m4
+++ b/lib/gl/m4/lcmessage.m4
@@ -1,5 +1,6 @@
# lcmessage.m4 serial 6 (gettext-0.18)
-dnl Copyright (C) 1995-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation,
+dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/ld-output-def.m4 b/lib/gl/m4/ld-output-def.m4
index 1aa6a6fbbf..2dc6bf5205 100644
--- a/lib/gl/m4/ld-output-def.m4
+++ b/lib/gl/m4/ld-output-def.m4
@@ -1,5 +1,5 @@
# ld-output-def.m4 serial 2
-dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/ld-version-script.m4 b/lib/gl/m4/ld-version-script.m4
index a97888f249..43c1ef12f9 100644
--- a/lib/gl/m4/ld-version-script.m4
+++ b/lib/gl/m4/ld-version-script.m4
@@ -1,5 +1,5 @@
# ld-version-script.m4 serial 1
-dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -27,7 +27,7 @@ AC_DEFUN([gl_LD_VERSION_SCRIPT],
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
cat > conftest.map <<EOF
VERS_1 {
- global: sym;
+ global: sym;
};
VERS_2 {
diff --git a/lib/gl/m4/lib-ld.m4 b/lib/gl/m4/lib-ld.m4
index e4863f2c9b..ebb30528bd 100644
--- a/lib/gl/m4/lib-ld.m4
+++ b/lib/gl/m4/lib-ld.m4
@@ -1,5 +1,5 @@
# lib-ld.m4 serial 4 (gettext-0.18)
-dnl Copyright (C) 1996-2003, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -59,7 +59,7 @@ if test "$GCC" = yes; then
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
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
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.
case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
*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
fi
done
diff --git a/lib/gl/m4/lib-link.m4 b/lib/gl/m4/lib-link.m4
index 2f8b7ff38f..90e1ac9170 100644
--- a/lib/gl/m4/lib-link.m4
+++ b/lib/gl/m4/lib-link.m4
@@ -1,5 +1,5 @@
# lib-link.m4 serial 20 (gettext-0.18)
-dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/lib-prefix.m4 b/lib/gl/m4/lib-prefix.m4
index 4b7ee3358d..1601ceaefd 100644
--- a/lib/gl/m4/lib-prefix.m4
+++ b/lib/gl/m4/lib-prefix.m4
@@ -1,5 +1,5 @@
# lib-prefix.m4 serial 7 (gettext-0.18)
-dnl Copyright (C) 2001-2005, 2008-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2005, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/lock.m4 b/lib/gl/m4/lock.m4
index b416e31a35..9da8465ebf 100644
--- a/lib/gl/m4/lock.m4
+++ b/lib/gl/m4/lock.m4
@@ -1,5 +1,5 @@
# lock.m4 serial 10 (gettext-0.18)
-dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/longlong.m4 b/lib/gl/m4/longlong.m4
index eedc8d5682..cca3c1a90f 100644
--- a/lib/gl/m4/longlong.m4
+++ b/lib/gl/m4/longlong.m4
@@ -1,5 +1,5 @@
# longlong.m4 serial 14
-dnl Copyright (C) 1999-2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1999-2007, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -20,30 +20,30 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
[AC_LINK_IFELSE(
[_AC_TYPE_LONG_LONG_SNIPPET],
[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 nobody cross compiles for this platform as far as we know.
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- [[@%:@include <limits.h>
- @%:@ifndef LLONG_MAX
- @%:@ define HALF \
- (1LL << (sizeof (long long int) * CHAR_BIT - 2))
- @%:@ define LLONG_MAX (HALF - 1 + HALF)
- @%:@endif]],
- [[long long int n = 1;
- int i;
- for (i = 0; ; i++)
- {
- long long int m = n << i;
- if (m >> i != n)
- return 1;
- if (LLONG_MAX / 2 < m)
- break;
- }
- return 0;]])],
- [ac_cv_type_long_long_int=yes],
- [ac_cv_type_long_long_int=no],
- [ac_cv_type_long_long_int=yes])],
+ dnl If cross compiling, assume the bug isn't important, since
+ dnl nobody cross compiles for this platform as far as we know.
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[@%:@include <limits.h>
+ @%:@ifndef LLONG_MAX
+ @%:@ define HALF \
+ (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+ @%:@ define LLONG_MAX (HALF - 1 + HALF)
+ @%:@endif]],
+ [[long long int n = 1;
+ int i;
+ for (i = 0; ; i++)
+ {
+ long long int m = n << i;
+ if (m >> i != n)
+ return 1;
+ if (LLONG_MAX / 2 < m)
+ break;
+ }
+ return 0;]])],
+ [ac_cv_type_long_long_int=yes],
+ [ac_cv_type_long_long_int=no],
+ [ac_cv_type_long_long_int=yes])],
[ac_cv_type_long_long_int=no])])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], [1],
@@ -83,24 +83,24 @@ AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
[
AC_LANG_PROGRAM(
[[/* For now, do not test the preprocessor; as of 2007 there are too many
- implementations with broken preprocessors. Perhaps this can
- be revisited in 2012. In the meantime, code should not expect
- #if to work with literals wider than 32 bits. */
+ implementations with broken preprocessors. Perhaps this can
+ be revisited in 2012. In the meantime, code should not expect
+ #if to work with literals wider than 32 bits. */
/* Test literals. */
long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL;
unsigned long long int ull = 18446744073709551615ULL;
/* Test constant expressions. */
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
- ? 1 : -1)];
+ ? 1 : -1)];
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
- ? 1 : -1)];
+ ? 1 : -1)];
int i = 63;]],
[[/* Test availability of runtime routines for shift and division. */
long long int llmax = 9223372036854775807ll;
unsigned long long int ullmax = 18446744073709551615ull;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
- | (llmax / ll) | (llmax % ll)
- | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
- | (ullmax / ull) | (ullmax % ull));]])
+ | (llmax / ll) | (llmax % ll)
+ | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
+ | (ullmax / ull) | (ullmax % ull));]])
])
diff --git a/lib/gl/m4/lseek.m4 b/lib/gl/m4/lseek.m4
index f336990709..f3084957c1 100644
--- a/lib/gl/m4/lseek.m4
+++ b/lib/gl/m4/lseek.m4
@@ -1,5 +1,5 @@
# lseek.m4 serial 4
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -19,21 +19,21 @@ int main ()
/* Exit with success only if stdin is seekable. */
return lseek (0, (off_t)0, SEEK_CUR) < 0;
}],
- [if test -s conftest$ac_exeext \
- && ./conftest$ac_exeext < conftest.$ac_ext \
- && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
- gl_cv_func_lseek_pipe=yes
- else
- gl_cv_func_lseek_pipe=no
- fi],
- [gl_cv_func_lseek_pipe=no])
+ [if test -s conftest$ac_exeext \
+ && ./conftest$ac_exeext < conftest.$ac_ext \
+ && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
+ gl_cv_func_lseek_pipe=yes
+ else
+ gl_cv_func_lseek_pipe=no
+ fi],
+ [gl_cv_func_lseek_pipe=no])
else
AC_COMPILE_IFELSE([
#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __BEOS__
/* mingw and BeOS mistakenly return 0 when trying to seek on pipes. */
Choke me.
#endif],
- [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
+ [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
fi])
if test $gl_cv_func_lseek_pipe = no; then
gl_REPLACE_LSEEK
@@ -46,5 +46,5 @@ AC_DEFUN([gl_REPLACE_LSEEK],
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
REPLACE_LSEEK=1
AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
- [Define to 1 if lseek does not detect pipes.])
+ [Define to 1 if lseek does not detect pipes.])
])
diff --git a/lib/gl/m4/malloc.m4 b/lib/gl/m4/malloc.m4
index 807017166b..910ac92292 100644
--- a/lib/gl/m4/malloc.m4
+++ b/lib/gl/m4/malloc.m4
@@ -1,5 +1,5 @@
# malloc.m4 serial 9
-dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/memchr.m4 b/lib/gl/m4/memchr.m4
index 1194bac2e8..94596ef959 100644
--- a/lib/gl/m4/memchr.m4
+++ b/lib/gl/m4/memchr.m4
@@ -1,5 +1,5 @@
# memchr.m4 serial 7
-dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -53,11 +53,11 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
{
int pagesize = getpagesize ();
char *two_pages =
- (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
- flags, fd, 0);
+ (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+ flags, fd, 0);
if (two_pages != (char *)(-1)
- && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
- fence = two_pages + pagesize;
+ && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+ fence = two_pages + pagesize;
}
#endif
if (fence)
diff --git a/lib/gl/m4/memmem.m4 b/lib/gl/m4/memmem.m4
index 9e3d3d956d..c6506ee5c8 100644
--- a/lib/gl/m4/memmem.m4
+++ b/lib/gl/m4/memmem.m4
@@ -1,5 +1,6 @@
# memmem.m4 serial 14
-dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010 Free Software
+dnl Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -42,19 +43,19 @@ AC_DEFUN([gl_FUNC_MEMMEM],
/* Check for quadratic performance. */
if (haystack && needle)
{
- memset (haystack, 'A', 2 * m);
- haystack[2 * m] = 'B';
- memset (needle, 'A', m);
- needle[m] = 'B';
- result = memmem (haystack, 2 * m + 1, needle, m + 1);
+ memset (haystack, 'A', 2 * m);
+ haystack[2 * m] = 'B';
+ memset (needle, 'A', m);
+ needle[m] = 'B';
+ result = memmem (haystack, 2 * m + 1, needle, m + 1);
}
/* Check for empty needle behavior. */
return !result || !memmem ("a", 1, 0, 0);]])],
- [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no],
- [dnl Only glibc >= 2.9 and cygwin >= 1.7.0 are known to have a
- dnl memmem that works in linear time.
- AC_EGREP_CPP([Lucky user],
- [
+ [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no],
+ [dnl Only glibc >= 2.9 and cygwin >= 1.7.0 are known to have a
+ dnl memmem that works in linear time.
+ AC_EGREP_CPP([Lucky user],
+ [
#include <features.h>
#ifdef __GNU_LIBRARY__
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2)
@@ -67,10 +68,10 @@ AC_DEFUN([gl_FUNC_MEMMEM],
Lucky user
#endif
#endif
- ],
- [gl_cv_func_memmem_works=yes],
- [gl_cv_func_memmem_works="guessing no"])
- ])
+ ],
+ [gl_cv_func_memmem_works=yes],
+ [gl_cv_func_memmem_works="guessing no"])
+ ])
])
if test "$gl_cv_func_memmem_works" != yes; then
REPLACE_MEMMEM=1
diff --git a/lib/gl/m4/minmax.m4 b/lib/gl/m4/minmax.m4
index d2993fbaf7..d9e9cecfd7 100644
--- a/lib/gl/m4/minmax.m4
+++ b/lib/gl/m4/minmax.m4
@@ -1,5 +1,5 @@
# minmax.m4 serial 3
-dnl Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/mmap-anon.m4 b/lib/gl/m4/mmap-anon.m4
index 14b6270d28..a6b7b9ac3b 100644
--- a/lib/gl/m4/mmap-anon.m4
+++ b/lib/gl/m4/mmap-anon.m4
@@ -1,5 +1,5 @@
# mmap-anon.m4 serial 8
-dnl Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/multiarch.m4 b/lib/gl/m4/multiarch.m4
index ec377bac86..389bd2bbaa 100644
--- a/lib/gl/m4/multiarch.m4
+++ b/lib/gl/m4/multiarch.m4
@@ -1,5 +1,5 @@
# multiarch.m4 serial 5
-dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/netdb_h.m4 b/lib/gl/m4/netdb_h.m4
index 5a12251f9a..84afce6e5e 100644
--- a/lib/gl/m4/netdb_h.m4
+++ b/lib/gl/m4/netdb_h.m4
@@ -1,5 +1,5 @@
-# netdb_h.m4 serial 5
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# netdb_h.m4 serial 6
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_HEADER_NETDB],
[
AC_REQUIRE([gl_NETDB_H_DEFAULTS])
+ AC_CHECK_HEADERS_ONCE([netdb.h])
gl_CHECK_NEXT_HEADERS([netdb.h])
if test $ac_cv_header_netdb_h = yes; then
AC_COMPILE_IFELSE(
diff --git a/lib/gl/m4/nls.m4 b/lib/gl/m4/nls.m4
index 0b36434215..003704c4b9 100644
--- a/lib/gl/m4/nls.m4
+++ b/lib/gl/m4/nls.m4
@@ -1,5 +1,6 @@
# nls.m4 serial 5 (gettext-0.18)
-dnl Copyright (C) 1995-2003, 2005-2006, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation,
+dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/po.m4 b/lib/gl/m4/po.m4
index 2284fa5054..960efe15d4 100644
--- a/lib/gl/m4/po.m4
+++ b/lib/gl/m4/po.m4
@@ -1,5 +1,5 @@
# po.m4 serial 17 (gettext-0.18)
-dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/printf-posix.m4 b/lib/gl/m4/printf-posix.m4
index 5922d27891..820ddf5256 100644
--- a/lib/gl/m4/printf-posix.m4
+++ b/lib/gl/m4/printf-posix.m4
@@ -1,5 +1,5 @@
# printf-posix.m4 serial 5 (gettext-0.18)
-dnl Copyright (C) 2003, 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/printf.m4 b/lib/gl/m4/printf.m4
index 87aa45c5e7..ebca5364c4 100644
--- a/lib/gl/m4/printf.m4
+++ b/lib/gl/m4/printf.m4
@@ -1,5 +1,5 @@
# printf.m4 serial 33
-dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/progtest.m4 b/lib/gl/m4/progtest.m4
index e1d445d267..2d804ac99d 100644
--- a/lib/gl/m4/progtest.m4
+++ b/lib/gl/m4/progtest.m4
@@ -1,5 +1,5 @@
# progtest.m4 serial 6 (gettext-0.18)
-dnl Copyright (C) 1996-2003, 2005, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/read-file.m4 b/lib/gl/m4/read-file.m4
index 8d1b8f3c5f..35a3a4817f 100644
--- a/lib/gl/m4/read-file.m4
+++ b/lib/gl/m4/read-file.m4
@@ -1,5 +1,6 @@
# read-file.m4 serial 2
-dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2010 Free Software
+dnl Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/realloc.m4 b/lib/gl/m4/realloc.m4
index 5925796864..dc30235c17 100644
--- a/lib/gl/m4/realloc.m4
+++ b/lib/gl/m4/realloc.m4
@@ -1,5 +1,5 @@
# realloc.m4 serial 9
-dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/size_max.m4 b/lib/gl/m4/size_max.m4
index 35bd3d6ae3..ce992db1f1 100644
--- a/lib/gl/m4/size_max.m4
+++ b/lib/gl/m4/size_max.m4
@@ -1,5 +1,5 @@
# size_max.m4 serial 9
-dnl Copyright (C) 2003, 2005-2006, 2008-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2005-2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/snprintf.m4 b/lib/gl/m4/snprintf.m4
index 6021786ee1..522b107b12 100644
--- a/lib/gl/m4/snprintf.m4
+++ b/lib/gl/m4/snprintf.m4
@@ -1,5 +1,5 @@
# snprintf.m4 serial 5
-dnl Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/sockets.m4 b/lib/gl/m4/sockets.m4
index 3edc010610..aefb936079 100644
--- a/lib/gl/m4/sockets.m4
+++ b/lib/gl/m4/sockets.m4
@@ -1,5 +1,5 @@
# sockets.m4 serial 6
-dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/socklen.m4 b/lib/gl/m4/socklen.m4
index 80ed5135fd..2933d4b890 100644
--- a/lib/gl/m4/socklen.m4
+++ b/lib/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
# socklen.m4 serial 7
-dnl Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -20,30 +20,30 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
AC_CHECK_TYPE([socklen_t], ,
[AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([gl_cv_socklen_t_equiv],
- [# Systems have either "struct sockaddr *" or
- # "void *" as the second argument to getpeername
- gl_cv_socklen_t_equiv=
- for arg2 in "struct sockaddr" void; do
- for t in int size_t "unsigned int" "long int" "unsigned long int"; do
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [# Systems have either "struct sockaddr *" or
+ # "void *" as the second argument to getpeername
+ gl_cv_socklen_t_equiv=
+ for arg2 in "struct sockaddr" void; do
+ for t in int size_t "unsigned int" "long int" "unsigned long int"; do
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <sys/types.h>
#include <sys/socket.h>
int getpeername (int, $arg2 *, $t *);]],
[[$t len;
getpeername (0, 0, &len);]])],
- [gl_cv_socklen_t_equiv="$t"])
- test "$gl_cv_socklen_t_equiv" != "" && break
- done
- test "$gl_cv_socklen_t_equiv" != "" && break
- done
+ [gl_cv_socklen_t_equiv="$t"])
+ test "$gl_cv_socklen_t_equiv" != "" && break
+ done
+ test "$gl_cv_socklen_t_equiv" != "" && break
+ done
])
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
AC_MSG_RESULT([$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>
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
diff --git a/lib/gl/m4/sockpfaf.m4 b/lib/gl/m4/sockpfaf.m4
index bbdfabc919..8a0c236038 100644
--- a/lib/gl/m4/sockpfaf.m4
+++ b/lib/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
# sockpfaf.m4 serial 7
-dnl Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/stdbool.m4 b/lib/gl/m4/stdbool.m4
index 57c804a80f..3d672d7476 100644
--- a/lib/gl/m4/stdbool.m4
+++ b/lib/gl/m4/stdbool.m4
@@ -1,6 +1,6 @@
# Check for stdbool.h that conforms to C99.
-dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -38,77 +38,77 @@ AC_DEFUN([AC_HEADER_STDBOOL],
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
[ac_cv_header_stdbool_h],
[AC_TRY_COMPILE(
- [
- #include <stdbool.h>
- #ifndef bool
- "error: bool is not defined"
- #endif
- #ifndef false
- "error: false is not defined"
- #endif
- #if false
- "error: false is not 0"
- #endif
- #ifndef true
- "error: true is not defined"
- #endif
- #if true != 1
- "error: true is not 1"
- #endif
- #ifndef __bool_true_false_are_defined
- "error: __bool_true_false_are_defined is not defined"
- #endif
+ [
+ #include <stdbool.h>
+ #ifndef bool
+ "error: bool is not defined"
+ #endif
+ #ifndef false
+ "error: false is not defined"
+ #endif
+ #if false
+ "error: false is not 0"
+ #endif
+ #ifndef true
+ "error: true is not defined"
+ #endif
+ #if true != 1
+ "error: true is not 1"
+ #endif
+ #ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+ #endif
- struct s { _Bool s: 1; _Bool t; } s;
+ struct s { _Bool s: 1; _Bool t; } s;
- char a[true == 1 ? 1 : -1];
- char b[false == 0 ? 1 : -1];
- char c[__bool_true_false_are_defined == 1 ? 1 : -1];
- char d[(bool) 0.5 == true ? 1 : -1];
- bool e = &s;
- char f[(_Bool) 0.0 == false ? 1 : -1];
- char g[true];
- char h[sizeof (_Bool)];
- char i[sizeof s.t];
- enum { j = false, k = true, l = false * true, m = true * 256 };
- _Bool n[m];
- char o[sizeof n == m * sizeof n[0] ? 1 : -1];
- char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
- #if defined __xlc__ || defined __GNUC__
- /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
- reported by James Lemley on 2005-10-05; see
- http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
- This test is not quite right, since xlc is allowed to
- reject this program, as the initializer for xlcbug is
- not one of the forms that C requires support for.
- However, doing the test right would require a run-time
- test, and that would make cross-compilation harder.
- Let us hope that IBM fixes the xlc bug, and also adds
- support for this kind of constant expression. In the
- meantime, this test will reject xlc, which is OK, since
- our stdbool.h substitute should suffice. We also test
- this with GCC, where it should work, to detect more
- quickly whether someone messes up the test in the
- future. */
- char digs[] = "0123456789";
- int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
- #endif
- /* Catch a bug in an HP-UX C compiler. See
- http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
- */
- _Bool q = true;
- _Bool *pq = &q;
- ],
- [
- *pq |= q;
- *pq |= ! q;
- /* Refer to every declared value, to avoid compiler optimizations. */
- return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
- + !m + !n + !o + !p + !q + !pq);
- ],
- [ac_cv_header_stdbool_h=yes],
- [ac_cv_header_stdbool_h=no])])
+ char a[true == 1 ? 1 : -1];
+ char b[false == 0 ? 1 : -1];
+ char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ char d[(bool) 0.5 == true ? 1 : -1];
+ bool e = &s;
+ char f[(_Bool) 0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ enum { j = false, k = true, l = false * true, m = true * 256 };
+ _Bool n[m];
+ char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+ #if defined __xlc__ || defined __GNUC__
+ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+ reported by James Lemley on 2005-10-05; see
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+ This test is not quite right, since xlc is allowed to
+ reject this program, as the initializer for xlcbug is
+ not one of the forms that C requires support for.
+ However, doing the test right would require a run-time
+ test, and that would make cross-compilation harder.
+ Let us hope that IBM fixes the xlc bug, and also adds
+ support for this kind of constant expression. In the
+ meantime, this test will reject xlc, which is OK, since
+ our stdbool.h substitute should suffice. We also test
+ this with GCC, where it should work, to detect more
+ quickly whether someone messes up the test in the
+ future. */
+ char digs[] = "0123456789";
+ int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+ #endif
+ /* Catch a bug in an HP-UX C compiler. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+ _Bool q = true;
+ _Bool *pq = &q;
+ ],
+ [
+ *pq |= q;
+ *pq |= ! q;
+ /* Refer to every declared value, to avoid compiler optimizations. */
+ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ + !m + !n + !o + !p + !q + !pq);
+ ],
+ [ac_cv_header_stdbool_h=yes],
+ [ac_cv_header_stdbool_h=no])])
AC_CHECK_TYPES([_Bool])
if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
diff --git a/lib/gl/m4/stddef_h.m4 b/lib/gl/m4/stddef_h.m4
index 682e9c626e..c8572de947 100644
--- a/lib/gl/m4/stddef_h.m4
+++ b/lib/gl/m4/stddef_h.m4
@@ -1,6 +1,6 @@
dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
# stddef_h.m4 serial 1
-dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/stdint.m4 b/lib/gl/m4/stdint.m4
index a2e8bdd628..1cc57e6e96 100644
--- a/lib/gl/m4/stdint.m4
+++ b/lib/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
# stdint.m4 serial 34
-dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -396,12 +396,12 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
case $glsuf in
'') gltype1='int';;
- l) gltype1='long int';;
- ll) gltype1='long long int';;
- i64) gltype1='__int64';;
- u) gltype1='unsigned int';;
- ul) gltype1='unsigned long int';;
- ull) gltype1='unsigned long long int';;
+ l) gltype1='long int';;
+ ll) gltype1='long long int';;
+ i64) gltype1='__int64';;
+ u) gltype1='unsigned int';;
+ ul) gltype1='unsigned long int';;
+ ull) gltype1='unsigned long long int';;
ui64)gltype1='unsigned __int64';;
esac
AC_COMPILE_IFELSE(
diff --git a/lib/gl/m4/stdint_h.m4 b/lib/gl/m4/stdint_h.m4
index 82f0c244c8..b8e3c6cc71 100644
--- a/lib/gl/m4/stdint_h.m4
+++ b/lib/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
# stdint_h.m4 serial 8
-dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/stdio_h.m4 b/lib/gl/m4/stdio_h.m4
index ed828eac89..20af579d14 100644
--- a/lib/gl/m4/stdio_h.m4
+++ b/lib/gl/m4/stdio_h.m4
@@ -1,5 +1,5 @@
-# stdio_h.m4 serial 21
-dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
+# stdio_h.m4 serial 24
+dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_STDIO_H],
[
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+ AC_REQUIRE([AC_C_INLINE])
gl_CHECK_NEXT_HEADERS([stdio.h])
dnl No need to create extra modules for these functions. Everyone who uses
dnl <stdio.h> likely needs them.
@@ -30,6 +31,13 @@ AC_DEFUN([gl_STDIO_H],
AC_LIBOBJ([stdio-write])
fi
])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use, and which is not
+ dnl guaranteed by C89.
+ gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
+ ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
+ snprintf vdprintf vsnprintf])
])
AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
@@ -89,8 +97,6 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
- HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
- HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
@@ -140,6 +146,6 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
choke me
# endif
#endif]])],
- [gl_cv_var_stdin_large_offset=yes],
- [gl_cv_var_stdin_large_offset=no])])
+ [gl_cv_var_stdin_large_offset=yes],
+ [gl_cv_var_stdin_large_offset=no])])
])
diff --git a/lib/gl/m4/stdlib_h.m4 b/lib/gl/m4/stdlib_h.m4
index 4556ac04c5..0693d1a5ec 100644
--- a/lib/gl/m4/stdlib_h.m4
+++ b/lib/gl/m4/stdlib_h.m4
@@ -1,5 +1,5 @@
-# stdlib_h.m4 serial 21
-dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
+# stdlib_h.m4 serial 22
+dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -22,6 +22,20 @@ AC_DEFUN([gl_STDLIB_H],
# include <random.h>
#endif
]])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use, and which is not
+ dnl guaranteed by C89.
+ gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
+#if HAVE_SYS_LOADAVG_H
+# include <sys/loadavg.h>
+#endif
+#if HAVE_RANDOM_H
+# include <random.h>
+#endif
+ ]], [atoll canonicalize_file_name getloadavg getsubopt mkdtemp
+ mkostemp mkostemps mkstemp mkstemps random_r initstat_r srandom_r
+ setstate_r realpath rpmatch setenv strtod strtoll strtoull unsetenv])
])
AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -80,6 +94,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
+ REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
- VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
+ REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
])
diff --git a/lib/gl/m4/strcase.m4 b/lib/gl/m4/strcase.m4
index 0dfdb1a181..33de423a02 100644
--- a/lib/gl/m4/strcase.m4
+++ b/lib/gl/m4/strcase.m4
@@ -1,5 +1,5 @@
# strcase.m4 serial 10
-dnl Copyright (C) 2002, 2005-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2005-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/string_h.m4 b/lib/gl/m4/string_h.m4
index edc5c6e825..73c6d83378 100644
--- a/lib/gl/m4/string_h.m4
+++ b/lib/gl/m4/string_h.m4
@@ -1,11 +1,11 @@
# Configure a GNU-like replacement for <string.h>.
-# Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 2007-2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 9
+# serial 11
# Written by Paul Eggert.
@@ -21,6 +21,13 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([string.h])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use, and which is not
+ dnl guaranteed by C89.
+ gl_WARN_ON_USE_PREPARE([[#include <string.h>
+ ]], [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
+ strndup strnlen strpbrk strsep strcasestr strtok_r strsignal strverscmp])
])
AC_DEFUN([gl_STRING_MODULE_INDICATOR],
@@ -64,33 +71,34 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
- GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
+ GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
+ HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
- HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
- HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
- HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
- HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
- HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
- HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
- HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
- HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
- HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
- HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
- HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
- HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
- HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
- HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
- HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
- HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
- REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
- REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
- REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
- REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
- REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
- REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
- REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
- REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
- REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
- UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
+ HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
+ HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
+ HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
+ HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
+ HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
+ HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
+ HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
+ HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
+ HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
+ HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
+ HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
+ HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
+ HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
+ HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
+ HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
+ HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
+ HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
+ REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
+ REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
+ REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
+ REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
+ REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
+ REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
+ REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
+ REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
+ REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
+ UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
])
diff --git a/lib/gl/m4/strings_h.m4 b/lib/gl/m4/strings_h.m4
index 03ac182f33..26aa1f782a 100644
--- a/lib/gl/m4/strings_h.m4
+++ b/lib/gl/m4/strings_h.m4
@@ -1,6 +1,7 @@
# Configure a replacement for <string.h>.
+# serial 2
-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -16,6 +17,11 @@ AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
[
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([strings.h])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[#include <strings.h>
+ ]], [strcasecmp strncasecmp])
])
AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
diff --git a/lib/gl/m4/strverscmp.m4 b/lib/gl/m4/strverscmp.m4
index becce2bb17..59e0950f18 100644
--- a/lib/gl/m4/strverscmp.m4
+++ b/lib/gl/m4/strverscmp.m4
@@ -1,5 +1,5 @@
# strverscmp.m4 serial 7
-dnl Copyright (C) 2002, 2005-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2005-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/sys_socket_h.m4 b/lib/gl/m4/sys_socket_h.m4
index e864b2c7e2..1d47656027 100644
--- a/lib/gl/m4/sys_socket_h.m4
+++ b/lib/gl/m4/sys_socket_h.m4
@@ -1,5 +1,5 @@
-# sys_socket_h.m4 serial 13
-dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
+# sys_socket_h.m4 serial 14
+dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -66,6 +66,18 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
gl_PREREQ_SYS_H_WINSOCK2
fi
AC_SUBST([SYS_SOCKET_H])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+/* Some systems require prerequisite headers. */
+#include <sys/types.h>
+#if !defined __GLIBC__ && HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <sys/select.h>
+ ]], [socket connect accept bind getpeername getsockname getsockopt
+ listen recv send recvfrom sendto setsockopt shutdown accept4])
])
AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
diff --git a/lib/gl/m4/sys_stat_h.m4 b/lib/gl/m4/sys_stat_h.m4
index 838cf484e9..5a113d02ea 100644
--- a/lib/gl/m4/sys_stat_h.m4
+++ b/lib/gl/m4/sys_stat_h.m4
@@ -1,5 +1,5 @@
-# sys_stat_h.m4 serial 21 -*- Autoconf -*-
-dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
+# sys_stat_h.m4 serial 22 -*- Autoconf -*-
+dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -27,6 +27,11 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
[#include <sys/types.h>
#include <sys/stat.h>])
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
+ ]], [fchmodat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat
+ mknod mknodat stat utimensat])
]) # gl_HEADER_SYS_STAT_H
AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
diff --git a/lib/gl/m4/threadlib.m4 b/lib/gl/m4/threadlib.m4
index f67791e813..bba460e4bc 100644
--- a/lib/gl/m4/threadlib.m4
+++ b/lib/gl/m4/threadlib.m4
@@ -1,5 +1,5 @@
# threadlib.m4 serial 4 (gettext-0.18)
-dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/time_h.m4 b/lib/gl/m4/time_h.m4
index 16fefa1974..c00bfae922 100644
--- a/lib/gl/m4/time_h.m4
+++ b/lib/gl/m4/time_h.m4
@@ -1,6 +1,6 @@
# Configure a more-standard replacement for <time.h>.
-# Copyright (C) 2000-2001, 2003-2007, 2009 Free Software Foundation, Inc.
+# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -45,9 +45,9 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
[gl_cv_sys_struct_timespec_in_time_h],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
- [[#include <time.h>
- ]],
- [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+ [[#include <time.h>
+ ]],
+ [[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=no])])
@@ -59,12 +59,12 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
[gl_cv_sys_struct_timespec_in_sys_time_h],
[AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <sys/time.h>
- ]],
- [[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=no])])
+ [AC_LANG_PROGRAM(
+ [[#include <sys/time.h>
+ ]],
+ [[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=no])])
if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
fi
diff --git a/lib/gl/m4/time_r.m4 b/lib/gl/m4/time_r.m4
index de22db906c..b5938e7963 100644
--- a/lib/gl/m4/time_r.m4
+++ b/lib/gl/m4/time_r.m4
@@ -1,6 +1,7 @@
dnl Reentrant time functions like localtime_r.
-dnl Copyright (C) 2003, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
+dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/uintmax_t.m4 b/lib/gl/m4/uintmax_t.m4
index 734b6933e2..03b51bcfe3 100644
--- a/lib/gl/m4/uintmax_t.m4
+++ b/lib/gl/m4/uintmax_t.m4
@@ -1,5 +1,5 @@
# uintmax_t.m4 serial 12
-dnl Copyright (C) 1997-2004, 2007-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2004, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/ungetc.m4 b/lib/gl/m4/ungetc.m4
index eb652356b5..68ccf88349 100644
--- a/lib/gl/m4/ungetc.m4
+++ b/lib/gl/m4/ungetc.m4
@@ -1,5 +1,5 @@
# ungetc.m4 serial 2
-dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -13,21 +13,21 @@ AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
]], [FILE *f;
- if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
- if (fputs ("abc", f) < 0) return 2;
- rewind (f);
- if (fgetc (f) != 'a') return 3;
- if (fgetc (f) != 'b') return 4;
- if (ungetc ('d', f) != 'd') return 5;
- if (ftell (f) != 1) return 6;
- if (fgetc (f) != 'd') return 7;
- if (ftell (f) != 2) return 8;
- if (fseek (f, 0, SEEK_CUR) != 0) return 9;
- if (ftell (f) != 2) return 10;
- if (fgetc (f) != 'c') return 11;
- fclose (f); remove ("conftest.tmp");])],
- [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
- [gl_cv_func_ungetc_works='guessing no'])
+ if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
+ if (fputs ("abc", f) < 0) return 2;
+ rewind (f);
+ if (fgetc (f) != 'a') return 3;
+ if (fgetc (f) != 'b') return 4;
+ if (ungetc ('d', f) != 'd') return 5;
+ if (ftell (f) != 1) return 6;
+ if (fgetc (f) != 'd') return 7;
+ if (ftell (f) != 2) return 8;
+ if (fseek (f, 0, SEEK_CUR) != 0) return 9;
+ if (ftell (f) != 2) return 10;
+ if (fgetc (f) != 'c') return 11;
+ fclose (f); remove ("conftest.tmp");])],
+ [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
+ [gl_cv_func_ungetc_works='guessing no'])
])
if test "$gl_cv_func_ungetc_works" != yes; then
AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
diff --git a/lib/gl/m4/unistd_h.m4 b/lib/gl/m4/unistd_h.m4
index 88e60a0538..31d31c1e93 100644
--- a/lib/gl/m4/unistd_h.m4
+++ b/lib/gl/m4/unistd_h.m4
@@ -1,5 +1,5 @@
-# unistd_h.m4 serial 34
-dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
+# unistd_h.m4 serial 39
+dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -11,6 +11,7 @@ AC_DEFUN([gl_UNISTD_H],
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
dnl once only, before all statements that occur in other macros.
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_REQUIRE([AC_C_INLINE])
gl_CHECK_NEXT_HEADERS([unistd.h])
@@ -21,6 +22,24 @@ AC_DEFUN([gl_UNISTD_H],
HAVE_UNISTD_H=0
fi
AC_SUBST([HAVE_UNISTD_H])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[#include <unistd.h>
+/* Some systems declare various items in the wrong headers. */
+#ifndef __GLIBC__
+# include <fcntl.h>
+# include <stdio.h>
+# include <stdlib.h>
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# include <io.h>
+# endif
+#endif
+ ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat
+ fsync ftruncate getcwd getdomainname getdtablesize getgroups
+ gethostname getlogin getlogin_r getpagesize getusershell setusershell
+ endusershell lchown link linkat lseek pipe2 pread readlink readlinkat
+ rmdir sleep symlink symlinkat unlink unlinkat usleep])
])
AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
@@ -48,6 +67,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
+ GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
@@ -56,6 +76,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
+ GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
@@ -66,6 +87,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
+ GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
@@ -80,12 +102,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
+ HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL])
HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
HAVE_LINK=1; AC_SUBST([HAVE_LINK])
HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
+ HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
@@ -96,6 +120,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
+ HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
@@ -109,11 +134,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
+ REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
+ REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
+ REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
diff --git a/lib/gl/m4/vasnprintf.m4 b/lib/gl/m4/vasnprintf.m4
index 3a1d1e0100..50a20cca23 100644
--- a/lib/gl/m4/vasnprintf.m4
+++ b/lib/gl/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
# vasnprintf.m4 serial 29
-dnl Copyright (C) 2002-2004, 2006-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/vasprintf.m4 b/lib/gl/m4/vasprintf.m4
index 074b03cf72..b142bc0ff1 100644
--- a/lib/gl/m4/vasprintf.m4
+++ b/lib/gl/m4/vasprintf.m4
@@ -1,5 +1,6 @@
# vasprintf.m4 serial 6
-dnl Copyright (C) 2002-2003, 2006-2007 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2003, 2006-2007, 2009-2010 Free Software Foundation,
+dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/visibility.m4 b/lib/gl/m4/visibility.m4
index 70bca56437..35a6dc0e7d 100644
--- a/lib/gl/m4/visibility.m4
+++ b/lib/gl/m4/visibility.m4
@@ -1,5 +1,5 @@
# visibility.m4 serial 2 (gettext-0.18)
-dnl Copyright (C) 2005, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/vsnprintf.m4 b/lib/gl/m4/vsnprintf.m4
index 3b37d460b3..ed189c2388 100644
--- a/lib/gl/m4/vsnprintf.m4
+++ b/lib/gl/m4/vsnprintf.m4
@@ -1,5 +1,5 @@
# vsnprintf.m4 serial 5
-dnl Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/wchar.m4 b/lib/gl/m4/wchar.m4
index ce53a45cf5..e81485d01e 100644
--- a/lib/gl/m4/wchar.m4
+++ b/lib/gl/m4/wchar.m4
@@ -1,23 +1,30 @@
dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
-dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Written by Eric Blake.
-# wchar.m4 serial 25
+# wchar.m4 serial 31
AC_DEFUN([gl_WCHAR_H],
[
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
- AC_CACHE_CHECK([whether <wchar.h> is standalone],
- [gl_cv_header_wchar_h_standalone],
- [AC_COMPILE_IFELSE([[#include <wchar.h>
-wchar_t w;]],
- [gl_cv_header_wchar_h_standalone=yes],
- [gl_cv_header_wchar_h_standalone=no])])
+ AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
+ dnl Prepare for creating substitute <wchar.h>.
+ dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
+ dnl character support).
+ dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
+ AC_CHECK_HEADERS_ONCE([wchar.h])
+ gl_CHECK_NEXT_HEADERS([wchar.h])
+ if test $ac_cv_header_wchar_h = yes; then
+ HAVE_WCHAR_H=1
+ else
+ HAVE_WCHAR_H=0
+ fi
+ AC_SUBST([HAVE_WCHAR_H])
AC_REQUIRE([gt_TYPE_WINT_T])
if test $gt_cv_c_wint_t = yes; then
@@ -27,32 +34,73 @@ wchar_t w;]],
fi
AC_SUBST([HAVE_WINT_T])
- dnl If <stddef.h> is replaced, then <wchar.h> must also be replaced.
- AC_REQUIRE([gl_STDDEF_H])
-
- if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
- WCHAR_H=wchar.h
- fi
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+/* Some systems require additional headers. */
+#ifndef __GLIBC__
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+#endif
+#include <wchar.h>
+ ]], [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
+ wcsrtombs wcsnrtombs wcwidth])
+])
- dnl Prepare for creating substitute <wchar.h>.
- dnl Do it always: WCHAR_H may be empty here but can be set later.
- dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
- dnl character support).
- AC_CHECK_HEADERS_ONCE([wchar.h])
- if test $ac_cv_header_wchar_h = yes; then
- HAVE_WCHAR_H=1
- else
- HAVE_WCHAR_H=0
+dnl Check whether <wchar.h> is usable at all.
+AC_DEFUN([gl_WCHAR_H_INLINE_OK],
+[
+ dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
+ dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
+ dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
+ dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
+ dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
+ AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
+ [gl_cv_header_wchar_h_correct_inline],
+ [gl_cv_header_wchar_h_correct_inline=yes
+ AC_LANG_CONFTEST([
+ AC_LANG_SOURCE([[#define wcstod renamed_wcstod
+#include <wchar.h>
+extern int zero (void);
+int main () { return zero(); }
+]])])
+ if AC_TRY_EVAL([ac_compile]); then
+ mv conftest.$ac_objext conftest1.$ac_objext
+ AC_LANG_CONFTEST([
+ AC_LANG_SOURCE([[#define wcstod renamed_wcstod
+#include <wchar.h>
+int zero (void) { return 0; }
+]])])
+ if AC_TRY_EVAL([ac_compile]); then
+ mv conftest.$ac_objext conftest2.$ac_objext
+ if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
+ :
+ else
+ gl_cv_header_wchar_h_correct_inline=no
+ fi
+ fi
+ fi
+ rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
+ ])
+ if test $gl_cv_header_wchar_h_correct_inline = no; then
+ AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
+This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
+C99 mode. You have four options:
+ - Add the flag -fgnu89-inline to CC and reconfigure, or
+ - Fix your include files, using parts of
+ <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
+ - Use a gcc version older than 4.3, or
+ - Don't use the flags -std=c99 or -std=gnu99.
+Configuration aborted.])
fi
- AC_SUBST([HAVE_WCHAR_H])
- gl_CHECK_NEXT_HEADERS([wchar.h])
])
dnl Unconditionally enables the replacement of <wchar.h>.
AC_DEFUN([gl_REPLACE_WCHAR_H],
[
- AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
- WCHAR_H=wchar.h
+ dnl This is a no-op, because <wchar.h> is always overridden.
+ :
])
AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
@@ -99,5 +147,4 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
- WCHAR_H=''; AC_SUBST([WCHAR_H])
])
diff --git a/lib/gl/m4/wchar_t.m4 b/lib/gl/m4/wchar_t.m4
index fb27a7f65f..ed804e664b 100644
--- a/lib/gl/m4/wchar_t.m4
+++ b/lib/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
# wchar_t.m4 serial 3 (gettext-0.18)
-dnl Copyright (C) 2002-2003, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/wint_t.m4 b/lib/gl/m4/wint_t.m4
index 47a4363d79..a6c7d15cb5 100644
--- a/lib/gl/m4/wint_t.m4
+++ b/lib/gl/m4/wint_t.m4
@@ -1,5 +1,5 @@
# wint_t.m4 serial 4 (gettext-0.18)
-dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/m4/xsize.m4 b/lib/gl/m4/xsize.m4
index 631893cf59..b653693a30 100644
--- a/lib/gl/m4/xsize.m4
+++ b/lib/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
# xsize.m4 serial 4
-dnl Copyright (C) 2003-2004, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2003-2004, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
diff --git a/lib/gl/memchr.c b/lib/gl/memchr.c
index a57179d52f..b0af681bae 100644
--- a/lib/gl/memchr.c
+++ b/lib/gl/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2010
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
@@ -97,15 +97,15 @@ __memchr (void const *s, int c_in, size_t n)
repeated_one |= repeated_one << 31 << 1;
repeated_c |= repeated_c << 31 << 1;
if (8 < sizeof (longword))
- {
- size_t i;
-
- for (i = 64; i < sizeof (longword) * 8; i *= 2)
- {
- repeated_one |= repeated_one << i;
- repeated_c |= repeated_c << i;
- }
- }
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
}
/* Instead of the traditional loop which tests each byte, we will test a
@@ -144,8 +144,8 @@ __memchr (void const *s, int c_in, size_t n)
longword longword1 = *longword_ptr ^ repeated_c;
if ((((longword1 - repeated_one) & ~longword1)
- & (repeated_one << 7)) != 0)
- break;
+ & (repeated_one << 7)) != 0)
+ break;
longword_ptr++;
n -= sizeof (longword);
}
@@ -162,7 +162,7 @@ __memchr (void const *s, int c_in, size_t n)
for (; n > 0; --n, ++char_ptr)
{
if (*char_ptr == c)
- return (void *) char_ptr;
+ return (void *) char_ptr;
}
return NULL;
diff --git a/lib/gl/memmem.c b/lib/gl/memmem.c
index e4816ed1a4..544ed45551 100644
--- a/lib/gl/memmem.c
+++ b/lib/gl/memmem.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 1991,92,93,94,96,97,98,2000,2004,2007,2008 Free Software
- Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000, 2004, 2007,
+ 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@@ -38,7 +38,7 @@
HAYSTACK. */
void *
memmem (const void *haystack_start, size_t haystack_len,
- const void *needle_start, size_t needle_len)
+ const void *needle_start, size_t needle_len)
{
/* Abstract memory is considered to be an array of 'unsigned char' values,
not an array of 'char' values. See ISO C 99 section 6.2.6.1. */
@@ -63,10 +63,10 @@ memmem (const void *haystack_start, size_t haystack_len,
{
haystack = memchr (haystack, *needle, haystack_len);
if (!haystack || __builtin_expect (needle_len == 1, 0))
- return (void *) haystack;
+ return (void *) haystack;
haystack_len -= haystack - (const unsigned char *) haystack_start;
if (haystack_len < needle_len)
- return NULL;
+ return NULL;
return two_way_short_needle (haystack, haystack_len, needle, needle_len);
}
else
diff --git a/lib/gl/minmax.h b/lib/gl/minmax.h
index 431e7dd918..76a683daa5 100644
--- a/lib/gl/minmax.h
+++ b/lib/gl/minmax.h
@@ -1,5 +1,6 @@
/* MIN, MAX macros.
- Copyright (C) 1995, 1998, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009, 2010 Free Software
+ Foundation, Inc.
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
diff --git a/lib/gl/netdb.in.h b/lib/gl/netdb.in.h
index a81e2b4378..e16d587a49 100644
--- a/lib/gl/netdb.in.h
+++ b/lib/gl/netdb.in.h
@@ -1,5 +1,5 @@
/* Provide a netdb.h header file for systems lacking it (read: MinGW).
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2010 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -39,6 +39,8 @@
/* Get netdb.h definitions such as struct hostent for MinGW. */
#include <sys/socket.h>
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
/* Declarations for a platform that lacks <netdb.h>, or where it is
incomplete. */
@@ -49,26 +51,26 @@
/* Structure to contain information about address of a service provider. */
struct addrinfo
{
- int ai_flags; /* Input flags. */
- int ai_family; /* Protocol family for socket. */
- int ai_socktype; /* Socket type. */
- int ai_protocol; /* Protocol for socket. */
- socklen_t ai_addrlen; /* Length of socket address. */
- struct sockaddr *ai_addr; /* Socket address for socket. */
- char *ai_canonname; /* Canonical name for service location. */
- struct addrinfo *ai_next; /* Pointer to next in list. */
+ int ai_flags; /* Input flags. */
+ int ai_family; /* Protocol family for socket. */
+ int ai_socktype; /* Socket type. */
+ int ai_protocol; /* Protocol for socket. */
+ socklen_t ai_addrlen; /* Length of socket address. */
+ struct sockaddr *ai_addr; /* Socket address for socket. */
+ char *ai_canonname; /* Canonical name for service location. */
+ struct addrinfo *ai_next; /* Pointer to next in list. */
};
# endif
/* Possible values for `ai_flags' field in `addrinfo' structure. */
# ifndef AI_PASSIVE
-# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
+# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
# endif
# ifndef AI_CANONNAME
-# define AI_CANONNAME 0x0002 /* Request for canonical name. */
+# define AI_CANONNAME 0x0002 /* Request for canonical name. */
# endif
# ifndef AI_NUMERICSERV
-# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
+# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
# endif
# if 0
@@ -78,24 +80,24 @@ struct addrinfo
define them.
If they are restored, be sure to protect the definitions with #ifndef. */
-# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
-# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
-# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
-# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
- returned address type.. */
+# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
+# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
+# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
+# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
+ returned address type.. */
# endif /* 0 */
/* Error values for `getaddrinfo' function. */
# ifndef EAI_BADFLAGS
-# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
-# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
-# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
-# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
-# define EAI_NODATA -5 /* No address associated with NAME. */
-# define EAI_FAMILY -6 /* `ai_family' not supported. */
-# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
-# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
-# define EAI_MEMORY -10 /* Memory allocation failure. */
+# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
+# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
+# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
+# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
+# define EAI_NODATA -5 /* No address associated with NAME. */
+# define EAI_FAMILY -6 /* `ai_family' not supported. */
+# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
+# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
+# define EAI_MEMORY -10 /* Memory allocation failure. */
# endif
/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
@@ -107,15 +109,15 @@ struct addrinfo
# ifndef EAI_OVERFLOW
/* Not defined on mingw32 and Haiku. */
-# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
+# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
# endif
# ifndef EAI_ADDRFAMILY
/* Not defined on mingw32. */
-# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
+# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
# endif
# ifndef EAI_SYSTEM
/* Not defined on mingw32. */
-# define EAI_SYSTEM -11 /* System error returned in `errno'. */
+# define EAI_SYSTEM -11 /* System error returned in `errno'. */
# endif
# if 0
@@ -124,12 +126,12 @@ struct addrinfo
If they are restored, be sure to protect the definitions with #ifndef. */
# ifndef EAI_INPROGRESS
-# define EAI_INPROGRESS -100 /* Processing request in progress. */
-# define EAI_CANCELED -101 /* Request canceled. */
-# define EAI_NOTCANCELED -102 /* Request not canceled. */
-# define EAI_ALLDONE -103 /* All requests done. */
-# define EAI_INTR -104 /* Interrupted by a signal. */
-# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
+# define EAI_INPROGRESS -100 /* Processing request in progress. */
+# define EAI_CANCELED -101 /* Request canceled. */
+# define EAI_NOTCANCELED -102 /* Request not canceled. */
+# define EAI_ALLDONE -103 /* All requests done. */
+# define EAI_INTR -104 /* Interrupted by a signal. */
+# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
# endif
# endif
@@ -139,16 +141,17 @@ struct addrinfo
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
extern int getaddrinfo (const char *restrict nodename,
- const char *restrict servname,
- const struct addrinfo *restrict hints,
- struct addrinfo **restrict res);
+ const char *restrict servname,
+ const struct addrinfo *restrict hints,
+ struct addrinfo **restrict res)
+ _GL_ARG_NONNULL ((4));
# endif
# if !@HAVE_DECL_FREEADDRINFO@
/* Free `addrinfo' structure AI including associated storage.
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
-extern void freeaddrinfo (struct addrinfo *ai);
+extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1));
# endif
# if !@HAVE_DECL_GAI_STRERROR@
@@ -163,9 +166,10 @@ extern const char *gai_strerror (int ecode);
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
- char *restrict node, socklen_t nodelen,
- char *restrict service, socklen_t servicelen,
- int flags);
+ char *restrict node, socklen_t nodelen,
+ char *restrict service, socklen_t servicelen,
+ int flags)
+ _GL_ARG_NONNULL ((1));
# endif
/* Possible flags for getnameinfo. */
diff --git a/lib/gl/override/lib/gettext.h.diff b/lib/gl/override/lib/gettext.h.diff
index ec8f03fe78..ae7f6a8107 100644
--- a/lib/gl/override/lib/gettext.h.diff
+++ b/lib/gl/override/lib/gettext.h.diff
@@ -1,6 +1,6 @@
---- lib/gl/gettext.h.orig 2008-11-17 17:11:58.000000000 +0100
-+++ lib/gl/gettext.h 2008-11-17 17:12:03.000000000 +0100
-@@ -162,109 +162,4 @@
+--- lib/gl/gettext.h.orig 2010-01-26 15:38:07.000000000 +0100
++++ lib/gl/gettext.h 2010-01-26 15:38:14.000000000 +0100
+@@ -172,109 +172,4 @@
return translation;
}
@@ -32,8 +32,8 @@
-#endif
-static const char *
-dcpgettext_expr (const char *domain,
-- const char *msgctxt, const char *msgid,
-- int category)
+- const char *msgctxt, const char *msgid,
+- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
@@ -55,10 +55,10 @@
- translation = dcgettext (domain, msg_ctxt_id, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
-- free (msg_ctxt_id);
+- free (msg_ctxt_id);
-#endif
- if (translation != msg_ctxt_id)
-- return translation;
+- return translation;
- }
- return msgid;
-}
@@ -77,9 +77,9 @@
-#endif
-static const char *
-dcnpgettext_expr (const char *domain,
-- const char *msgctxt, const char *msgid,
-- const char *msgid_plural, unsigned long int n,
-- int category)
+- const char *msgctxt, const char *msgid,
+- const char *msgid_plural, unsigned long int n,
+- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
@@ -101,10 +101,10 @@
- translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
-- free (msg_ctxt_id);
+- free (msg_ctxt_id);
-#endif
- if (!(translation == msg_ctxt_id || translation == msgid_plural))
-- return translation;
+- return translation;
- }
- return (n == 1 ? msgid : msgid_plural);
-}
diff --git a/lib/gl/printf-args.c b/lib/gl/printf-args.c
index bf2e60b724..b37cae2004 100644
--- a/lib/gl/printf-args.c
+++ b/lib/gl/printf-args.c
@@ -1,5 +1,6 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 Free Software
+ Foundation, Inc.
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
@@ -42,146 +43,146 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
switch (ap->type)
{
case TYPE_SCHAR:
- ap->a.a_schar = va_arg (args, /*signed char*/ int);
- break;
+ ap->a.a_schar = va_arg (args, /*signed char*/ int);
+ break;
case TYPE_UCHAR:
- ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
- break;
+ ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
+ break;
case TYPE_SHORT:
- ap->a.a_short = va_arg (args, /*short*/ int);
- break;
+ ap->a.a_short = va_arg (args, /*short*/ int);
+ break;
case TYPE_USHORT:
- ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
- break;
+ ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
+ break;
case TYPE_INT:
- ap->a.a_int = va_arg (args, int);
- break;
+ ap->a.a_int = va_arg (args, int);
+ break;
case TYPE_UINT:
- ap->a.a_uint = va_arg (args, unsigned int);
- break;
+ ap->a.a_uint = va_arg (args, unsigned int);
+ break;
case TYPE_LONGINT:
- ap->a.a_longint = va_arg (args, long int);
- break;
+ ap->a.a_longint = va_arg (args, long int);
+ break;
case TYPE_ULONGINT:
- ap->a.a_ulongint = va_arg (args, unsigned long int);
- break;
+ ap->a.a_ulongint = va_arg (args, unsigned long int);
+ break;
#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
- ap->a.a_longlongint = va_arg (args, long long int);
- break;
+ ap->a.a_longlongint = va_arg (args, long long int);
+ break;
case TYPE_ULONGLONGINT:
- ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
- break;
+ ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
+ break;
#endif
case TYPE_DOUBLE:
- ap->a.a_double = va_arg (args, double);
- break;
+ ap->a.a_double = va_arg (args, double);
+ break;
case TYPE_LONGDOUBLE:
- ap->a.a_longdouble = va_arg (args, long double);
- break;
+ ap->a.a_longdouble = va_arg (args, long double);
+ break;
case TYPE_CHAR:
- ap->a.a_char = va_arg (args, int);
- break;
+ ap->a.a_char = va_arg (args, int);
+ break;
#if HAVE_WINT_T
case TYPE_WIDE_CHAR:
- /* 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,
- where wint_t is 'unsigned short'. */
- ap->a.a_wide_char =
- (sizeof (wint_t) < sizeof (int)
- ? va_arg (args, int)
- : va_arg (args, wint_t));
- break;
+ /* 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,
+ where wint_t is 'unsigned short'. */
+ ap->a.a_wide_char =
+ (sizeof (wint_t) < sizeof (int)
+ ? (wint_t) va_arg (args, int)
+ : va_arg (args, wint_t));
+ break;
#endif
case TYPE_STRING:
- ap->a.a_string = va_arg (args, const char *);
- /* A null pointer is an invalid argument for "%s", but in practice
- it occurs quite frequently in printf statements that produce
- debug output. Use a fallback in this case. */
- if (ap->a.a_string == NULL)
- ap->a.a_string = "(NULL)";
- break;
+ ap->a.a_string = va_arg (args, const char *);
+ /* A null pointer is an invalid argument for "%s", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_string == NULL)
+ ap->a.a_string = "(NULL)";
+ break;
#if HAVE_WCHAR_T
case TYPE_WIDE_STRING:
- ap->a.a_wide_string = va_arg (args, const wchar_t *);
- /* A null pointer is an invalid argument for "%ls", but in practice
- it occurs quite frequently in printf statements that produce
- debug output. Use a fallback in this case. */
- if (ap->a.a_wide_string == NULL)
- {
- static const wchar_t wide_null_string[] =
- {
- (wchar_t)'(',
- (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
- (wchar_t)')',
- (wchar_t)0
- };
- ap->a.a_wide_string = wide_null_string;
- }
- break;
+ ap->a.a_wide_string = va_arg (args, const wchar_t *);
+ /* A null pointer is an invalid argument for "%ls", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_wide_string == NULL)
+ {
+ static const wchar_t wide_null_string[] =
+ {
+ (wchar_t)'(',
+ (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
+ (wchar_t)')',
+ (wchar_t)0
+ };
+ ap->a.a_wide_string = wide_null_string;
+ }
+ break;
#endif
case TYPE_POINTER:
- ap->a.a_pointer = va_arg (args, void *);
- break;
+ ap->a.a_pointer = va_arg (args, void *);
+ break;
case TYPE_COUNT_SCHAR_POINTER:
- ap->a.a_count_schar_pointer = va_arg (args, signed char *);
- break;
+ ap->a.a_count_schar_pointer = va_arg (args, signed char *);
+ break;
case TYPE_COUNT_SHORT_POINTER:
- ap->a.a_count_short_pointer = va_arg (args, short *);
- break;
+ ap->a.a_count_short_pointer = va_arg (args, short *);
+ break;
case TYPE_COUNT_INT_POINTER:
- ap->a.a_count_int_pointer = va_arg (args, int *);
- break;
+ ap->a.a_count_int_pointer = va_arg (args, int *);
+ break;
case TYPE_COUNT_LONGINT_POINTER:
- ap->a.a_count_longint_pointer = va_arg (args, long int *);
- break;
+ ap->a.a_count_longint_pointer = va_arg (args, long int *);
+ break;
#if HAVE_LONG_LONG_INT
case TYPE_COUNT_LONGLONGINT_POINTER:
- ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
- break;
+ ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
+ break;
#endif
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
case TYPE_U8_STRING:
- ap->a.a_u8_string = va_arg (args, const uint8_t *);
- /* A null pointer is an invalid argument for "%U", but in practice
- it occurs quite frequently in printf statements that produce
- debug output. Use a fallback in this case. */
- if (ap->a.a_u8_string == NULL)
- {
- static const uint8_t u8_null_string[] =
- { '(', 'N', 'U', 'L', 'L', ')', 0 };
- ap->a.a_u8_string = u8_null_string;
- }
- break;
+ ap->a.a_u8_string = va_arg (args, const uint8_t *);
+ /* A null pointer is an invalid argument for "%U", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_u8_string == NULL)
+ {
+ static const uint8_t u8_null_string[] =
+ { '(', 'N', 'U', 'L', 'L', ')', 0 };
+ ap->a.a_u8_string = u8_null_string;
+ }
+ break;
case TYPE_U16_STRING:
- ap->a.a_u16_string = va_arg (args, const uint16_t *);
- /* A null pointer is an invalid argument for "%lU", but in practice
- it occurs quite frequently in printf statements that produce
- debug output. Use a fallback in this case. */
- if (ap->a.a_u16_string == NULL)
- {
- static const uint16_t u16_null_string[] =
- { '(', 'N', 'U', 'L', 'L', ')', 0 };
- ap->a.a_u16_string = u16_null_string;
- }
- break;
+ ap->a.a_u16_string = va_arg (args, const uint16_t *);
+ /* A null pointer is an invalid argument for "%lU", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_u16_string == NULL)
+ {
+ static const uint16_t u16_null_string[] =
+ { '(', 'N', 'U', 'L', 'L', ')', 0 };
+ ap->a.a_u16_string = u16_null_string;
+ }
+ break;
case TYPE_U32_STRING:
- ap->a.a_u32_string = va_arg (args, const uint32_t *);
- /* A null pointer is an invalid argument for "%llU", but in practice
- it occurs quite frequently in printf statements that produce
- debug output. Use a fallback in this case. */
- if (ap->a.a_u32_string == NULL)
- {
- static const uint32_t u32_null_string[] =
- { '(', 'N', 'U', 'L', 'L', ')', 0 };
- ap->a.a_u32_string = u32_null_string;
- }
- break;
+ ap->a.a_u32_string = va_arg (args, const uint32_t *);
+ /* A null pointer is an invalid argument for "%llU", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_u32_string == NULL)
+ {
+ static const uint32_t u32_null_string[] =
+ { '(', 'N', 'U', 'L', 'L', ')', 0 };
+ ap->a.a_u32_string = u32_null_string;
+ }
+ break;
#endif
default:
- /* Unknown type. */
- return -1;
+ /* Unknown type. */
+ return -1;
}
return 0;
}
diff --git a/lib/gl/printf-args.h b/lib/gl/printf-args.h
index b663a63b17..fcdee85c0d 100644
--- a/lib/gl/printf-args.h
+++ b/lib/gl/printf-args.h
@@ -1,5 +1,6 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2003, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
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
@@ -93,42 +94,42 @@ typedef struct
arg_type type;
union
{
- signed char a_schar;
- unsigned char a_uchar;
- short a_short;
- unsigned short a_ushort;
- int a_int;
- unsigned int a_uint;
- long int a_longint;
- unsigned long int a_ulongint;
+ signed char a_schar;
+ unsigned char a_uchar;
+ short a_short;
+ unsigned short a_ushort;
+ int a_int;
+ unsigned int a_uint;
+ long int a_longint;
+ unsigned long int a_ulongint;
#if HAVE_LONG_LONG_INT
- long long int a_longlongint;
- unsigned long long int a_ulonglongint;
+ long long int a_longlongint;
+ unsigned long long int a_ulonglongint;
#endif
- float a_float;
- double a_double;
- long double a_longdouble;
- int a_char;
+ float a_float;
+ double a_double;
+ long double a_longdouble;
+ int a_char;
#if HAVE_WINT_T
- wint_t a_wide_char;
+ wint_t a_wide_char;
#endif
- const char* a_string;
+ const char* a_string;
#if HAVE_WCHAR_T
- const wchar_t* a_wide_string;
+ const wchar_t* a_wide_string;
#endif
- void* a_pointer;
- signed char * a_count_schar_pointer;
- short * a_count_short_pointer;
- int * a_count_int_pointer;
- long int * a_count_longint_pointer;
+ void* a_pointer;
+ signed char * a_count_schar_pointer;
+ short * a_count_short_pointer;
+ int * a_count_int_pointer;
+ long int * a_count_longint_pointer;
#if HAVE_LONG_LONG_INT
- long long int * a_count_longlongint_pointer;
+ long long int * a_count_longlongint_pointer;
#endif
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
- const uint8_t * a_u8_string;
- const uint16_t * a_u16_string;
- const uint32_t * a_u32_string;
+ const uint8_t * a_u8_string;
+ const uint16_t * a_u16_string;
+ const uint32_t * a_u32_string;
#endif
}
a;
diff --git a/lib/gl/printf-parse.c b/lib/gl/printf-parse.c
index 66b45a73f2..85be6d16c4 100644
--- a/lib/gl/printf-parse.c
+++ b/lib/gl/printf-parse.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2003, 2006-2008 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002-2003, 2006-2010 Free Software Foundation, Inc.
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
@@ -80,10 +80,10 @@ STATIC
int
PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
{
- const CHAR_T *cp = format; /* pointer into format */
- size_t arg_posn = 0; /* number of regular arguments consumed */
- size_t d_allocated; /* allocated elements of d->dir */
- size_t a_allocated; /* allocated elements of a->arg */
+ const CHAR_T *cp = format; /* pointer into format */
+ size_t arg_posn = 0; /* number of regular arguments consumed */
+ size_t d_allocated; /* allocated elements of d->dir */
+ size_t a_allocated; /* allocated elements of a->arg */
size_t max_width_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;
#define REGISTER_ARG(_index_,_type_) \
- { \
- size_t n = (_index_); \
- if (n >= a_allocated) \
- { \
- size_t memory_size; \
- argument *memory; \
- \
- a_allocated = xtimes (a_allocated, 2); \
- if (a_allocated <= n) \
- a_allocated = xsum (n, 1); \
- memory_size = xtimes (a_allocated, sizeof (argument)); \
- if (size_overflow_p (memory_size)) \
- /* Overflow, would lead to out of memory. */ \
- goto out_of_memory; \
- memory = (argument *) (a->arg \
- ? realloc (a->arg, memory_size) \
- : malloc (memory_size)); \
- if (memory == NULL) \
- /* Out of memory. */ \
- goto out_of_memory; \
- a->arg = memory; \
- } \
- while (a->count <= n) \
- a->arg[a->count++].type = TYPE_NONE; \
- if (a->arg[n].type == TYPE_NONE) \
- a->arg[n].type = (_type_); \
- else if (a->arg[n].type != (_type_)) \
- /* Ambiguous type for positional argument. */ \
- goto error; \
+ { \
+ size_t n = (_index_); \
+ if (n >= a_allocated) \
+ { \
+ size_t memory_size; \
+ argument *memory; \
+ \
+ a_allocated = xtimes (a_allocated, 2); \
+ if (a_allocated <= n) \
+ a_allocated = xsum (n, 1); \
+ memory_size = xtimes (a_allocated, sizeof (argument)); \
+ if (size_overflow_p (memory_size)) \
+ /* Overflow, would lead to out of memory. */ \
+ goto out_of_memory; \
+ memory = (argument *) (a->arg \
+ ? realloc (a->arg, memory_size) \
+ : malloc (memory_size)); \
+ if (memory == NULL) \
+ /* Out of memory. */ \
+ goto out_of_memory; \
+ a->arg = memory; \
+ } \
+ while (a->count <= n) \
+ a->arg[a->count++].type = TYPE_NONE; \
+ if (a->arg[n].type == TYPE_NONE) \
+ a->arg[n].type = (_type_); \
+ else if (a->arg[n].type != (_type_)) \
+ /* Ambiguous type for positional argument. */ \
+ goto error; \
}
while (*cp != '\0')
{
CHAR_T c = *cp++;
if (c == '%')
- {
- size_t arg_index = ARG_NONE;
- DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
-
- /* Initialize the next directive. */
- dp->dir_start = cp - 1;
- dp->flags = 0;
- dp->width_start = NULL;
- dp->width_end = NULL;
- dp->width_arg_index = ARG_NONE;
- dp->precision_start = NULL;
- dp->precision_end = NULL;
- dp->precision_arg_index = ARG_NONE;
- dp->arg_index = ARG_NONE;
-
- /* Test for positional argument. */
- if (*cp >= '0' && *cp <= '9')
- {
- const CHAR_T *np;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- ;
- if (*np == '$')
- {
- size_t n = 0;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- n = xsum (xtimes (n, 10), *np - '0');
- if (n == 0)
- /* Positional argument 0. */
- goto error;
- if (size_overflow_p (n))
- /* n too large, would lead to out of memory later. */
- goto error;
- arg_index = n - 1;
- cp = np + 1;
- }
- }
-
- /* Read the flags. */
- for (;;)
- {
- if (*cp == '\'')
- {
- dp->flags |= FLAG_GROUP;
- cp++;
- }
- else if (*cp == '-')
- {
- dp->flags |= FLAG_LEFT;
- cp++;
- }
- else if (*cp == '+')
- {
- dp->flags |= FLAG_SHOWSIGN;
- cp++;
- }
- else if (*cp == ' ')
- {
- dp->flags |= FLAG_SPACE;
- cp++;
- }
- else if (*cp == '#')
- {
- dp->flags |= FLAG_ALT;
- cp++;
- }
- else if (*cp == '0')
- {
- dp->flags |= FLAG_ZERO;
- cp++;
- }
- else
- break;
- }
-
- /* Parse the field width. */
- if (*cp == '*')
- {
- dp->width_start = cp;
- cp++;
- dp->width_end = cp;
- if (max_width_length < 1)
- max_width_length = 1;
-
- /* Test for positional argument. */
- if (*cp >= '0' && *cp <= '9')
- {
- const CHAR_T *np;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- ;
- if (*np == '$')
- {
- size_t n = 0;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- n = xsum (xtimes (n, 10), *np - '0');
- if (n == 0)
- /* Positional argument 0. */
- goto error;
- if (size_overflow_p (n))
- /* n too large, would lead to out of memory later. */
- goto error;
- dp->width_arg_index = n - 1;
- cp = np + 1;
- }
- }
- if (dp->width_arg_index == ARG_NONE)
- {
- dp->width_arg_index = arg_posn++;
- if (dp->width_arg_index == ARG_NONE)
- /* arg_posn wrapped around. */
- goto error;
- }
- REGISTER_ARG (dp->width_arg_index, TYPE_INT);
- }
- else if (*cp >= '0' && *cp <= '9')
- {
- size_t width_length;
-
- dp->width_start = cp;
- for (; *cp >= '0' && *cp <= '9'; cp++)
- ;
- dp->width_end = cp;
- width_length = dp->width_end - dp->width_start;
- if (max_width_length < width_length)
- max_width_length = width_length;
- }
-
- /* Parse the precision. */
- if (*cp == '.')
- {
- cp++;
- if (*cp == '*')
- {
- dp->precision_start = cp - 1;
- cp++;
- dp->precision_end = cp;
- if (max_precision_length < 2)
- max_precision_length = 2;
-
- /* Test for positional argument. */
- if (*cp >= '0' && *cp <= '9')
- {
- const CHAR_T *np;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- ;
- if (*np == '$')
- {
- size_t n = 0;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- n = xsum (xtimes (n, 10), *np - '0');
- if (n == 0)
- /* Positional argument 0. */
- goto error;
- if (size_overflow_p (n))
- /* n too large, would lead to out of memory
- later. */
- goto error;
- dp->precision_arg_index = n - 1;
- cp = np + 1;
- }
- }
- if (dp->precision_arg_index == ARG_NONE)
- {
- dp->precision_arg_index = arg_posn++;
- if (dp->precision_arg_index == ARG_NONE)
- /* arg_posn wrapped around. */
- goto error;
- }
- REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
- }
- else
- {
- size_t precision_length;
-
- dp->precision_start = cp - 1;
- for (; *cp >= '0' && *cp <= '9'; cp++)
- ;
- dp->precision_end = cp;
- precision_length = dp->precision_end - dp->precision_start;
- if (max_precision_length < precision_length)
- max_precision_length = precision_length;
- }
- }
-
- {
- arg_type type;
-
- /* Parse argument type/size specifiers. */
- {
- int flags = 0;
-
- for (;;)
- {
- if (*cp == 'h')
- {
- flags |= (1 << (flags & 1));
- cp++;
- }
- else if (*cp == 'L')
- {
- flags |= 4;
- cp++;
- }
- else if (*cp == 'l')
- {
- flags += 8;
- cp++;
- }
- else if (*cp == 'j')
- {
- if (sizeof (intmax_t) > sizeof (long))
- {
- /* intmax_t = long long */
- flags += 16;
- }
- else if (sizeof (intmax_t) > sizeof (int))
- {
- /* intmax_t = long */
- flags += 8;
- }
- cp++;
- }
- else if (*cp == 'z' || *cp == 'Z')
- {
- /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
- because the warning facility in gcc-2.95.2 understands
- only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
- if (sizeof (size_t) > sizeof (long))
- {
- /* size_t = long long */
- flags += 16;
- }
- else if (sizeof (size_t) > sizeof (int))
- {
- /* size_t = long */
- flags += 8;
- }
- cp++;
- }
- else if (*cp == 't')
- {
- if (sizeof (ptrdiff_t) > sizeof (long))
- {
- /* ptrdiff_t = long long */
- flags += 16;
- }
- else if (sizeof (ptrdiff_t) > sizeof (int))
- {
- /* ptrdiff_t = long */
- flags += 8;
- }
- cp++;
- }
+ {
+ size_t arg_index = ARG_NONE;
+ DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
+
+ /* Initialize the next directive. */
+ dp->dir_start = cp - 1;
+ dp->flags = 0;
+ dp->width_start = NULL;
+ dp->width_end = NULL;
+ dp->width_arg_index = ARG_NONE;
+ dp->precision_start = NULL;
+ dp->precision_end = NULL;
+ dp->precision_arg_index = ARG_NONE;
+ dp->arg_index = ARG_NONE;
+
+ /* Test for positional argument. */
+ if (*cp >= '0' && *cp <= '9')
+ {
+ const CHAR_T *np;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ ;
+ if (*np == '$')
+ {
+ size_t n = 0;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ n = xsum (xtimes (n, 10), *np - '0');
+ if (n == 0)
+ /* Positional argument 0. */
+ goto error;
+ if (size_overflow_p (n))
+ /* n too large, would lead to out of memory later. */
+ goto error;
+ arg_index = n - 1;
+ cp = np + 1;
+ }
+ }
+
+ /* Read the flags. */
+ for (;;)
+ {
+ if (*cp == '\'')
+ {
+ dp->flags |= FLAG_GROUP;
+ cp++;
+ }
+ else if (*cp == '-')
+ {
+ dp->flags |= FLAG_LEFT;
+ cp++;
+ }
+ else if (*cp == '+')
+ {
+ dp->flags |= FLAG_SHOWSIGN;
+ cp++;
+ }
+ else if (*cp == ' ')
+ {
+ dp->flags |= FLAG_SPACE;
+ cp++;
+ }
+ else if (*cp == '#')
+ {
+ dp->flags |= FLAG_ALT;
+ cp++;
+ }
+ else if (*cp == '0')
+ {
+ dp->flags |= FLAG_ZERO;
+ cp++;
+ }
+ else
+ break;
+ }
+
+ /* Parse the field width. */
+ if (*cp == '*')
+ {
+ dp->width_start = cp;
+ cp++;
+ dp->width_end = cp;
+ if (max_width_length < 1)
+ max_width_length = 1;
+
+ /* Test for positional argument. */
+ if (*cp >= '0' && *cp <= '9')
+ {
+ const CHAR_T *np;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ ;
+ if (*np == '$')
+ {
+ size_t n = 0;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ n = xsum (xtimes (n, 10), *np - '0');
+ if (n == 0)
+ /* Positional argument 0. */
+ goto error;
+ if (size_overflow_p (n))
+ /* n too large, would lead to out of memory later. */
+ goto error;
+ dp->width_arg_index = n - 1;
+ cp = np + 1;
+ }
+ }
+ if (dp->width_arg_index == ARG_NONE)
+ {
+ dp->width_arg_index = arg_posn++;
+ if (dp->width_arg_index == ARG_NONE)
+ /* arg_posn wrapped around. */
+ goto error;
+ }
+ REGISTER_ARG (dp->width_arg_index, TYPE_INT);
+ }
+ else if (*cp >= '0' && *cp <= '9')
+ {
+ size_t width_length;
+
+ dp->width_start = cp;
+ for (; *cp >= '0' && *cp <= '9'; cp++)
+ ;
+ dp->width_end = cp;
+ width_length = dp->width_end - dp->width_start;
+ if (max_width_length < width_length)
+ max_width_length = width_length;
+ }
+
+ /* Parse the precision. */
+ if (*cp == '.')
+ {
+ cp++;
+ if (*cp == '*')
+ {
+ dp->precision_start = cp - 1;
+ cp++;
+ dp->precision_end = cp;
+ if (max_precision_length < 2)
+ max_precision_length = 2;
+
+ /* Test for positional argument. */
+ if (*cp >= '0' && *cp <= '9')
+ {
+ const CHAR_T *np;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ ;
+ if (*np == '$')
+ {
+ size_t n = 0;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ n = xsum (xtimes (n, 10), *np - '0');
+ if (n == 0)
+ /* Positional argument 0. */
+ goto error;
+ if (size_overflow_p (n))
+ /* n too large, would lead to out of memory
+ later. */
+ goto error;
+ dp->precision_arg_index = n - 1;
+ cp = np + 1;
+ }
+ }
+ if (dp->precision_arg_index == ARG_NONE)
+ {
+ dp->precision_arg_index = arg_posn++;
+ if (dp->precision_arg_index == ARG_NONE)
+ /* arg_posn wrapped around. */
+ goto error;
+ }
+ REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
+ }
+ else
+ {
+ size_t precision_length;
+
+ dp->precision_start = cp - 1;
+ for (; *cp >= '0' && *cp <= '9'; cp++)
+ ;
+ dp->precision_end = cp;
+ precision_length = dp->precision_end - dp->precision_start;
+ if (max_precision_length < precision_length)
+ max_precision_length = precision_length;
+ }
+ }
+
+ {
+ arg_type type;
+
+ /* Parse argument type/size specifiers. */
+ {
+ int flags = 0;
+
+ for (;;)
+ {
+ if (*cp == 'h')
+ {
+ flags |= (1 << (flags & 1));
+ cp++;
+ }
+ else if (*cp == 'L')
+ {
+ flags |= 4;
+ cp++;
+ }
+ else if (*cp == 'l')
+ {
+ flags += 8;
+ cp++;
+ }
+ else if (*cp == 'j')
+ {
+ if (sizeof (intmax_t) > sizeof (long))
+ {
+ /* intmax_t = long long */
+ flags += 16;
+ }
+ else if (sizeof (intmax_t) > sizeof (int))
+ {
+ /* intmax_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
+ else if (*cp == 'z' || *cp == 'Z')
+ {
+ /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
+ because the warning facility in gcc-2.95.2 understands
+ only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
+ if (sizeof (size_t) > sizeof (long))
+ {
+ /* size_t = long long */
+ flags += 16;
+ }
+ else if (sizeof (size_t) > sizeof (int))
+ {
+ /* size_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
+ else if (*cp == 't')
+ {
+ if (sizeof (ptrdiff_t) > sizeof (long))
+ {
+ /* ptrdiff_t = long long */
+ flags += 16;
+ }
+ else if (sizeof (ptrdiff_t) > sizeof (int))
+ {
+ /* ptrdiff_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
#if defined __APPLE__ && defined __MACH__
- /* On MacOS X 10.3, PRIdMAX is defined as "qd".
- We cannot change it to "lld" because PRIdMAX must also
- be understood by the system's printf routines. */
- else if (*cp == 'q')
- {
- if (64 / 8 > sizeof (long))
- {
- /* int64_t = long long */
- flags += 16;
- }
- else
- {
- /* int64_t = long */
- flags += 8;
- }
- cp++;
- }
+ /* On MacOS X 10.3, PRIdMAX is defined as "qd".
+ We cannot change it to "lld" because PRIdMAX must also
+ be understood by the system's printf routines. */
+ else if (*cp == 'q')
+ {
+ if (64 / 8 > sizeof (long))
+ {
+ /* int64_t = long long */
+ flags += 16;
+ }
+ else
+ {
+ /* int64_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
#endif
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- /* On native Win32, PRIdMAX is defined as "I64d".
- We cannot change it to "lld" because PRIdMAX must also
- be understood by the system's printf routines. */
- else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
- {
- if (64 / 8 > sizeof (long))
- {
- /* __int64 = long long */
- flags += 16;
- }
- else
- {
- /* __int64 = long */
- flags += 8;
- }
- cp += 3;
- }
+ /* On native Win32, PRIdMAX is defined as "I64d".
+ We cannot change it to "lld" because PRIdMAX must also
+ be understood by the system's printf routines. */
+ else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
+ {
+ if (64 / 8 > sizeof (long))
+ {
+ /* __int64 = long long */
+ flags += 16;
+ }
+ else
+ {
+ /* __int64 = long */
+ flags += 8;
+ }
+ cp += 3;
+ }
#endif
- else
- break;
- }
-
- /* Read the conversion character. */
- c = *cp++;
- switch (c)
- {
- case 'd': case 'i':
+ else
+ break;
+ }
+
+ /* Read the conversion character. */
+ c = *cp++;
+ switch (c)
+ {
+ case 'd': case 'i':
#if HAVE_LONG_LONG_INT
- /* If 'long long' exists and is larger than 'long': */
- if (flags >= 16 || (flags & 4))
- type = TYPE_LONGLONGINT;
- else
+ /* If 'long long' exists and is larger than 'long': */
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_LONGLONGINT;
+ else
#endif
- /* If 'long long' exists and is the same as 'long', we parse
- "lld" into TYPE_LONGINT. */
- if (flags >= 8)
- type = TYPE_LONGINT;
- else if (flags & 2)
- type = TYPE_SCHAR;
- else if (flags & 1)
- type = TYPE_SHORT;
- else
- type = TYPE_INT;
- break;
- case 'o': case 'u': case 'x': case 'X':
+ /* If 'long long' exists and is the same as 'long', we parse
+ "lld" into TYPE_LONGINT. */
+ if (flags >= 8)
+ type = TYPE_LONGINT;
+ else if (flags & 2)
+ type = TYPE_SCHAR;
+ else if (flags & 1)
+ type = TYPE_SHORT;
+ else
+ type = TYPE_INT;
+ break;
+ case 'o': case 'u': case 'x': case 'X':
#if HAVE_LONG_LONG_INT
- /* If 'long long' exists and is larger than 'long': */
- if (flags >= 16 || (flags & 4))
- type = TYPE_ULONGLONGINT;
- else
+ /* If 'long long' exists and is larger than 'long': */
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_ULONGLONGINT;
+ else
#endif
- /* If 'unsigned long long' exists and is the same as
- 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
- if (flags >= 8)
- type = TYPE_ULONGINT;
- else if (flags & 2)
- type = TYPE_UCHAR;
- else if (flags & 1)
- type = TYPE_USHORT;
- else
- type = TYPE_UINT;
- break;
- case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
- case 'a': case 'A':
- if (flags >= 16 || (flags & 4))
- type = TYPE_LONGDOUBLE;
- else
- type = TYPE_DOUBLE;
- break;
- case 'c':
- if (flags >= 8)
+ /* If 'unsigned long long' exists and is the same as
+ 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
+ if (flags >= 8)
+ type = TYPE_ULONGINT;
+ else if (flags & 2)
+ type = TYPE_UCHAR;
+ else if (flags & 1)
+ type = TYPE_USHORT;
+ else
+ type = TYPE_UINT;
+ break;
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+ case 'a': case 'A':
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_LONGDOUBLE;
+ else
+ type = TYPE_DOUBLE;
+ break;
+ case 'c':
+ if (flags >= 8)
#if HAVE_WINT_T
- type = TYPE_WIDE_CHAR;
+ type = TYPE_WIDE_CHAR;
#else
- goto error;
+ goto error;
#endif
- else
- type = TYPE_CHAR;
- break;
+ else
+ type = TYPE_CHAR;
+ break;
#if HAVE_WINT_T
- case 'C':
- type = TYPE_WIDE_CHAR;
- c = 'c';
- break;
+ case 'C':
+ type = TYPE_WIDE_CHAR;
+ c = 'c';
+ break;
#endif
- case 's':
- if (flags >= 8)
+ case 's':
+ if (flags >= 8)
#if HAVE_WCHAR_T
- type = TYPE_WIDE_STRING;
+ type = TYPE_WIDE_STRING;
#else
- goto error;
+ goto error;
#endif
- else
- type = TYPE_STRING;
- break;
+ else
+ type = TYPE_STRING;
+ break;
#if HAVE_WCHAR_T
- case 'S':
- type = TYPE_WIDE_STRING;
- c = 's';
- break;
+ case 'S':
+ type = TYPE_WIDE_STRING;
+ c = 's';
+ break;
#endif
- case 'p':
- type = TYPE_POINTER;
- break;
- case 'n':
+ case 'p':
+ type = TYPE_POINTER;
+ break;
+ case 'n':
#if HAVE_LONG_LONG_INT
- /* If 'long long' exists and is larger than 'long': */
- if (flags >= 16 || (flags & 4))
- type = TYPE_COUNT_LONGLONGINT_POINTER;
- else
+ /* If 'long long' exists and is larger than 'long': */
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_COUNT_LONGLONGINT_POINTER;
+ else
#endif
- /* If 'long long' exists and is the same as 'long', we parse
- "lln" into TYPE_COUNT_LONGINT_POINTER. */
- if (flags >= 8)
- type = TYPE_COUNT_LONGINT_POINTER;
- else if (flags & 2)
- type = TYPE_COUNT_SCHAR_POINTER;
- else if (flags & 1)
- type = TYPE_COUNT_SHORT_POINTER;
- else
- type = TYPE_COUNT_INT_POINTER;
- break;
+ /* If 'long long' exists and is the same as 'long', we parse
+ "lln" into TYPE_COUNT_LONGINT_POINTER. */
+ if (flags >= 8)
+ type = TYPE_COUNT_LONGINT_POINTER;
+ else if (flags & 2)
+ type = TYPE_COUNT_SCHAR_POINTER;
+ else if (flags & 1)
+ type = TYPE_COUNT_SHORT_POINTER;
+ else
+ type = TYPE_COUNT_INT_POINTER;
+ break;
#if ENABLE_UNISTDIO
- /* The unistdio extensions. */
- case 'U':
- if (flags >= 16)
- type = TYPE_U32_STRING;
- else if (flags >= 8)
- type = TYPE_U16_STRING;
- else
- type = TYPE_U8_STRING;
- break;
+ /* The unistdio extensions. */
+ case 'U':
+ if (flags >= 16)
+ type = TYPE_U32_STRING;
+ else if (flags >= 8)
+ type = TYPE_U16_STRING;
+ else
+ type = TYPE_U8_STRING;
+ break;
#endif
- case '%':
- type = TYPE_NONE;
- break;
- default:
- /* Unknown conversion character. */
- goto error;
- }
- }
-
- if (type != TYPE_NONE)
- {
- dp->arg_index = arg_index;
- if (dp->arg_index == ARG_NONE)
- {
- dp->arg_index = arg_posn++;
- if (dp->arg_index == ARG_NONE)
- /* arg_posn wrapped around. */
- goto error;
- }
- REGISTER_ARG (dp->arg_index, type);
- }
- dp->conversion = c;
- dp->dir_end = cp;
- }
-
- d->count++;
- if (d->count >= d_allocated)
- {
- size_t memory_size;
- DIRECTIVE *memory;
-
- d_allocated = xtimes (d_allocated, 2);
- memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
- if (size_overflow_p (memory_size))
- /* Overflow, would lead to out of memory. */
- goto out_of_memory;
- memory = (DIRECTIVE *) realloc (d->dir, memory_size);
- if (memory == NULL)
- /* Out of memory. */
- goto out_of_memory;
- d->dir = memory;
- }
- }
+ case '%':
+ type = TYPE_NONE;
+ break;
+ default:
+ /* Unknown conversion character. */
+ goto error;
+ }
+ }
+
+ if (type != TYPE_NONE)
+ {
+ dp->arg_index = arg_index;
+ if (dp->arg_index == ARG_NONE)
+ {
+ dp->arg_index = arg_posn++;
+ if (dp->arg_index == ARG_NONE)
+ /* arg_posn wrapped around. */
+ goto error;
+ }
+ REGISTER_ARG (dp->arg_index, type);
+ }
+ dp->conversion = c;
+ dp->dir_end = cp;
+ }
+
+ d->count++;
+ if (d->count >= d_allocated)
+ {
+ size_t memory_size;
+ DIRECTIVE *memory;
+
+ d_allocated = xtimes (d_allocated, 2);
+ memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
+ if (size_overflow_p (memory_size))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ memory = (DIRECTIVE *) realloc (d->dir, memory_size);
+ if (memory == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ d->dir = memory;
+ }
+ }
#if CHAR_T_ONLY_ASCII
else if (!c_isascii (c))
- {
- /* Non-ASCII character. Not supported. */
- goto error;
- }
+ {
+ /* Non-ASCII character. Not supported. */
+ goto error;
+ }
#endif
}
d->dir[d->count].dir_start = cp;
diff --git a/lib/gl/printf-parse.h b/lib/gl/printf-parse.h
index 196aa19692..685f7f76f4 100644
--- a/lib/gl/printf-parse.h
+++ b/lib/gl/printf-parse.h
@@ -1,5 +1,6 @@
/* Parse printf format string.
- Copyright (C) 1999, 2002-2003, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2010 Free Software
+ Foundation, Inc.
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
@@ -26,15 +27,15 @@
/* Flags */
-#define FLAG_GROUP 1 /* ' flag */
-#define FLAG_LEFT 2 /* - flag */
-#define FLAG_SHOWSIGN 4 /* + flag */
-#define FLAG_SPACE 8 /* space flag */
-#define FLAG_ALT 16 /* # flag */
-#define FLAG_ZERO 32
+#define FLAG_GROUP 1 /* ' flag */
+#define FLAG_LEFT 2 /* - flag */
+#define FLAG_SHOWSIGN 4 /* + flag */
+#define FLAG_SPACE 8 /* space flag */
+#define FLAG_ALT 16 /* # flag */
+#define FLAG_ZERO 32
/* 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_directives: A parsed format string. */
@@ -163,10 +164,10 @@ extern int
u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
extern int
u16_printf_parse (const uint16_t *format, u16_directives *d,
- arguments *a);
+ arguments *a);
extern int
u32_printf_parse (const uint32_t *format, u32_directives *d,
- arguments *a);
+ arguments *a);
#else
# ifdef STATIC
STATIC
diff --git a/lib/gl/read-file.c b/lib/gl/read-file.c
index 5771488ab1..3d27d7193c 100644
--- a/lib/gl/read-file.c
+++ b/lib/gl/read-file.c
@@ -1,5 +1,5 @@
/* read-file.c -- read file contents into a string
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
Written by Simon Josefsson and Bruno Haible.
This program is free software; you can redistribute it and/or modify
@@ -45,36 +45,36 @@ fread_file (FILE * stream, size_t * length)
size_t requested;
if (size + BUFSIZ + 1 > alloc)
- {
- char *new_buf;
+ {
+ char *new_buf;
- alloc += alloc / 2;
- if (alloc < size + BUFSIZ + 1)
- alloc = size + BUFSIZ + 1;
+ alloc += alloc / 2;
+ if (alloc < size + BUFSIZ + 1)
+ alloc = size + BUFSIZ + 1;
- new_buf = realloc (buf, alloc);
- if (!new_buf)
- {
- save_errno = errno;
- break;
- }
+ new_buf = realloc (buf, alloc);
+ if (!new_buf)
+ {
+ save_errno = errno;
+ break;
+ }
- buf = new_buf;
- }
+ buf = new_buf;
+ }
requested = alloc - size - 1;
count = fread (buf + size, 1, requested, stream);
size += count;
if (count != requested)
- {
- save_errno = errno;
- if (ferror (stream))
- break;
- buf[size] = '\0';
- *length = size;
- return buf;
- }
+ {
+ save_errno = errno;
+ if (ferror (stream))
+ break;
+ buf[size] = '\0';
+ *length = size;
+ return buf;
+ }
}
free (buf);
@@ -99,10 +99,10 @@ internal_read_file (const char *filename, size_t * length, const char *mode)
if (fclose (stream) != 0)
{
if (out)
- {
- save_errno = errno;
- free (out);
- }
+ {
+ save_errno = errno;
+ free (out);
+ }
errno = save_errno;
return NULL;
}
diff --git a/lib/gl/read-file.h b/lib/gl/read-file.h
index 798d841fc3..465c3d1f78 100644
--- a/lib/gl/read-file.h
+++ b/lib/gl/read-file.h
@@ -1,5 +1,5 @@
/* read-file.h -- read file contents into a string
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/gl/realloc.c b/lib/gl/realloc.c
index 64b7d78c57..f67e79d36a 100644
--- a/lib/gl/realloc.c
+++ b/lib/gl/realloc.c
@@ -1,6 +1,7 @@
/* realloc() function that is glibc compatible.
- Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2010 Free Software
+ Foundation, Inc.
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
@@ -71,7 +72,7 @@ rpl_realloc (void *p, size_t n)
{
#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
if (n == 0)
- n = 1;
+ n = 1;
#endif
result = malloc (n);
}
diff --git a/lib/gl/size_max.h b/lib/gl/size_max.h
index 68f3409202..cc99ee3f3d 100644
--- a/lib/gl/size_max.h
+++ b/lib/gl/size_max.h
@@ -1,5 +1,5 @@
/* size_max.h -- declare SIZE_MAX through system headers
- Copyright (C) 2005-2006 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/gl/snprintf.c b/lib/gl/snprintf.c
index 65434a94c1..d9207a8e6e 100644
--- a/lib/gl/snprintf.c
+++ b/lib/gl/snprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc.
Written by Simon Josefsson and Paul Eggert.
This program is free software; you can redistribute it and/or modify
@@ -53,11 +53,11 @@ snprintf (char *str, size_t size, const char *format, ...)
if (output != str)
{
if (size)
- {
- size_t pruned_len = (len < size ? len : size - 1);
- memcpy (str, output, pruned_len);
- str[pruned_len] = '\0';
- }
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
free (output);
}
diff --git a/lib/gl/sockets.c b/lib/gl/sockets.c
index a6bbf03c9e..113dc17dcb 100644
--- a/lib/gl/sockets.c
+++ b/lib/gl/sockets.c
@@ -1,6 +1,6 @@
/* sockets.c --- wrappers for Windows socket functions
- Copyright (C) 2008-2009 Free Software Foundation, Inc.
+ Copyright (C) 2008-2010 Free Software Foundation, Inc.
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
@@ -46,21 +46,21 @@ close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
{
/* fd refers to a socket. */
/* FIXME: other applications, like squid, use an undocumented
- _free_osfhnd free function. But this is not enough: The 'osfile'
- flags for fd also needs to be cleared, but it is hard to access it.
- Instead, here we just close twice the file descriptor. */
+ _free_osfhnd free function. But this is not enough: The 'osfile'
+ flags for fd also needs to be cleared, but it is hard to access it.
+ Instead, here we just close twice the file descriptor. */
if (closesocket (sock))
- {
- set_winsock_errno ();
- return -1;
- }
+ {
+ set_winsock_errno ();
+ return -1;
+ }
else
- {
- /* This call frees the file descriptor and does a
- CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
- _close (fd);
- return 0;
- }
+ {
+ /* This call frees the file descriptor and does a
+ CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
+ _close (fd);
+ return 0;
+ }
}
else
/* Some other type of file descriptor. */
@@ -74,7 +74,7 @@ static int initialized_sockets_version /* = 0 */;
#endif /* WINDOWS_SOCKETS */
int
-gl_sockets_startup (int version _UNUSED_PARAMETER_)
+gl_sockets_startup (int version _GL_UNUSED)
{
#if WINDOWS_SOCKETS
if (version > initialized_sockets_version)
@@ -84,13 +84,13 @@ gl_sockets_startup (int version _UNUSED_PARAMETER_)
err = WSAStartup (version, &data);
if (err != 0)
- return 1;
+ return 1;
if (data.wVersion < version)
- return 2;
+ return 2;
if (initialized_sockets_version == 0)
- register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
+ register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
initialized_sockets_version = version;
}
diff --git a/lib/gl/sockets.h b/lib/gl/sockets.h
index 315d1b6422..0bcbd9f70c 100644
--- a/lib/gl/sockets.h
+++ b/lib/gl/sockets.h
@@ -1,6 +1,6 @@
/* sockets.h - wrappers for Windows socket functions
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/stdbool.in.h b/lib/gl/stdbool.in.h
index 45375b367e..7db57b2305 100644
--- a/lib/gl/stdbool.in.h
+++ b/lib/gl/stdbool.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/gl/stddef.in.h b/lib/gl/stddef.in.h
index d47d0d962b..c8900d5fee 100644
--- a/lib/gl/stddef.in.h
+++ b/lib/gl/stddef.in.h
@@ -1,6 +1,6 @@
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/stdint.in.h b/lib/gl/stdint.in.h
index e7a3be57b0..4251ef5255 100644
--- a/lib/gl/stdint.in.h
+++ b/lib/gl/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2010 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
@@ -102,8 +102,8 @@
((signed) \
? ~ _STDINT_MIN (signed, bits, zero) \
: /* The expression for the unsigned case. The subtraction of (signed) \
- is a nop in the unsigned case and avoids "signed integer overflow" \
- warnings in the signed case. */ \
+ is a nop in the unsigned case and avoids "signed integer overflow" \
+ warnings in the signed case. */ \
((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
/* 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
#define SIG_ATOMIC_MIN \
_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 \
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
- 0@SIG_ATOMIC_T_SUFFIX@)
+ 0@SIG_ATOMIC_T_SUFFIX@)
/* size_t limit */
diff --git a/lib/gl/stdio-impl.h b/lib/gl/stdio-impl.h
index e52a7d8840..63687797f1 100644
--- a/lib/gl/stdio-impl.h
+++ b/lib/gl/stdio-impl.h
@@ -1,5 +1,5 @@
/* Implementation details of FILE streams.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
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
@@ -26,21 +26,21 @@
# if defined __DragonFly__ /* DragonFly */
/* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
# define fp_ ((struct { struct __FILE_public pub; \
- struct { unsigned char *_base; int _size; } _bf; \
- void *cookie; \
- void *_close; \
- void *_read; \
- void *_seek; \
- void *_write; \
- struct { unsigned char *_base; int _size; } _ub; \
- int _ur; \
- unsigned char _ubuf[3]; \
- unsigned char _nbuf[1]; \
- struct { unsigned char *_base; int _size; } _lb; \
- int _blksize; \
- fpos_t _offset; \
- /* More fields, not relevant here. */ \
- } *) fp)
+ struct { unsigned char *_base; int _size; } _bf; \
+ void *cookie; \
+ void *_close; \
+ void *_read; \
+ void *_seek; \
+ void *_write; \
+ struct { unsigned char *_base; int _size; } _ub; \
+ int _ur; \
+ unsigned char _ubuf[3]; \
+ unsigned char _nbuf[1]; \
+ struct { unsigned char *_base; int _size; } _lb; \
+ int _blksize; \
+ fpos_t _offset; \
+ /* More fields, not relevant here. */ \
+ } *) fp)
/* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
# define _p pub._p
# define _flags pub._flags
@@ -74,12 +74,12 @@
# if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
# define fp_ ((struct { unsigned char *_ptr; \
- unsigned char *_base; \
- unsigned char *_end; \
- long _cnt; \
- int _file; \
- unsigned int _flag; \
- } *) fp)
+ unsigned char *_base; \
+ unsigned char *_end; \
+ long _cnt; \
+ int _file; \
+ unsigned int _flag; \
+ } *) fp)
# else
# define fp_ fp
# endif
diff --git a/lib/gl/stdio-write.c b/lib/gl/stdio-write.c
index 01102d66cb..866047c67d 100644
--- a/lib/gl/stdio-write.c
+++ b/lib/gl/stdio-write.c
@@ -1,5 +1,5 @@
/* POSIX compatible FILE stream write function.
- Copyright (C) 2008-2009 Free Software Foundation, Inc.
+ Copyright (C) 2008-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -39,27 +39,27 @@
# include <windows.h>
# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
- if (ferror (stream)) \
- return (EXPRESSION); \
- else \
- { \
- RETTYPE ret; \
- SetLastError (0); \
- ret = (EXPRESSION); \
+ if (ferror (stream)) \
+ return (EXPRESSION); \
+ else \
+ { \
+ RETTYPE ret; \
+ SetLastError (0); \
+ ret = (EXPRESSION); \
if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \
- { \
- int fd = fileno (stream); \
- if (fd >= 0 \
- && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
- { \
- /* Try to raise signal SIGPIPE. */ \
- raise (SIGPIPE); \
- /* If it is currently blocked or ignored, change errno from \
- EINVAL to EPIPE. */ \
- errno = EPIPE; \
- } \
- } \
- return ret; \
+ { \
+ int fd = fileno (stream); \
+ if (fd >= 0 \
+ && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
+ { \
+ /* Try to raise signal SIGPIPE. */ \
+ raise (SIGPIPE); \
+ /* If it is currently blocked or ignored, change errno from \
+ EINVAL to EPIPE. */ \
+ errno = EPIPE; \
+ } \
+ } \
+ return ret; \
}
# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
diff --git a/lib/gl/stdio.in.h b/lib/gl/stdio.in.h
index cd11a52a91..156d28dcfc 100644
--- a/lib/gl/stdio.in.h
+++ b/lib/gl/stdio.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdio.h>.
- Copyright (C) 2004, 2007-2009 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
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
@@ -36,32 +36,30 @@
#ifndef _GL_STDIO_H
#define _GL_STDIO_H
+/* Get va_list. Needed on many systems, including glibc 2.8. */
#include <stdarg.h>
+
#include <stddef.h>
-#if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
- || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
- || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
- || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
-/* Get off_t and ssize_t. */
-# include <sys/types.h>
-#endif
+/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */
+#include <sys/types.h>
#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable __attribute__ only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
+# define __attribute__(Spec) /* empty */
# endif
#endif
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
#ifdef __cplusplus
@@ -74,29 +72,27 @@ extern "C" {
# endif
# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
extern int dprintf (int fd, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef dprintf
-# define dprintf(d,f,a) \
- (GL_LINK_WARNING ("dprintf is unportable - " \
- "use gnulib module dprintf for portability"), \
- dprintf (d, f, a))
+# if HAVE_RAW_DECL_DPRINTF
+_GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
+ "use gnulib module dprintf for portability");
+# endif
#endif
#if @GNULIB_FCLOSE@
# if @REPLACE_FCLOSE@
# define fclose rpl_fclose
/* Close STREAM and its underlying file descriptor. */
-extern int fclose (FILE *stream);
+extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef fclose
-# define fclose(f) \
- (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \
- "use gnulib module fclose for portable " \
- "POSIX compliance"), \
- fclose (f))
+/* Assume fclose is always declared. */
+_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
+ "use gnulib module fclose for portable POSIX compliance");
#endif
#if @GNULIB_FFLUSH@
@@ -112,44 +108,49 @@ extern int fclose (FILE *stream);
# endif
#elif defined GNULIB_POSIXCHECK
# undef fflush
-# define fflush(f) \
- (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
- "use gnulib module fflush for portable " \
- "POSIX compliance"), \
- fflush (f))
+/* Assume fflush is always declared. */
+_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
+ "use gnulib module fflush for portable POSIX compliance");
#endif
+/* It is very rare that the developer ever has full control of stdin,
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+#undef gets
+_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+
#if @GNULIB_FOPEN@
# if @REPLACE_FOPEN@
# undef 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
#elif defined GNULIB_POSIXCHECK
# undef fopen
-# define fopen(f,m) \
- (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
- "use gnulib module fopen for portability"), \
- fopen (f, m))
+/* Assume fopen is always declared. */
+_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
+ "use gnulib module fopen for portability");
#endif
#if @GNULIB_FPRINTF_POSIX@
# if @REPLACE_FPRINTF@
# define fprintf rpl_fprintf
extern int fprintf (FILE *fp, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3)))
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define fprintf rpl_fprintf
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
# undef fprintf
-# define fprintf \
- (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
- "use gnulib module fprintf-posix for portable " \
- "POSIX compliance"), \
- fprintf)
+/* Assume fprintf is always declared. */
+_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
+ "use gnulib module fprintf-posix for portable "
+ "POSIX compliance");
#endif
#if @GNULIB_FPURGE@
@@ -163,134 +164,179 @@ extern int fprintf (FILE *fp, const char *format, ...)
was before the write calls. When discarding pending input, the file
position is advanced to match the end of the previously read input.
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
#elif defined GNULIB_POSIXCHECK
# undef fpurge
-# define fpurge(f) \
- (GL_LINK_WARNING ("fpurge is not always present - " \
- "use gnulib module fpurge for portability"), \
- fpurge (f))
+# if HAVE_RAW_DECL_FPURGE
+_GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
+ "use gnulib module fpurge for portability");
+# endif
#endif
#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef fputc
# define fputc rpl_fputc
-extern int fputc (int c, FILE *stream);
+extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
#endif
#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef 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
#if @GNULIB_FREOPEN@
# if @REPLACE_FREOPEN@
# undef 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
#elif defined GNULIB_POSIXCHECK
# undef freopen
-# define freopen(f,m,s) \
- (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
- "use gnulib module freopen for portability"), \
- freopen (f, m, s))
-#endif
-
-#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
-extern int rpl_fseek (FILE *fp, long offset, int whence);
-# undef fseek
-# if defined GNULIB_POSIXCHECK
-# define fseek(f,o,w) \
- (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
- "on 32-bit platforms - " \
- "use fseeko function for handling of large files"), \
- rpl_fseek (f, o, w))
-# else
+/* Assume freopen is always declared. */
+_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - "
+ "use gnulib module freopen for portability");
+#endif
+
+/* Set up the following warnings, based on which modules are in use.
+ GNU Coding Standards discourage the use of fseek, since it imposes
+ an arbitrary limitation on some 32-bit hosts. Remember that the
+ fseek module depends on the fseeko module, so we only have three
+ cases to consider:
+
+ 1. The developer is not using either module. Issue a warning under
+ GNULIB_POSIXCHECK for both functions, to remind them that both
+ functions have bugs on some systems. _GL_NO_LARGE_FILES has no
+ impact on this warning.
+
+ 2. The developer is using both modules. They may be unaware of the
+ arbitrary limitations of fseek, so issue a warning under
+ GNULIB_POSIXCHECK. On the other hand, they may be using both
+ modules intentionally, so the developer can define
+ _GL_NO_LARGE_FILES in the compilation units where the use of fseek
+ is safe, to silence the warning.
+
+ 3. The developer is using the fseeko module, but not fseek. Gnulib
+ guarantees that fseek will still work around platform bugs in that
+ case, but we presume that the developer is aware of the pitfalls of
+ fseek and was trying to avoid it, so issue a warning even when
+ GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
+ defined to silence the warning in particular compilation units.
+
+ Most gnulib clients that perform stream operations should fall into
+ category three. */
+
+#if @GNULIB_FSEEK@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+# define _GL_FSEEK_WARN /* Category 2, above. */
+# undef fseek
+# endif
+# if @REPLACE_FSEEK@
+# undef fseek
# define fseek rpl_fseek
-# endif
-#elif defined GNULIB_POSIXCHECK
-# ifndef fseek
-# define fseek(f,o,w) \
- (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
- "on 32-bit platforms - " \
- "use fseeko function for handling of large files"), \
- fseek (f, o, w))
+extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
# endif
#endif
#if @GNULIB_FSEEKO@
+# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
+# define _GL_FSEEK_WARN /* Category 3, above. */
+# undef fseek
+# endif
# if @REPLACE_FSEEKO@
/* Provide fseek, fseeko functions that are aware of a preceding
fflush(), and which detect pipes. */
+# undef 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@
# undef fseek
-# define fseek(f,o,w) \
- (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
- "on 32-bit platforms - " \
- "use fseeko function for handling of large files"), \
- fseeko (f, o, w))
+# define fseek rpl_fseek
+static inline int _GL_ARG_NONNULL ((1))
+rpl_fseek (FILE *fp, long offset, int whence)
+{
+ return fseeko (fp, offset, whence);
+}
# endif
# endif
#elif defined GNULIB_POSIXCHECK
+# define _GL_FSEEK_WARN /* Category 1, above. */
+# undef fseek
# undef fseeko
-# define fseeko(f,o,w) \
- (GL_LINK_WARNING ("fseeko is unportable - " \
- "use gnulib module fseeko for portability"), \
- fseeko (f, o, w))
+# if HAVE_RAW_DECL_FSEEKO
+_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
+ "use gnulib module fseeko for portability");
+# endif
#endif
-#if @GNULIB_FTELL@ && @REPLACE_FTELL@
-extern long rpl_ftell (FILE *fp);
-# undef ftell
-# if GNULIB_POSIXCHECK
-# define ftell(f) \
- (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
- "on 32-bit platforms - " \
- "use ftello function for handling of large files"), \
- rpl_ftell (f))
-# else
-# define ftell rpl_ftell
+#ifdef _GL_FSEEK_WARN
+# undef _GL_FSEEK_WARN
+/* Here, either fseek is undefined (but C89 guarantees that it is
+ declared), or it is defined as rpl_fseek (declared above). */
+_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
+ "on 32-bit platforms - "
+ "use fseeko function for handling of large files");
+#endif
+
+/* See the comments on fseek/fseeko. */
+
+#if @GNULIB_FTELL@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+# define _GL_FTELL_WARN /* Category 2, above. */
+# undef ftell
# endif
-#elif defined GNULIB_POSIXCHECK
-# ifndef ftell
-# define ftell(f) \
- (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
- "on 32-bit platforms - " \
- "use ftello function for handling of large files"), \
- ftell (f))
+# if @REPLACE_FTELL@
+# undef ftell
+# define ftell rpl_ftell
+extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1));
# endif
#endif
#if @GNULIB_FTELLO@
+# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
+# define _GL_FTELL_WARN /* Category 3, above. */
+# undef ftell
+# endif
# if @REPLACE_FTELLO@
+# undef ftello
# define ftello rpl_ftello
-extern off_t ftello (FILE *fp);
+extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
# if !@GNULIB_FTELL@
# undef ftell
-# define ftell(f) \
- (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
- "on 32-bit platforms - " \
- "use ftello function for handling of large files"), \
- ftello (f))
+# define ftell rpl_ftell
+static inline long _GL_ARG_NONNULL ((1))
+rpl_ftell (FILE *f)
+{
+ return ftello (f);
+}
# endif
# endif
#elif defined GNULIB_POSIXCHECK
+# define _GL_FTELL_WARN /* Category 1, above. */
+# undef ftell
# undef ftello
-# define ftello(f) \
- (GL_LINK_WARNING ("ftello is unportable - " \
- "use gnulib module ftello for portability"), \
- ftello (f))
+# if HAVE_RAW_DECL_FTELLO
+_GL_WARN_ON_USE (ftello, "ftello is unportable - "
+ "use gnulib module ftello for portability");
+# endif
+#endif
+
+#ifdef _GL_FTELL_WARN
+# undef _GL_FTELL_WARN
+/* Here, either ftell is undefined (but C89 guarantees that it is
+ declared), or it is defined as rpl_ftell (declared above). */
+_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
+ "on 32-bit platforms - "
+ "use ftello function for handling of large files");
#endif
#if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef 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
#if @GNULIB_GETDELIM@
@@ -302,14 +348,15 @@ 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
NUL terminator), or -1 on error or EOF. */
extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
- FILE *stream);
+ FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 4));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getdelim
-# define getdelim(l, s, d, f) \
- (GL_LINK_WARNING ("getdelim is unportable - " \
- "use gnulib module getdelim for portability"), \
- getdelim (l, s, d, f))
+# if HAVE_RAW_DECL_GETDELIM
+_GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
+ "use gnulib module getdelim for portability");
+# endif
#endif
#if @GNULIB_GETLINE@
@@ -324,14 +371,15 @@ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
bytes of space. It is realloc'd as necessary.
Return the number of bytes read and stored at *LINEPTR (not including the
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
#elif defined GNULIB_POSIXCHECK
# undef getline
-# define getline(l, s, f) \
- (GL_LINK_WARNING ("getline is unportable - " \
- "use gnulib module getline for portability"), \
- getline (l, s, f))
+# if HAVE_RAW_DECL_GETLINE
+_GL_WARN_ON_USE (getline, "getline is unportable - "
+ "use gnulib module getline for portability");
+# endif
#endif
#if @GNULIB_OBSTACK_PRINTF@
@@ -347,10 +395,10 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
memory allocation error, call obstack_alloc_failed_handler. Upon
other error, return -1. */
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,
- va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ va_list args)
+ __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -364,24 +412,24 @@ extern void perror (const char *string);
# endif
#elif defined GNULIB_POSIXCHECK
# undef perror
-# define perror(s) \
- (GL_LINK_WARNING ("perror is not always POSIX compliant - " \
- "use gnulib module perror for portability"), \
- perror (s))
+/* Assume perror is always declared. */
+_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
+ "use gnulib module perror for portability");
#endif
#if @GNULIB_POPEN@
# if @REPLACE_POPEN@
# undef 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
#elif defined GNULIB_POSIXCHECK
# undef popen
-# define popen(c,m) \
- (GL_LINK_WARNING ("popen is buggy on some platforms - " \
- "use gnulib module popen or pipe for more portability"), \
- popen (c, m))
+# if HAVE_RAW_DECL_POPEN
+_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
+ "use gnulib module popen or pipe for more portability");
+# endif
#endif
#if @GNULIB_PRINTF_POSIX@
@@ -389,33 +437,25 @@ extern FILE *popen (const char *cmd, const char *mode);
/* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__
extern int printf (const char *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
# endif
#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
/* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__
extern int printf (const char *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
#elif defined GNULIB_POSIXCHECK
# undef printf
-# define printf \
- (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
- "use gnulib module printf-posix for portable " \
- "POSIX compliance"), \
- printf)
-/* Don't break __attribute__((format(printf,M,N))). */
-# define format(kind,m,n) format (__##kind##__, m, n)
-# define __format__(kind,m,n) __format__ (__##kind##__, m, n)
-# define ____printf____ __printf__
-# define ____scanf____ __scanf__
-# define ____strftime____ __strftime__
-# define ____strfmon____ __strfmon__
+/* Assume printf is always declared. */
+_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
+ "use gnulib module printf-posix for portable "
+ "POSIX compliance");
#endif
#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef putc
# define putc rpl_fputc
-extern int putc (int c, FILE *stream);
+extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
#endif
#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
@@ -427,35 +467,34 @@ extern int putchar (int c);
#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# undef puts
# define puts rpl_puts
-extern int puts (const char *string);
+extern int puts (const char *string) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_REMOVE@
# if @REPLACE_REMOVE@
# undef remove
# define remove rpl_remove
-extern int remove (const char *name);
+extern int remove (const char *name) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef remove
-# define remove(n) \
- (GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \
- "use gnulib module remove for more portability"), \
- remove (n))
+/* Assume remove is always declared. */
+_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
+ "use gnulib module remove for more portability");
#endif
#if @GNULIB_RENAME@
# if @REPLACE_RENAME@
# undef 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
#elif defined GNULIB_POSIXCHECK
# undef rename
-# define rename(o,n) \
- (GL_LINK_WARNING ("rename is buggy on some platforms - " \
- "use gnulib module rename for more portability"), \
- rename (o, n))
+/* Assume rename is always declared. */
+_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
+ "use gnulib module rename for more portability");
#endif
#if @GNULIB_RENAMEAT@
@@ -464,14 +503,15 @@ extern int rename (const char *old, const char *new);
# define renameat rpl_renameat
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef renameat
-# define renameat(d1,f1,d2,f2) \
- (GL_LINK_WARNING ("renameat is not portable - " \
- "use gnulib module renameat for portability"), \
- renameat (d1, f1, d2, f2))
+# if HAVE_RAW_DECL_RENAMEAT
+_GL_WARN_ON_USE (renameat, "renameat is not portable - "
+ "use gnulib module renameat for portability");
+# endif
#endif
#if @GNULIB_SNPRINTF@
@@ -480,29 +520,39 @@ extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
# endif
# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
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
#elif defined GNULIB_POSIXCHECK
# undef snprintf
-# define snprintf \
- (GL_LINK_WARNING ("snprintf is unportable - " \
- "use gnulib module snprintf for portability"), \
- snprintf)
+# if HAVE_RAW_DECL_SNPRINTF
+_GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
+ "use gnulib module snprintf for portability");
+# endif
#endif
+/* Some people would argue that sprintf should be handled like gets
+ (for example, OpenBSD issues a link warning for both functions),
+ since both can cause security holes due to buffer overruns.
+ However, we believe that sprintf can be used safely, and is more
+ efficient than snprintf in those safe cases; and as proof of our
+ belief, we use sprintf in several gnulib modules. So this header
+ intentionally avoids adding a warning to sprintf except when
+ GNULIB_POSIXCHECK is defined. */
+
#if @GNULIB_SPRINTF_POSIX@
# if @REPLACE_SPRINTF@
# define sprintf rpl_sprintf
extern int sprintf (char *str, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ __attribute__ ((__format__ (__printf__, 2, 3)))
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef sprintf
-# define sprintf \
- (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
- "use gnulib module sprintf-posix for portable " \
- "POSIX compliance"), \
- sprintf)
+/* Assume sprintf is always declared. */
+_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
+ "use gnulib module sprintf-posix for portable "
+ "POSIX compliance");
#endif
#if @GNULIB_VASPRINTF@
@@ -516,9 +566,9 @@ extern int sprintf (char *str, const char *format, ...)
*RESULT and return the number of resulting bytes, excluding the trailing
NUL. Upon memory allocation error, or some other error, return -1. */
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)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
# endif
#endif
@@ -528,52 +578,52 @@ extern int sprintf (char *str, const char *format, ...)
# endif
# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
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
#elif defined GNULIB_POSIXCHECK
# undef vdprintf
-# define vdprintf(d,f,a) \
- (GL_LINK_WARNING ("vdprintf is unportable - " \
- "use gnulib module vdprintf for portability"), \
- vdprintf (d, f, a))
+# if HAVE_RAW_DECL_VDPRINTF
+_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
+ "use gnulib module vdprintf for portability");
+# endif
#endif
#if @GNULIB_VFPRINTF_POSIX@
# if @REPLACE_VFPRINTF@
# define vfprintf rpl_vfprintf
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
#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define vfprintf rpl_vfprintf
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
# undef vfprintf
-# define vfprintf(s,f,a) \
- (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
- "use gnulib module vfprintf-posix for portable " \
- "POSIX compliance"), \
- vfprintf (s, f, a))
+/* Assume vfprintf is always declared. */
+_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
+ "use gnulib module vfprintf-posix for portable "
+ "POSIX compliance");
#endif
#if @GNULIB_VPRINTF_POSIX@
# if @REPLACE_VPRINTF@
# define vprintf rpl_vprintf
extern int vprintf (const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 1, 0)));
+ __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
# endif
#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
# define vprintf rpl_vprintf
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
# undef vprintf
-# define vprintf(f,a) \
- (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
- "use gnulib module vprintf-posix for portable " \
- "POSIX compliance"), \
- vprintf (f, a))
+/* Assume vprintf is always declared. */
+_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
+ "use gnulib module vprintf-posix for portable "
+ "POSIX compliance");
#endif
#if @GNULIB_VSNPRINTF@
@@ -582,29 +632,30 @@ extern int vprintf (const char *format, va_list args)
# endif
# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
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
#elif defined GNULIB_POSIXCHECK
# undef vsnprintf
-# define vsnprintf(b,s,f,a) \
- (GL_LINK_WARNING ("vsnprintf is unportable - " \
- "use gnulib module vsnprintf for portability"), \
- vsnprintf (b, s, f, a))
+# if HAVE_RAW_DECL_VSNPRINTF
+_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
+ "use gnulib module vsnprintf for portability");
+# endif
#endif
#if @GNULIB_VSPRINTF_POSIX@
# if @REPLACE_VSPRINTF@
# define vsprintf rpl_vsprintf
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
#elif defined GNULIB_POSIXCHECK
# undef vsprintf
-# define vsprintf(b,f,a) \
- (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
- "use gnulib module vsprintf-posix for portable " \
- "POSIX compliance"), \
- vsprintf (b, f, a))
+/* Assume vsprintf is always declared. */
+_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
+ "use gnulib module vsprintf-posix for portable "
+ "POSIX compliance");
#endif
#ifdef __cplusplus
diff --git a/lib/gl/stdlib.in.h b/lib/gl/stdlib.in.h
index 6ef85047fb..a4ae16ebc0 100644
--- a/lib/gl/stdlib.in.h
+++ b/lib/gl/stdlib.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdlib.h>.
- Copyright (C) 1995, 2001-2004, 2006-2009 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2001-2004, 2006-2010 Free Software Foundation, Inc.
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
@@ -39,7 +39,7 @@
#include <stddef.h>
/* Solaris declares getloadavg() in <sys/loadavg.h>. */
-#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
+#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
# include <sys/loadavg.h>
#endif
@@ -49,24 +49,34 @@
# include <random.h>
#endif
-#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
+#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \
+ || defined GNULIB_POSIXCHECK
# include <stdint.h>
#endif
#if !@HAVE_STRUCT_RANDOM_DATA@
struct random_data
{
- int32_t *fptr; /* Front pointer. */
- int32_t *rptr; /* Rear pointer. */
- int32_t *state; /* Array of state values. */
- int rand_type; /* Type of random number generator. */
- int rand_deg; /* Degree of random number generator. */
- int rand_sep; /* Distance between front and rear. */
- int32_t *end_ptr; /* Pointer behind state table. */
+ int32_t *fptr; /* Front pointer. */
+ int32_t *rptr; /* Rear pointer. */
+ int32_t *state; /* Array of state values. */
+ int rand_type; /* Type of random number generator. */
+ int rand_deg; /* Degree of random number generator. */
+ int rand_sep; /* Distance between front and rear. */
+ int32_t *end_ptr; /* Pointer behind state table. */
};
#endif
-/* The definition of GL_LINK_WARNING is copied here. */
+#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
+/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
+/* But avoid namespace pollution on glibc systems. */
+# include <unistd.h>
+#endif
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
@@ -91,14 +101,14 @@ extern "C" {
# if !@HAVE_ATOLL@
/* Parse a signed decimal integer.
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
#elif defined GNULIB_POSIXCHECK
# undef atoll
-# define atoll(s) \
- (GL_LINK_WARNING ("atoll is unportable - " \
- "use gnulib module atoll for portability"), \
- atoll (s))
+# if HAVE_RAW_DECL_ATOLL
+_GL_WARN_ON_USE (atoll, "atoll is unportable - "
+ "use gnulib module atoll for portability");
+# endif
#endif
#if @GNULIB_CALLOC_POSIX@
@@ -109,10 +119,9 @@ extern void * calloc (size_t nmemb, size_t size);
# endif
#elif defined GNULIB_POSIXCHECK
# undef calloc
-# define calloc(n,s) \
- (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \
- "use gnulib module calloc-posix for portability"), \
- calloc (n, s))
+/* Assume calloc is always declared. */
+_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
+ "use gnulib module calloc-posix for portability");
#endif
#if @GNULIB_CANONICALIZE_FILE_NAME@
@@ -120,14 +129,14 @@ extern void * calloc (size_t nmemb, size_t size);
# define canonicalize_file_name rpl_canonicalize_file_name
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef canonicalize_file_name
-# define canonicalize_file_name(n) \
- (GL_LINK_WARNING ("canonicalize_file_name is unportable - " \
- "use gnulib module canonicalize-lgpl for portability"), \
- canonicalize_file_name (n))
+# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
+_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - "
+ "use gnulib module canonicalize-lgpl for portability");
+# endif
#endif
#if @GNULIB_GETLOADAVG@
@@ -136,14 +145,14 @@ extern char *canonicalize_file_name (const char *name);
The three numbers are the load average of the last 1 minute, the last 5
minutes, and the last 15 minutes, respectively.
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
#elif defined GNULIB_POSIXCHECK
# undef getloadavg
-# define getloadavg(l,n) \
- (GL_LINK_WARNING ("getloadavg is not portable - " \
- "use gnulib module getloadavg for portability"), \
- getloadavg (l, n))
+# if HAVE_RAW_DECL_GETLOADAVG
+_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
+ "use gnulib module getloadavg for portability");
+# endif
#endif
#if @GNULIB_GETSUBOPT@
@@ -159,14 +168,15 @@ extern int getloadavg (double loadavg[], int nelem);
For more details see the POSIX:2001 specification.
http://www.opengroup.org/susv3xsh/getsubopt.html */
# 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
#elif defined GNULIB_POSIXCHECK
# undef getsubopt
-# define getsubopt(o,t,v) \
- (GL_LINK_WARNING ("getsubopt is unportable - " \
- "use gnulib module getsubopt for portability"), \
- getsubopt (o, t, v))
+# if HAVE_RAW_DECL_GETSUBOPT
+_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
+ "use gnulib module getsubopt for portability");
+# endif
#endif
#if @GNULIB_MALLOC_POSIX@
@@ -177,10 +187,9 @@ extern void * malloc (size_t size);
# endif
#elif defined GNULIB_POSIXCHECK
# undef malloc
-# define malloc(s) \
- (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
- "use gnulib module malloc-posix for portability"), \
- malloc (s))
+/* Assume malloc is always declared. */
+_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
+ "use gnulib module malloc-posix for portability");
#endif
#if @GNULIB_MKDTEMP@
@@ -190,14 +199,14 @@ extern void * malloc (size_t size);
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.
The directory is created mode 700. */
-extern char * mkdtemp (char * /*template*/);
+extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkdtemp
-# define mkdtemp(t) \
- (GL_LINK_WARNING ("mkdtemp is unportable - " \
- "use gnulib module mkdtemp for portability"), \
- mkdtemp (t))
+# if HAVE_RAW_DECL_MKDTEMP
+_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
+ "use gnulib module mkdtemp for portability");
+# endif
#endif
#if @GNULIB_MKOSTEMP@
@@ -214,14 +223,14 @@ extern char * mkdtemp (char * /*template*/);
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
-extern int mkostemp (char * /*template*/, int /*flags*/);
+extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkostemp
-# define mkostemp(t,f) \
- (GL_LINK_WARNING ("mkostemp is unportable - " \
- "use gnulib module mkostemp for portability"), \
- mkostemp (t, f))
+# if HAVE_RAW_DECL_MKOSTEMP
+_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
+ "use gnulib module mkostemp for portability");
+# endif
#endif
#if @GNULIB_MKOSTEMPS@
@@ -239,14 +248,15 @@ extern int mkostemp (char * /*template*/, int /*flags*/);
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
-extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
+extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkostemps
-# define mkostemps(t,s,f) \
- (GL_LINK_WARNING ("mkostemps is unportable - " \
- "use gnulib module mkostemps for portability"), \
- mkostemps (t, s, f))
+# if HAVE_RAW_DECL_MKOSTEMPS
+_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
+ "use gnulib module mkostemps for portability");
+# endif
#endif
#if @GNULIB_MKSTEMP@
@@ -261,17 +271,14 @@ extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
# define mkstemp rpl_mkstemp
-extern int mkstemp (char * /*template*/);
-# else
-/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
-# include <unistd.h>
+extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkstemp
-# define mkstemp(t) \
- (GL_LINK_WARNING ("mkstemp is unportable - " \
- "use gnulib module mkstemp for portability"), \
- mkstemp (t))
+# if HAVE_RAW_DECL_MKSTEMP
+_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
+ "use gnulib module mkstemp for portability");
+# endif
#endif
#if @GNULIB_MKSTEMPS@
@@ -286,21 +293,22 @@ extern int mkstemp (char * /*template*/);
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
-extern int mkstemps (char * /*template*/, int /*suffixlen*/);
+extern int mkstemps (char * /*template*/, int /*suffixlen*/)
+ _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mkstemps
-# define mkstemps(t,s) \
- (GL_LINK_WARNING ("mkstemps is unportable - " \
- "use gnulib module mkstemps for portability"), \
- mkstemps (t, s))
+# if HAVE_RAW_DECL_MKSTEMPS
+_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
+ "use gnulib module mkstemps for portability");
+# endif
#endif
#if @GNULIB_PUTENV@
# if @REPLACE_PUTENV@
# undef putenv
# define putenv rpl_putenv
-extern int putenv (char *string);
+extern int putenv (char *string) _GL_ARG_NONNULL ((1));
# endif
#endif
@@ -311,33 +319,37 @@ extern int putenv (char *string);
# define RAND_MAX 2147483647
# 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,
- struct random_data *rand_state);
-int setstate_r (char *arg_state, struct random_data *rand_state);
-int random_r (struct random_data *buf, int32_t *result);
+ struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2, 4));
+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
#elif defined GNULIB_POSIXCHECK
# undef random_r
-# define random_r(b,r) \
- (GL_LINK_WARNING ("random_r is unportable - " \
- "use gnulib module random_r for portability"), \
- random_r (b,r))
+# if HAVE_RAW_DECL_RANDOM_R
+_GL_WARN_ON_USE (random_r, "random_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
# undef initstate_r
-# define initstate_r(s,b,sz,r) \
- (GL_LINK_WARNING ("initstate_r is unportable - " \
- "use gnulib module random_r for portability"), \
- initstate_r (s,b,sz,r))
+# if HAVE_RAW_DECL_INITSTATE_R
+_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
# undef srandom_r
-# define srandom_r(s,r) \
- (GL_LINK_WARNING ("srandom_r is unportable - " \
- "use gnulib module random_r for portability"), \
- srandom_r (s,r))
+# if HAVE_RAW_DECL_SRANDOM_R
+_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
# undef setstate_r
-# define setstate_r(a,r) \
- (GL_LINK_WARNING ("setstate_r is unportable - " \
- "use gnulib module random_r for portability"), \
- setstate_r (a,r))
+# if HAVE_RAW_DECL_SETSTATE_R
+_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
#endif
#if @GNULIB_REALLOC_POSIX@
@@ -348,10 +360,9 @@ extern void * realloc (void *ptr, size_t size);
# endif
#elif defined GNULIB_POSIXCHECK
# undef realloc
-# define realloc(p,s) \
- (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
- "use gnulib module realloc-posix for portability"), \
- realloc (p, s))
+/* Assume realloc is always declared. */
+_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
+ "use gnulib module realloc-posix for portability");
#endif
#if @GNULIB_REALPATH@
@@ -359,35 +370,46 @@ extern void * realloc (void *ptr, size_t size);
# define realpath rpl_realpath
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef realpath
-# define realpath(n,r) \
- (GL_LINK_WARNING ("realpath is unportable - use gnulib module " \
- "canonicalize or canonicalize-lgpl for portability"), \
- realpath (n, r))
+# if HAVE_RAW_DECL_REALPATH
+_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
+ "canonicalize or canonicalize-lgpl for portability");
+# endif
#endif
#if @GNULIB_RPMATCH@
# if !@HAVE_RPMATCH@
/* Test a user response to a question.
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
#elif defined GNULIB_POSIXCHECK
# undef rpmatch
-# define rpmatch(r) \
- (GL_LINK_WARNING ("rpmatch is unportable - " \
- "use gnulib module rpmatch for portability"), \
- rpmatch (r))
+# if HAVE_RAW_DECL_RPMATCH
+_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
+ "use gnulib module rpmatch for portability");
+# endif
#endif
#if @GNULIB_SETENV@
-# if !@HAVE_SETENV@
+# if @REPLACE_SETENV@
+# undef setenv
+# define setenv rpl_setenv
+# endif
+# if !@HAVE_SETENV@ || @REPLACE_SETENV@
/* Set NAME to VALUE in the environment.
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
+#elif defined GNULIB_POSIXCHECK
+# undef setenv
+# if HAVE_RAW_DECL_SETENV
+_GL_WARN_ON_USE (setenv, "setenv is unportable - "
+ "use gnulib module setenv for portability");
# endif
#endif
@@ -397,14 +419,14 @@ extern int setenv (const char *name, const char *value, int replace);
# endif
# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
/* 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
#elif defined GNULIB_POSIXCHECK
# undef strtod
-# define strtod(s, e) \
- (GL_LINK_WARNING ("strtod is unportable - " \
- "use gnulib module strtod for portability"), \
- strtod (s, e))
+# if HAVE_RAW_DECL_STRTOD
+_GL_WARN_ON_USE (strtod, "strtod is unportable - "
+ "use gnulib module strtod for portability");
+# endif
#endif
#if @GNULIB_STRTOLL@
@@ -417,14 +439,15 @@ extern double strtod (const char *str, char **endp);
stored in *ENDPTR.
Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
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
#elif defined GNULIB_POSIXCHECK
# undef strtoll
-# define strtoll(s,e,b) \
- (GL_LINK_WARNING ("strtoll is unportable - " \
- "use gnulib module strtoll for portability"), \
- strtoll (s, e, b))
+# if HAVE_RAW_DECL_STRTOLL
+_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
+ "use gnulib module strtoll for portability");
+# endif
#endif
#if @GNULIB_STRTOULL@
@@ -437,26 +460,31 @@ extern long long strtoll (const char *string, char **endptr, int base);
stored in *ENDPTR.
Upon overflow, the return value is ULLONG_MAX, and errno is set to
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
#elif defined GNULIB_POSIXCHECK
# undef strtoull
-# define strtoull(s,e,b) \
- (GL_LINK_WARNING ("strtoull is unportable - " \
- "use gnulib module strtoull for portability"), \
- strtoull (s, e, b))
+# if HAVE_RAW_DECL_STRTOULL
+_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
+ "use gnulib module strtoull for portability");
+# endif
#endif
#if @GNULIB_UNSETENV@
-# if @HAVE_UNSETENV@
-# if @VOID_UNSETENV@
-/* On some systems, unsetenv() returns void.
- This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */
-# define unsetenv(name) ((unsetenv)(name), 0)
-# endif
-# else
+# if @REPLACE_UNSETENV@
+# undef unsetenv
+# define unsetenv rpl_unsetenv
+# endif
+# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
/* Remove the variable NAME from the environment. */
-extern int unsetenv (const char *name);
+extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unsetenv
+# if HAVE_RAW_DECL_UNSETENV
+_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
+ "use gnulib module unsetenv for portability");
# endif
#endif
diff --git a/lib/gl/str-two-way.h b/lib/gl/str-two-way.h
index 69580736fa..fa6eba04bc 100644
--- a/lib/gl/str-two-way.h
+++ b/lib/gl/str-two-way.h
@@ -1,5 +1,5 @@
/* Byte-wise substring search, using the Two-Way algorithm.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Eric Blake <ebb9@byu.net>, 2008.
@@ -21,21 +21,21 @@
<string.h>, and define:
RESULT_TYPE A macro that expands to the return type.
AVAILABLE(h, h_l, j, n_l)
- A macro that returns nonzero if there are
- at least N_L bytes left starting at H[J].
- H is 'unsigned char *', H_L, J, and N_L
- are 'size_t'; H_L is an lvalue. For
- NUL-terminated searches, H_L can be
- modified each iteration to avoid having
- to compute the end of H up front.
+ A macro that returns nonzero if there are
+ at least N_L bytes left starting at H[J].
+ H is 'unsigned char *', H_L, J, and N_L
+ are 'size_t'; H_L is an lvalue. For
+ NUL-terminated searches, H_L can be
+ modified each iteration to avoid having
+ to compute the end of H up front.
For case-insensitivity, you may optionally define:
CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L
- characters of P1 and P2 are equal.
+ characters of P1 and P2 are equal.
CANON_ELEMENT(c) A macro that canonicalizes an element right after
- it has been fetched from one of the two strings.
- The argument is an 'unsigned char'; the result
- must be an 'unsigned char' as well.
+ it has been fetched from one of the two strings.
+ The argument is an 'unsigned char'; the result
+ must be an 'unsigned char' as well.
This file undefines the macros documented above, and defines
LONG_NEEDLE_THRESHOLD.
@@ -103,7 +103,7 @@
periodicity. */
static size_t
critical_factorization (const unsigned char *needle, size_t needle_len,
- size_t *period)
+ size_t *period)
{
/* Index of last byte of left half, or SIZE_MAX. */
size_t max_suffix, max_suffix_rev;
@@ -130,29 +130,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
a = CANON_ELEMENT (needle[j + k]);
b = CANON_ELEMENT (needle[max_suffix + k]);
if (a < b)
- {
- /* Suffix is smaller, period is entire prefix so far. */
- j += k;
- k = 1;
- p = j - max_suffix;
- }
+ {
+ /* Suffix is smaller, period is entire prefix so far. */
+ j += k;
+ k = 1;
+ p = j - max_suffix;
+ }
else if (a == b)
- {
- /* Advance through repetition of the current period. */
- if (k != p)
- ++k;
- else
- {
- j += p;
- k = 1;
- }
- }
+ {
+ /* Advance through repetition of the current period. */
+ if (k != p)
+ ++k;
+ else
+ {
+ j += p;
+ k = 1;
+ }
+ }
else /* b < a */
- {
- /* Suffix is larger, start over from current location. */
- max_suffix = j++;
- k = p = 1;
- }
+ {
+ /* Suffix is larger, start over from current location. */
+ max_suffix = j++;
+ k = p = 1;
+ }
}
*period = p;
@@ -165,29 +165,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
a = CANON_ELEMENT (needle[j + k]);
b = CANON_ELEMENT (needle[max_suffix_rev + k]);
if (b < a)
- {
- /* Suffix is smaller, period is entire prefix so far. */
- j += k;
- k = 1;
- p = j - max_suffix_rev;
- }
+ {
+ /* Suffix is smaller, period is entire prefix so far. */
+ j += k;
+ k = 1;
+ p = j - max_suffix_rev;
+ }
else if (a == b)
- {
- /* Advance through repetition of the current period. */
- if (k != p)
- ++k;
- else
- {
- j += p;
- k = 1;
- }
- }
+ {
+ /* Advance through repetition of the current period. */
+ if (k != p)
+ ++k;
+ else
+ {
+ j += p;
+ k = 1;
+ }
+ }
else /* a < b */
- {
- /* Suffix is larger, start over from current location. */
- max_suffix_rev = j++;
- k = p = 1;
- }
+ {
+ /* Suffix is larger, start over from current location. */
+ max_suffix_rev = j++;
+ k = p = 1;
+ }
}
/* Choose the longer suffix. Return the first byte of the right
@@ -210,7 +210,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */
static RETURN_TYPE
two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
- const unsigned char *needle, size_t needle_len)
+ const unsigned char *needle, size_t needle_len)
{
size_t i; /* Index into current byte of NEEDLE. */
size_t j; /* Index into current window of HAYSTACK. */
@@ -227,65 +227,65 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
if (CMP_FUNC (needle, needle + period, suffix) == 0)
{
/* Entire needle is periodic; a mismatch can only advance by the
- period, so use memory to avoid rescanning known occurrences
- of the period. */
+ period, so use memory to avoid rescanning known occurrences
+ of the period. */
size_t memory = 0;
j = 0;
while (AVAILABLE (haystack, haystack_len, j, needle_len))
- {
- /* Scan for matches in right half. */
- i = MAX (suffix, memory);
- while (i < needle_len && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- ++i;
- if (needle_len <= i)
- {
- /* Scan for matches in left half. */
- i = suffix - 1;
- while (memory < i + 1 && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- --i;
- if (i + 1 < memory + 1)
- return (RETURN_TYPE) (haystack + j);
- /* No match, so remember how many repetitions of period
- on the right half were scanned. */
- j += period;
- memory = needle_len - period;
- }
- else
- {
- j += i - suffix + 1;
- memory = 0;
- }
- }
+ {
+ /* Scan for matches in right half. */
+ i = MAX (suffix, memory);
+ while (i < needle_len && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ ++i;
+ if (needle_len <= i)
+ {
+ /* Scan for matches in left half. */
+ i = suffix - 1;
+ while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ --i;
+ if (i + 1 < memory + 1)
+ return (RETURN_TYPE) (haystack + j);
+ /* No match, so remember how many repetitions of period
+ on the right half were scanned. */
+ j += period;
+ memory = needle_len - period;
+ }
+ else
+ {
+ j += i - suffix + 1;
+ memory = 0;
+ }
+ }
}
else
{
/* The two halves of needle are distinct; no extra memory is
- required, and any mismatch results in a maximal shift. */
+ required, and any mismatch results in a maximal shift. */
period = MAX (suffix, needle_len - suffix) + 1;
j = 0;
while (AVAILABLE (haystack, haystack_len, j, needle_len))
- {
- /* Scan for matches in right half. */
- i = suffix;
- while (i < needle_len && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- ++i;
- if (needle_len <= i)
- {
- /* Scan for matches in left half. */
- i = suffix - 1;
- while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- --i;
- if (i == SIZE_MAX)
- return (RETURN_TYPE) (haystack + j);
- j += period;
- }
- else
- j += i - suffix + 1;
- }
+ {
+ /* Scan for matches in right half. */
+ i = suffix;
+ while (i < needle_len && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ ++i;
+ if (needle_len <= i)
+ {
+ /* Scan for matches in left half. */
+ i = suffix - 1;
+ while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ --i;
+ if (i == SIZE_MAX)
+ return (RETURN_TYPE) (haystack + j);
+ j += period;
+ }
+ else
+ j += i - suffix + 1;
+ }
}
return NULL;
}
@@ -304,7 +304,7 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
sublinear performance is not possible. */
static RETURN_TYPE
two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
- const unsigned char *needle, size_t needle_len)
+ const unsigned char *needle, size_t needle_len)
{
size_t i; /* Index into current byte of NEEDLE. */
size_t j; /* Index into current window of HAYSTACK. */
@@ -331,93 +331,93 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
if (CMP_FUNC (needle, needle + period, suffix) == 0)
{
/* Entire needle is periodic; a mismatch can only advance by the
- period, so use memory to avoid rescanning known occurrences
- of the period. */
+ period, so use memory to avoid rescanning known occurrences
+ of the period. */
size_t memory = 0;
size_t shift;
j = 0;
while (AVAILABLE (haystack, haystack_len, j, needle_len))
- {
- /* Check the last byte first; if it does not match, then
- shift to the next possible match location. */
- shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
- if (0 < shift)
- {
- if (memory && shift < period)
- {
- /* Since needle is periodic, but the last period has
- a byte out of place, there can be no match until
- after the mismatch. */
- shift = needle_len - period;
- memory = 0;
- }
- j += shift;
- continue;
- }
- /* Scan for matches in right half. The last byte has
- already been matched, by virtue of the shift table. */
- i = MAX (suffix, memory);
- while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- ++i;
- if (needle_len - 1 <= i)
- {
- /* Scan for matches in left half. */
- i = suffix - 1;
- while (memory < i + 1 && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- --i;
- if (i + 1 < memory + 1)
- return (RETURN_TYPE) (haystack + j);
- /* No match, so remember how many repetitions of period
- on the right half were scanned. */
- j += period;
- memory = needle_len - period;
- }
- else
- {
- j += i - suffix + 1;
- memory = 0;
- }
- }
+ {
+ /* Check the last byte first; if it does not match, then
+ shift to the next possible match location. */
+ shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+ if (0 < shift)
+ {
+ if (memory && shift < period)
+ {
+ /* Since needle is periodic, but the last period has
+ a byte out of place, there can be no match until
+ after the mismatch. */
+ shift = needle_len - period;
+ memory = 0;
+ }
+ j += shift;
+ continue;
+ }
+ /* Scan for matches in right half. The last byte has
+ already been matched, by virtue of the shift table. */
+ i = MAX (suffix, memory);
+ while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ ++i;
+ if (needle_len - 1 <= i)
+ {
+ /* Scan for matches in left half. */
+ i = suffix - 1;
+ while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ --i;
+ if (i + 1 < memory + 1)
+ return (RETURN_TYPE) (haystack + j);
+ /* No match, so remember how many repetitions of period
+ on the right half were scanned. */
+ j += period;
+ memory = needle_len - period;
+ }
+ else
+ {
+ j += i - suffix + 1;
+ memory = 0;
+ }
+ }
}
else
{
/* The two halves of needle are distinct; no extra memory is
- required, and any mismatch results in a maximal shift. */
+ required, and any mismatch results in a maximal shift. */
size_t shift;
period = MAX (suffix, needle_len - suffix) + 1;
j = 0;
while (AVAILABLE (haystack, haystack_len, j, needle_len))
- {
- /* Check the last byte first; if it does not match, then
- shift to the next possible match location. */
- shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
- if (0 < shift)
- {
- j += shift;
- continue;
- }
- /* Scan for matches in right half. The last byte has
- already been matched, by virtue of the shift table. */
- i = suffix;
- while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- ++i;
- if (needle_len - 1 <= i)
- {
- /* Scan for matches in left half. */
- i = suffix - 1;
- while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
- == CANON_ELEMENT (haystack[i + j])))
- --i;
- if (i == SIZE_MAX)
- return (RETURN_TYPE) (haystack + j);
- j += period;
- }
- else
- j += i - suffix + 1;
- }
+ {
+ /* Check the last byte first; if it does not match, then
+ shift to the next possible match location. */
+ shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+ if (0 < shift)
+ {
+ j += shift;
+ continue;
+ }
+ /* Scan for matches in right half. The last byte has
+ already been matched, by virtue of the shift table. */
+ i = suffix;
+ while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ ++i;
+ if (needle_len - 1 <= i)
+ {
+ /* Scan for matches in left half. */
+ i = suffix - 1;
+ while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+ == CANON_ELEMENT (haystack[i + j])))
+ --i;
+ if (i == SIZE_MAX)
+ return (RETURN_TYPE) (haystack + j);
+ j += period;
+ }
+ else
+ j += i - suffix + 1;
+ }
}
return NULL;
}
diff --git a/lib/gl/strcasecmp.c b/lib/gl/strcasecmp.c
index 065c9e378d..3d9ea4ac19 100644
--- a/lib/gl/strcasecmp.c
+++ b/lib/gl/strcasecmp.c
@@ -1,5 +1,5 @@
/* Case-insensitive string comparison function.
- Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2007, 2009-2010 Free Software Foundation, Inc.
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
@@ -46,7 +46,7 @@ strcasecmp (const char *s1, const char *s2)
c2 = TOLOWER (*p2);
if (c1 == '\0')
- break;
+ break;
++p1;
++p2;
diff --git a/lib/gl/string.in.h b/lib/gl/string.in.h
index 4b6d47f10d..4213e14488 100644
--- a/lib/gl/string.in.h
+++ b/lib/gl/string.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <string.h>.
- Copyright (C) 1995-1996, 2001-2009 Free Software Foundation, Inc.
+ Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc.
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
@@ -31,6 +31,11 @@
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
+/* MirBSD defines mbslen as a macro. */
+#if @GNULIB_MBSLEN@ && defined __MirBSD__
+# include <wchar.h>
+#endif
+
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
@@ -43,7 +48,9 @@
#endif
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
#ifdef __cplusplus
@@ -56,14 +63,13 @@ extern "C" {
# if @REPLACE_MEMCHR@
# define memchr rpl_memchr
extern void *memchr (void const *__s, int __c, size_t __n)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memchr
-# define memchr(s,c,n) \
- (GL_LINK_WARNING ("memchr has platform-specific bugs - " \
- "use gnulib module memchr for portability" ), \
- memchr (s, c, n))
+/* Assume memchr is always declared. */
+_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
+ "use gnulib module memchr for portability" );
#endif
/* Return the first occurrence of NEEDLE in HAYSTACK. */
@@ -73,16 +79,16 @@ extern void *memchr (void const *__s, int __c, size_t __n)
# endif
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
extern void *memmem (void const *__haystack, size_t __haystack_len,
- void const *__needle, size_t __needle_len)
- __attribute__ ((__pure__));
+ void const *__needle, size_t __needle_len)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memmem
-# define memmem(a,al,b,bl) \
- (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
- "use gnulib module memmem-simple for portability, " \
- "and module memmem for speed" ), \
- memmem (a, al, b, bl))
+# if HAVE_RAW_DECL_MEMMEM
+_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
+ "use gnulib module memmem-simple for portability, "
+ "and module memmem for speed" );
+# endif
#endif
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
@@ -90,28 +96,29 @@ extern void *memmem (void const *__haystack, size_t __haystack_len,
#if @GNULIB_MEMPCPY@
# if ! @HAVE_MEMPCPY@
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
- size_t __n);
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef mempcpy
-# define mempcpy(a,b,n) \
- (GL_LINK_WARNING ("mempcpy is unportable - " \
- "use gnulib module mempcpy for portability"), \
- mempcpy (a, b, n))
+# if HAVE_RAW_DECL_MEMPCPY
+_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
+ "use gnulib module mempcpy for portability");
+# endif
#endif
/* Search backwards through a block for a byte (specified as an int). */
#if @GNULIB_MEMRCHR@
# if ! @HAVE_DECL_MEMRCHR@
extern void *memrchr (void const *, int, size_t)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memrchr
-# define memrchr(a,b,c) \
- (GL_LINK_WARNING ("memrchr is unportable - " \
- "use gnulib module memrchr for portability"), \
- memrchr (a, b, c))
+# if HAVE_RAW_DECL_MEMRCHR
+_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
+ "use gnulib module memrchr for portability");
+# endif
#endif
/* Find the first occurrence of C in S. More efficient than
@@ -120,27 +127,28 @@ extern void *memrchr (void const *, int, size_t)
#if @GNULIB_RAWMEMCHR@
# if ! @HAVE_RAWMEMCHR@
extern void *rawmemchr (void const *__s, int __c_in)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef rawmemchr
-# define rawmemchr(a,b) \
- (GL_LINK_WARNING ("rawmemchr is unportable - " \
- "use gnulib module rawmemchr for portability"), \
- rawmemchr (a, b))
+# if HAVE_RAW_DECL_RAWMEMCHR
+_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
+ "use gnulib module rawmemchr for portability");
+# endif
#endif
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef stpcpy
-# define stpcpy(a,b) \
- (GL_LINK_WARNING ("stpcpy is unportable - " \
- "use gnulib module stpcpy for portability"), \
- stpcpy (a, b))
+# if HAVE_RAW_DECL_STPCPY
+_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
+ "use gnulib module stpcpy for portability");
+# endif
#endif
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
@@ -149,39 +157,39 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src);
# if ! @HAVE_STPNCPY@
# define stpncpy gnu_stpncpy
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
- size_t __n);
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef stpncpy
-# define stpncpy(a,b,n) \
- (GL_LINK_WARNING ("stpncpy is unportable - " \
- "use gnulib module stpncpy for portability"), \
- stpncpy (a, b, n))
+# if HAVE_RAW_DECL_STPNCPY
+_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
+ "use gnulib module stpncpy for portability");
+# endif
#endif
#if defined GNULIB_POSIXCHECK
/* strchr() does not work with multibyte strings if the locale encoding is
GB18030 and the character to be searched is a digit. */
# undef strchr
-# define strchr(s,c) \
- (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
- "in some multibyte locales - " \
- "use mbschr if you care about internationalization"), \
- strchr (s, c))
+/* Assume strchr is always declared. */
+_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
+ "in some multibyte locales - "
+ "use mbschr if you care about internationalization");
#endif
/* Find the first occurrence of C in S or the final NUL byte. */
#if @GNULIB_STRCHRNUL@
# if ! @HAVE_STRCHRNUL@
extern char *strchrnul (char const *__s, int __c_in)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strchrnul
-# define strchrnul(a,b) \
- (GL_LINK_WARNING ("strchrnul is unportable - " \
- "use gnulib module strchrnul for portability"), \
- strchrnul (a, b))
+# if HAVE_RAW_DECL_STRCHRNUL
+_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
+ "use gnulib module strchrnul for portability");
+# endif
#endif
/* Duplicate S, returning an identical malloc'd string. */
@@ -191,14 +199,14 @@ extern char *strchrnul (char const *__s, int __c_in)
# define strdup rpl_strdup
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef strdup
-# define strdup(a) \
- (GL_LINK_WARNING ("strdup is unportable - " \
- "use gnulib module strdup for portability"), \
- strdup (a))
+# if HAVE_RAW_DECL_STRDUP
+_GL_WARN_ON_USE (strdup, "strdup is unportable - "
+ "use gnulib module strdup for portability");
+# endif
#endif
/* Return a newly allocated copy of at most N bytes of STRING. */
@@ -208,14 +216,14 @@ extern char *strdup (char const *__s);
# define strndup rpl_strndup
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef strndup
-# define strndup(a,n) \
- (GL_LINK_WARNING ("strndup is unportable - " \
- "use gnulib module strndup for portability"), \
- strndup (a, n))
+# if HAVE_RAW_DECL_STRNDUP
+_GL_WARN_ON_USE (strndup, "strndup is unportable - "
+ "use gnulib module strndup for portability");
+# endif
#endif
/* Find the length (number of bytes) of STRING, but scan at most
@@ -224,14 +232,14 @@ extern char *strndup (char const *__string, size_t __n);
#if @GNULIB_STRNLEN@
# if ! @HAVE_DECL_STRNLEN@
extern size_t strnlen (char const *__string, size_t __maxlen)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strnlen
-# define strnlen(a,n) \
- (GL_LINK_WARNING ("strnlen is unportable - " \
- "use gnulib module strnlen for portability"), \
- strnlen (a, n))
+# if HAVE_RAW_DECL_STRNLEN
+_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
+ "use gnulib module strnlen for portability");
+# endif
#endif
#if defined GNULIB_POSIXCHECK
@@ -240,18 +248,17 @@ extern size_t strnlen (char const *__string, size_t __maxlen)
locale encoding is GB18030 and one of the characters to be searched is a
digit. */
# undef strcspn
-# define strcspn(s,a) \
- (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
- "in multibyte locales - " \
- "use mbscspn if you care about internationalization"), \
- strcspn (s, a))
+/* Assume strcspn is always declared. */
+_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbscspn if you care about internationalization");
#endif
/* Find the first occurrence in S of any character in ACCEPT. */
#if @GNULIB_STRPBRK@
# if ! @HAVE_STRPBRK@
extern char *strpbrk (char const *__s, char const *__accept)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif
# if defined GNULIB_POSIXCHECK
/* strpbrk() assumes the second argument is a list of single-byte characters.
@@ -259,40 +266,36 @@ extern char *strpbrk (char const *__s, char const *__accept)
locale encoding is GB18030 and one of the characters to be searched is a
digit. */
# undef strpbrk
-# define strpbrk(s,a) \
- (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
- "in multibyte locales - " \
- "use mbspbrk if you care about internationalization"), \
- strpbrk (s, a))
+_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbspbrk if you care about internationalization");
# endif
#elif defined GNULIB_POSIXCHECK
# undef strpbrk
-# define strpbrk(s,a) \
- (GL_LINK_WARNING ("strpbrk is unportable - " \
- "use gnulib module strpbrk for portability"), \
- strpbrk (s, a))
+# if HAVE_RAW_DECL_STRPBRK
+_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
+ "use gnulib module strpbrk for portability");
+# endif
#endif
#if defined GNULIB_POSIXCHECK
/* strspn() assumes the second argument is a list of single-byte characters.
Even in this simple case, it cannot work with multibyte strings. */
# undef strspn
-# define strspn(s,a) \
- (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
- "in multibyte locales - " \
- "use mbsspn if you care about internationalization"), \
- strspn (s, a))
+/* Assume strspn is always declared. */
+_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbsspn if you care about internationalization");
#endif
#if defined GNULIB_POSIXCHECK
/* strrchr() does not work with multibyte strings if the locale encoding is
GB18030 and the character to be searched is a digit. */
# undef strrchr
-# define strrchr(s,c) \
- (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
- "in some multibyte locales - " \
- "use mbsrchr if you care about internationalization"), \
- strrchr (s, c))
+/* Assume strrchr is always declared. */
+_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
+ "in some multibyte locales - "
+ "use mbsrchr if you care about internationalization");
#endif
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -313,29 +316,28 @@ extern char *strpbrk (char const *__s, char const *__accept)
See also strtok_r(). */
#if @GNULIB_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
# if defined GNULIB_POSIXCHECK
# undef strsep
-# define strsep(s,d) \
- (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
- "in multibyte locales - " \
- "use mbssep if you care about internationalization"), \
- strsep (s, d))
+_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbssep if you care about internationalization");
# endif
#elif defined GNULIB_POSIXCHECK
# undef strsep
-# define strsep(s,d) \
- (GL_LINK_WARNING ("strsep is unportable - " \
- "use gnulib module strsep for portability"), \
- strsep (s, d))
+# if HAVE_RAW_DECL_STRSEP
+_GL_WARN_ON_USE (strsep, "strsep is unportable - "
+ "use gnulib module strsep for portability");
+# endif
#endif
#if @GNULIB_STRSTR@
# if @REPLACE_STRSTR@
# define strstr rpl_strstr
-char *strstr (const char *haystack, const char *needle)
- __attribute__ ((__pure__));
+extern char *strstr (const char *haystack, const char *needle)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
/* strstr() does not work with multibyte strings if the locale encoding is
@@ -343,13 +345,12 @@ char *strstr (const char *haystack, const char *needle)
POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */
# undef strstr
-# define strstr(a,b) \
- (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
- "work correctly on character strings in most " \
- "multibyte locales - " \
- "use mbsstr if you care about internationalization, " \
- "or use strstr if you care about speed"), \
- strstr (a, b))
+/* Assume strstr is always declared. */
+_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
+ "work correctly on character strings in most "
+ "multibyte locales - "
+ "use mbsstr if you care about internationalization, "
+ "or use strstr if you care about speed");
#endif
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
@@ -360,31 +361,31 @@ char *strstr (const char *haystack, const char *needle)
# endif
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
extern char *strcasestr (const char *haystack, const char *needle)
- __attribute__ ((__pure__));
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
/* strcasestr() does not work with multibyte strings:
It is a glibc extension, and glibc implements it only for unibyte
locales. */
# undef strcasestr
-# define strcasestr(a,b) \
- (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
- "in multibyte locales - " \
- "use mbscasestr if you care about " \
- "internationalization, or use c-strcasestr if you want " \
- "a locale independent function"), \
- strcasestr (a, b))
+# if HAVE_RAW_DECL_STRCASESTR
+_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
+ "strings in multibyte locales - "
+ "use mbscasestr if you care about "
+ "internationalization, or use c-strcasestr if you want "
+ "a locale independent function");
+# endif
#endif
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
- char s[] = "-abc-=-def";
- char *sp;
- x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
- x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
- x = strtok_r(NULL, "=", &sp); // x = NULL
- // s = "abc\0-def\0"
+ char s[] = "-abc-=-def";
+ char *sp;
+ x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
+ x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
+ x = strtok_r(NULL, "=", &sp); // x = NULL
+ // s = "abc\0-def\0"
This is a variant of strtok() that is multithread-safe.
@@ -402,27 +403,25 @@ extern char *strcasestr (const char *haystack, const char *needle)
# if @REPLACE_STRTOK_R@
# undef strtok_r
# define strtok_r rpl_strtok_r
-# elif @UNDEFINE_STRTOK_R@
+# elif @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
# undef strtok_r
# endif
# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
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
# if defined GNULIB_POSIXCHECK
-# undef strtok_r
-# define strtok_r(s,d,p) \
- (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
- "in multibyte locales - " \
- "use mbstok_r if you care about internationalization"), \
- strtok_r (s, d, p))
+_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbstok_r if you care about internationalization");
# endif
#elif defined GNULIB_POSIXCHECK
# undef strtok_r
-# define strtok_r(s,d,p) \
- (GL_LINK_WARNING ("strtok_r is unportable - " \
- "use gnulib module strtok_r for portability"), \
- strtok_r (s, d, p))
+# if HAVE_RAW_DECL_STRTOK_R
+_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
+ "use gnulib module strtok_r for portability");
+# endif
#endif
@@ -432,13 +431,19 @@ extern char *strtok_r (char *restrict s, char const *restrict delim,
#if @GNULIB_MBSLEN@
/* Return the number of multibyte characters in the character string STRING.
This considers multibyte characters, unlike strlen, which counts bytes. */
-extern size_t mbslen (const char *string);
+# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
+# undef mbslen
+# endif
+# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
+# define mbslen rpl_mbslen
+# endif
+extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_MBSNLEN@
/* Return the number of multibyte characters in the character string starting
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
#if @GNULIB_MBSCHR@
@@ -447,7 +452,7 @@ extern size_t mbsnlen (const char *string, size_t len);
Unlike strchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */
# 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
#if @GNULIB_MBSRCHR@
@@ -456,7 +461,7 @@ extern char * mbschr (const char *string, int c);
Unlike strrchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */
# 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
#if @GNULIB_MBSSTR@
@@ -464,7 +469,8 @@ extern char * mbsrchr (const char *string, int c);
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
Unlike strstr(), this function works correctly in multibyte locales with
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
#if @GNULIB_MBSCASECMP@
@@ -474,7 +480,8 @@ extern char * mbsstr (const char *haystack, const char *needle);
Note: This function may, in multibyte locales, return 0 for strings of
different lengths!
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
#if @GNULIB_MBSNCASECMP@
@@ -487,7 +494,8 @@ extern int mbscasecmp (const char *s1, const char *s2);
of different lengths!
Unlike strncasecmp(), this function works correctly in multibyte locales.
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
#if @GNULIB_MBSPCASECMP@
@@ -500,7 +508,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
smaller length than PREFIX!
Unlike strncasecmp(), this function works correctly in multibyte
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
#if @GNULIB_MBSCASESTR@
@@ -509,7 +518,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix);
Note: This function may, in multibyte locales, return success even if
strlen (haystack) < strlen (needle) !
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
#if @GNULIB_MBSCSPN@
@@ -518,7 +528,8 @@ extern char * mbscasestr (const char *haystack, const char *needle);
beginning of the string to this occurrence, or to the end of the string
if none exists.
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
#if @GNULIB_MBSPBRK@
@@ -527,7 +538,8 @@ extern size_t mbscspn (const char *string, const char *accept);
exists.
Unlike strpbrk(), this function works correctly in multibyte locales. */
# 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
#if @GNULIB_MBSSPN@
@@ -536,7 +548,8 @@ extern char * mbspbrk (const char *string, const char *accept);
beginning of the string to this occurrence, or to the end of the string
if none exists.
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
#if @GNULIB_MBSSEP@
@@ -554,7 +567,8 @@ extern size_t mbsspn (const char *string, const char *reject);
Caveat: The identity of the delimiting character is lost.
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
#if @GNULIB_MBSTOK_R@
@@ -562,19 +576,20 @@ extern char * mbssep (char **stringp, const char *delim);
the character string DELIM.
If STRING is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
- char s[] = "-abc-=-def";
- char *sp;
- x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
- x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
- x = mbstok_r(NULL, "=", &sp); // x = NULL
- // s = "abc\0-def\0"
+ char s[] = "-abc-=-def";
+ char *sp;
+ x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
+ x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
+ x = mbstok_r(NULL, "=", &sp); // x = NULL
+ // s = "abc\0-def\0"
Caveat: It modifies the original string.
Caveat: These functions cannot be used on constant strings.
Caveat: The identity of the delimiting character is lost.
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
/* Map any int, typically from errno, into an error message. */
@@ -586,10 +601,9 @@ extern char *strerror (int);
# endif
#elif defined GNULIB_POSIXCHECK
# undef strerror
-# define strerror(e) \
- (GL_LINK_WARNING ("strerror is unportable - " \
- "use gnulib module strerror to guarantee non-NULL result"), \
- strerror (e))
+/* Assume strerror is always declared. */
+_GL_WARN_ON_USE (strerror, "strerror is unportable - "
+ "use gnulib module strerror to guarantee non-NULL result");
#endif
#if @GNULIB_STRSIGNAL@
@@ -601,22 +615,22 @@ extern char *strsignal (int __sig);
# endif
#elif defined GNULIB_POSIXCHECK
# undef strsignal
-# define strsignal(a) \
- (GL_LINK_WARNING ("strsignal is unportable - " \
- "use gnulib module strsignal for portability"), \
- strsignal (a))
+# if HAVE_RAW_DECL_STRSIGNAL
+_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
+ "use gnulib module strsignal for portability");
+# endif
#endif
#if @GNULIB_STRVERSCMP@
# if !@HAVE_STRVERSCMP@
-extern int strverscmp (const char *, const char *);
+extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
# endif
#elif defined GNULIB_POSIXCHECK
# undef strverscmp
-# define strverscmp(a, b) \
- (GL_LINK_WARNING ("strverscmp is unportable - " \
- "use gnulib module strverscmp for portability"), \
- strverscmp (a, b))
+# if HAVE_RAW_DECL_STRVERSCMP
+_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
+ "use gnulib module strverscmp for portability");
+# endif
#endif
diff --git a/lib/gl/strings.in.h b/lib/gl/strings.in.h
index 8d9e9f1449..4eff2f04f0 100644
--- a/lib/gl/strings.in.h
+++ b/lib/gl/strings.in.h
@@ -1,6 +1,6 @@
/* A substitute <strings.h>.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
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
@@ -29,8 +29,9 @@
#define _GL_STRINGS_H
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+/* The definition of _GL_WARN_ON_USE is copied here. */
#ifdef __cplusplus
extern "C" {
@@ -42,21 +43,22 @@ extern "C" {
than S2.
Note: This function does not work in multibyte locales. */
#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
#if defined GNULIB_POSIXCHECK
/* strcasecmp() does not work with multibyte strings:
POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */
# undef strcasecmp
-# define strcasecmp(a,b) \
- (GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings " \
- "in multibyte locales - " \
- "use mbscasecmp if you care about " \
- "internationalization, or use c_strcasecmp (from " \
- "gnulib module c-strcase) if you want a locale " \
- "independent function"), \
- strcasecmp (a, b))
+# if HAVE_RAW_DECL_STRCASECMP
+_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbscasecmp if you care about "
+ "internationalization, or use c_strcasecmp , "
+ "gnulib module c-strcase) if you want a locale "
+ "independent function");
+# endif
#endif
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
@@ -64,21 +66,22 @@ extern int strcasecmp (char const *s1, char const *s2);
lexicographically less than, equal to or greater than S2.
Note: This function cannot work correctly in multibyte locales. */
#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
#if defined GNULIB_POSIXCHECK
/* strncasecmp() does not work with multibyte strings:
POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */
# undef strncasecmp
-# define strncasecmp(a,b,n) \
- (GL_LINK_WARNING ("strncasecmp cannot work correctly on character " \
- "strings in multibyte locales - " \
- "use mbsncasecmp or mbspcasecmp if you care about " \
- "internationalization, or use c_strncasecmp (from " \
- "gnulib module c-strcase) if you want a locale " \
- "independent function"), \
- strncasecmp (a, b, n))
+# if HAVE_RAW_DECL_STRNCASECMP
+_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbsncasecmp or mbspcasecmp if you care about "
+ "internationalization, or use c_strncasecmp , "
+ "gnulib module c-strcase) if you want a locale "
+ "independent function");
+# endif
#endif
diff --git a/lib/gl/strncasecmp.c b/lib/gl/strncasecmp.c
index 5b2af35fd9..788e4234e4 100644
--- a/lib/gl/strncasecmp.c
+++ b/lib/gl/strncasecmp.c
@@ -1,5 +1,5 @@
/* strncasecmp.c -- case insensitive string comparator
- Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2007, 2009-2010 Free Software Foundation, Inc.
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
@@ -46,7 +46,7 @@ strncasecmp (const char *s1, const char *s2, size_t n)
c2 = TOLOWER (*p2);
if (--n == 0 || c1 == '\0')
- break;
+ break;
++p1;
++p2;
diff --git a/lib/gl/strverscmp.c b/lib/gl/strverscmp.c
index 84b4ab8a88..5757d647f1 100644
--- a/lib/gl/strverscmp.c
+++ b/lib/gl/strverscmp.c
@@ -1,5 +1,6 @@
/* Compare strings while treating digits characters numerically.
- Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2000, 2002, 2004, 2006, 2009-2010 Free Software
+ Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997.
@@ -117,8 +118,8 @@ __strverscmp (const char *s1, const char *s2)
case LEN:
while (ISDIGIT (*p1++))
- if (!ISDIGIT (*p2++))
- return 1;
+ if (!ISDIGIT (*p2++))
+ return 1;
return ISDIGIT (*p2) ? -1 : diff;
diff --git a/lib/gl/sys_socket.in.h b/lib/gl/sys_socket.in.h
index 8e9a7970e7..30b0d03522 100644
--- a/lib/gl/sys_socket.in.h
+++ b/lib/gl/sys_socket.in.h
@@ -1,6 +1,6 @@
/* Provide a sys/socket header file for systems lacking it (read: MinGW)
and for systems where it is incomplete.
- Copyright (C) 2005-2009 Free Software Foundation, Inc.
+ Copyright (C) 2005-2010 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -43,6 +43,8 @@
#ifndef _GL_SYS_SOCKET_H
#define _GL_SYS_SOCKET_H
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
#if !@HAVE_SA_FAMILY_T@
typedef unsigned short sa_family_t;
#endif
@@ -54,10 +56,10 @@ typedef unsigned short sa_family_t;
# define __ss_aligntype unsigned long int
# define _SS_SIZE 256
# define _SS_PADSIZE \
- (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
- ? sizeof (sa_family_t) \
- : alignof (__ss_aligntype)) \
- + sizeof (__ss_aligntype)))
+ (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
+ ? sizeof (sa_family_t) \
+ : alignof (__ss_aligntype)) \
+ + sizeof (__ss_aligntype)))
struct sockaddr_storage
{
@@ -124,7 +126,7 @@ struct sockaddr_storage
# define SHUT_RDWR SD_BOTH
# endif
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_WARN_ON_USE is copied here. */
# if @HAVE_WINSOCK2_H@
/* Include headers needed by the emulation code. */
@@ -177,7 +179,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
# if @GNULIB_SOCKET@
# if @HAVE_WINSOCK2_H@
# undef socket
-# define socket rpl_socket
+# define socket rpl_socket
extern int rpl_socket (int, int, int protocol);
# endif
# elif @HAVE_WINSOCK2_H@
@@ -185,33 +187,33 @@ extern int rpl_socket (int, int, int protocol);
# define socket socket_used_without_requesting_gnulib_module_socket
# elif defined GNULIB_POSIXCHECK
# undef socket
-# define socket(d,t,p) \
- (GL_LINK_WARNING ("socket is not always POSIX compliant - " \
- "use gnulib module socket for portability"), \
- socket (d, t, p))
+# if HAVE_RAW_DECL_SOCKET
+_GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
+ "use gnulib module socket for portability");
+# endif
# endif
# if @GNULIB_CONNECT@
# if @HAVE_WINSOCK2_H@
# undef connect
-# define connect rpl_connect
-extern int rpl_connect (int, struct sockaddr *, int);
+# define connect rpl_connect
+extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef connect
# define connect socket_used_without_requesting_gnulib_module_connect
# elif defined GNULIB_POSIXCHECK
# undef connect
-# define connect(s,a,l) \
- (GL_LINK_WARNING ("connect is not always POSIX compliant - " \
- "use gnulib module connect for portability"), \
- connect (s, a, l))
+# if HAVE_RAW_DECL_CONNECT
+_GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
+ "use gnulib module connect for portability");
+# endif
# endif
# if @GNULIB_ACCEPT@
# if @HAVE_WINSOCK2_H@
# undef accept
-# define accept rpl_accept
+# define accept rpl_accept
extern int rpl_accept (int, struct sockaddr *, int *);
# endif
# elif @HAVE_WINSOCK2_H@
@@ -219,84 +221,87 @@ extern int rpl_accept (int, struct sockaddr *, int *);
# define accept accept_used_without_requesting_gnulib_module_accept
# elif defined GNULIB_POSIXCHECK
# undef accept
-# define accept(s,a,l) \
- (GL_LINK_WARNING ("accept is not always POSIX compliant - " \
- "use gnulib module accept for portability"), \
- accept (s, a, l))
+# if HAVE_RAW_DECL_ACCEPT
+_GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
+ "use gnulib module accept for portability");
+# endif
# endif
# if @GNULIB_BIND@
# if @HAVE_WINSOCK2_H@
# undef bind
-# define bind rpl_bind
-extern int rpl_bind (int, struct sockaddr *, int);
+# define bind rpl_bind
+extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef bind
# define bind bind_used_without_requesting_gnulib_module_bind
# elif defined GNULIB_POSIXCHECK
# undef bind
-# define bind(s,a,l) \
- (GL_LINK_WARNING ("bind is not always POSIX compliant - " \
- "use gnulib module bind for portability"), \
- bind (s, a, l))
+# if HAVE_RAW_DECL_BIND
+_GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
+ "use gnulib module bind for portability");
+# endif
# endif
# if @GNULIB_GETPEERNAME@
# if @HAVE_WINSOCK2_H@
# undef getpeername
-# define getpeername rpl_getpeername
-extern int rpl_getpeername (int, struct sockaddr *, int *);
+# define getpeername rpl_getpeername
+extern int rpl_getpeername (int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getpeername
# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
# elif defined GNULIB_POSIXCHECK
# undef getpeername
-# define getpeername(s,a,l) \
- (GL_LINK_WARNING ("getpeername is not always POSIX compliant - " \
- "use gnulib module getpeername for portability"), \
- getpeername (s, a, l))
+# if HAVE_RAW_DECL_GETPEERNAME
+_GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
+ "use gnulib module getpeername for portability");
+# endif
# endif
# if @GNULIB_GETSOCKNAME@
# if @HAVE_WINSOCK2_H@
# undef getsockname
-# define getsockname rpl_getsockname
-extern int rpl_getsockname (int, struct sockaddr *, int *);
+# define getsockname rpl_getsockname
+extern int rpl_getsockname (int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2, 3));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getsockname
# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
# elif defined GNULIB_POSIXCHECK
# undef getsockname
-# define getsockname(s,a,l) \
- (GL_LINK_WARNING ("getsockname is not always POSIX compliant - " \
- "use gnulib module getsockname for portability"), \
- getsockname (s, a, l))
+# if HAVE_RAW_DECL_GETSOCKNAME
+_GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
+ "use gnulib module getsockname for portability");
+# endif
# endif
# if @GNULIB_GETSOCKOPT@
# if @HAVE_WINSOCK2_H@
# undef getsockopt
-# define getsockopt rpl_getsockopt
-extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
+# define getsockopt rpl_getsockopt
+extern int rpl_getsockopt (int, int, int, void *, socklen_t *)
+ _GL_ARG_NONNULL ((4, 5));
# endif
# elif @HAVE_WINSOCK2_H@
# undef getsockopt
# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
# elif defined GNULIB_POSIXCHECK
# undef getsockopt
-# define getsockopt(s,lvl,o,v,l) \
- (GL_LINK_WARNING ("getsockopt is not always POSIX compliant - " \
- "use gnulib module getsockopt for portability"), \
- getsockopt (s, lvl, o, v, l))
+# if HAVE_RAW_DECL_GETSOCKOPT
+_GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
+ "use gnulib module getsockopt for portability");
+# endif
# endif
# if @GNULIB_LISTEN@
# if @HAVE_WINSOCK2_H@
# undef listen
-# define listen rpl_listen
+# define listen rpl_listen
extern int rpl_listen (int, int);
# endif
# elif @HAVE_WINSOCK2_H@
@@ -304,101 +309,104 @@ extern int rpl_listen (int, int);
# define listen listen_used_without_requesting_gnulib_module_listen
# elif defined GNULIB_POSIXCHECK
# undef listen
-# define listen(s,b) \
- (GL_LINK_WARNING ("listen is not always POSIX compliant - " \
- "use gnulib module listen for portability"), \
- listen (s, b))
+# if HAVE_RAW_DECL_LISTEN
+_GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
+ "use gnulib module listen for portability");
+# endif
# endif
# if @GNULIB_RECV@
# if @HAVE_WINSOCK2_H@
# undef recv
-# define recv rpl_recv
-extern int rpl_recv (int, void *, int, int);
+# define recv rpl_recv
+extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef recv
# define recv recv_used_without_requesting_gnulib_module_recv
# elif defined GNULIB_POSIXCHECK
# undef recv
-# define recv(s,b,n,f) \
- (GL_LINK_WARNING ("recv is not always POSIX compliant - " \
- "use gnulib module recv for portability"), \
- recv (s, b, n, f))
+# if HAVE_RAW_DECL_RECV
+_GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
+ "use gnulib module recv for portability");
+# endif
# endif
# if @GNULIB_SEND@
# if @HAVE_WINSOCK2_H@
# undef send
-# define send rpl_send
-extern int rpl_send (int, const void *, int, int);
+# define send rpl_send
+extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef send
# define send send_used_without_requesting_gnulib_module_send
# elif defined GNULIB_POSIXCHECK
# undef send
-# define send(s,b,n,f) \
- (GL_LINK_WARNING ("send is not always POSIX compliant - " \
- "use gnulib module send for portability"), \
- send (s, b, n, f))
+# if HAVE_RAW_DECL_SEND
+_GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
+ "use gnulib module send for portability");
+# endif
# endif
# if @GNULIB_RECVFROM@
# if @HAVE_WINSOCK2_H@
# undef recvfrom
-# define recvfrom rpl_recvfrom
-extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
+# define recvfrom rpl_recvfrom
+extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *)
+ _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef recvfrom
# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
# elif defined GNULIB_POSIXCHECK
# undef recvfrom
-# define recvfrom(s,b,n,f,a,l) \
- (GL_LINK_WARNING ("recvfrom is not always POSIX compliant - " \
- "use gnulib module recvfrom for portability"), \
- recvfrom (s, b, n, f, a, l))
+# if HAVE_RAW_DECL_RECVFROM
+_GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
+ "use gnulib module recvfrom for portability");
+# endif
# endif
# if @GNULIB_SENDTO@
# if @HAVE_WINSOCK2_H@
# undef sendto
-# define sendto rpl_sendto
-extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
+# define sendto rpl_sendto
+extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int)
+ _GL_ARG_NONNULL ((2));
# endif
# elif @HAVE_WINSOCK2_H@
# undef sendto
# define sendto sendto_used_without_requesting_gnulib_module_sendto
# elif defined GNULIB_POSIXCHECK
# undef sendto
-# define sendto(s,b,n,f,a,l) \
- (GL_LINK_WARNING ("sendto is not always POSIX compliant - " \
- "use gnulib module sendto for portability"), \
- sendto (s, b, n, f, a, l))
+# if HAVE_RAW_DECL_SENDTO
+_GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
+ "use gnulib module sendto for portability");
+# endif
# endif
# if @GNULIB_SETSOCKOPT@
# if @HAVE_WINSOCK2_H@
# undef setsockopt
-# define setsockopt rpl_setsockopt
-extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
+# define setsockopt rpl_setsockopt
+extern int rpl_setsockopt (int, int, int, const void *, socklen_t)
+ _GL_ARG_NONNULL ((4));
# endif
# elif @HAVE_WINSOCK2_H@
# undef setsockopt
# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
# elif defined GNULIB_POSIXCHECK
# undef setsockopt
-# define setsockopt(s,lvl,o,v,l) \
- (GL_LINK_WARNING ("setsockopt is not always POSIX compliant - " \
- "use gnulib module setsockopt for portability"), \
- setsockopt (s, lvl, o, v, l))
+# if HAVE_RAW_DECL_SETSOCKOPT
+_GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
+ "use gnulib module setsockopt for portability");
+# endif
# endif
# if @GNULIB_SHUTDOWN@
# if @HAVE_WINSOCK2_H@
# undef shutdown
-# define shutdown rpl_shutdown
+# define shutdown rpl_shutdown
extern int rpl_shutdown (int, int);
# endif
# elif @HAVE_WINSOCK2_H@
@@ -406,15 +414,15 @@ extern int rpl_shutdown (int, int);
# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
# elif defined GNULIB_POSIXCHECK
# undef shutdown
-# define shutdown(s,h) \
- (GL_LINK_WARNING ("shutdown is not always POSIX compliant - " \
- "use gnulib module shutdown for portability"), \
- shutdown (s, h))
+# if HAVE_RAW_DECL_SHUTDOWN
+_GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
+ "use gnulib module shutdown for portability");
+# endif
# endif
# if @HAVE_WINSOCK2_H@
# undef select
-# define select select_used_without_including_sys_select_h
+# define select select_used_without_including_sys_select_h
# endif
# ifdef __cplusplus
@@ -437,13 +445,13 @@ extern "C" {
# define accept4 rpl_accept4
# endif
extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
- int flags);
+ int flags);
#elif defined GNULIB_POSIXCHECK
# undef accept4
-# define accept4(s,a,l,f) \
- (GL_LINK_WARNING ("accept4 is unportable - " \
- "use gnulib module accept4 for portability"), \
- accept4 (s, a, l, f))
+# if HAVE_RAW_DECL_ACCEPT4
+_GL_WARN_ON_USE (accept4, "accept4 is unportable - "
+ "use gnulib module accept4 for portability");
+# endif
#endif
#ifdef __cplusplus
diff --git a/lib/gl/sys_stat.in.h b/lib/gl/sys_stat.in.h
index f95571d679..8423f50a0e 100644
--- a/lib/gl/sys_stat.in.h
+++ b/lib/gl/sys_stat.in.h
@@ -1,5 +1,5 @@
/* Provide a more complete sys/stat header file.
- Copyright (C) 2005-2009 Free Software Foundation, Inc.
+ Copyright (C) 2005-2010 Free Software Foundation, Inc.
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
@@ -47,7 +47,9 @@
#ifndef _GL_SYS_STAT_H
#define _GL_SYS_STAT_H
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). */
@@ -295,20 +297,21 @@ extern "C" {
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef fchmodat
-# define fchmodat(d,n,m,f) \
- (GL_LINK_WARNING ("fchmodat is not portable - " \
- "use gnulib module openat for portability"), \
- fchmodat (d, n, m, f))
+# if HAVE_RAW_DECL_FCHMODAT
+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
+ "use gnulib module openat for portability");
+# endif
#endif
#if @REPLACE_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
@@ -318,14 +321,15 @@ extern int fstat (int fd, struct stat *buf);
# define fstatat rpl_fstatat
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef fstatat
-# define fstatat(d,n,s,f) \
- (GL_LINK_WARNING ("fstatat is not portable - " \
- "use gnulib module openat for portability"), \
- fstatat (d, n, s, f))
+# if HAVE_RAW_DECL_FSTATAT
+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
+ "use gnulib module openat for portability");
+# endif
#endif
@@ -339,10 +343,10 @@ extern int futimens (int fd, struct timespec const times[2]);
# endif
#elif defined GNULIB_POSIXCHECK
# undef futimens
-# define futimens(f,t) \
- (GL_LINK_WARNING ("futimens is not portable - " \
- "use gnulib module futimens for portability"), \
- futimens (f, t))
+# if HAVE_RAW_DECL_FUTIMENS
+_GL_WARN_ON_USE (futimens, "futimens is not portable - "
+ "use gnulib module futimens for portability");
+# endif
#endif
@@ -360,14 +364,14 @@ extern int futimens (int fd, struct timespec const times[2]);
# define lchmod chmod
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef lchmod
-# define lchmod(f,m) \
- (GL_LINK_WARNING ("lchmod is unportable - " \
- "use gnulib module lchmod for portability"), \
- lchmod (f, m))
+# if HAVE_RAW_DECL_LCHMOD
+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
+ "use gnulib module lchmod for portability");
+# endif
#endif
@@ -379,21 +383,22 @@ extern int lchmod (const char *filename, mode_t mode);
# elif @REPLACE_LSTAT@
# undef 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
#elif defined GNULIB_POSIXCHECK
# undef lstat
-# define lstat(p,b) \
- (GL_LINK_WARNING ("lstat is unportable - " \
- "use gnulib module lstat for portability"), \
- lstat (p, b))
+# if HAVE_RAW_DECL_LSTAT
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
+ "use gnulib module lstat for portability");
+# endif
#endif
#if @REPLACE_MKDIR@
# undef 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
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Additionally, it declares _mkdir (and depending on compile flags, an
@@ -413,14 +418,15 @@ rpl_mkdir (char const *name, mode_t mode)
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef mkdirat
-# define mkdirat(d,n,m) \
- (GL_LINK_WARNING ("mkdirat is not portable - " \
- "use gnulib module openat for portability"), \
- mkdirat (d, n, m))
+# if HAVE_RAW_DECL_MKDIRAT
+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
+ "use gnulib module openat for portability");
+# endif
#endif
@@ -430,27 +436,28 @@ extern int mkdirat (int fd, char const *file, mode_t mode);
# define mkfifo rpl_mkfifo
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef mkfifo
-# define mkfifo(n,m) \
- (GL_LINK_WARNING ("mkfifo is not portable - " \
- "use gnulib module mkfifo for portability"), \
- mkfifo (n, m))
+# if HAVE_RAW_DECL_MKFIFO
+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
+ "use gnulib module mkfifo for portability");
+# endif
#endif
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef mkfifoat
-# define mkfifoat(d,n,m) \
- (GL_LINK_WARNING ("mkfifoat is not portable - " \
- "use gnulib module mkfifoat for portability"), \
- mkfifoat (d, n, m))
+# if HAVE_RAW_DECL_MKFIFOAT
+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
+ "use gnulib module mkfifoat for portability");
+# endif
#endif
@@ -460,27 +467,29 @@ int mkfifoat (int fd, char const *file, mode_t mode);
# define mknod rpl_mknod
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef mknod
-# define mknod(n,m,d) \
- (GL_LINK_WARNING ("mknod is not portable - " \
- "use gnulib module mknod for portability"), \
- mknod (n, m, d))
+# if HAVE_RAW_DECL_MKNOD
+_GL_WARN_ON_USE (mknod, "mknod is not portable - "
+ "use gnulib module mknod for portability");
+# endif
#endif
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef mknodat
-# define mknodat(f,n,m,d) \
- (GL_LINK_WARNING ("mknodat is not portable - " \
- "use gnulib module mkfifoat for portability"), \
- mknodat (f, n, m, d))
+# if HAVE_RAW_DECL_MKNODAT
+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
+ "use gnulib module mkfifoat for portability");
+# endif
#endif
@@ -499,14 +508,14 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
# else /* !_LARGE_FILES */
# define stat(name, st) rpl_stat (name, st)
# 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
#elif defined GNULIB_POSIXCHECK
# undef stat
-# define stat(p,b) \
- (GL_LINK_WARNING ("stat is unportable - " \
- "use gnulib module stat for portability"), \
- stat (p, b))
+# if HAVE_RAW_DECL_STAT
+_GL_WARN_ON_USE (stat, "stat is unportable - "
+ "use gnulib module stat for portability");
+# endif
#endif
@@ -517,14 +526,15 @@ extern int stat (const char *name, struct stat *buf);
# endif
# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
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
#elif defined GNULIB_POSIXCHECK
# undef utimensat
-# define utimensat(d,n,t,f) \
- (GL_LINK_WARNING ("utimensat is not portable - " \
- "use gnulib module utimensat for portability"), \
- utimensat (d, n, t, f))
+# if HAVE_RAW_DECL_UTIMENSAT
+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
+ "use gnulib module utimensat for portability");
+# endif
#endif
diff --git a/lib/gl/tests/Makefile.am b/lib/gl/tests/Makefile.am
index 58311a3b15..e70c294d2d 100644
--- a/lib/gl/tests/Makefile.am
+++ b/lib/gl/tests/Makefile.am
@@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2009 Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
@@ -14,6 +14,7 @@ AUTOMAKE_OPTIONS = 1.5 foreign
SUBDIRS =
TESTS =
+XFAIL_TESTS =
TESTS_ENVIRONMENT =
noinst_PROGRAMS =
check_PROGRAMS =
@@ -42,6 +43,8 @@ libtests_a_DEPENDENCIES = $(lgltests_LIBOBJS)
EXTRA_libtests_a_SOURCES =
AM_LIBTOOLFLAGS = --preserve-dup-deps
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
+
## begin gnulib module alloca-opt-tests
TESTS += test-alloca-opt
@@ -51,12 +54,35 @@ EXTRA_DIST += test-alloca-opt.c
## end gnulib module alloca-opt-tests
+## begin gnulib module arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+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 byteswap-tests
TESTS += test-byteswap
check_PROGRAMS += test-byteswap
-
-EXTRA_DIST += test-byteswap.c
+EXTRA_DIST += test-byteswap.c macros.h
## end gnulib module byteswap-tests
@@ -65,7 +91,7 @@ EXTRA_DIST += test-byteswap.c
TESTS += test-c-ctype
check_PROGRAMS += test-c-ctype
-EXTRA_DIST += test-c-ctype.c
+EXTRA_DIST += test-c-ctype.c macros.h
## end gnulib module c-ctype-tests
@@ -81,9 +107,8 @@ EXTRA_DIST += test-errno.c
## begin gnulib module fseeko-tests
TESTS += test-fseeko.sh test-fseeko2.sh
-TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
check_PROGRAMS += test-fseeko
-EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh
+EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh signature.h macros.h
## end gnulib module fseeko-tests
@@ -91,7 +116,7 @@ EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh
TESTS += test-func
check_PROGRAMS += test-func
-EXTRA_DIST += test-func.c
+EXTRA_DIST += test-func.c macros.h
## end gnulib module func-tests
@@ -102,19 +127,11 @@ EXTRA_DIST += intprops.h
## end gnulib module intprops
-## begin gnulib module link-warning
-
-LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
-
-EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
-
-## end gnulib module link-warning
-
## begin gnulib module memchr-tests
TESTS += test-memchr
check_PROGRAMS += test-memchr
-EXTRA_DIST += test-memchr.c zerosize-ptr.h
+EXTRA_DIST += test-memchr.c zerosize-ptr.h signature.h macros.h
## end gnulib module memchr-tests
@@ -122,7 +139,6 @@ EXTRA_DIST += test-memchr.c zerosize-ptr.h
TESTS += test-netdb
check_PROGRAMS += test-netdb
-
EXTRA_DIST += test-netdb.c
## end gnulib module netdb-tests
@@ -140,7 +156,7 @@ EXTRA_DIST += test-read-file.c
TESTS += test-snprintf
check_PROGRAMS += test-snprintf
-EXTRA_DIST += test-snprintf.c
+EXTRA_DIST += test-snprintf.c signature.h macros.h
## end gnulib module snprintf-tests
@@ -157,7 +173,6 @@ EXTRA_DIST += test-sockets.c
TESTS += test-stdbool
check_PROGRAMS += test-stdbool
-
EXTRA_DIST += test-stdbool.c
## end gnulib module stdbool-tests
@@ -166,7 +181,6 @@ EXTRA_DIST += test-stdbool.c
TESTS += test-stddef
check_PROGRAMS += test-stddef
-
EXTRA_DIST += test-stddef.c
## end gnulib module stddef-tests
@@ -175,7 +189,6 @@ EXTRA_DIST += test-stddef.c
TESTS += test-stdint
check_PROGRAMS += test-stdint
-
EXTRA_DIST += test-stdint.c
## end gnulib module stdint-tests
@@ -184,7 +197,6 @@ EXTRA_DIST += test-stdint.c
TESTS += test-stdio
check_PROGRAMS += test-stdio
-
EXTRA_DIST += test-stdio.c
## end gnulib module stdio-tests
@@ -193,7 +205,6 @@ EXTRA_DIST += test-stdio.c
TESTS += test-stdlib
check_PROGRAMS += test-stdlib
-
EXTRA_DIST += test-stdlib.c
## end gnulib module stdlib-tests
@@ -202,7 +213,6 @@ EXTRA_DIST += test-stdlib.c
TESTS += test-string
check_PROGRAMS += test-string
-
EXTRA_DIST += test-string.c
## end gnulib module string-tests
@@ -211,7 +221,6 @@ EXTRA_DIST += test-string.c
TESTS += test-strings
check_PROGRAMS += test-strings
-
EXTRA_DIST += test-strings.c
## end gnulib module strings-tests
@@ -220,7 +229,7 @@ EXTRA_DIST += test-strings.c
TESTS += test-strverscmp
check_PROGRAMS += test-strverscmp
-EXTRA_DIST += test-strverscmp.c
+EXTRA_DIST += test-strverscmp.c signature.h macros.h
## end gnulib module strverscmp-tests
@@ -228,7 +237,6 @@ EXTRA_DIST += test-strverscmp.c
TESTS += test-sys_socket
check_PROGRAMS += test-sys_socket
-
EXTRA_DIST += test-sys_socket.c
## end gnulib module sys_socket-tests
@@ -237,7 +245,6 @@ EXTRA_DIST += test-sys_socket.c
TESTS += test-sys_stat
check_PROGRAMS += test-sys_stat
-
EXTRA_DIST += test-sys_stat.c
## end gnulib module sys_stat-tests
@@ -246,7 +253,6 @@ EXTRA_DIST += test-sys_stat.c
TESTS += test-time
check_PROGRAMS += test-time
-
EXTRA_DIST += test-time.c
## end gnulib module time-tests
@@ -255,7 +261,6 @@ EXTRA_DIST += test-time.c
TESTS += test-unistd
check_PROGRAMS += test-unistd
-
EXTRA_DIST += test-unistd.c
## end gnulib module unistd-tests
@@ -265,7 +270,7 @@ EXTRA_DIST += test-unistd.c
TESTS += test-vasnprintf
check_PROGRAMS += test-vasnprintf
-EXTRA_DIST += test-vasnprintf.c
+EXTRA_DIST += test-vasnprintf.c macros.h
## end gnulib module vasnprintf-tests
@@ -274,7 +279,7 @@ EXTRA_DIST += test-vasnprintf.c
TESTS += test-vasprintf
check_PROGRAMS += test-vasprintf
-EXTRA_DIST += test-vasprintf.c
+EXTRA_DIST += test-vasprintf.c signature.h macros.h
## end gnulib module vasprintf-tests
@@ -289,15 +294,33 @@ libtests_a_SOURCES += verify.h
TESTS += test-vsnprintf
check_PROGRAMS += test-vsnprintf
-EXTRA_DIST += test-vsnprintf.c
+EXTRA_DIST += test-vsnprintf.c signature.h macros.h
## end gnulib module vsnprintf-tests
+## begin gnulib module warn-on-use
+
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ sed -n -e '/^.ifndef/,$$p' \
+ < $(top_srcdir)/build-aux/warn-on-use.h \
+ > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+EXTRA_DIST += $(top_srcdir)/build-aux/warn-on-use.h
+
+## end gnulib module warn-on-use
+
## begin gnulib module wchar-tests
TESTS += test-wchar
check_PROGRAMS += test-wchar
-
EXTRA_DIST += test-wchar.c
## end gnulib module wchar-tests
diff --git a/lib/gl/tests/dummy.c b/lib/gl/tests/dummy.c
index ccb5c26f87..0f9a277962 100644
--- a/lib/gl/tests/dummy.c
+++ b/lib/gl/tests/dummy.c
@@ -1,5 +1,5 @@
/* A dummy file, to prevent empty libraries from breaking builds.
- Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007, 2009, 2010 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
diff --git a/lib/gl/tests/intprops.h b/lib/gl/tests/intprops.h
index 325c397997..46f4d47d70 100644
--- a/lib/gl/tests/intprops.h
+++ b/lib/gl/tests/intprops.h
@@ -1,6 +1,6 @@
/* intprops.h -- properties of integer types
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -47,14 +47,14 @@
your host. */
# define TYPE_MINIMUM(t) \
((t) (! TYPE_SIGNED (t) \
- ? (t) 0 \
- : TYPE_SIGNED_MAGNITUDE (t) \
- ? ~ (t) 0 \
- : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
+ ? (t) 0 \
+ : TYPE_SIGNED_MAGNITUDE (t) \
+ ? ~ (t) 0 \
+ : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
# define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
- ? (t) -1 \
- : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
+ ? (t) -1 \
+ : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
/* Return zero if T can be determined to be an unsigned type.
Otherwise, return 1.
diff --git a/lib/gl/tests/test-alloca-opt.c b/lib/gl/tests/test-alloca-opt.c
index 68d906d869..cfbecafcb9 100644
--- a/lib/gl/tests/test-alloca-opt.c
+++ b/lib/gl/tests/test-alloca-opt.c
@@ -1,5 +1,5 @@
/* Test of optional automatic memory allocation.
- Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-byteswap.c b/lib/gl/tests/test-byteswap.c
index 78f142d72d..0c036052f7 100644
--- a/lib/gl/tests/test-byteswap.c
+++ b/lib/gl/tests/test-byteswap.c
@@ -1,5 +1,5 @@
/* Test of <byteswap.h> substitute.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
@@ -20,20 +20,7 @@
#include <byteswap.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
diff --git a/lib/gl/tests/test-c-ctype.c b/lib/gl/tests/test-c-ctype.c
index 6d7fe1b7a3..ebe594dd4f 100644
--- a/lib/gl/tests/test-c-ctype.c
+++ b/lib/gl/tests/test-c-ctype.c
@@ -1,5 +1,5 @@
/* Test of character handling in C locale.
- Copyright (C) 2005, 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007-2010 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
@@ -21,20 +21,8 @@
#include "c-ctype.h"
#include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static void
test_all (void)
@@ -46,81 +34,81 @@ test_all (void)
ASSERT (c_isascii (c) == (c >= 0 && c < 0x80));
switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- ASSERT (c_isalnum (c) == 1);
- break;
- default:
- ASSERT (c_isalnum (c) == 0);
- break;
- }
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+ case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ case '0': case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ ASSERT (c_isalnum (c) == 1);
+ break;
+ default:
+ ASSERT (c_isalnum (c) == 0);
+ break;
+ }
switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- ASSERT (c_isalpha (c) == 1);
- break;
- default:
- ASSERT (c_isalpha (c) == 0);
- break;
- }
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+ case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ ASSERT (c_isalpha (c) == 1);
+ break;
+ default:
+ ASSERT (c_isalpha (c) == 0);
+ break;
+ }
switch (c)
- {
- case '\t': case ' ':
- ASSERT (c_isblank (c) == 1);
- break;
- default:
- ASSERT (c_isblank (c) == 0);
- break;
- }
+ {
+ case '\t': case ' ':
+ ASSERT (c_isblank (c) == 1);
+ break;
+ default:
+ ASSERT (c_isblank (c) == 0);
+ break;
+ }
ASSERT (c_iscntrl (c) == ((c >= 0 && c < 0x20) || c == 0x7f));
switch (c)
- {
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- ASSERT (c_isdigit (c) == 1);
- break;
- default:
- ASSERT (c_isdigit (c) == 0);
- break;
- }
+ {
+ case '0': case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ ASSERT (c_isdigit (c) == 1);
+ break;
+ default:
+ ASSERT (c_isdigit (c) == 0);
+ break;
+ }
switch (c)
- {
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- ASSERT (c_islower (c) == 1);
- break;
- default:
- ASSERT (c_islower (c) == 0);
- break;
- }
+ {
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+ case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ ASSERT (c_islower (c) == 1);
+ break;
+ default:
+ ASSERT (c_islower (c) == 0);
+ break;
+ }
ASSERT (c_isgraph (c) == ((c >= 0x20 && c < 0x7f) && c != ' '));
@@ -129,257 +117,257 @@ test_all (void)
ASSERT (c_ispunct (c) == (c_isgraph (c) && !c_isalnum (c)));
switch (c)
- {
- case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
- ASSERT (c_isspace (c) == 1);
- break;
- default:
- ASSERT (c_isspace (c) == 0);
- break;
- }
+ {
+ case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
+ ASSERT (c_isspace (c) == 1);
+ break;
+ default:
+ ASSERT (c_isspace (c) == 0);
+ break;
+ }
switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- ASSERT (c_isupper (c) == 1);
- break;
- default:
- ASSERT (c_isupper (c) == 0);
- break;
- }
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ ASSERT (c_isupper (c) == 1);
+ break;
+ default:
+ ASSERT (c_isupper (c) == 0);
+ break;
+ }
switch (c)
- {
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- ASSERT (c_isxdigit (c) == 1);
- break;
- default:
- ASSERT (c_isxdigit (c) == 0);
- break;
- }
+ {
+ case '0': case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ ASSERT (c_isxdigit (c) == 1);
+ break;
+ default:
+ ASSERT (c_isxdigit (c) == 0);
+ break;
+ }
switch (c)
- {
- case 'A':
- ASSERT (c_tolower (c) == 'a');
- ASSERT (c_toupper (c) == c);
- break;
- case 'B':
- ASSERT (c_tolower (c) == 'b');
- ASSERT (c_toupper (c) == c);
- break;
- case 'C':
- ASSERT (c_tolower (c) == 'c');
- ASSERT (c_toupper (c) == c);
- break;
- case 'D':
- ASSERT (c_tolower (c) == 'd');
- ASSERT (c_toupper (c) == c);
- break;
- case 'E':
- ASSERT (c_tolower (c) == 'e');
- ASSERT (c_toupper (c) == c);
- break;
- case 'F':
- ASSERT (c_tolower (c) == 'f');
- ASSERT (c_toupper (c) == c);
- break;
- case 'G':
- ASSERT (c_tolower (c) == 'g');
- ASSERT (c_toupper (c) == c);
- break;
- case 'H':
- ASSERT (c_tolower (c) == 'h');
- ASSERT (c_toupper (c) == c);
- break;
- case 'I':
- ASSERT (c_tolower (c) == 'i');
- ASSERT (c_toupper (c) == c);
- break;
- case 'J':
- ASSERT (c_tolower (c) == 'j');
- ASSERT (c_toupper (c) == c);
- break;
- case 'K':
- ASSERT (c_tolower (c) == 'k');
- ASSERT (c_toupper (c) == c);
- break;
- case 'L':
- ASSERT (c_tolower (c) == 'l');
- ASSERT (c_toupper (c) == c);
- break;
- case 'M':
- ASSERT (c_tolower (c) == 'm');
- ASSERT (c_toupper (c) == c);
- break;
- case 'N':
- ASSERT (c_tolower (c) == 'n');
- ASSERT (c_toupper (c) == c);
- break;
- case 'O':
- ASSERT (c_tolower (c) == 'o');
- ASSERT (c_toupper (c) == c);
- break;
- case 'P':
- ASSERT (c_tolower (c) == 'p');
- ASSERT (c_toupper (c) == c);
- break;
- case 'Q':
- ASSERT (c_tolower (c) == 'q');
- ASSERT (c_toupper (c) == c);
- break;
- case 'R':
- ASSERT (c_tolower (c) == 'r');
- ASSERT (c_toupper (c) == c);
- break;
- case 'S':
- ASSERT (c_tolower (c) == 's');
- ASSERT (c_toupper (c) == c);
- break;
- case 'T':
- ASSERT (c_tolower (c) == 't');
- ASSERT (c_toupper (c) == c);
- break;
- case 'U':
- ASSERT (c_tolower (c) == 'u');
- ASSERT (c_toupper (c) == c);
- break;
- case 'V':
- ASSERT (c_tolower (c) == 'v');
- ASSERT (c_toupper (c) == c);
- break;
- case 'W':
- ASSERT (c_tolower (c) == 'w');
- ASSERT (c_toupper (c) == c);
- break;
- case 'X':
- ASSERT (c_tolower (c) == 'x');
- ASSERT (c_toupper (c) == c);
- break;
- case 'Y':
- ASSERT (c_tolower (c) == 'y');
- ASSERT (c_toupper (c) == c);
- break;
- case 'Z':
- ASSERT (c_tolower (c) == 'z');
- ASSERT (c_toupper (c) == c);
- break;
- case 'a':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'A');
- break;
- case 'b':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'B');
- break;
- case 'c':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'C');
- break;
- case 'd':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'D');
- break;
- case 'e':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'E');
- break;
- case 'f':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'F');
- break;
- case 'g':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'G');
- break;
- case 'h':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'H');
- break;
- case 'i':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'I');
- break;
- case 'j':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'J');
- break;
- case 'k':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'K');
- break;
- case 'l':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'L');
- break;
- case 'm':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'M');
- break;
- case 'n':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'N');
- break;
- case 'o':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'O');
- break;
- case 'p':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'P');
- break;
- case 'q':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'Q');
- break;
- case 'r':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'R');
- break;
- case 's':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'S');
- break;
- case 't':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'T');
- break;
- case 'u':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'U');
- break;
- case 'v':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'V');
- break;
- case 'w':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'W');
- break;
- case 'x':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'X');
- break;
- case 'y':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'Y');
- break;
- case 'z':
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == 'Z');
- break;
- default:
- ASSERT (c_tolower (c) == c);
- ASSERT (c_toupper (c) == c);
- break;
- }
+ {
+ case 'A':
+ ASSERT (c_tolower (c) == 'a');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'B':
+ ASSERT (c_tolower (c) == 'b');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'C':
+ ASSERT (c_tolower (c) == 'c');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'D':
+ ASSERT (c_tolower (c) == 'd');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'E':
+ ASSERT (c_tolower (c) == 'e');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'F':
+ ASSERT (c_tolower (c) == 'f');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'G':
+ ASSERT (c_tolower (c) == 'g');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'H':
+ ASSERT (c_tolower (c) == 'h');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'I':
+ ASSERT (c_tolower (c) == 'i');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'J':
+ ASSERT (c_tolower (c) == 'j');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'K':
+ ASSERT (c_tolower (c) == 'k');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'L':
+ ASSERT (c_tolower (c) == 'l');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'M':
+ ASSERT (c_tolower (c) == 'm');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'N':
+ ASSERT (c_tolower (c) == 'n');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'O':
+ ASSERT (c_tolower (c) == 'o');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'P':
+ ASSERT (c_tolower (c) == 'p');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'Q':
+ ASSERT (c_tolower (c) == 'q');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'R':
+ ASSERT (c_tolower (c) == 'r');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'S':
+ ASSERT (c_tolower (c) == 's');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'T':
+ ASSERT (c_tolower (c) == 't');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'U':
+ ASSERT (c_tolower (c) == 'u');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'V':
+ ASSERT (c_tolower (c) == 'v');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'W':
+ ASSERT (c_tolower (c) == 'w');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'X':
+ ASSERT (c_tolower (c) == 'x');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'Y':
+ ASSERT (c_tolower (c) == 'y');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'Z':
+ ASSERT (c_tolower (c) == 'z');
+ ASSERT (c_toupper (c) == c);
+ break;
+ case 'a':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'A');
+ break;
+ case 'b':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'B');
+ break;
+ case 'c':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'C');
+ break;
+ case 'd':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'D');
+ break;
+ case 'e':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'E');
+ break;
+ case 'f':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'F');
+ break;
+ case 'g':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'G');
+ break;
+ case 'h':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'H');
+ break;
+ case 'i':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'I');
+ break;
+ case 'j':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'J');
+ break;
+ case 'k':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'K');
+ break;
+ case 'l':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'L');
+ break;
+ case 'm':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'M');
+ break;
+ case 'n':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'N');
+ break;
+ case 'o':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'O');
+ break;
+ case 'p':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'P');
+ break;
+ case 'q':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'Q');
+ break;
+ case 'r':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'R');
+ break;
+ case 's':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'S');
+ break;
+ case 't':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'T');
+ break;
+ case 'u':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'U');
+ break;
+ case 'v':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'V');
+ break;
+ case 'w':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'W');
+ break;
+ case 'x':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'X');
+ break;
+ case 'y':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'Y');
+ break;
+ case 'z':
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == 'Z');
+ break;
+ default:
+ ASSERT (c_tolower (c) == c);
+ ASSERT (c_toupper (c) == c);
+ break;
+ }
}
}
diff --git a/lib/gl/tests/test-errno.c b/lib/gl/tests/test-errno.c
index 4642027dce..129b236fe9 100644
--- a/lib/gl/tests/test-errno.c
+++ b/lib/gl/tests/test-errno.c
@@ -1,5 +1,5 @@
/* Test of <errno.h> substitute.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 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
diff --git a/lib/gl/tests/test-fseeko.c b/lib/gl/tests/test-fseeko.c
index 93b0adc361..be2a78dce1 100644
--- a/lib/gl/tests/test-fseeko.c
+++ b/lib/gl/tests/test-fseeko.c
@@ -1,5 +1,5 @@
/* Test of fseeko() function.
- Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009, 2010 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
@@ -18,33 +18,23 @@
#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-
/* None of the files accessed by this test are large, so disable the
fseek link warning if we are not using the gnulib fseek module. */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
+#define _GL_NO_LARGE_FILES
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fseeko, int, (FILE *, off_t, int));
+
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#ifndef FUNC_UNGETC_BROKEN
# define FUNC_UNGETC_BROKEN 0
#endif
int
-main (int argc, char **argv)
+main (int argc, char **argv _GL_UNUSED)
{
/* Assume stdin is non-empty, seekable, and starts with '#!/bin/sh'
iff argc > 1. */
diff --git a/lib/gl/tests/test-func.c b/lib/gl/tests/test-func.c
index 106a20edce..476e04dd9e 100644
--- a/lib/gl/tests/test-func.c
+++ b/lib/gl/tests/test-func.c
@@ -1,5 +1,5 @@
/* Test whether __func__ is available
- Copyright (C) 2008-2009 Free Software Foundation, Inc.
+ Copyright (C) 2008-2010 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
@@ -19,20 +19,8 @@
#include <config.h>
#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+
+#include "macros.h"
int
main ()
@@ -46,7 +34,7 @@ main ()
#endif
ASSERT (strcmp (__func__, "main") == 0
- || strcmp (__func__, "<unknown function>") == 0);
+ || strcmp (__func__, "<unknown function>") == 0);
return 0;
}
diff --git a/lib/gl/tests/test-memchr.c b/lib/gl/tests/test-memchr.c
index d5e53e0081..5d31e76f27 100644
--- a/lib/gl/tests/test-memchr.c
+++ b/lib/gl/tests/test-memchr.c
@@ -19,22 +19,13 @@
#include <string.h>
-#include <stdio.h>
+#include "signature.h"
+SIGNATURE_CHECK (memchr, void *, (void const *, int, size_t));
+
#include <stdlib.h>
#include "zerosize-ptr.h"
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
/* Calculating void * + int is not portable, so this wrapper converts
to char * to make the tests easier to write. */
@@ -76,7 +67,7 @@ main (void)
size_t repeat = 10000;
for (; repeat > 0; repeat--)
{
- ASSERT (MEMCHR (input, 'c', n) == input + 2);
+ ASSERT (MEMCHR (input, 'c', n) == input + 2);
}
}
@@ -85,12 +76,12 @@ main (void)
int i, j;
for (i = 0; i < 32; i++)
{
- for (j = 0; j < 256; j++)
- input[i + j] = j;
- for (j = 0; j < 256; j++)
- {
- ASSERT (MEMCHR (input + i, j, 256) == input + i + j);
- }
+ for (j = 0; j < 256; j++)
+ input[i + j] = j;
+ for (j = 0; j < 256; j++)
+ {
+ ASSERT (MEMCHR (input + i, j, 256) == input + i + j);
+ }
}
}
@@ -102,23 +93,23 @@ main (void)
if (page_boundary != NULL)
{
- for (n = 1; n <= 500; n++)
- {
- char *mem = page_boundary - n;
- memset (mem, 'X', n);
- ASSERT (MEMCHR (mem, 'U', n) == NULL);
-
- {
- size_t i;
-
- for (i = 0; i < n; i++)
- {
- mem[i] = 'U';
- ASSERT (MEMCHR (mem, 'U', 4000) == mem + i);
- mem[i] = 'X';
- }
- }
- }
+ for (n = 1; n <= 500; n++)
+ {
+ char *mem = page_boundary - n;
+ memset (mem, 'X', n);
+ ASSERT (MEMCHR (mem, 'U', n) == NULL);
+
+ {
+ size_t i;
+
+ for (i = 0; i < n; i++)
+ {
+ mem[i] = 'U';
+ ASSERT (MEMCHR (mem, 'U', 4000) == mem + i);
+ mem[i] = 'X';
+ }
+ }
+ }
}
}
diff --git a/lib/gl/tests/test-netdb.c b/lib/gl/tests/test-netdb.c
index cde9105fde..5f2bcd4e52 100644
--- a/lib/gl/tests/test-netdb.c
+++ b/lib/gl/tests/test-netdb.c
@@ -1,5 +1,5 @@
/* Test of <netdb.h> substitute.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
diff --git a/lib/gl/tests/test-read-file.c b/lib/gl/tests/test-read-file.c
index 392c4f7eaf..2509680bae 100644
--- a/lib/gl/tests/test-read-file.c
+++ b/lib/gl/tests/test-read-file.c
@@ -41,25 +41,25 @@ main (void)
if (!out)
{
- perror ("Could not read file");
- err = 1;
- }
+ perror ("Could not read file");
+ err = 1;
+ }
else
- {
- if (out[len] != '\0')
- {
- perror ("BAD: out[len] not zero");
- err = 1;
- }
+ {
+ if (out[len] != '\0')
+ {
+ perror ("BAD: out[len] not zero");
+ err = 1;
+ }
- /* Assume FILE1 is a regular file or a symlink to a regular file. */
- if (len != statbuf.st_size)
- {
- fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1);
- err = 1;
- }
- free (out);
- }
+ /* Assume FILE1 is a regular file or a symlink to a regular file. */
+ if (len != statbuf.st_size)
+ {
+ fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1);
+ err = 1;
+ }
+ free (out);
+ }
}
/* We can perform the test only if the file exists and is readable.
@@ -71,26 +71,26 @@ main (void)
if (!out)
{
- perror ("Could not read file");
- err = 1;
- }
+ perror ("Could not read file");
+ err = 1;
+ }
else
- {
- if (out[len] != '\0')
- {
- perror ("BAD: out[len] not zero");
- err = 1;
- }
+ {
+ if (out[len] != '\0')
+ {
+ perror ("BAD: out[len] not zero");
+ err = 1;
+ }
- /* /dev/null should always be empty. Ignore statbuf.st_size, since it
- is not a regular file. */
- if (len != 0)
- {
- fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE2);
- err = 1;
- }
- free (out);
- }
+ /* /dev/null should always be empty. Ignore statbuf.st_size, since it
+ is not a regular file. */
+ if (len != 0)
+ {
+ fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE2);
+ err = 1;
+ }
+ free (out);
+ }
}
return err;
diff --git a/lib/gl/tests/test-snprintf.c b/lib/gl/tests/test-snprintf.c
index 790c999649..62a411bf91 100644
--- a/lib/gl/tests/test-snprintf.c
+++ b/lib/gl/tests/test-snprintf.c
@@ -1,5 +1,5 @@
/* Test of snprintf() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
@@ -20,20 +20,12 @@
#include <stdio.h>
-#include <stdlib.h>
+#include "signature.h"
+SIGNATURE_CHECK (snprintf, int, (char *, size_t, char const *, ...));
+
#include <string.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main (int argc, char *argv[])
@@ -47,25 +39,25 @@ main (int argc, char *argv[])
memcpy (buf, "DEADBEEF", 8);
retval = snprintf (buf, size, "%d", 12345);
if (size < 6)
- {
+ {
#if CHECK_SNPRINTF_POSIX
- ASSERT (retval < 0 || retval >= size);
+ ASSERT (retval < 0 || retval >= size);
#endif
- if (size > 0)
- {
- ASSERT (memcmp (buf, "12345", size - 1) == 0);
- ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size);
- }
+ if (size > 0)
+ {
+ ASSERT (memcmp (buf, "12345", size - 1) == 0);
+ ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size);
+ }
#if !CHECK_SNPRINTF_POSIX
- if (size > 0)
+ if (size > 0)
#endif
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
- }
+ ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+ }
else
- {
- ASSERT (retval == 5);
- ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
- }
+ {
+ ASSERT (retval == 5);
+ ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
+ }
}
return 0;
diff --git a/lib/gl/tests/test-stdbool.c b/lib/gl/tests/test-stdbool.c
index 30d53217a5..560e0e534d 100644
--- a/lib/gl/tests/test-stdbool.c
+++ b/lib/gl/tests/test-stdbool.c
@@ -1,5 +1,5 @@
/* Test of <stdbool.h> substitute.
- Copyright (C) 2002-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002-2007, 2009-2010 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
diff --git a/lib/gl/tests/test-stddef.c b/lib/gl/tests/test-stddef.c
index c0a7515ecc..d047e57b65 100644
--- a/lib/gl/tests/test-stddef.c
+++ b/lib/gl/tests/test-stddef.c
@@ -1,5 +1,5 @@
/* Test of <stddef.h> substitute.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 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
diff --git a/lib/gl/tests/test-stdint.c b/lib/gl/tests/test-stdint.c
index 4e9b3621ee..9cec2e2f80 100644
--- a/lib/gl/tests/test-stdint.c
+++ b/lib/gl/tests/test-stdint.c
@@ -1,5 +1,5 @@
/* Test of <stdint.h> substitute.
- Copyright (C) 2006-2009 Free Software Foundation, Inc.
+ Copyright (C) 2006-2010 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
diff --git a/lib/gl/tests/test-stdio.c b/lib/gl/tests/test-stdio.c
index 3f2f0677f0..87100576f0 100644
--- a/lib/gl/tests/test-stdio.c
+++ b/lib/gl/tests/test-stdio.c
@@ -1,5 +1,5 @@
/* Test of <stdio.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2010 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
@@ -29,6 +29,13 @@ int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
per POSIX 2008. */
verify (sizeof NULL == sizeof (void *));
+/* Check that the types are all defined. */
+fpos_t t1;
+off_t t2;
+size_t t3;
+ssize_t t4;
+va_list t5;
+
int
main (void)
{
diff --git a/lib/gl/tests/test-stdlib.c b/lib/gl/tests/test-stdlib.c
index fad5cf450e..4bd8715f3d 100644
--- a/lib/gl/tests/test-stdlib.c
+++ b/lib/gl/tests/test-stdlib.c
@@ -1,5 +1,5 @@
/* Test of <stdlib.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-string.c b/lib/gl/tests/test-string.c
index 69df747eb6..019a8174ac 100644
--- a/lib/gl/tests/test-string.c
+++ b/lib/gl/tests/test-string.c
@@ -1,5 +1,5 @@
/* Test of <string.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-strings.c b/lib/gl/tests/test-strings.c
index 81e7362fb4..caba95cd2a 100644
--- a/lib/gl/tests/test-strings.c
+++ b/lib/gl/tests/test-strings.c
@@ -1,5 +1,5 @@
/* Test of <strings.h> substitute.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-strverscmp.c b/lib/gl/tests/test-strverscmp.c
index a98695baa0..d7348150e1 100644
--- a/lib/gl/tests/test-strverscmp.c
+++ b/lib/gl/tests/test-strverscmp.c
@@ -1,5 +1,5 @@
/* Test of strverscmp() function.
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 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
@@ -21,20 +21,10 @@
#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "signature.h"
+SIGNATURE_CHECK (strverscmp, int, (const char *, const char *));
+
+#include "macros.h"
int
main (void)
diff --git a/lib/gl/tests/test-sys_socket.c b/lib/gl/tests/test-sys_socket.c
index 606708dc1a..badf308b7a 100644
--- a/lib/gl/tests/test-sys_socket.c
+++ b/lib/gl/tests/test-sys_socket.c
@@ -1,5 +1,5 @@
/* Test of <sys/socket.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-sys_stat.c b/lib/gl/tests/test-sys_stat.c
index 4a85c9f08b..5f1aacd1cc 100644
--- a/lib/gl/tests/test-sys_stat.c
+++ b/lib/gl/tests/test-sys_stat.c
@@ -1,5 +1,5 @@
/* Test of <sys/stat.h> substitute.
- Copyright (C) 2007-2009 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
diff --git a/lib/gl/tests/test-time.c b/lib/gl/tests/test-time.c
index 4afa3b3988..8e250bd2d5 100644
--- a/lib/gl/tests/test-time.c
+++ b/lib/gl/tests/test-time.c
@@ -1,5 +1,5 @@
/* Test of <time.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-unistd.c b/lib/gl/tests/test-unistd.c
index dd907f4ebe..ec02eeefca 100644
--- a/lib/gl/tests/test-unistd.c
+++ b/lib/gl/tests/test-unistd.c
@@ -1,5 +1,5 @@
/* Test of <unistd.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 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
diff --git a/lib/gl/tests/test-vasnprintf.c b/lib/gl/tests/test-vasnprintf.c
index 2f3f8900d7..e2831420b4 100644
--- a/lib/gl/tests/test-vasnprintf.c
+++ b/lib/gl/tests/test-vasnprintf.c
@@ -1,5 +1,5 @@
/* Test of vasnprintf() and asnprintf() functions.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
@@ -21,21 +21,10 @@
#include "vasnprintf.h"
#include <stdarg.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static char *
my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
@@ -77,10 +66,10 @@ test_vasnprintf ()
ASSERT (strcmp (result, "12345") == 0);
ASSERT (length == 5);
if (size < 6)
- ASSERT (result != buf);
+ ASSERT (result != buf);
ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
if (result != buf)
- free (result);
+ free (result);
}
}
@@ -112,10 +101,10 @@ test_asnprintf ()
ASSERT (strcmp (result, "12345") == 0);
ASSERT (length == 5);
if (size < 6)
- ASSERT (result != buf);
+ ASSERT (result != buf);
ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
if (result != buf)
- free (result);
+ free (result);
}
}
diff --git a/lib/gl/tests/test-vasprintf.c b/lib/gl/tests/test-vasprintf.c
index 7c4a728b05..e5dc3cd3d3 100644
--- a/lib/gl/tests/test-vasprintf.c
+++ b/lib/gl/tests/test-vasprintf.c
@@ -1,5 +1,5 @@
/* Test of vasprintf() and asprintf() functions.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
@@ -20,21 +20,15 @@
#include <stdio.h>
+#include "signature.h"
+SIGNATURE_CHECK (asprintf, int, (char **, char const *, ...));
+SIGNATURE_CHECK (vasprintf, int, (char **, char const *, va_list));
+
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
my_asprintf (char **result, const char *format, ...)
diff --git a/lib/gl/tests/test-vsnprintf.c b/lib/gl/tests/test-vsnprintf.c
index 9c1be8d115..1bfa5540f7 100644
--- a/lib/gl/tests/test-vsnprintf.c
+++ b/lib/gl/tests/test-vsnprintf.c
@@ -1,5 +1,5 @@
/* Test of vsnprintf() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
@@ -20,21 +20,13 @@
#include <stdio.h>
+#include "signature.h"
+SIGNATURE_CHECK (vsnprintf, int, (char *, size_t, char const *, va_list));
+
#include <stdarg.h>
-#include <stdlib.h>
#include <string.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
my_snprintf (char *buf, int size, const char *format, ...)
@@ -60,25 +52,25 @@ main (int argc, char *argv[])
memcpy (buf, "DEADBEEF", 8);
retval = my_snprintf (buf, size, "%d", 12345);
if (size < 6)
- {
+ {
#if CHECK_VSNPRINTF_POSIX
- ASSERT (retval < 0 || retval >= size);
+ ASSERT (retval < 0 || retval >= size);
#endif
- if (size > 0)
- {
- ASSERT (memcmp (buf, "12345", size - 1) == 0);
- ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size);
- }
+ if (size > 0)
+ {
+ ASSERT (memcmp (buf, "12345", size - 1) == 0);
+ ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size);
+ }
#if !CHECK_VSNPRINTF_POSIX
- if (size > 0)
+ if (size > 0)
#endif
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
- }
+ ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+ }
else
- {
- ASSERT (retval == 5);
- ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
- }
+ {
+ ASSERT (retval == 5);
+ ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
+ }
}
return 0;
diff --git a/lib/gl/tests/test-wchar.c b/lib/gl/tests/test-wchar.c
index 2e60bb86db..2a03d6b669 100644
--- a/lib/gl/tests/test-wchar.c
+++ b/lib/gl/tests/test-wchar.c
@@ -1,5 +1,5 @@
/* Test of <wchar.h> substitute.
- Copyright (C) 2007-2009 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 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
diff --git a/lib/gl/tests/verify.h b/lib/gl/tests/verify.h
index fac53f6fc4..bcd3f5a09d 100644
--- a/lib/gl/tests/verify.h
+++ b/lib/gl/tests/verify.h
@@ -1,6 +1,6 @@
/* Compile-time assert-like macros.
- Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2010 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
@@ -110,8 +110,8 @@
#if 4 <= __GNUC__
# define verify(R) \
- extern int (* verify_function__ (void)) \
- [__builtin_constant_p (R) && (R) ? 1 : -1]
+ extern int (* verify_function__ (void)) \
+ [__builtin_constant_p (R) && (R) ? 1 : -1]
#endif
* In C++, any struct definition inside sizeof is invalid.
diff --git a/lib/gl/tests/zerosize-ptr.h b/lib/gl/tests/zerosize-ptr.h
index a38a2cf494..cfab200871 100644
--- a/lib/gl/tests/zerosize-ptr.h
+++ b/lib/gl/tests/zerosize-ptr.h
@@ -1,5 +1,5 @@
/* Return a pointer to a zero-size object in memory.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 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
@@ -57,11 +57,11 @@ zerosize_ptr (void)
{
int pagesize = getpagesize ();
char *two_pages =
- (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
- flags, fd, 0);
+ (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+ flags, fd, 0);
if (two_pages != (char *)(-1)
- && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
- return two_pages + pagesize;
+ && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+ return two_pages + pagesize;
}
#endif
return NULL;
diff --git a/lib/gl/time.in.h b/lib/gl/time.in.h
index 6b218e8f11..ed8f51b9de 100644
--- a/lib/gl/time.in.h
+++ b/lib/gl/time.in.h
@@ -1,6 +1,6 @@
/* A more-standard <time.h>.
- Copyright (C) 2007-2009 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
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
@@ -40,6 +40,8 @@
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
# ifdef __cplusplus
extern "C" {
# endif
@@ -66,13 +68,14 @@ struct timespec
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
# if @REPLACE_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
/* Return the 'time_t' representation of TP and normalize TP. */
# if @REPLACE_MKTIME@
# define mktime rpl_mktime
-extern time_t mktime (struct tm *__tp);
+extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
# endif
/* 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
# undef gmtime_r
# define gmtime_r rpl_gmtime_r
-struct tm *localtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
-struct tm *gmtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
+extern struct tm *localtime_r (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2));
+extern struct tm *gmtime_r (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2));
# endif
/* 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@
# undef strptime
# define strptime rpl_strptime
-char *strptime (char const *restrict __buf, char const *restrict __format,
- struct tm *restrict __tm);
+extern char *strptime (char const *restrict __buf,
+ char const *restrict __format,
+ struct tm *restrict __tm)
+ _GL_ARG_NONNULL ((1, 2, 3));
# endif
/* Convert TM to a time_t value, assuming UTC. */
# if @REPLACE_TIMEGM@
# undef timegm
# define timegm rpl_timegm
-time_t timegm (struct tm *__tm);
+extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
# endif
/* Encourage applications to avoid unsafe functions that can overrun
diff --git a/lib/gl/time_r.c b/lib/gl/time_r.c
index 7317195e30..e5f57a917a 100644
--- a/lib/gl/time_r.c
+++ b/lib/gl/time_r.c
@@ -1,6 +1,6 @@
/* Reentrant time functions like localtime_r.
- Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/unistd.in.h b/lib/gl/unistd.in.h
index 49883e7e23..b618bc2c9c 100644
--- a/lib/gl/unistd.in.h
+++ b/lib/gl/unistd.in.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around <unistd.h>.
- Copyright (C) 2003-2009 Free Software Foundation, Inc.
+ Copyright (C) 2003-2010 Free Software Foundation, Inc.
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
@@ -33,23 +33,43 @@
#include <stddef.h>
/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
-#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
+/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
+ || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
+ && ! defined __GLIBC__
# include <stdio.h>
#endif
+/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+# include <fcntl.h>
+#endif
+
/* mingw fails to declare _exit in <unistd.h>. */
/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
-#include <stdlib.h>
+/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#ifndef __GLIBC__
+# include <stdlib.h>
+#endif
-#if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
- || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
- || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@))
+/* mingw declares getcwd in <io.h>, not in <unistd.h>. */
+#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
+ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# include <io.h>
+#endif
+
+#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
+ || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
/* Get ssize_t. */
# include <sys/types.h>
#endif
-/* Get getopt(), optarg, optind, opterr, optopt. */
-#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
+/* Get getopt(), optarg, optind, opterr, optopt.
+ But avoid namespace pollution on glibc systems. */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
# include <getopt.h>
#endif
@@ -59,42 +79,44 @@
# include <winsock2.h>
# if !defined _GL_SYS_SOCKET_H
# undef socket
-# define socket socket_used_without_including_sys_socket_h
+# define socket socket_used_without_including_sys_socket_h
# undef connect
-# define connect connect_used_without_including_sys_socket_h
+# define connect connect_used_without_including_sys_socket_h
# undef accept
-# define accept accept_used_without_including_sys_socket_h
+# define accept accept_used_without_including_sys_socket_h
# undef bind
-# define bind bind_used_without_including_sys_socket_h
+# define bind bind_used_without_including_sys_socket_h
# undef getpeername
-# define getpeername getpeername_used_without_including_sys_socket_h
+# define getpeername getpeername_used_without_including_sys_socket_h
# undef getsockname
-# define getsockname getsockname_used_without_including_sys_socket_h
+# define getsockname getsockname_used_without_including_sys_socket_h
# undef getsockopt
-# define getsockopt getsockopt_used_without_including_sys_socket_h
+# define getsockopt getsockopt_used_without_including_sys_socket_h
# undef listen
-# define listen listen_used_without_including_sys_socket_h
+# define listen listen_used_without_including_sys_socket_h
# undef recv
-# define recv recv_used_without_including_sys_socket_h
+# define recv recv_used_without_including_sys_socket_h
# undef send
-# define send send_used_without_including_sys_socket_h
+# define send send_used_without_including_sys_socket_h
# undef recvfrom
-# define recvfrom recvfrom_used_without_including_sys_socket_h
+# define recvfrom recvfrom_used_without_including_sys_socket_h
# undef sendto
-# define sendto sendto_used_without_including_sys_socket_h
+# define sendto sendto_used_without_including_sys_socket_h
# undef setsockopt
-# define setsockopt setsockopt_used_without_including_sys_socket_h
+# define setsockopt setsockopt_used_without_including_sys_socket_h
# undef shutdown
-# define shutdown shutdown_used_without_including_sys_socket_h
+# define shutdown shutdown_used_without_including_sys_socket_h
# endif
# if !defined _GL_SYS_SELECT_H
# undef select
-# define select select_used_without_including_sys_select_h
+# define select select_used_without_including_sys_select_h
# endif
# endif
#endif
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
/* OS/2 EMX lacks these macros. */
@@ -135,15 +157,16 @@ extern "C" {
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<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
#elif defined GNULIB_POSIXCHECK
# undef chown
-# define chown(f,u,g) \
- (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
- "doesn't treat a uid or gid of -1 on some systems - " \
- "use gnulib module chown for portability"), \
- chown (f, u, g))
+# if HAVE_RAW_DECL_CHOWN
+_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
+ "doesn't treat a uid or gid of -1 on some systems - "
+ "use gnulib module chown for portability");
+# endif
#endif
@@ -159,10 +182,9 @@ extern int close (int);
# define close close_used_without_requesting_gnulib_module_close
#elif defined GNULIB_POSIXCHECK
# undef close
-# define close(f) \
- (GL_LINK_WARNING ("close does not portably work on sockets - " \
- "use gnulib module close for portability"), \
- close (f))
+/* Assume close is always declared. */
+_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
+ "use gnulib module close for portability");
#endif
@@ -186,10 +208,10 @@ extern int dup2 (int oldfd, int newfd);
# endif
#elif defined GNULIB_POSIXCHECK
# undef dup2
-# define dup2(o,n) \
- (GL_LINK_WARNING ("dup2 is unportable - " \
- "use gnulib module dup2 for portability"), \
- dup2 (o, n))
+# if HAVE_RAW_DECL_DUP2
+_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
+ "use gnulib module dup2 for portability");
+# endif
#endif
@@ -208,10 +230,10 @@ extern int dup2 (int oldfd, int newfd);
extern int dup3 (int oldfd, int newfd, int flags);
#elif defined GNULIB_POSIXCHECK
# undef dup3
-# define dup3(o,n,f) \
- (GL_LINK_WARNING ("dup3 is unportable - " \
- "use gnulib module dup3 for portability"), \
- dup3 (o, n, f))
+# if HAVE_RAW_DECL_DUP3
+_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
+ "use gnulib module dup3 for portability");
+# endif
#endif
@@ -227,11 +249,17 @@ extern char **environ;
# endif
# endif
#elif defined GNULIB_POSIXCHECK
-# undef environ
-# define environ \
- (GL_LINK_WARNING ("environ is unportable - " \
- "use gnulib module environ for portability"), \
- environ)
+# if HAVE_RAW_DECL_ENVIRON
+static inline char ***
+rpl_environ (void)
+{
+ return &environ;
+}
+_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
+ "use gnulib module environ for portability");
+# undef environ
+# define environ (*rpl_environ ())
+# endif
#endif
@@ -239,27 +267,28 @@ extern char **environ;
# if !@HAVE_EUIDACCESS@
/* Like access(), except that it uses the effective user id and group id of
the current process. */
-extern int euidaccess (const char *filename, int mode);
+extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef euidaccess
-# define euidaccess(f,m) \
- (GL_LINK_WARNING ("euidaccess is unportable - " \
- "use gnulib module euidaccess for portability"), \
- euidaccess (f, m))
+# if HAVE_RAW_DECL_EUIDACCESS
+_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
+ "use gnulib module euidaccess for portability");
+# endif
#endif
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef faccessat
-# define faccessat(d,n,m,f) \
- (GL_LINK_WARNING ("faccessat is not portable - " \
- "use gnulib module faccessat for portability"), \
- faccessat (d, n, m, f))
+# if HAVE_RAW_DECL_FACCESSAT
+_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
+ "use gnulib module faccessat for portability");
+# endif
#endif
@@ -273,7 +302,8 @@ int faccessat (int fd, char const *file, int mode, int flag);
extern int fchdir (int /*fd*/);
/* 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 int _gl_register_dup (int oldfd, int newfd);
extern const char *_gl_directory_name (int fd);
@@ -281,10 +311,10 @@ extern const char *_gl_directory_name (int fd);
# endif
#elif defined GNULIB_POSIXCHECK
# undef fchdir
-# define fchdir(f) \
- (GL_LINK_WARNING ("fchdir is unportable - " \
- "use gnulib module fchdir for portability"), \
- fchdir (f))
+# if HAVE_RAW_DECL_FCHDIR
+_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
+ "use gnulib module fchdir for portability");
+# endif
#endif
@@ -294,14 +324,15 @@ extern const char *_gl_directory_name (int fd);
# define fchownat rpl_fchownat
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef fchownat
-# define fchownat(d,n,o,g,f) \
- (GL_LINK_WARNING ("fchownat is not portable - " \
- "use gnulib module openat for portability"), \
- fchownat (d, n, o, g, f))
+# if HAVE_RAW_DECL_FCHOWNAT
+_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
+ "use gnulib module openat for portability");
+# endif
#endif
@@ -315,10 +346,10 @@ extern int fsync (int fd);
# endif
#elif defined GNULIB_POSIXCHECK
# undef fsync
-# define fsync(fd) \
- (GL_LINK_WARNING ("fsync is unportable - " \
- "use gnulib module fsync for portability"), \
- fsync (fd))
+# if HAVE_RAW_DECL_FSYNC
+_GL_WARN_ON_USE (fsync, "fsync is unportable - "
+ "use gnulib module fsync for portability");
+# endif
#endif
@@ -332,17 +363,14 @@ extern int ftruncate (int fd, off_t length);
# endif
#elif defined GNULIB_POSIXCHECK
# undef ftruncate
-# define ftruncate(f,l) \
- (GL_LINK_WARNING ("ftruncate is unportable - " \
- "use gnulib module ftruncate for portability"), \
- ftruncate (f, l))
+# if HAVE_RAW_DECL_FTRUNCATE
+_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
+ "use gnulib module ftruncate for portability");
+# endif
#endif
#if @GNULIB_GETCWD@
-/* Include the headers that might declare getcwd so that they will not
- cause confusion if included after this file. */
-# include <stdlib.h>
# if @REPLACE_GETCWD@
/* Get the name of the current working directory, and put it in SIZE bytes
of BUF.
@@ -359,10 +387,10 @@ extern char * getcwd (char *buf, size_t size);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getcwd
-# define getcwd(b,s) \
- (GL_LINK_WARNING ("getcwd is unportable - " \
- "use gnulib module getcwd for portability"), \
- getcwd (b, s))
+# if HAVE_RAW_DECL_GETCWD
+_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
+ "use gnulib module getcwd for portability");
+# endif
#endif
@@ -378,14 +406,14 @@ extern char * getcwd (char *buf, size_t size);
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. */
# if !@HAVE_GETDOMAINNAME@
-extern int getdomainname(char *name, size_t len);
+extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef getdomainname
-# define getdomainname(n,l) \
- (GL_LINK_WARNING ("getdomainname is unportable - " \
- "use gnulib module getdomainname for portability"), \
- getdomainname (n, l))
+# if HAVE_RAW_DECL_GETDOMAINNAME
+_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
+ "use gnulib module getdomainname for portability");
+# endif
#endif
@@ -397,10 +425,10 @@ extern int getdtablesize (void);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getdtablesize
-# define getdtablesize() \
- (GL_LINK_WARNING ("getdtablesize is unportable - " \
- "use gnulib module getdtablesize for portability"), \
- getdtablesize ())
+# if HAVE_RAW_DECL_GETDTABLESIZE
+_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
+ "use gnulib module getdtablesize for portability");
+# endif
#endif
@@ -419,10 +447,10 @@ int getgroups (int n, gid_t *groups);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getgroups
-# define getgroups(n,g) \
- (GL_LINK_WARNING ("getgroups is unportable - " \
- "use gnulib module getgroups for portability"), \
- getgroups (n, g))
+# if HAVE_RAW_DECL_GETGROUPS
+_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
+ "use gnulib module getgroups for portability");
+# endif
#endif
@@ -439,17 +467,40 @@ int getgroups (int n, gid_t *groups);
# define gethostname rpl_gethostname
# endif
# 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
#elif @UNISTD_H_HAVE_WINSOCK2_H@
# undef gethostname
# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
#elif defined GNULIB_POSIXCHECK
# undef gethostname
-# define gethostname(n,l) \
- (GL_LINK_WARNING ("gethostname is unportable - " \
- "use gnulib module gethostname for portability"), \
- gethostname (n, l))
+# if HAVE_RAW_DECL_GETHOSTNAME
+_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
+ "use gnulib module gethostname for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETLOGIN@
+/* Returns the user's login name, or NULL if it cannot be found. Upon error,
+ returns NULL with errno set.
+
+ See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+
+ Most programs don't need to use this function, because the information is
+ available through environment variables:
+ ${LOGNAME-$USER} on Unix platforms,
+ $USERNAME on native Windows platforms.
+ */
+# if !@HAVE_GETLOGIN@
+extern char *getlogin (void);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getlogin
+# if HAVE_RAW_DECL_GETLOGIN
+_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
+ "use gnulib module getlogin for portability");
+# endif
#endif
@@ -462,16 +513,21 @@ extern int gethostname(char *name, size_t len);
provided (this case is hopefully rare but is left open by the POSIX spec).
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+
+ Most programs don't need to use this function, because the information is
+ available through environment variables:
+ ${LOGNAME-$USER} on Unix platforms,
+ $USERNAME on native Windows platforms.
*/
# 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
#elif defined GNULIB_POSIXCHECK
# undef getlogin_r
-# define getlogin_r(n,s) \
- (GL_LINK_WARNING ("getlogin_r is unportable - " \
- "use gnulib module getlogin_r for portability"), \
- getlogin_r (n, s))
+# if HAVE_RAW_DECL_GETLOGIN_R
+_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
+ "use gnulib module getlogin_r for portability");
+# endif
#endif
@@ -526,10 +582,10 @@ extern int getpagesize (void);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getpagesize
-# define getpagesize() \
- (GL_LINK_WARNING ("getpagesize is unportable - " \
- "use gnulib module getpagesize for portability"), \
- getpagesize ())
+# if HAVE_RAW_DECL_GETPAGESIZE
+_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
+ "use gnulib module getpagesize for portability");
+# endif
#endif
@@ -546,20 +602,20 @@ extern void endusershell (void);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getusershell
-# define getusershell() \
- (GL_LINK_WARNING ("getusershell is unportable - " \
- "use gnulib module getusershell for portability"), \
- getusershell ())
+# if HAVE_RAW_DECL_GETUSERSHELL
+_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
+ "use gnulib module getusershell for portability");
+# endif
# undef setusershell
-# define setusershell() \
- (GL_LINK_WARNING ("setusershell is unportable - " \
- "use gnulib module getusershell for portability"), \
- setusershell ())
+# if HAVE_RAW_DECL_SETUSERSHELL
+_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
+ "use gnulib module getusershell for portability");
+# endif
# undef endusershell
-# define endusershell() \
- (GL_LINK_WARNING ("endusershell is unportable - " \
- "use gnulib module getusershell for portability"), \
- endusershell ())
+# if HAVE_RAW_DECL_ENDUSERSHELL
+_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
+ "use gnulib module getusershell for portability");
+# endif
#endif
@@ -574,14 +630,15 @@ extern void endusershell (void);
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<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
#elif defined GNULIB_POSIXCHECK
# undef lchown
-# define lchown(f,u,g) \
- (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
- "systems - use gnulib module lchown for portability"), \
- lchown (f, u, g))
+# if HAVE_RAW_DECL_LCHOWN
+_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
+ "use gnulib module lchown for portability");
+# endif
#endif
@@ -594,14 +651,15 @@ extern int lchown (char const *file, uid_t owner, gid_t group);
See POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/link.html>. */
# 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
#elif defined GNULIB_POSIXCHECK
# undef link
-# define link(path1,path2) \
- (GL_LINK_WARNING ("link is unportable - " \
- "use gnulib module link for portability"), \
- link (path1, path2))
+# if HAVE_RAW_DECL_LINK
+_GL_WARN_ON_USE (link, "link is unportable - "
+ "use gnulib module link for portability");
+# endif
#endif
#if @GNULIB_LINKAT@
@@ -614,14 +672,15 @@ extern int link (const char *path1, const char *path2);
Return 0 if successful, otherwise -1 and errno set. */
# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
- int flag);
+ int flag)
+ _GL_ARG_NONNULL ((2, 4));
# endif
#elif defined GNULIB_POSIXCHECK
# undef linkat
-# define link(f1,path1,f2,path2,f) \
- (GL_LINK_WARNING ("linkat is unportable - " \
- "use gnulib module linkat for portability"), \
- linkat (f1, path1, f2, path2,f))
+# if HAVE_RAW_DECL_LINKAT
+_GL_WARN_ON_USE (linkat, "linkat is unportable - "
+ "use gnulib module linkat for portability");
+# endif
#endif
#if @GNULIB_LSEEK@
@@ -635,10 +694,10 @@ extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
# endif
#elif defined GNULIB_POSIXCHECK
# undef lseek
-# define lseek(f,o,w) \
- (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
- "systems - use gnulib module lseek for portability"), \
- lseek (f, o, w))
+# if HAVE_RAW_DECL_LSEEK
+_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
+ "systems - use gnulib module lseek for portability");
+# endif
#endif
@@ -654,13 +713,34 @@ extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
# if @HAVE_PIPE2@
# define pipe2 rpl_pipe2
# 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
# undef pipe2
-# define pipe2(f,o) \
- (GL_LINK_WARNING ("pipe2 is unportable - " \
- "use gnulib module pipe2 for portability"), \
- pipe2 (f, o))
+# if HAVE_RAW_DECL_PIPE2
+_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
+ "use gnulib module pipe2 for portability");
+# 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
+# if HAVE_RAW_DECL_PREAD
+_GL_WARN_ON_USE (pread, "pread is unportable - "
+ "use gnulib module pread for portability");
+# endif
#endif
@@ -674,27 +754,29 @@ extern int pipe2 (int fd[2], int flags);
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/readlink.html>. */
# 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
#elif defined GNULIB_POSIXCHECK
# undef readlink
-# define readlink(f,b,s) \
- (GL_LINK_WARNING ("readlink is unportable - " \
- "use gnulib module readlink for portability"), \
- readlink (f, b, s))
+# if HAVE_RAW_DECL_READLINK
+_GL_WARN_ON_USE (readlink, "readlink is unportable - "
+ "use gnulib module readlink for portability");
+# endif
#endif
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef readlinkat
-# define readlinkat(d,n,b,l) \
- (GL_LINK_WARNING ("readlinkat is not portable - " \
- "use gnulib module symlinkat for portability"), \
- readlinkat (d, n, b, l))
+# if HAVE_RAW_DECL_READLINKAT
+_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
+ "use gnulib module symlinkat for portability");
+# endif
#endif
@@ -702,31 +784,35 @@ ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
# if @REPLACE_RMDIR@
# define rmdir rpl_rmdir
/* Remove the directory DIR. */
-extern int rmdir (char const *name);
+extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef rmdir
-# define rmdir(n) \
- (GL_LINK_WARNING ("rmdir is unportable - " \
- "use gnulib module rmdir for portability"), \
- rmdir (n))
+# if HAVE_RAW_DECL_RMDIR
+_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
+ "use gnulib module rmdir for portability");
+# endif
#endif
#if @GNULIB_SLEEP@
+# if @REPLACE_SLEEP@
+# undef sleep
+# define sleep rpl_sleep
+# endif
/* Pause the execution of the current thread for N seconds.
Returns the number of seconds left to sleep.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/sleep.html>. */
-# if !@HAVE_SLEEP@
+# if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
extern unsigned int sleep (unsigned int n);
# endif
#elif defined GNULIB_POSIXCHECK
# undef sleep
-# define sleep(n) \
- (GL_LINK_WARNING ("sleep is unportable - " \
- "use gnulib module sleep for portability"), \
- sleep (n))
+# if HAVE_RAW_DECL_SLEEP
+_GL_WARN_ON_USE (sleep, "sleep is unportable - "
+ "use gnulib module sleep for portability");
+# endif
#endif
@@ -736,27 +822,29 @@ extern unsigned int sleep (unsigned int n);
# define symlink rpl_symlink
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef symlink
-# define symlink(c,n) \
- (GL_LINK_WARNING ("symlink is not portable - " \
- "use gnulib module symlink for portability"), \
- symlink (c, n))
+# if HAVE_RAW_DECL_SYMLINK
+_GL_WARN_ON_USE (symlink, "symlink is not portable - "
+ "use gnulib module symlink for portability");
+# endif
#endif
#if @GNULIB_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
#elif defined GNULIB_POSIXCHECK
# undef symlinkat
-# define symlinkat(c,d,n) \
- (GL_LINK_WARNING ("symlinkat is not portable - " \
- "use gnulib module symlinkat for portability"), \
- symlinkat (c, d, n))
+# if HAVE_RAW_DECL_SYMLINKAT
+_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
+ "use gnulib module symlinkat for portability");
+# endif
#endif
@@ -764,14 +852,14 @@ int symlinkat (char const *contents, int fd, char const *file);
# if @REPLACE_UNLINK@
# undef unlink
# define unlink rpl_unlink
-extern int unlink (char const *file);
+extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
# endif
#elif defined GNULIB_POSIXCHECK
# undef unlink
-# define unlink(n) \
- (GL_LINK_WARNING ("unlink is not portable - " \
- "use gnulib module unlink for portability"), \
- unlink (n))
+# if HAVE_RAW_DECL_UNLINK
+_GL_WARN_ON_USE (unlink, "unlink is not portable - "
+ "use gnulib module unlink for portability");
+# endif
#endif
@@ -781,14 +869,35 @@ extern int unlink (char const *file);
# define unlinkat rpl_unlinkat
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef unlinkat
-# define unlinkat(d,n,f) \
- (GL_LINK_WARNING ("unlinkat is not portable - " \
- "use gnulib module openat for portability"), \
- unlinkat (d, n, f))
+# if HAVE_RAW_DECL_UNLINKAT
+_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_USLEEP@
+# if @REPLACE_USLEEP@
+# undef usleep
+# define usleep rpl_usleep
+# endif
+# if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
+/* Pause the execution of the current thread for N microseconds.
+ Returns 0 on completion, or -1 on range error.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/sleep.html>. */
+extern int usleep (useconds_t n);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef usleep
+# if HAVE_RAW_DECL_USLEEP
+_GL_WARN_ON_USE (usleep, "usleep is unportable - "
+ "use gnulib module usleep for portability");
+# endif
#endif
@@ -798,7 +907,8 @@ extern int unlinkat (int fd, char const *file, int flag);
<http://www.opengroup.org/susv3xsh/write.html>. */
# undef 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
diff --git a/lib/gl/vasnprintf.c b/lib/gl/vasnprintf.c
index 6f1b4660b2..ae238a87a6 100644
--- a/lib/gl/vasnprintf.c
+++ b/lib/gl/vasnprintf.c
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2009 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2010 Free Software Foundation, Inc.
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
@@ -67,13 +67,13 @@
# endif
#endif
-#include <locale.h> /* localeconv() */
-#include <stdio.h> /* snprintf(), sprintf() */
-#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
-#include <string.h> /* memcpy(), strlen() */
-#include <errno.h> /* errno */
-#include <limits.h> /* CHAR_BIT */
-#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
+#include <locale.h> /* localeconv() */
+#include <stdio.h> /* snprintf(), sprintf() */
+#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
+#include <string.h> /* memcpy(), strlen() */
+#include <errno.h> /* errno */
+#include <limits.h> /* CHAR_BIT */
+#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
#if HAVE_NL_LANGINFO
# include <langinfo.h>
#endif
@@ -261,10 +261,10 @@ decimal_point_char (void)
{
const char *point;
/* Determine it in a multithread-safe way. We know nl_langinfo is
- multithread-safe on glibc systems, but is not required to be multithread-
- safe by POSIX. sprintf(), however, is multithread-safe. localeconv()
- is rarely multithread-safe. */
-# if HAVE_NL_LANGINFO && __GLIBC__
+ multithread-safe on glibc systems and MacOS X systems, but is not required
+ to be multithread-safe by POSIX. sprintf(), however, is multithread-safe.
+ localeconv() is rarely multithread-safe. */
+# if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__))
point = nl_langinfo (RADIXCHAR);
# elif 1
char pointbuf[5];
@@ -364,26 +364,26 @@ multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
dlen = len1 + len2;
dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t));
if (dp == NULL)
- return NULL;
+ return NULL;
for (k = len2; k > 0; )
- dp[--k] = 0;
+ dp[--k] = 0;
for (i = 0; i < len1; i++)
- {
- mp_limb_t digit1 = p1[i];
- mp_twolimb_t carry = 0;
- for (j = 0; j < len2; j++)
- {
- mp_limb_t digit2 = p2[j];
- carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
- carry += dp[i + j];
- dp[i + j] = (mp_limb_t) carry;
- carry = carry >> GMP_LIMB_BITS;
- }
- dp[i + len2] = (mp_limb_t) carry;
- }
+ {
+ mp_limb_t digit1 = p1[i];
+ mp_twolimb_t carry = 0;
+ for (j = 0; j < len2; j++)
+ {
+ mp_limb_t digit2 = p2[j];
+ carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+ carry += dp[i + j];
+ dp[i + j] = (mp_limb_t) carry;
+ carry = carry >> GMP_LIMB_BITS;
+ }
+ dp[i + len2] = (mp_limb_t) carry;
+ }
/* Normalise. */
while (dlen > 0 && dp[dlen - 1] == 0)
- dlen--;
+ dlen--;
dest->nlimbs = dlen;
dest->limbs = dp;
}
@@ -477,12 +477,12 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
for (;;)
{
if (b_len == 0)
- /* Division by zero. */
- abort ();
+ /* Division by zero. */
+ abort ();
if (b_ptr[b_len - 1] == 0)
- b_len--;
+ b_len--;
else
- break;
+ break;
}
/* Here m = a_len >= 0 and n = b_len > 0. */
@@ -499,261 +499,261 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
else if (b_len == 1)
{
/* n=1: single precision division.
- beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */
+ beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */
r_ptr = roomptr;
q_ptr = roomptr + 1;
{
- mp_limb_t den = b_ptr[0];
- mp_limb_t remainder = 0;
- const mp_limb_t *sourceptr = a_ptr + a_len;
- mp_limb_t *destptr = q_ptr + a_len;
- size_t count;
- for (count = a_len; count > 0; count--)
- {
- mp_twolimb_t num =
- ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
- *--destptr = num / den;
- remainder = num % den;
- }
- /* Normalise and store r. */
- if (remainder > 0)
- {
- r_ptr[0] = remainder;
- r_len = 1;
- }
- else
- r_len = 0;
- /* Normalise q. */
- q_len = a_len;
- if (q_ptr[q_len - 1] == 0)
- q_len--;
+ mp_limb_t den = b_ptr[0];
+ mp_limb_t remainder = 0;
+ const mp_limb_t *sourceptr = a_ptr + a_len;
+ mp_limb_t *destptr = q_ptr + a_len;
+ size_t count;
+ for (count = a_len; count > 0; count--)
+ {
+ mp_twolimb_t num =
+ ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
+ *--destptr = num / den;
+ remainder = num % den;
+ }
+ /* Normalise and store r. */
+ if (remainder > 0)
+ {
+ r_ptr[0] = remainder;
+ r_len = 1;
+ }
+ else
+ r_len = 0;
+ /* Normalise q. */
+ q_len = a_len;
+ if (q_ptr[q_len - 1] == 0)
+ q_len--;
}
}
else
{
/* n>1: multiple precision division.
- beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==>
- beta^(m-n-1) <= a/b < beta^(m-n+1). */
+ beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==>
+ beta^(m-n-1) <= a/b < beta^(m-n+1). */
/* Determine s. */
size_t s;
{
- mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
- s = 31;
- if (msd >= 0x10000)
- {
- msd = msd >> 16;
- s -= 16;
- }
- if (msd >= 0x100)
- {
- msd = msd >> 8;
- s -= 8;
- }
- if (msd >= 0x10)
- {
- msd = msd >> 4;
- s -= 4;
- }
- if (msd >= 0x4)
- {
- msd = msd >> 2;
- s -= 2;
- }
- if (msd >= 0x2)
- {
- msd = msd >> 1;
- s -= 1;
- }
+ mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
+ s = 31;
+ if (msd >= 0x10000)
+ {
+ msd = msd >> 16;
+ s -= 16;
+ }
+ if (msd >= 0x100)
+ {
+ msd = msd >> 8;
+ s -= 8;
+ }
+ if (msd >= 0x10)
+ {
+ msd = msd >> 4;
+ s -= 4;
+ }
+ if (msd >= 0x4)
+ {
+ msd = msd >> 2;
+ s -= 2;
+ }
+ if (msd >= 0x2)
+ {
+ msd = msd >> 1;
+ s -= 1;
+ }
}
/* 0 <= s < GMP_LIMB_BITS.
- Copy b, shifting it left by s bits. */
+ Copy b, shifting it left by s bits. */
if (s > 0)
- {
- tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
- if (tmp_roomptr == NULL)
- {
- free (roomptr);
- return NULL;
- }
- {
- const mp_limb_t *sourceptr = b_ptr;
- mp_limb_t *destptr = tmp_roomptr;
- mp_twolimb_t accu = 0;
- size_t count;
- for (count = b_len; count > 0; count--)
- {
- accu += (mp_twolimb_t) *sourceptr++ << s;
- *destptr++ = (mp_limb_t) accu;
- accu = accu >> GMP_LIMB_BITS;
- }
- /* accu must be zero, since that was how s was determined. */
- if (accu != 0)
- abort ();
- }
- b_ptr = tmp_roomptr;
- }
+ {
+ tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
+ if (tmp_roomptr == NULL)
+ {
+ free (roomptr);
+ return NULL;
+ }
+ {
+ const mp_limb_t *sourceptr = b_ptr;
+ mp_limb_t *destptr = tmp_roomptr;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = b_len; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *sourceptr++ << s;
+ *destptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ /* accu must be zero, since that was how s was determined. */
+ if (accu != 0)
+ abort ();
+ }
+ b_ptr = tmp_roomptr;
+ }
/* Copy a, shifting it left by s bits, yields r.
- Memory layout:
- At the beginning: r = roomptr[0..a_len],
- at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */
+ Memory layout:
+ At the beginning: r = roomptr[0..a_len],
+ at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */
r_ptr = roomptr;
if (s == 0)
- {
- memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
- r_ptr[a_len] = 0;
- }
+ {
+ memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
+ r_ptr[a_len] = 0;
+ }
else
- {
- const mp_limb_t *sourceptr = a_ptr;
- mp_limb_t *destptr = r_ptr;
- mp_twolimb_t accu = 0;
- size_t count;
- for (count = a_len; count > 0; count--)
- {
- accu += (mp_twolimb_t) *sourceptr++ << s;
- *destptr++ = (mp_limb_t) accu;
- accu = accu >> GMP_LIMB_BITS;
- }
- *destptr++ = (mp_limb_t) accu;
- }
+ {
+ const mp_limb_t *sourceptr = a_ptr;
+ mp_limb_t *destptr = r_ptr;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = a_len; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *sourceptr++ << s;
+ *destptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ *destptr++ = (mp_limb_t) accu;
+ }
q_ptr = roomptr + b_len;
q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */
{
- size_t j = a_len - b_len; /* m-n */
- mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
- mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
- mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
- ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
- /* Division loop, traversed m-n+1 times.
- j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */
- for (;;)
- {
- mp_limb_t q_star;
- mp_limb_t c1;
- if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
- {
- /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */
- mp_twolimb_t num =
- ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
- | r_ptr[j + b_len - 1];
- q_star = num / b_msd;
- c1 = num % b_msd;
- }
- else
- {
- /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */
- q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
- /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
- <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
- <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
- {<= beta !}.
- If yes, jump directly to the subtraction loop.
- (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
- <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
- if (r_ptr[j + b_len] > b_msd
- || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
- /* r[j+n] >= b[n-1]+1 or
- r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
- carry. */
- goto subtract;
- }
- /* q_star = q*,
- c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */
- {
- mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
- ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
- mp_twolimb_t c3 = /* b[n-2] * q* */
- (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
- /* While c2 < c3, increase c2 and decrease c3.
- Consider c3-c2. While it is > 0, decrease it by
- b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2
- this can happen only twice. */
- if (c3 > c2)
- {
- q_star = q_star - 1; /* q* := q* - 1 */
- if (c3 - c2 > b_msdd)
- q_star = q_star - 1; /* q* := q* - 1 */
- }
- }
- if (q_star > 0)
- subtract:
- {
- /* Subtract r := r - b * q* * beta^j. */
- mp_limb_t cr;
- {
- const mp_limb_t *sourceptr = b_ptr;
- mp_limb_t *destptr = r_ptr + j;
- mp_twolimb_t carry = 0;
- size_t count;
- for (count = b_len; count > 0; count--)
- {
- /* Here 0 <= carry <= q*. */
- carry =
- carry
- + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
- + (mp_limb_t) ~(*destptr);
- /* Here 0 <= carry <= beta*q* + beta-1. */
- *destptr++ = ~(mp_limb_t) carry;
- carry = carry >> GMP_LIMB_BITS; /* <= q* */
- }
- cr = (mp_limb_t) carry;
- }
- /* Subtract cr from r_ptr[j + b_len], then forget about
- r_ptr[j + b_len]. */
- if (cr > r_ptr[j + b_len])
- {
- /* Subtraction gave a carry. */
- q_star = q_star - 1; /* q* := q* - 1 */
- /* Add b back. */
- {
- const mp_limb_t *sourceptr = b_ptr;
- mp_limb_t *destptr = r_ptr + j;
- mp_limb_t carry = 0;
- size_t count;
- for (count = b_len; count > 0; count--)
- {
- mp_limb_t source1 = *sourceptr++;
- mp_limb_t source2 = *destptr;
- *destptr++ = source1 + source2 + carry;
- carry =
- (carry
- ? source1 >= (mp_limb_t) ~source2
- : source1 > (mp_limb_t) ~source2);
- }
- }
- /* Forget about the carry and about r[j+n]. */
- }
- }
- /* q* is determined. Store it as q[j]. */
- q_ptr[j] = q_star;
- if (j == 0)
- break;
- j--;
- }
+ size_t j = a_len - b_len; /* m-n */
+ mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
+ mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
+ mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
+ ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
+ /* Division loop, traversed m-n+1 times.
+ j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */
+ for (;;)
+ {
+ mp_limb_t q_star;
+ mp_limb_t c1;
+ if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
+ {
+ /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */
+ mp_twolimb_t num =
+ ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
+ | r_ptr[j + b_len - 1];
+ q_star = num / b_msd;
+ c1 = num % b_msd;
+ }
+ else
+ {
+ /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */
+ q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
+ /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
+ <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
+ <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
+ {<= beta !}.
+ If yes, jump directly to the subtraction loop.
+ (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
+ <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
+ if (r_ptr[j + b_len] > b_msd
+ || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
+ /* r[j+n] >= b[n-1]+1 or
+ r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
+ carry. */
+ goto subtract;
+ }
+ /* q_star = q*,
+ c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */
+ {
+ mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
+ ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
+ mp_twolimb_t c3 = /* b[n-2] * q* */
+ (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
+ /* While c2 < c3, increase c2 and decrease c3.
+ Consider c3-c2. While it is > 0, decrease it by
+ b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2
+ this can happen only twice. */
+ if (c3 > c2)
+ {
+ q_star = q_star - 1; /* q* := q* - 1 */
+ if (c3 - c2 > b_msdd)
+ q_star = q_star - 1; /* q* := q* - 1 */
+ }
+ }
+ if (q_star > 0)
+ subtract:
+ {
+ /* Subtract r := r - b * q* * beta^j. */
+ mp_limb_t cr;
+ {
+ const mp_limb_t *sourceptr = b_ptr;
+ mp_limb_t *destptr = r_ptr + j;
+ mp_twolimb_t carry = 0;
+ size_t count;
+ for (count = b_len; count > 0; count--)
+ {
+ /* Here 0 <= carry <= q*. */
+ carry =
+ carry
+ + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
+ + (mp_limb_t) ~(*destptr);
+ /* Here 0 <= carry <= beta*q* + beta-1. */
+ *destptr++ = ~(mp_limb_t) carry;
+ carry = carry >> GMP_LIMB_BITS; /* <= q* */
+ }
+ cr = (mp_limb_t) carry;
+ }
+ /* Subtract cr from r_ptr[j + b_len], then forget about
+ r_ptr[j + b_len]. */
+ if (cr > r_ptr[j + b_len])
+ {
+ /* Subtraction gave a carry. */
+ q_star = q_star - 1; /* q* := q* - 1 */
+ /* Add b back. */
+ {
+ const mp_limb_t *sourceptr = b_ptr;
+ mp_limb_t *destptr = r_ptr + j;
+ mp_limb_t carry = 0;
+ size_t count;
+ for (count = b_len; count > 0; count--)
+ {
+ mp_limb_t source1 = *sourceptr++;
+ mp_limb_t source2 = *destptr;
+ *destptr++ = source1 + source2 + carry;
+ carry =
+ (carry
+ ? source1 >= (mp_limb_t) ~source2
+ : source1 > (mp_limb_t) ~source2);
+ }
+ }
+ /* Forget about the carry and about r[j+n]. */
+ }
+ }
+ /* q* is determined. Store it as q[j]. */
+ q_ptr[j] = q_star;
+ if (j == 0)
+ break;
+ j--;
+ }
}
r_len = b_len;
/* Normalise q. */
if (q_ptr[q_len - 1] == 0)
- q_len--;
+ q_len--;
# if 0 /* Not needed here, since we need r only to compare it with b/2, and
- b is shifted left by s bits. */
+ b is shifted left by s bits. */
/* Shift r right by s bits. */
if (s > 0)
- {
- mp_limb_t ptr = r_ptr + r_len;
- mp_twolimb_t accu = 0;
- size_t count;
- for (count = r_len; count > 0; count--)
- {
- accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
- accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
- *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
- }
- }
+ {
+ mp_limb_t ptr = r_ptr + r_len;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = r_len; count > 0; count--)
+ {
+ accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
+ accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
+ *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
+ }
+ }
# endif
/* Normalise r. */
while (r_len > 0 && r_ptr[r_len - 1] == 0)
- r_len--;
+ r_len--;
}
/* Compare r << 1 with b. */
if (r_len > b_len)
@@ -762,17 +762,17 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
size_t i;
for (i = b_len;;)
{
- mp_limb_t r_i =
- (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
- | (i < r_len ? r_ptr[i] << 1 : 0);
- mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
- if (r_i > b_i)
- goto increment_q;
- if (r_i < b_i)
- goto keep_q;
- if (i == 0)
- break;
- i--;
+ mp_limb_t r_i =
+ (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
+ | (i < r_len ? r_ptr[i] << 1 : 0);
+ mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
+ if (r_i > b_i)
+ goto increment_q;
+ if (r_i < b_i)
+ goto keep_q;
+ if (i == 0)
+ break;
+ i--;
}
}
if (q_len > 0 && ((q_ptr[0] & 1) != 0))
@@ -781,8 +781,8 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
{
size_t i;
for (i = 0; i < q_len; i++)
- if (++(q_ptr[i]) != 0)
- goto keep_q;
+ if (++(q_ptr[i]) != 0)
+ goto keep_q;
q_ptr[q_len++] = 1;
}
keep_q:
@@ -811,36 +811,36 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
{
char *d_ptr = c_ptr;
for (; extra_zeroes > 0; extra_zeroes--)
- *d_ptr++ = '0';
+ *d_ptr++ = '0';
while (a_len > 0)
- {
- /* Divide a by 10^9, in-place. */
- mp_limb_t remainder = 0;
- mp_limb_t *ptr = a_ptr + a_len;
- size_t count;
- for (count = a_len; count > 0; count--)
- {
- mp_twolimb_t num =
- ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
- *ptr = num / 1000000000;
- remainder = num % 1000000000;
- }
- /* Store the remainder as 9 decimal digits. */
- for (count = 9; count > 0; count--)
- {
- *d_ptr++ = '0' + (remainder % 10);
- remainder = remainder / 10;
- }
- /* Normalize a. */
- if (a_ptr[a_len - 1] == 0)
- a_len--;
- }
+ {
+ /* Divide a by 10^9, in-place. */
+ mp_limb_t remainder = 0;
+ mp_limb_t *ptr = a_ptr + a_len;
+ size_t count;
+ for (count = a_len; count > 0; count--)
+ {
+ mp_twolimb_t num =
+ ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
+ *ptr = num / 1000000000;
+ remainder = num % 1000000000;
+ }
+ /* Store the remainder as 9 decimal digits. */
+ for (count = 9; count > 0; count--)
+ {
+ *d_ptr++ = '0' + (remainder % 10);
+ remainder = remainder / 10;
+ }
+ /* Normalize a. */
+ if (a_ptr[a_len - 1] == 0)
+ a_len--;
+ }
/* Remove leading zeroes. */
while (d_ptr > c_ptr && d_ptr[-1] == '0')
- d_ptr--;
+ d_ptr--;
/* But keep at least one zero. */
if (d_ptr == c_ptr)
- *d_ptr++ = '0';
+ *d_ptr++ = '0';
/* Terminate the string. */
*d_ptr = '\0';
}
@@ -885,12 +885,12 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
hi = (int) y;
y -= hi;
if (!(y >= 0.0L && y < 1.0L))
- abort ();
+ abort ();
y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
lo = (int) y;
y -= lo;
if (!(y >= 0.0L && y < 1.0L))
- abort ();
+ abort ();
m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
}
# else
@@ -900,7 +900,7 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
d = (int) y;
y -= d;
if (!(y >= 0.0L && y < 1.0L))
- abort ();
+ abort ();
m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d;
}
# endif
@@ -912,12 +912,12 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
hi = (int) y;
y -= hi;
if (!(y >= 0.0L && y < 1.0L))
- abort ();
+ abort ();
y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
lo = (int) y;
y -= lo;
if (!(y >= 0.0L && y < 1.0L))
- abort ();
+ abort ();
m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
}
#if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
@@ -973,12 +973,12 @@ decode_double (double x, int *ep, mpn_t *mp)
hi = (int) y;
y -= hi;
if (!(y >= 0.0 && y < 1.0))
- abort ();
+ abort ();
y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
lo = (int) y;
y -= lo;
if (!(y >= 0.0 && y < 1.0))
- abort ();
+ abort ();
m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
}
# else
@@ -988,7 +988,7 @@ decode_double (double x, int *ep, mpn_t *mp)
d = (int) y;
y -= d;
if (!(y >= 0.0 && y < 1.0))
- abort ();
+ abort ();
m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d;
}
# endif
@@ -1000,12 +1000,12 @@ decode_double (double x, int *ep, mpn_t *mp)
hi = (int) y;
y -= hi;
if (!(y >= 0.0 && y < 1.0))
- abort ();
+ abort ();
y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
lo = (int) y;
y -= lo;
if (!(y >= 0.0 && y < 1.0))
- abort ();
+ abort ();
m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
}
if (!(y == 0.0))
@@ -1063,8 +1063,8 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
abs_n = (n >= 0 ? n : -n);
abs_s = (s >= 0 ? s : -s);
pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
- + abs_s / GMP_LIMB_BITS + 1)
- * sizeof (mp_limb_t));
+ + abs_s / GMP_LIMB_BITS + 1)
+ * sizeof (mp_limb_t));
if (pow5_ptr == NULL)
{
free (memory);
@@ -1077,26 +1077,26 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
if (abs_n > 0)
{
static mp_limb_t const small_pow5[13 + 1] =
- {
- 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
- 48828125, 244140625, 1220703125
- };
+ {
+ 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
+ 48828125, 244140625, 1220703125
+ };
unsigned int n13;
for (n13 = 0; n13 <= abs_n; n13 += 13)
- {
- mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
- size_t j;
- mp_twolimb_t carry = 0;
- for (j = 0; j < pow5_len; j++)
- {
- mp_limb_t digit2 = pow5_ptr[j];
- carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
- pow5_ptr[j] = (mp_limb_t) carry;
- carry = carry >> GMP_LIMB_BITS;
- }
- if (carry > 0)
- pow5_ptr[pow5_len++] = (mp_limb_t) carry;
- }
+ {
+ mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
+ size_t j;
+ mp_twolimb_t carry = 0;
+ for (j = 0; j < pow5_len; j++)
+ {
+ mp_limb_t digit2 = pow5_ptr[j];
+ carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+ pow5_ptr[j] = (mp_limb_t) carry;
+ carry = carry >> GMP_LIMB_BITS;
+ }
+ if (carry > 0)
+ pow5_ptr[pow5_len++] = (mp_limb_t) carry;
+ }
}
s_limbs = abs_s / GMP_LIMB_BITS;
s_bits = abs_s % GMP_LIMB_BITS;
@@ -1104,129 +1104,129 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
{
/* Multiply with 2^|s|. */
if (s_bits > 0)
- {
- mp_limb_t *ptr = pow5_ptr;
- mp_twolimb_t accu = 0;
- size_t count;
- for (count = pow5_len; count > 0; count--)
- {
- accu += (mp_twolimb_t) *ptr << s_bits;
- *ptr++ = (mp_limb_t) accu;
- accu = accu >> GMP_LIMB_BITS;
- }
- if (accu > 0)
- {
- *ptr = (mp_limb_t) accu;
- pow5_len++;
- }
- }
+ {
+ mp_limb_t *ptr = pow5_ptr;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = pow5_len; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *ptr << s_bits;
+ *ptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ if (accu > 0)
+ {
+ *ptr = (mp_limb_t) accu;
+ pow5_len++;
+ }
+ }
if (s_limbs > 0)
- {
- size_t count;
- for (count = pow5_len; count > 0;)
- {
- count--;
- pow5_ptr[s_limbs + count] = pow5_ptr[count];
- }
- for (count = s_limbs; count > 0;)
- {
- count--;
- pow5_ptr[count] = 0;
- }
- pow5_len += s_limbs;
- }
+ {
+ size_t count;
+ for (count = pow5_len; count > 0;)
+ {
+ count--;
+ pow5_ptr[s_limbs + count] = pow5_ptr[count];
+ }
+ for (count = s_limbs; count > 0;)
+ {
+ count--;
+ pow5_ptr[count] = 0;
+ }
+ pow5_len += s_limbs;
+ }
pow5.limbs = pow5_ptr;
pow5.nlimbs = pow5_len;
if (n >= 0)
- {
- /* Multiply m with pow5. No division needed. */
- z_memory = multiply (m, pow5, &z);
- }
+ {
+ /* Multiply m with pow5. No division needed. */
+ z_memory = multiply (m, pow5, &z);
+ }
else
- {
- /* Divide m by pow5 and round. */
- z_memory = divide (m, pow5, &z);
- }
+ {
+ /* Divide m by pow5 and round. */
+ z_memory = divide (m, pow5, &z);
+ }
}
else
{
pow5.limbs = pow5_ptr;
pow5.nlimbs = pow5_len;
if (n >= 0)
- {
- /* n >= 0, s < 0.
- Multiply m with pow5, then divide by 2^|s|. */
- mpn_t numerator;
- mpn_t denominator;
- void *tmp_memory;
- tmp_memory = multiply (m, pow5, &numerator);
- if (tmp_memory == NULL)
- {
- free (pow5_ptr);
- free (memory);
- return NULL;
- }
- /* Construct 2^|s|. */
- {
- mp_limb_t *ptr = pow5_ptr + pow5_len;
- size_t i;
- for (i = 0; i < s_limbs; i++)
- ptr[i] = 0;
- ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
- denominator.limbs = ptr;
- denominator.nlimbs = s_limbs + 1;
- }
- z_memory = divide (numerator, denominator, &z);
- free (tmp_memory);
- }
+ {
+ /* n >= 0, s < 0.
+ Multiply m with pow5, then divide by 2^|s|. */
+ mpn_t numerator;
+ mpn_t denominator;
+ void *tmp_memory;
+ tmp_memory = multiply (m, pow5, &numerator);
+ if (tmp_memory == NULL)
+ {
+ free (pow5_ptr);
+ free (memory);
+ return NULL;
+ }
+ /* Construct 2^|s|. */
+ {
+ mp_limb_t *ptr = pow5_ptr + pow5_len;
+ size_t i;
+ for (i = 0; i < s_limbs; i++)
+ ptr[i] = 0;
+ ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
+ denominator.limbs = ptr;
+ denominator.nlimbs = s_limbs + 1;
+ }
+ z_memory = divide (numerator, denominator, &z);
+ free (tmp_memory);
+ }
else
- {
- /* n < 0, s > 0.
- Multiply m with 2^s, then divide by pow5. */
- mpn_t numerator;
- mp_limb_t *num_ptr;
- num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
- * sizeof (mp_limb_t));
- if (num_ptr == NULL)
- {
- free (pow5_ptr);
- free (memory);
- return NULL;
- }
- {
- mp_limb_t *destptr = num_ptr;
- {
- size_t i;
- for (i = 0; i < s_limbs; i++)
- *destptr++ = 0;
- }
- if (s_bits > 0)
- {
- const mp_limb_t *sourceptr = m.limbs;
- mp_twolimb_t accu = 0;
- size_t count;
- for (count = m.nlimbs; count > 0; count--)
- {
- accu += (mp_twolimb_t) *sourceptr++ << s_bits;
- *destptr++ = (mp_limb_t) accu;
- accu = accu >> GMP_LIMB_BITS;
- }
- if (accu > 0)
- *destptr++ = (mp_limb_t) accu;
- }
- else
- {
- const mp_limb_t *sourceptr = m.limbs;
- size_t count;
- for (count = m.nlimbs; count > 0; count--)
- *destptr++ = *sourceptr++;
- }
- numerator.limbs = num_ptr;
- numerator.nlimbs = destptr - num_ptr;
- }
- z_memory = divide (numerator, pow5, &z);
- free (num_ptr);
- }
+ {
+ /* n < 0, s > 0.
+ Multiply m with 2^s, then divide by pow5. */
+ mpn_t numerator;
+ mp_limb_t *num_ptr;
+ num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
+ * sizeof (mp_limb_t));
+ if (num_ptr == NULL)
+ {
+ free (pow5_ptr);
+ free (memory);
+ return NULL;
+ }
+ {
+ mp_limb_t *destptr = num_ptr;
+ {
+ size_t i;
+ for (i = 0; i < s_limbs; i++)
+ *destptr++ = 0;
+ }
+ if (s_bits > 0)
+ {
+ const mp_limb_t *sourceptr = m.limbs;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = m.nlimbs; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *sourceptr++ << s_bits;
+ *destptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ if (accu > 0)
+ *destptr++ = (mp_limb_t) accu;
+ }
+ else
+ {
+ const mp_limb_t *sourceptr = m.limbs;
+ size_t count;
+ for (count = m.nlimbs; count > 0; count--)
+ *destptr++ = *sourceptr++;
+ }
+ numerator.limbs = num_ptr;
+ numerator.nlimbs = destptr - num_ptr;
+ }
+ z_memory = divide (numerator, pow5, &z);
+ free (num_ptr);
+ }
}
free (pow5_ptr);
free (memory);
@@ -1298,35 +1298,35 @@ floorlog10l (long double x)
if (y < 0.5L)
{
while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
- {
- y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
- exp -= GMP_LIMB_BITS;
- }
+ {
+ y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+ exp -= GMP_LIMB_BITS;
+ }
if (y < (1.0L / (1 << 16)))
- {
- y *= 1.0L * (1 << 16);
- exp -= 16;
- }
+ {
+ y *= 1.0L * (1 << 16);
+ exp -= 16;
+ }
if (y < (1.0L / (1 << 8)))
- {
- y *= 1.0L * (1 << 8);
- exp -= 8;
- }
+ {
+ y *= 1.0L * (1 << 8);
+ exp -= 8;
+ }
if (y < (1.0L / (1 << 4)))
- {
- y *= 1.0L * (1 << 4);
- exp -= 4;
- }
+ {
+ y *= 1.0L * (1 << 4);
+ exp -= 4;
+ }
if (y < (1.0L / (1 << 2)))
- {
- y *= 1.0L * (1 << 2);
- exp -= 2;
- }
+ {
+ y *= 1.0L * (1 << 2);
+ exp -= 2;
+ }
if (y < (1.0L / (1 << 1)))
- {
- y *= 1.0L * (1 << 1);
- exp -= 1;
- }
+ {
+ y *= 1.0L * (1 << 1);
+ exp -= 1;
+ }
}
if (!(y >= 0.5L && y < 1.0L))
abort ();
@@ -1389,35 +1389,35 @@ floorlog10 (double x)
if (y < 0.5)
{
while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
- {
- y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
- exp -= GMP_LIMB_BITS;
- }
+ {
+ y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+ exp -= GMP_LIMB_BITS;
+ }
if (y < (1.0 / (1 << 16)))
- {
- y *= 1.0 * (1 << 16);
- exp -= 16;
- }
+ {
+ y *= 1.0 * (1 << 16);
+ exp -= 16;
+ }
if (y < (1.0 / (1 << 8)))
- {
- y *= 1.0 * (1 << 8);
- exp -= 8;
- }
+ {
+ y *= 1.0 * (1 << 8);
+ exp -= 8;
+ }
if (y < (1.0 / (1 << 4)))
- {
- y *= 1.0 * (1 << 4);
- exp -= 4;
- }
+ {
+ y *= 1.0 * (1 << 4);
+ exp -= 4;
+ }
if (y < (1.0 / (1 << 2)))
- {
- y *= 1.0 * (1 << 2);
- exp -= 2;
- }
+ {
+ y *= 1.0 * (1 << 2);
+ exp -= 2;
+ }
if (y < (1.0 / (1 << 1)))
- {
- y *= 1.0 * (1 << 1);
- exp -= 1;
- }
+ {
+ y *= 1.0 * (1 << 1);
+ exp -= 1;
+ }
}
if (!(y >= 0.5 && y < 1.0))
abort ();
@@ -1476,7 +1476,7 @@ is_borderline (const char *digits, size_t precision)
DCHAR_T *
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
- const FCHAR_T *format, va_list args)
+ const FCHAR_T *format, va_list args)
{
DIRECTIVES d;
arguments a;
@@ -1486,8 +1486,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
return NULL;
#define CLEANUP() \
- free (d.dir); \
- if (a.arg) \
+ free (d.dir); \
+ if (a.arg) \
free (a.arg);
if (PRINTF_FETCHARGS (args, &a) < 0)
@@ -1516,30 +1516,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if HAVE_ALLOCA
if (buf_neededlength < 4000 / sizeof (TCHAR_T))
{
- buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
- buf_malloced = NULL;
+ buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
+ buf_malloced = NULL;
}
else
#endif
{
- size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
- if (size_overflow_p (buf_memsize))
- goto out_of_memory_1;
- buf = (TCHAR_T *) malloc (buf_memsize);
- if (buf == NULL)
- goto out_of_memory_1;
- buf_malloced = buf;
+ size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
+ if (size_overflow_p (buf_memsize))
+ goto out_of_memory_1;
+ buf = (TCHAR_T *) malloc (buf_memsize);
+ if (buf == NULL)
+ goto out_of_memory_1;
+ buf_malloced = buf;
}
if (resultbuf != NULL)
{
- result = resultbuf;
- allocated = *lengthp;
+ result = resultbuf;
+ allocated = *lengthp;
}
else
{
- result = NULL;
- allocated = 0;
+ result = NULL;
+ allocated = 0;
}
length = 0;
/* Invariants:
@@ -1549,3881 +1549,3881 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Ensures that allocated >= needed. Aborts through a jump to
out_of_memory if needed is SIZE_MAX or otherwise too big. */
#define ENSURE_ALLOCATION(needed) \
- if ((needed) > allocated) \
- { \
- size_t memory_size; \
- DCHAR_T *memory; \
- \
- allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
- if ((needed) > allocated) \
- allocated = (needed); \
- memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
- if (size_overflow_p (memory_size)) \
- goto out_of_memory; \
- if (result == resultbuf || result == NULL) \
- memory = (DCHAR_T *) malloc (memory_size); \
- else \
- memory = (DCHAR_T *) realloc (result, memory_size); \
- if (memory == NULL) \
- goto out_of_memory; \
- if (result == resultbuf && length > 0) \
- DCHAR_CPY (memory, result, length); \
- result = memory; \
+ if ((needed) > allocated) \
+ { \
+ size_t memory_size; \
+ DCHAR_T *memory; \
+ \
+ allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
+ if ((needed) > allocated) \
+ allocated = (needed); \
+ memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
+ if (size_overflow_p (memory_size)) \
+ goto out_of_memory; \
+ if (result == resultbuf || result == NULL) \
+ memory = (DCHAR_T *) malloc (memory_size); \
+ else \
+ memory = (DCHAR_T *) realloc (result, memory_size); \
+ if (memory == NULL) \
+ goto out_of_memory; \
+ if (result == resultbuf && length > 0) \
+ DCHAR_CPY (memory, result, length); \
+ result = memory; \
}
for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
{
- if (cp != dp->dir_start)
- {
- size_t n = dp->dir_start - cp;
- size_t augmented_length = xsum (length, n);
-
- ENSURE_ALLOCATION (augmented_length);
- /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we
- need that the format string contains only ASCII characters
- if FCHAR_T and DCHAR_T are not the same type. */
- if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
- {
- DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
- length = augmented_length;
- }
- else
- {
- do
- result[length++] = (unsigned char) *cp++;
- while (--n > 0);
- }
- }
- if (i == d.count)
- break;
-
- /* Execute a single directive. */
- if (dp->conversion == '%')
- {
- size_t augmented_length;
-
- if (!(dp->arg_index == ARG_NONE))
- abort ();
- augmented_length = xsum (length, 1);
- ENSURE_ALLOCATION (augmented_length);
- result[length] = '%';
- length = augmented_length;
- }
- else
- {
- if (!(dp->arg_index != ARG_NONE))
- abort ();
-
- if (dp->conversion == 'n')
- {
- switch (a.arg[dp->arg_index].type)
- {
- case TYPE_COUNT_SCHAR_POINTER:
- *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
- break;
- case TYPE_COUNT_SHORT_POINTER:
- *a.arg[dp->arg_index].a.a_count_short_pointer = length;
- break;
- case TYPE_COUNT_INT_POINTER:
- *a.arg[dp->arg_index].a.a_count_int_pointer = length;
- break;
- case TYPE_COUNT_LONGINT_POINTER:
- *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
- break;
+ if (cp != dp->dir_start)
+ {
+ size_t n = dp->dir_start - cp;
+ size_t augmented_length = xsum (length, n);
+
+ ENSURE_ALLOCATION (augmented_length);
+ /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we
+ need that the format string contains only ASCII characters
+ if FCHAR_T and DCHAR_T are not the same type. */
+ if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
+ {
+ DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
+ length = augmented_length;
+ }
+ else
+ {
+ do
+ result[length++] = (unsigned char) *cp++;
+ while (--n > 0);
+ }
+ }
+ if (i == d.count)
+ break;
+
+ /* Execute a single directive. */
+ if (dp->conversion == '%')
+ {
+ size_t augmented_length;
+
+ if (!(dp->arg_index == ARG_NONE))
+ abort ();
+ augmented_length = xsum (length, 1);
+ ENSURE_ALLOCATION (augmented_length);
+ result[length] = '%';
+ length = augmented_length;
+ }
+ else
+ {
+ if (!(dp->arg_index != ARG_NONE))
+ abort ();
+
+ if (dp->conversion == 'n')
+ {
+ switch (a.arg[dp->arg_index].type)
+ {
+ case TYPE_COUNT_SCHAR_POINTER:
+ *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
+ break;
+ case TYPE_COUNT_SHORT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_short_pointer = length;
+ break;
+ case TYPE_COUNT_INT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_int_pointer = length;
+ break;
+ case TYPE_COUNT_LONGINT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
+ break;
#if HAVE_LONG_LONG_INT
- case TYPE_COUNT_LONGLONGINT_POINTER:
- *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
- break;
+ case TYPE_COUNT_LONGLONGINT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
+ break;
#endif
- default:
- abort ();
- }
- }
+ default:
+ abort ();
+ }
+ }
#if ENABLE_UNISTDIO
- /* The unistdio extensions. */
- else if (dp->conversion == 'U')
- {
- arg_type type = a.arg[dp->arg_index].type;
- int flags = dp->flags;
- int has_width;
- size_t width;
- int has_precision;
- size_t precision;
-
- has_width = 0;
- width = 0;
- if (dp->width_start != dp->width_end)
- {
- if (dp->width_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->width_arg_index].a.a_int;
- if (arg < 0)
- {
- /* "A negative field width is taken as a '-' flag
- followed by a positive field width." */
- flags |= FLAG_LEFT;
- width = (unsigned int) (-arg);
- }
- else
- width = arg;
- }
- else
- {
- const FCHAR_T *digitp = dp->width_start;
-
- do
- width = xsum (xtimes (width, 10), *digitp++ - '0');
- while (digitp != dp->width_end);
- }
- has_width = 1;
- }
-
- has_precision = 0;
- precision = 0;
- if (dp->precision_start != dp->precision_end)
- {
- if (dp->precision_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->precision_arg_index].a.a_int;
- /* "A negative precision is taken as if the precision
- were omitted." */
- if (arg >= 0)
- {
- precision = arg;
- has_precision = 1;
- }
- }
- else
- {
- const FCHAR_T *digitp = dp->precision_start + 1;
-
- precision = 0;
- while (digitp != dp->precision_end)
- precision = xsum (xtimes (precision, 10), *digitp++ - '0');
- has_precision = 1;
- }
- }
-
- switch (type)
- {
- case TYPE_U8_STRING:
- {
- const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
- const uint8_t *arg_end;
- size_t characters;
-
- if (has_precision)
- {
- /* Use only PRECISION characters, from the left. */
- arg_end = arg;
- characters = 0;
- for (; precision > 0; precision--)
- {
- int count = u8_strmblen (arg_end);
- if (count == 0)
- break;
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else if (has_width)
- {
- /* Use the entire string, and count the number of
- characters. */
- arg_end = arg;
- characters = 0;
- for (;;)
- {
- int count = u8_strmblen (arg_end);
- if (count == 0)
- break;
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else
- {
- /* Use the entire string. */
- arg_end = arg + u8_strlen (arg);
- /* The number of characters doesn't matter. */
- characters = 0;
- }
-
- if (has_width && width > characters
- && !(dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
+ /* The unistdio extensions. */
+ else if (dp->conversion == 'U')
+ {
+ arg_type type = a.arg[dp->arg_index].type;
+ int flags = dp->flags;
+ int has_width;
+ size_t width;
+ int has_precision;
+ size_t precision;
+
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = (unsigned int) (-arg);
+ }
+ else
+ width = arg;
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
+
+ has_precision = 0;
+ precision = 0;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+ switch (type)
+ {
+ case TYPE_U8_STRING:
+ {
+ const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
+ const uint8_t *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only PRECISION characters, from the left. */
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count = u8_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of
+ characters. */
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count = u8_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + u8_strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (has_width && width > characters
+ && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
# if DCHAR_IS_UINT8_T
- {
- size_t n = arg_end - arg;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_CPY (result + length, arg, n);
- length += n;
- }
+ {
+ size_t n = arg_end - arg;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_CPY (result + length, arg, n);
+ length += n;
+ }
# else
- { /* Convert. */
- DCHAR_T *converted = result + length;
- size_t converted_len = allocated - length;
+ { /* Convert. */
+ DCHAR_T *converted = result + length;
+ size_t converted_len = allocated - length;
# if DCHAR_IS_TCHAR
- /* Convert from UTF-8 to locale encoding. */
- converted =
- u8_conv_to_encoding (locale_charset (),
- iconveh_question_mark,
- arg, arg_end - arg, NULL,
- converted, &converted_len);
+ /* Convert from UTF-8 to locale encoding. */
+ converted =
+ u8_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
# else
- /* Convert from UTF-8 to UTF-16/UTF-32. */
- converted =
- U8_TO_DCHAR (arg, arg_end - arg,
- converted, &converted_len);
+ /* Convert from UTF-8 to UTF-16/UTF-32. */
+ converted =
+ U8_TO_DCHAR (arg, arg_end - arg,
+ converted, &converted_len);
# endif
- if (converted == NULL)
- {
- int saved_errno = errno;
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = saved_errno;
- return NULL;
- }
- if (converted != result + length)
- {
- ENSURE_ALLOCATION (xsum (length, converted_len));
- DCHAR_CPY (result + length, converted, converted_len);
- free (converted);
- }
- length += converted_len;
- }
+ if (converted == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ if (converted != result + length)
+ {
+ ENSURE_ALLOCATION (xsum (length, converted_len));
+ DCHAR_CPY (result + length, converted, converted_len);
+ free (converted);
+ }
+ length += converted_len;
+ }
# endif
- if (has_width && width > characters
- && (dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
- }
- break;
-
- case TYPE_U16_STRING:
- {
- const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string;
- const uint16_t *arg_end;
- size_t characters;
-
- if (has_precision)
- {
- /* Use only PRECISION characters, from the left. */
- arg_end = arg;
- characters = 0;
- for (; precision > 0; precision--)
- {
- int count = u16_strmblen (arg_end);
- if (count == 0)
- break;
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else if (has_width)
- {
- /* Use the entire string, and count the number of
- characters. */
- arg_end = arg;
- characters = 0;
- for (;;)
- {
- int count = u16_strmblen (arg_end);
- if (count == 0)
- break;
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else
- {
- /* Use the entire string. */
- arg_end = arg + u16_strlen (arg);
- /* The number of characters doesn't matter. */
- characters = 0;
- }
-
- if (has_width && width > characters
- && !(dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
+ if (has_width && width > characters
+ && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ break;
+
+ case TYPE_U16_STRING:
+ {
+ const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string;
+ const uint16_t *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only PRECISION characters, from the left. */
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count = u16_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of
+ characters. */
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count = u16_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + u16_strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (has_width && width > characters
+ && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
# if DCHAR_IS_UINT16_T
- {
- size_t n = arg_end - arg;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_CPY (result + length, arg, n);
- length += n;
- }
+ {
+ size_t n = arg_end - arg;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_CPY (result + length, arg, n);
+ length += n;
+ }
# else
- { /* Convert. */
- DCHAR_T *converted = result + length;
- size_t converted_len = allocated - length;
+ { /* Convert. */
+ DCHAR_T *converted = result + length;
+ size_t converted_len = allocated - length;
# if DCHAR_IS_TCHAR
- /* Convert from UTF-16 to locale encoding. */
- converted =
- u16_conv_to_encoding (locale_charset (),
- iconveh_question_mark,
- arg, arg_end - arg, NULL,
- converted, &converted_len);
+ /* Convert from UTF-16 to locale encoding. */
+ converted =
+ u16_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
# else
- /* Convert from UTF-16 to UTF-8/UTF-32. */
- converted =
- U16_TO_DCHAR (arg, arg_end - arg,
- converted, &converted_len);
+ /* Convert from UTF-16 to UTF-8/UTF-32. */
+ converted =
+ U16_TO_DCHAR (arg, arg_end - arg,
+ converted, &converted_len);
# endif
- if (converted == NULL)
- {
- int saved_errno = errno;
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = saved_errno;
- return NULL;
- }
- if (converted != result + length)
- {
- ENSURE_ALLOCATION (xsum (length, converted_len));
- DCHAR_CPY (result + length, converted, converted_len);
- free (converted);
- }
- length += converted_len;
- }
+ if (converted == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ if (converted != result + length)
+ {
+ ENSURE_ALLOCATION (xsum (length, converted_len));
+ DCHAR_CPY (result + length, converted, converted_len);
+ free (converted);
+ }
+ length += converted_len;
+ }
# endif
- if (has_width && width > characters
- && (dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
- }
- break;
-
- case TYPE_U32_STRING:
- {
- const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string;
- const uint32_t *arg_end;
- size_t characters;
-
- if (has_precision)
- {
- /* Use only PRECISION characters, from the left. */
- arg_end = arg;
- characters = 0;
- for (; precision > 0; precision--)
- {
- int count = u32_strmblen (arg_end);
- if (count == 0)
- break;
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else if (has_width)
- {
- /* Use the entire string, and count the number of
- characters. */
- arg_end = arg;
- characters = 0;
- for (;;)
- {
- int count = u32_strmblen (arg_end);
- if (count == 0)
- break;
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else
- {
- /* Use the entire string. */
- arg_end = arg + u32_strlen (arg);
- /* The number of characters doesn't matter. */
- characters = 0;
- }
-
- if (has_width && width > characters
- && !(dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
+ if (has_width && width > characters
+ && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ break;
+
+ case TYPE_U32_STRING:
+ {
+ const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string;
+ const uint32_t *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only PRECISION characters, from the left. */
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count = u32_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of
+ characters. */
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count = u32_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + u32_strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (has_width && width > characters
+ && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
# if DCHAR_IS_UINT32_T
- {
- size_t n = arg_end - arg;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_CPY (result + length, arg, n);
- length += n;
- }
+ {
+ size_t n = arg_end - arg;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_CPY (result + length, arg, n);
+ length += n;
+ }
# else
- { /* Convert. */
- DCHAR_T *converted = result + length;
- size_t converted_len = allocated - length;
+ { /* Convert. */
+ DCHAR_T *converted = result + length;
+ size_t converted_len = allocated - length;
# if DCHAR_IS_TCHAR
- /* Convert from UTF-32 to locale encoding. */
- converted =
- u32_conv_to_encoding (locale_charset (),
- iconveh_question_mark,
- arg, arg_end - arg, NULL,
- converted, &converted_len);
+ /* Convert from UTF-32 to locale encoding. */
+ converted =
+ u32_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
# else
- /* Convert from UTF-32 to UTF-8/UTF-16. */
- converted =
- U32_TO_DCHAR (arg, arg_end - arg,
- converted, &converted_len);
+ /* Convert from UTF-32 to UTF-8/UTF-16. */
+ converted =
+ U32_TO_DCHAR (arg, arg_end - arg,
+ converted, &converted_len);
# endif
- if (converted == NULL)
- {
- int saved_errno = errno;
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = saved_errno;
- return NULL;
- }
- if (converted != result + length)
- {
- ENSURE_ALLOCATION (xsum (length, converted_len));
- DCHAR_CPY (result + length, converted, converted_len);
- free (converted);
- }
- length += converted_len;
- }
+ if (converted == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ if (converted != result + length)
+ {
+ ENSURE_ALLOCATION (xsum (length, converted_len));
+ DCHAR_CPY (result + length, converted, converted_len);
+ free (converted);
+ }
+ length += converted_len;
+ }
# endif
- if (has_width && width > characters
- && (dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
- }
- break;
-
- default:
- abort ();
- }
- }
+ if (has_width && width > characters
+ && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
#endif
#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
- else if (dp->conversion == 's'
+ else if (dp->conversion == 's'
# if WIDE_CHAR_VERSION
- && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
+ && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
# else
- && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
+ && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
# endif
- )
- {
- /* The normal handling of the 's' directive below requires
- allocating a temporary buffer. The determination of its
- length (tmp_length), in the case when a precision is
- specified, below requires a conversion between a char[]
- string and a wchar_t[] wide string. It could be done, but
- we have no guarantee that the implementation of sprintf will
- use the exactly same algorithm. Without this guarantee, it
- is possible to have buffer overrun bugs. In order to avoid
- such bugs, we implement the entire processing of the 's'
- directive ourselves. */
- int flags = dp->flags;
- int has_width;
- size_t width;
- int has_precision;
- size_t precision;
-
- has_width = 0;
- width = 0;
- if (dp->width_start != dp->width_end)
- {
- if (dp->width_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->width_arg_index].a.a_int;
- if (arg < 0)
- {
- /* "A negative field width is taken as a '-' flag
- followed by a positive field width." */
- flags |= FLAG_LEFT;
- width = (unsigned int) (-arg);
- }
- else
- width = arg;
- }
- else
- {
- const FCHAR_T *digitp = dp->width_start;
-
- do
- width = xsum (xtimes (width, 10), *digitp++ - '0');
- while (digitp != dp->width_end);
- }
- has_width = 1;
- }
-
- has_precision = 0;
- precision = 6;
- if (dp->precision_start != dp->precision_end)
- {
- if (dp->precision_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->precision_arg_index].a.a_int;
- /* "A negative precision is taken as if the precision
- were omitted." */
- if (arg >= 0)
- {
- precision = arg;
- has_precision = 1;
- }
- }
- else
- {
- const FCHAR_T *digitp = dp->precision_start + 1;
-
- precision = 0;
- while (digitp != dp->precision_end)
- precision = xsum (xtimes (precision, 10), *digitp++ - '0');
- has_precision = 1;
- }
- }
+ )
+ {
+ /* The normal handling of the 's' directive below requires
+ allocating a temporary buffer. The determination of its
+ length (tmp_length), in the case when a precision is
+ specified, below requires a conversion between a char[]
+ string and a wchar_t[] wide string. It could be done, but
+ we have no guarantee that the implementation of sprintf will
+ use the exactly same algorithm. Without this guarantee, it
+ is possible to have buffer overrun bugs. In order to avoid
+ such bugs, we implement the entire processing of the 's'
+ directive ourselves. */
+ int flags = dp->flags;
+ int has_width;
+ size_t width;
+ int has_precision;
+ size_t precision;
+
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = (unsigned int) (-arg);
+ }
+ else
+ width = arg;
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
+
+ has_precision = 0;
+ precision = 6;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
# if WIDE_CHAR_VERSION
- /* %s in vasnwprintf. See the specification of fwprintf. */
- {
- const char *arg = a.arg[dp->arg_index].a.a_string;
- const char *arg_end;
- size_t characters;
-
- if (has_precision)
- {
- /* Use only as many bytes as needed to produce PRECISION
- wide characters, from the left. */
+ /* %s in vasnwprintf. See the specification of fwprintf. */
+ {
+ const char *arg = a.arg[dp->arg_index].a.a_string;
+ const char *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only as many bytes as needed to produce PRECISION
+ wide characters, from the left. */
# if HAVE_MBRTOWC
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- arg_end = arg;
- characters = 0;
- for (; precision > 0; precision--)
- {
- int count;
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count;
# if HAVE_MBRTOWC
- count = mbrlen (arg_end, MB_CUR_MAX, &state);
+ count = mbrlen (arg_end, MB_CUR_MAX, &state);
# else
- count = mblen (arg_end, MB_CUR_MAX);
+ count = mblen (arg_end, MB_CUR_MAX);
# endif
- if (count == 0)
- /* Found the terminating NUL. */
- break;
- if (count < 0)
- {
- /* Invalid or incomplete multibyte character. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else if (has_width)
- {
- /* Use the entire string, and count the number of wide
- characters. */
+ if (count == 0)
+ /* Found the terminating NUL. */
+ break;
+ if (count < 0)
+ {
+ /* Invalid or incomplete multibyte character. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of wide
+ characters. */
# if HAVE_MBRTOWC
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- arg_end = arg;
- characters = 0;
- for (;;)
- {
- int count;
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count;
# if HAVE_MBRTOWC
- count = mbrlen (arg_end, MB_CUR_MAX, &state);
+ count = mbrlen (arg_end, MB_CUR_MAX, &state);
# else
- count = mblen (arg_end, MB_CUR_MAX);
+ count = mblen (arg_end, MB_CUR_MAX);
# endif
- if (count == 0)
- /* Found the terminating NUL. */
- break;
- if (count < 0)
- {
- /* Invalid or incomplete multibyte character. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end += count;
- characters++;
- }
- }
- else
- {
- /* Use the entire string. */
- arg_end = arg + strlen (arg);
- /* The number of characters doesn't matter. */
- characters = 0;
- }
-
- if (has_width && width > characters
- && !(dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
-
- if (has_precision || has_width)
- {
- /* We know the number of wide characters in advance. */
- size_t remaining;
+ if (count == 0)
+ /* Found the terminating NUL. */
+ break;
+ if (count < 0)
+ {
+ /* Invalid or incomplete multibyte character. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (has_width && width > characters
+ && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+
+ if (has_precision || has_width)
+ {
+ /* We know the number of wide characters in advance. */
+ size_t remaining;
# if HAVE_MBRTOWC
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- ENSURE_ALLOCATION (xsum (length, characters));
- for (remaining = characters; remaining > 0; remaining--)
- {
- wchar_t wc;
- int count;
+ ENSURE_ALLOCATION (xsum (length, characters));
+ for (remaining = characters; remaining > 0; remaining--)
+ {
+ wchar_t wc;
+ int count;
# if HAVE_MBRTOWC
- count = mbrtowc (&wc, arg, arg_end - arg, &state);
+ count = mbrtowc (&wc, arg, arg_end - arg, &state);
# else
- count = mbtowc (&wc, arg, arg_end - arg);
+ count = mbtowc (&wc, arg, arg_end - arg);
# endif
- if (count <= 0)
- /* mbrtowc not consistent with mbrlen, or mbtowc
- not consistent with mblen. */
- abort ();
- result[length++] = wc;
- arg += count;
- }
- if (!(arg == arg_end))
- abort ();
- }
- else
- {
+ if (count <= 0)
+ /* mbrtowc not consistent with mbrlen, or mbtowc
+ not consistent with mblen. */
+ abort ();
+ result[length++] = wc;
+ arg += count;
+ }
+ if (!(arg == arg_end))
+ abort ();
+ }
+ else
+ {
# if HAVE_MBRTOWC
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- while (arg < arg_end)
- {
- wchar_t wc;
- int count;
+ while (arg < arg_end)
+ {
+ wchar_t wc;
+ int count;
# if HAVE_MBRTOWC
- count = mbrtowc (&wc, arg, arg_end - arg, &state);
+ count = mbrtowc (&wc, arg, arg_end - arg, &state);
# else
- count = mbtowc (&wc, arg, arg_end - arg);
+ count = mbtowc (&wc, arg, arg_end - arg);
# endif
- if (count <= 0)
- /* mbrtowc not consistent with mbrlen, or mbtowc
- not consistent with mblen. */
- abort ();
- ENSURE_ALLOCATION (xsum (length, 1));
- result[length++] = wc;
- arg += count;
- }
- }
-
- if (has_width && width > characters
- && (dp->flags & FLAG_LEFT))
- {
- size_t n = width - characters;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
- }
+ if (count <= 0)
+ /* mbrtowc not consistent with mbrlen, or mbtowc
+ not consistent with mblen. */
+ abort ();
+ ENSURE_ALLOCATION (xsum (length, 1));
+ result[length++] = wc;
+ arg += count;
+ }
+ }
+
+ if (has_width && width > characters
+ && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
# else
- /* %ls in vasnprintf. See the specification of fprintf. */
- {
- const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
- const wchar_t *arg_end;
- size_t characters;
+ /* %ls in vasnprintf. See the specification of fprintf. */
+ {
+ const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+ const wchar_t *arg_end;
+ size_t characters;
# if !DCHAR_IS_TCHAR
- /* This code assumes that TCHAR_T is 'char'. */
- typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
- TCHAR_T *tmpsrc;
- DCHAR_T *tmpdst;
- size_t tmpdst_len;
+ /* This code assumes that TCHAR_T is 'char'. */
+ typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
+ TCHAR_T *tmpsrc;
+ DCHAR_T *tmpdst;
+ size_t tmpdst_len;
# endif
- size_t w;
-
- if (has_precision)
- {
- /* Use only as many wide characters as needed to produce
- at most PRECISION bytes, from the left. */
-# if HAVE_WCRTOMB
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ size_t w;
+
+ if (has_precision)
+ {
+ /* Use only as many wide characters as needed to produce
+ at most PRECISION bytes, from the left. */
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- arg_end = arg;
- characters = 0;
- while (precision > 0)
- {
- char buf[64]; /* Assume MB_CUR_MAX <= 64. */
- int count;
-
- if (*arg_end == 0)
- /* Found the terminating null wide character. */
- break;
-# if HAVE_WCRTOMB
- count = wcrtomb (buf, *arg_end, &state);
+ arg_end = arg;
+ characters = 0;
+ while (precision > 0)
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg_end == 0)
+ /* Found the terminating null wide character. */
+ break;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg_end, &state);
# else
- count = wctomb (buf, *arg_end);
+ count = wctomb (cbuf, *arg_end);
# endif
- if (count < 0)
- {
- /* Cannot convert. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- if (precision < count)
- break;
- arg_end++;
- characters += count;
- precision -= count;
- }
- }
+ if (count < 0)
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ if (precision < count)
+ break;
+ arg_end++;
+ characters += count;
+ precision -= count;
+ }
+ }
# if DCHAR_IS_TCHAR
- else if (has_width)
+ else if (has_width)
# else
- else
+ else
# endif
- {
- /* Use the entire string, and count the number of
- bytes. */
-# if HAVE_WCRTOMB
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ {
+ /* Use the entire string, and count the number of
+ bytes. */
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- arg_end = arg;
- characters = 0;
- for (;;)
- {
- char buf[64]; /* Assume MB_CUR_MAX <= 64. */
- int count;
-
- if (*arg_end == 0)
- /* Found the terminating null wide character. */
- break;
-# if HAVE_WCRTOMB
- count = wcrtomb (buf, *arg_end, &state);
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg_end == 0)
+ /* Found the terminating null wide character. */
+ break;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg_end, &state);
# else
- count = wctomb (buf, *arg_end);
+ count = wctomb (cbuf, *arg_end);
# endif
- if (count < 0)
- {
- /* Cannot convert. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
- arg_end++;
- characters += count;
- }
- }
+ if (count < 0)
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end++;
+ characters += count;
+ }
+ }
# if DCHAR_IS_TCHAR
- else
- {
- /* Use the entire string. */
- arg_end = arg + local_wcslen (arg);
- /* The number of bytes doesn't matter. */
- characters = 0;
- }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + local_wcslen (arg);
+ /* The number of bytes doesn't matter. */
+ characters = 0;
+ }
# endif
# if !DCHAR_IS_TCHAR
- /* Convert the string into a piece of temporary memory. */
- tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
- if (tmpsrc == NULL)
- goto out_of_memory;
- {
- TCHAR_T *tmpptr = tmpsrc;
- size_t remaining;
-# if HAVE_WCRTOMB
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ /* Convert the string into a piece of temporary memory. */
+ tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
+ if (tmpsrc == NULL)
+ goto out_of_memory;
+ {
+ TCHAR_T *tmpptr = tmpsrc;
+ size_t remaining;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- for (remaining = characters; remaining > 0; )
- {
- char buf[64]; /* Assume MB_CUR_MAX <= 64. */
- int count;
-
- if (*arg == 0)
- abort ();
-# if HAVE_WCRTOMB
- count = wcrtomb (buf, *arg, &state);
+ for (remaining = characters; remaining > 0; )
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg == 0)
+ abort ();
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg, &state);
# else
- count = wctomb (buf, *arg);
+ count = wctomb (cbuf, *arg);
# endif
- if (count <= 0)
- /* Inconsistency. */
- abort ();
- memcpy (tmpptr, buf, count);
- tmpptr += count;
- arg++;
- remaining -= count;
- }
- if (!(arg == arg_end))
- abort ();
- }
-
- /* Convert from TCHAR_T[] to DCHAR_T[]. */
- tmpdst =
- DCHAR_CONV_FROM_ENCODING (locale_charset (),
- iconveh_question_mark,
- tmpsrc, characters,
- NULL,
- NULL, &tmpdst_len);
- if (tmpdst == NULL)
- {
- int saved_errno = errno;
- free (tmpsrc);
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = saved_errno;
- return NULL;
- }
- free (tmpsrc);
+ if (count <= 0)
+ /* Inconsistency. */
+ abort ();
+ memcpy (tmpptr, cbuf, count);
+ tmpptr += count;
+ arg++;
+ remaining -= count;
+ }
+ if (!(arg == arg_end))
+ abort ();
+ }
+
+ /* Convert from TCHAR_T[] to DCHAR_T[]. */
+ tmpdst =
+ DCHAR_CONV_FROM_ENCODING (locale_charset (),
+ iconveh_question_mark,
+ tmpsrc, characters,
+ NULL,
+ NULL, &tmpdst_len);
+ if (tmpdst == NULL)
+ {
+ int saved_errno = errno;
+ free (tmpsrc);
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ free (tmpsrc);
# endif
- if (has_width)
- {
+ if (has_width)
+ {
# if ENABLE_UNISTDIO
- /* Outside POSIX, it's preferrable to compare the width
- against the number of _characters_ of the converted
- value. */
- w = DCHAR_MBSNLEN (result + length, characters);
+ /* Outside POSIX, it's preferrable to compare the width
+ against the number of _characters_ of the converted
+ value. */
+ w = DCHAR_MBSNLEN (result + length, characters);
# else
- /* The width is compared against the number of _bytes_
- of the converted value, says POSIX. */
- w = characters;
+ /* The width is compared against the number of _bytes_
+ of the converted value, says POSIX. */
+ w = characters;
# endif
- }
- else
- /* w doesn't matter. */
- w = 0;
-
- if (has_width && width > w
- && !(dp->flags & FLAG_LEFT))
- {
- size_t n = width - w;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
+ }
+ else
+ /* w doesn't matter. */
+ w = 0;
+
+ if (has_width && width > w
+ && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - w;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
# if DCHAR_IS_TCHAR
- if (has_precision || has_width)
- {
- /* We know the number of bytes in advance. */
- size_t remaining;
-# if HAVE_WCRTOMB
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ if (has_precision || has_width)
+ {
+ /* We know the number of bytes in advance. */
+ size_t remaining;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- ENSURE_ALLOCATION (xsum (length, characters));
- for (remaining = characters; remaining > 0; )
- {
- char buf[64]; /* Assume MB_CUR_MAX <= 64. */
- int count;
-
- if (*arg == 0)
- abort ();
-# if HAVE_WCRTOMB
- count = wcrtomb (buf, *arg, &state);
+ ENSURE_ALLOCATION (xsum (length, characters));
+ for (remaining = characters; remaining > 0; )
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg == 0)
+ abort ();
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg, &state);
# else
- count = wctomb (buf, *arg);
+ count = wctomb (cbuf, *arg);
# endif
- if (count <= 0)
- /* Inconsistency. */
- abort ();
- memcpy (result + length, buf, count);
- length += count;
- arg++;
- remaining -= count;
- }
- if (!(arg == arg_end))
- abort ();
- }
- else
- {
-# if HAVE_WCRTOMB
- mbstate_t state;
- memset (&state, '\0', sizeof (mbstate_t));
+ if (count <= 0)
+ /* Inconsistency. */
+ abort ();
+ memcpy (result + length, cbuf, count);
+ length += count;
+ arg++;
+ remaining -= count;
+ }
+ if (!(arg == arg_end))
+ abort ();
+ }
+ else
+ {
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
# endif
- while (arg < arg_end)
- {
- char buf[64]; /* Assume MB_CUR_MAX <= 64. */
- int count;
-
- if (*arg == 0)
- abort ();
-# if HAVE_WCRTOMB
- count = wcrtomb (buf, *arg, &state);
+ while (arg < arg_end)
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg == 0)
+ abort ();
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg, &state);
# else
- count = wctomb (buf, *arg);
+ count = wctomb (cbuf, *arg);
# endif
- if (count <= 0)
- /* Inconsistency. */
- abort ();
- ENSURE_ALLOCATION (xsum (length, count));
- memcpy (result + length, buf, count);
- length += count;
- arg++;
- }
- }
+ if (count <= 0)
+ /* Inconsistency. */
+ abort ();
+ ENSURE_ALLOCATION (xsum (length, count));
+ memcpy (result + length, cbuf, count);
+ length += count;
+ arg++;
+ }
+ }
# else
- ENSURE_ALLOCATION (xsum (length, tmpdst_len));
- DCHAR_CPY (result + length, tmpdst, tmpdst_len);
- free (tmpdst);
- length += tmpdst_len;
+ ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+ DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+ free (tmpdst);
+ length += tmpdst_len;
# endif
- if (has_width && width > w
- && (dp->flags & FLAG_LEFT))
- {
- size_t n = width - w;
- ENSURE_ALLOCATION (xsum (length, n));
- DCHAR_SET (result + length, ' ', n);
- length += n;
- }
- }
- }
+ if (has_width && width > w
+ && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - w;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ }
# endif
#endif
#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
- else if ((dp->conversion == 'a' || dp->conversion == 'A')
+ else if ((dp->conversion == 'a' || dp->conversion == 'A')
# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
- && (0
+ && (0
# if NEED_PRINTF_DOUBLE
- || a.arg[dp->arg_index].type == TYPE_DOUBLE
+ || a.arg[dp->arg_index].type == TYPE_DOUBLE
# endif
# if NEED_PRINTF_LONG_DOUBLE
- || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+ || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
# endif
- )
+ )
# endif
- )
- {
- arg_type type = a.arg[dp->arg_index].type;
- int flags = dp->flags;
- int has_width;
- size_t width;
- int has_precision;
- size_t precision;
- size_t tmp_length;
- DCHAR_T tmpbuf[700];
- DCHAR_T *tmp;
- DCHAR_T *pad_ptr;
- DCHAR_T *p;
-
- has_width = 0;
- width = 0;
- if (dp->width_start != dp->width_end)
- {
- if (dp->width_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->width_arg_index].a.a_int;
- if (arg < 0)
- {
- /* "A negative field width is taken as a '-' flag
- followed by a positive field width." */
- flags |= FLAG_LEFT;
- width = (unsigned int) (-arg);
- }
- else
- width = arg;
- }
- else
- {
- const FCHAR_T *digitp = dp->width_start;
-
- do
- width = xsum (xtimes (width, 10), *digitp++ - '0');
- while (digitp != dp->width_end);
- }
- has_width = 1;
- }
-
- has_precision = 0;
- precision = 0;
- if (dp->precision_start != dp->precision_end)
- {
- if (dp->precision_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->precision_arg_index].a.a_int;
- /* "A negative precision is taken as if the precision
- were omitted." */
- if (arg >= 0)
- {
- precision = arg;
- has_precision = 1;
- }
- }
- else
- {
- const FCHAR_T *digitp = dp->precision_start + 1;
-
- precision = 0;
- while (digitp != dp->precision_end)
- precision = xsum (xtimes (precision, 10), *digitp++ - '0');
- has_precision = 1;
- }
- }
-
- /* Allocate a temporary buffer of sufficient size. */
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) ((LDBL_DIG + 1)
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) ((DBL_DIG + 1)
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Account for sign, decimal point etc. */
- tmp_length = xsum (tmp_length, 12);
-
- if (tmp_length < width)
- tmp_length = width;
-
- tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
-
- if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
- tmp = tmpbuf;
- else
- {
- size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
-
- if (size_overflow_p (tmp_memsize))
- /* Overflow, would lead to out of memory. */
- goto out_of_memory;
- tmp = (DCHAR_T *) malloc (tmp_memsize);
- if (tmp == NULL)
- /* Out of memory. */
- goto out_of_memory;
- }
-
- pad_ptr = NULL;
- p = tmp;
- if (type == TYPE_LONGDOUBLE)
- {
+ )
+ {
+ arg_type type = a.arg[dp->arg_index].type;
+ int flags = dp->flags;
+ int has_width;
+ size_t width;
+ int has_precision;
+ size_t precision;
+ size_t tmp_length;
+ DCHAR_T tmpbuf[700];
+ DCHAR_T *tmp;
+ DCHAR_T *pad_ptr;
+ DCHAR_T *p;
+
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = (unsigned int) (-arg);
+ }
+ else
+ width = arg;
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
+
+ has_precision = 0;
+ precision = 0;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+ /* Allocate a temporary buffer of sufficient size. */
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) ((LDBL_DIG + 1)
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) ((DBL_DIG + 1)
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+
+ if (tmp_length < width)
+ tmp_length = width;
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+ if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+ tmp = tmpbuf;
+ else
+ {
+ size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+
+ if (size_overflow_p (tmp_memsize))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ tmp = (DCHAR_T *) malloc (tmp_memsize);
+ if (tmp == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ }
+
+ pad_ptr = NULL;
+ p = tmp;
+ if (type == TYPE_LONGDOUBLE)
+ {
# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE
- long double arg = a.arg[dp->arg_index].a.a_longdouble;
-
- if (isnanl (arg))
- {
- if (dp->conversion == 'A')
- {
- *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
- }
- else
- {
- *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
- }
- }
- else
- {
- int sign = 0;
- DECL_LONG_DOUBLE_ROUNDING
-
- BEGIN_LONG_DOUBLE_ROUNDING ();
-
- if (signbit (arg)) /* arg < 0.0L or negative zero */
- {
- sign = -1;
- arg = -arg;
- }
-
- if (sign < 0)
- *p++ = '-';
- else if (flags & FLAG_SHOWSIGN)
- *p++ = '+';
- else if (flags & FLAG_SPACE)
- *p++ = ' ';
-
- if (arg > 0.0L && arg + arg == arg)
- {
- if (dp->conversion == 'A')
- {
- *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
- }
- else
- {
- *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
- }
- }
- else
- {
- int exponent;
- long double mantissa;
-
- if (arg > 0.0L)
- mantissa = printf_frexpl (arg, &exponent);
- else
- {
- exponent = 0;
- mantissa = 0.0L;
- }
-
- if (has_precision
- && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
- {
- /* Round the mantissa. */
- long double tail = mantissa;
- size_t q;
-
- for (q = precision; ; q--)
- {
- int digit = (int) tail;
- tail -= digit;
- if (q == 0)
- {
- if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
- tail = 1 - tail;
- else
- tail = - tail;
- break;
- }
- tail *= 16.0L;
- }
- if (tail != 0.0L)
- for (q = precision; q > 0; q--)
- tail *= 0.0625L;
- mantissa += tail;
- }
-
- *p++ = '0';
- *p++ = dp->conversion - 'A' + 'X';
- pad_ptr = p;
- {
- int digit;
-
- digit = (int) mantissa;
- mantissa -= digit;
- *p++ = '0' + digit;
- if ((flags & FLAG_ALT)
- || mantissa > 0.0L || precision > 0)
- {
- *p++ = decimal_point_char ();
- /* This loop terminates because we assume
- that FLT_RADIX is a power of 2. */
- while (mantissa > 0.0L)
- {
- mantissa *= 16.0L;
- digit = (int) mantissa;
- mantissa -= digit;
- *p++ = digit
- + (digit < 10
- ? '0'
- : dp->conversion - 10);
- if (precision > 0)
- precision--;
- }
- while (precision > 0)
- {
- *p++ = '0';
- precision--;
- }
- }
- }
- *p++ = dp->conversion - 'A' + 'P';
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+
+ if (isnanl (arg))
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+ DECL_LONG_DOUBLE_ROUNDING
+
+ BEGIN_LONG_DOUBLE_ROUNDING ();
+
+ if (signbit (arg)) /* arg < 0.0L or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0L && arg + arg == arg)
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
+ int exponent;
+ long double mantissa;
+
+ if (arg > 0.0L)
+ mantissa = printf_frexpl (arg, &exponent);
+ else
+ {
+ exponent = 0;
+ mantissa = 0.0L;
+ }
+
+ if (has_precision
+ && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
+ {
+ /* Round the mantissa. */
+ long double tail = mantissa;
+ size_t q;
+
+ for (q = precision; ; q--)
+ {
+ int digit = (int) tail;
+ tail -= digit;
+ if (q == 0)
+ {
+ if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
+ tail = 1 - tail;
+ else
+ tail = - tail;
+ break;
+ }
+ tail *= 16.0L;
+ }
+ if (tail != 0.0L)
+ for (q = precision; q > 0; q--)
+ tail *= 0.0625L;
+ mantissa += tail;
+ }
+
+ *p++ = '0';
+ *p++ = dp->conversion - 'A' + 'X';
+ pad_ptr = p;
+ {
+ int digit;
+
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = '0' + digit;
+ if ((flags & FLAG_ALT)
+ || mantissa > 0.0L || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ /* This loop terminates because we assume
+ that FLT_RADIX is a power of 2. */
+ while (mantissa > 0.0L)
+ {
+ mantissa *= 16.0L;
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = digit
+ + (digit < 10
+ ? '0'
+ : dp->conversion - 10);
+ if (precision > 0)
+ precision--;
+ }
+ while (precision > 0)
+ {
+ *p++ = '0';
+ precision--;
+ }
+ }
+ }
+ *p++ = dp->conversion - 'A' + 'P';
# if WIDE_CHAR_VERSION
- {
- static const wchar_t decimal_format[] =
- { '%', '+', 'd', '\0' };
- SNPRINTF (p, 6 + 1, decimal_format, exponent);
- }
- while (*p != '\0')
- p++;
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
# else
- if (sizeof (DCHAR_T) == 1)
- {
- sprintf ((char *) p, "%+d", exponent);
- while (*p != '\0')
- p++;
- }
- else
- {
- char expbuf[6 + 1];
- const char *ep;
- sprintf (expbuf, "%+d", exponent);
- for (ep = expbuf; (*p = *ep) != '\0'; ep++)
- p++;
- }
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
# endif
- }
+ }
- END_LONG_DOUBLE_ROUNDING ();
- }
+ END_LONG_DOUBLE_ROUNDING ();
+ }
# else
- abort ();
+ abort ();
# endif
- }
- else
- {
+ }
+ else
+ {
# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
- double arg = a.arg[dp->arg_index].a.a_double;
-
- if (isnand (arg))
- {
- if (dp->conversion == 'A')
- {
- *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
- }
- else
- {
- *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
- }
- }
- else
- {
- int sign = 0;
-
- if (signbit (arg)) /* arg < 0.0 or negative zero */
- {
- sign = -1;
- arg = -arg;
- }
-
- if (sign < 0)
- *p++ = '-';
- else if (flags & FLAG_SHOWSIGN)
- *p++ = '+';
- else if (flags & FLAG_SPACE)
- *p++ = ' ';
-
- if (arg > 0.0 && arg + arg == arg)
- {
- if (dp->conversion == 'A')
- {
- *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
- }
- else
- {
- *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
- }
- }
- else
- {
- int exponent;
- double mantissa;
-
- if (arg > 0.0)
- mantissa = printf_frexp (arg, &exponent);
- else
- {
- exponent = 0;
- mantissa = 0.0;
- }
-
- if (has_precision
- && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
- {
- /* Round the mantissa. */
- double tail = mantissa;
- size_t q;
-
- for (q = precision; ; q--)
- {
- int digit = (int) tail;
- tail -= digit;
- if (q == 0)
- {
- if (digit & 1 ? tail >= 0.5 : tail > 0.5)
- tail = 1 - tail;
- else
- tail = - tail;
- break;
- }
- tail *= 16.0;
- }
- if (tail != 0.0)
- for (q = precision; q > 0; q--)
- tail *= 0.0625;
- mantissa += tail;
- }
-
- *p++ = '0';
- *p++ = dp->conversion - 'A' + 'X';
- pad_ptr = p;
- {
- int digit;
-
- digit = (int) mantissa;
- mantissa -= digit;
- *p++ = '0' + digit;
- if ((flags & FLAG_ALT)
- || mantissa > 0.0 || precision > 0)
- {
- *p++ = decimal_point_char ();
- /* This loop terminates because we assume
- that FLT_RADIX is a power of 2. */
- while (mantissa > 0.0)
- {
- mantissa *= 16.0;
- digit = (int) mantissa;
- mantissa -= digit;
- *p++ = digit
- + (digit < 10
- ? '0'
- : dp->conversion - 10);
- if (precision > 0)
- precision--;
- }
- while (precision > 0)
- {
- *p++ = '0';
- precision--;
- }
- }
- }
- *p++ = dp->conversion - 'A' + 'P';
+ double arg = a.arg[dp->arg_index].a.a_double;
+
+ if (isnand (arg))
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+
+ if (signbit (arg)) /* arg < 0.0 or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0 && arg + arg == arg)
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
+ int exponent;
+ double mantissa;
+
+ if (arg > 0.0)
+ mantissa = printf_frexp (arg, &exponent);
+ else
+ {
+ exponent = 0;
+ mantissa = 0.0;
+ }
+
+ if (has_precision
+ && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
+ {
+ /* Round the mantissa. */
+ double tail = mantissa;
+ size_t q;
+
+ for (q = precision; ; q--)
+ {
+ int digit = (int) tail;
+ tail -= digit;
+ if (q == 0)
+ {
+ if (digit & 1 ? tail >= 0.5 : tail > 0.5)
+ tail = 1 - tail;
+ else
+ tail = - tail;
+ break;
+ }
+ tail *= 16.0;
+ }
+ if (tail != 0.0)
+ for (q = precision; q > 0; q--)
+ tail *= 0.0625;
+ mantissa += tail;
+ }
+
+ *p++ = '0';
+ *p++ = dp->conversion - 'A' + 'X';
+ pad_ptr = p;
+ {
+ int digit;
+
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = '0' + digit;
+ if ((flags & FLAG_ALT)
+ || mantissa > 0.0 || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ /* This loop terminates because we assume
+ that FLT_RADIX is a power of 2. */
+ while (mantissa > 0.0)
+ {
+ mantissa *= 16.0;
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = digit
+ + (digit < 10
+ ? '0'
+ : dp->conversion - 10);
+ if (precision > 0)
+ precision--;
+ }
+ while (precision > 0)
+ {
+ *p++ = '0';
+ precision--;
+ }
+ }
+ }
+ *p++ = dp->conversion - 'A' + 'P';
# if WIDE_CHAR_VERSION
- {
- static const wchar_t decimal_format[] =
- { '%', '+', 'd', '\0' };
- SNPRINTF (p, 6 + 1, decimal_format, exponent);
- }
- while (*p != '\0')
- p++;
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
# else
- if (sizeof (DCHAR_T) == 1)
- {
- sprintf ((char *) p, "%+d", exponent);
- while (*p != '\0')
- p++;
- }
- else
- {
- char expbuf[6 + 1];
- const char *ep;
- sprintf (expbuf, "%+d", exponent);
- for (ep = expbuf; (*p = *ep) != '\0'; ep++)
- p++;
- }
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
# endif
- }
- }
+ }
+ }
# else
- abort ();
+ abort ();
# endif
- }
- /* The generated string now extends from tmp to p, with the
- zero padding insertion point being at pad_ptr. */
- if (has_width && p - tmp < width)
- {
- size_t pad = width - (p - tmp);
- DCHAR_T *end = p + pad;
-
- if (flags & FLAG_LEFT)
- {
- /* Pad with spaces on the right. */
- for (; pad > 0; pad--)
- *p++ = ' ';
- }
- else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
- {
- /* Pad with zeroes. */
- DCHAR_T *q = end;
-
- while (p > pad_ptr)
- *--q = *--p;
- for (; pad > 0; pad--)
- *p++ = '0';
- }
- else
- {
- /* Pad with spaces on the left. */
- DCHAR_T *q = end;
-
- while (p > tmp)
- *--q = *--p;
- for (; pad > 0; pad--)
- *p++ = ' ';
- }
-
- p = end;
- }
-
- {
- size_t count = p - tmp;
-
- if (count >= tmp_length)
- /* tmp_length was incorrectly calculated - fix the
- code above! */
- abort ();
-
- /* Make room for the result. */
- if (count >= allocated - length)
- {
- size_t n = xsum (length, count);
-
- ENSURE_ALLOCATION (n);
- }
-
- /* Append the result. */
- memcpy (result + length, tmp, count * sizeof (DCHAR_T));
- if (tmp != tmpbuf)
- free (tmp);
- length += count;
- }
- }
+ }
+ /* The generated string now extends from tmp to p, with the
+ zero padding insertion point being at pad_ptr. */
+ if (has_width && p - tmp < width)
+ {
+ size_t pad = width - (p - tmp);
+ DCHAR_T *end = p + pad;
+
+ if (flags & FLAG_LEFT)
+ {
+ /* Pad with spaces on the right. */
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+ {
+ /* Pad with zeroes. */
+ DCHAR_T *q = end;
+
+ while (p > pad_ptr)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = '0';
+ }
+ else
+ {
+ /* Pad with spaces on the left. */
+ DCHAR_T *q = end;
+
+ while (p > tmp)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+
+ p = end;
+ }
+
+ {
+ size_t count = p - tmp;
+
+ if (count >= tmp_length)
+ /* tmp_length was incorrectly calculated - fix the
+ code above! */
+ abort ();
+
+ /* Make room for the result. */
+ if (count >= allocated - length)
+ {
+ size_t n = xsum (length, count);
+
+ ENSURE_ALLOCATION (n);
+ }
+
+ /* Append the result. */
+ memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+ if (tmp != tmpbuf)
+ free (tmp);
+ length += count;
+ }
+ }
#endif
#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
- else if ((dp->conversion == 'f' || dp->conversion == 'F'
- || dp->conversion == 'e' || dp->conversion == 'E'
- || dp->conversion == 'g' || dp->conversion == 'G'
- || dp->conversion == 'a' || dp->conversion == 'A')
- && (0
+ else if ((dp->conversion == 'f' || dp->conversion == 'F'
+ || dp->conversion == 'e' || dp->conversion == 'E'
+ || dp->conversion == 'g' || dp->conversion == 'G'
+ || dp->conversion == 'a' || dp->conversion == 'A')
+ && (0
# if NEED_PRINTF_DOUBLE
- || a.arg[dp->arg_index].type == TYPE_DOUBLE
+ || a.arg[dp->arg_index].type == TYPE_DOUBLE
# elif NEED_PRINTF_INFINITE_DOUBLE
- || (a.arg[dp->arg_index].type == TYPE_DOUBLE
- /* The systems (mingw) which produce wrong output
- for Inf, -Inf, and NaN also do so for -0.0.
- Therefore we treat this case here as well. */
- && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double))
+ || (a.arg[dp->arg_index].type == TYPE_DOUBLE
+ /* The systems (mingw) which produce wrong output
+ for Inf, -Inf, and NaN also do so for -0.0.
+ Therefore we treat this case here as well. */
+ && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double))
# endif
# if NEED_PRINTF_LONG_DOUBLE
- || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+ || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
# elif NEED_PRINTF_INFINITE_LONG_DOUBLE
- || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
- /* Some systems produce wrong output for Inf,
- -Inf, and NaN. Some systems in this category
- (IRIX 5.3) also do so for -0.0. Therefore we
- treat this case here as well. */
- && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
+ || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+ /* Some systems produce wrong output for Inf,
+ -Inf, and NaN. Some systems in this category
+ (IRIX 5.3) also do so for -0.0. Therefore we
+ treat this case here as well. */
+ && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
# endif
- ))
- {
+ ))
+ {
# if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE)
- arg_type type = a.arg[dp->arg_index].type;
+ arg_type type = a.arg[dp->arg_index].type;
# endif
- int flags = dp->flags;
- int has_width;
- size_t width;
- int has_precision;
- size_t precision;
- size_t tmp_length;
- DCHAR_T tmpbuf[700];
- DCHAR_T *tmp;
- DCHAR_T *pad_ptr;
- DCHAR_T *p;
-
- has_width = 0;
- width = 0;
- if (dp->width_start != dp->width_end)
- {
- if (dp->width_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->width_arg_index].a.a_int;
- if (arg < 0)
- {
- /* "A negative field width is taken as a '-' flag
- followed by a positive field width." */
- flags |= FLAG_LEFT;
- width = (unsigned int) (-arg);
- }
- else
- width = arg;
- }
- else
- {
- const FCHAR_T *digitp = dp->width_start;
-
- do
- width = xsum (xtimes (width, 10), *digitp++ - '0');
- while (digitp != dp->width_end);
- }
- has_width = 1;
- }
-
- has_precision = 0;
- precision = 0;
- if (dp->precision_start != dp->precision_end)
- {
- if (dp->precision_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->precision_arg_index].a.a_int;
- /* "A negative precision is taken as if the precision
- were omitted." */
- if (arg >= 0)
- {
- precision = arg;
- has_precision = 1;
- }
- }
- else
- {
- const FCHAR_T *digitp = dp->precision_start + 1;
-
- precision = 0;
- while (digitp != dp->precision_end)
- precision = xsum (xtimes (precision, 10), *digitp++ - '0');
- has_precision = 1;
- }
- }
-
- /* POSIX specifies the default precision to be 6 for %f, %F,
- %e, %E, but not for %g, %G. Implementations appear to use
- the same default precision also for %g, %G. But for %a, %A,
- the default precision is 0. */
- if (!has_precision)
- if (!(dp->conversion == 'a' || dp->conversion == 'A'))
- precision = 6;
-
- /* Allocate a temporary buffer of sufficient size. */
+ int flags = dp->flags;
+ int has_width;
+ size_t width;
+ int has_precision;
+ size_t precision;
+ size_t tmp_length;
+ DCHAR_T tmpbuf[700];
+ DCHAR_T *tmp;
+ DCHAR_T *pad_ptr;
+ DCHAR_T *p;
+
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = (unsigned int) (-arg);
+ }
+ else
+ width = arg;
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
+
+ has_precision = 0;
+ precision = 0;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+ /* POSIX specifies the default precision to be 6 for %f, %F,
+ %e, %E, but not for %g, %G. Implementations appear to use
+ the same default precision also for %g, %G. But for %a, %A,
+ the default precision is 0. */
+ if (!has_precision)
+ if (!(dp->conversion == 'a' || dp->conversion == 'A'))
+ precision = 6;
+
+ /* Allocate a temporary buffer of sufficient size. */
# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
- tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
+ tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE
- tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0);
+ tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0);
# elif NEED_PRINTF_LONG_DOUBLE
- tmp_length = LDBL_DIG + 1;
+ tmp_length = LDBL_DIG + 1;
# elif NEED_PRINTF_DOUBLE
- tmp_length = DBL_DIG + 1;
+ tmp_length = DBL_DIG + 1;
# else
- tmp_length = 0;
+ tmp_length = 0;
# endif
- if (tmp_length < precision)
- tmp_length = precision;
+ if (tmp_length < precision)
+ tmp_length = precision;
# if NEED_PRINTF_LONG_DOUBLE
# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
- if (type == TYPE_LONGDOUBLE)
+ if (type == TYPE_LONGDOUBLE)
# endif
- if (dp->conversion == 'f' || dp->conversion == 'F')
- {
- long double arg = a.arg[dp->arg_index].a.a_longdouble;
- if (!(isnanl (arg) || arg + arg == arg))
- {
- /* arg is finite and nonzero. */
- int exponent = floorlog10l (arg < 0 ? -arg : arg);
- if (exponent >= 0 && tmp_length < exponent + precision)
- tmp_length = exponent + precision;
- }
- }
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+ if (!(isnanl (arg) || arg + arg == arg))
+ {
+ /* arg is finite and nonzero. */
+ int exponent = floorlog10l (arg < 0 ? -arg : arg);
+ if (exponent >= 0 && tmp_length < exponent + precision)
+ tmp_length = exponent + precision;
+ }
+ }
# endif
# if NEED_PRINTF_DOUBLE
# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
- if (type == TYPE_DOUBLE)
+ if (type == TYPE_DOUBLE)
# endif
- if (dp->conversion == 'f' || dp->conversion == 'F')
- {
- double arg = a.arg[dp->arg_index].a.a_double;
- if (!(isnand (arg) || arg + arg == arg))
- {
- /* arg is finite and nonzero. */
- int exponent = floorlog10 (arg < 0 ? -arg : arg);
- if (exponent >= 0 && tmp_length < exponent + precision)
- tmp_length = exponent + precision;
- }
- }
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ double arg = a.arg[dp->arg_index].a.a_double;
+ if (!(isnand (arg) || arg + arg == arg))
+ {
+ /* arg is finite and nonzero. */
+ int exponent = floorlog10 (arg < 0 ? -arg : arg);
+ if (exponent >= 0 && tmp_length < exponent + precision)
+ tmp_length = exponent + precision;
+ }
+ }
# endif
- /* Account for sign, decimal point etc. */
- tmp_length = xsum (tmp_length, 12);
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
- if (tmp_length < width)
- tmp_length = width;
+ if (tmp_length < width)
+ tmp_length = width;
- tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
- if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
- tmp = tmpbuf;
- else
- {
- size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+ if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+ tmp = tmpbuf;
+ else
+ {
+ size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
- if (size_overflow_p (tmp_memsize))
- /* Overflow, would lead to out of memory. */
- goto out_of_memory;
- tmp = (DCHAR_T *) malloc (tmp_memsize);
- if (tmp == NULL)
- /* Out of memory. */
- goto out_of_memory;
- }
+ if (size_overflow_p (tmp_memsize))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ tmp = (DCHAR_T *) malloc (tmp_memsize);
+ if (tmp == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ }
- pad_ptr = NULL;
- p = tmp;
+ pad_ptr = NULL;
+ p = tmp;
# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
- if (type == TYPE_LONGDOUBLE)
+ if (type == TYPE_LONGDOUBLE)
# endif
- {
- long double arg = a.arg[dp->arg_index].a.a_longdouble;
-
- if (isnanl (arg))
- {
- if (dp->conversion >= 'A' && dp->conversion <= 'Z')
- {
- *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
- }
- else
- {
- *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
- }
- }
- else
- {
- int sign = 0;
- DECL_LONG_DOUBLE_ROUNDING
-
- BEGIN_LONG_DOUBLE_ROUNDING ();
-
- if (signbit (arg)) /* arg < 0.0L or negative zero */
- {
- sign = -1;
- arg = -arg;
- }
-
- if (sign < 0)
- *p++ = '-';
- else if (flags & FLAG_SHOWSIGN)
- *p++ = '+';
- else if (flags & FLAG_SPACE)
- *p++ = ' ';
-
- if (arg > 0.0L && arg + arg == arg)
- {
- if (dp->conversion >= 'A' && dp->conversion <= 'Z')
- {
- *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
- }
- else
- {
- *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
- }
- }
- else
- {
+ {
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+
+ if (isnanl (arg))
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+ DECL_LONG_DOUBLE_ROUNDING
+
+ BEGIN_LONG_DOUBLE_ROUNDING ();
+
+ if (signbit (arg)) /* arg < 0.0L or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0L && arg + arg == arg)
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
# if NEED_PRINTF_LONG_DOUBLE
- pad_ptr = p;
-
- if (dp->conversion == 'f' || dp->conversion == 'F')
- {
- char *digits;
- size_t ndigits;
-
- digits =
- scale10_round_decimal_long_double (arg, precision);
- if (digits == NULL)
- {
- END_LONG_DOUBLE_ROUNDING ();
- goto out_of_memory;
- }
- ndigits = strlen (digits);
-
- if (ndigits > precision)
- do
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- while (ndigits > precision);
- else
- *p++ = '0';
- /* Here ndigits <= precision. */
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > ndigits; precision--)
- *p++ = '0';
- while (ndigits > 0)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
-
- free (digits);
- }
- else if (dp->conversion == 'e' || dp->conversion == 'E')
- {
- int exponent;
-
- if (arg == 0.0L)
- {
- exponent = 0;
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- }
- else
- {
- /* arg > 0.0L. */
- int adjusted;
- char *digits;
- size_t ndigits;
-
- exponent = floorlog10l (arg);
- adjusted = 0;
- for (;;)
- {
- digits =
- scale10_round_decimal_long_double (arg,
- (int)precision - exponent);
- if (digits == NULL)
- {
- END_LONG_DOUBLE_ROUNDING ();
- goto out_of_memory;
- }
- ndigits = strlen (digits);
-
- if (ndigits == precision + 1)
- break;
- if (ndigits < precision
- || ndigits > precision + 2)
- /* The exponent was not guessed
- precisely enough. */
- abort ();
- if (adjusted)
- /* None of two values of exponent is
- the right one. Prevent an endless
- loop. */
- abort ();
- free (digits);
- if (ndigits == precision)
- exponent -= 1;
- else
- exponent += 1;
- adjusted = 1;
- }
- /* Here ndigits = precision+1. */
- if (is_borderline (digits, precision))
- {
- /* Maybe the exponent guess was too high
- and a smaller exponent can be reached
- by turning a 10...0 into 9...9x. */
- char *digits2 =
- scale10_round_decimal_long_double (arg,
- (int)precision - exponent + 1);
- if (digits2 == NULL)
- {
- free (digits);
- END_LONG_DOUBLE_ROUNDING ();
- goto out_of_memory;
- }
- if (strlen (digits2) == precision + 1)
- {
- free (digits);
- digits = digits2;
- exponent -= 1;
- }
- else
- free (digits2);
- }
- /* Here ndigits = precision+1. */
-
- *p++ = digits[--ndigits];
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- while (ndigits > 0)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
-
- free (digits);
- }
-
- *p++ = dp->conversion; /* 'e' or 'E' */
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ char *digits;
+ size_t ndigits;
+
+ digits =
+ scale10_round_decimal_long_double (arg, precision);
+ if (digits == NULL)
+ {
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ ndigits = strlen (digits);
+
+ if (ndigits > precision)
+ do
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ while (ndigits > precision);
+ else
+ *p++ = '0';
+ /* Here ndigits <= precision. */
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > ndigits; precision--)
+ *p++ = '0';
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ int exponent;
+
+ if (arg == 0.0L)
+ {
+ exponent = 0;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else
+ {
+ /* arg > 0.0L. */
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+
+ exponent = floorlog10l (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_long_double (arg,
+ (int)precision - exponent);
+ if (digits == NULL)
+ {
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ ndigits = strlen (digits);
+
+ if (ndigits == precision + 1)
+ break;
+ if (ndigits < precision
+ || ndigits > precision + 2)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits == precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision+1. */
+ if (is_borderline (digits, precision))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_long_double (arg,
+ (int)precision - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision + 1)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision+1. */
+
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+
+ *p++ = dp->conversion; /* 'e' or 'E' */
# if WIDE_CHAR_VERSION
- {
- static const wchar_t decimal_format[] =
- { '%', '+', '.', '2', 'd', '\0' };
- SNPRINTF (p, 6 + 1, decimal_format, exponent);
- }
- while (*p != '\0')
- p++;
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', '.', '2', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
# else
- if (sizeof (DCHAR_T) == 1)
- {
- sprintf ((char *) p, "%+.2d", exponent);
- while (*p != '\0')
- p++;
- }
- else
- {
- char expbuf[6 + 1];
- const char *ep;
- sprintf (expbuf, "%+.2d", exponent);
- for (ep = expbuf; (*p = *ep) != '\0'; ep++)
- p++;
- }
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+.2d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+.2d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
# endif
- }
- else if (dp->conversion == 'g' || dp->conversion == 'G')
- {
- if (precision == 0)
- precision = 1;
- /* precision >= 1. */
-
- if (arg == 0.0L)
- /* The exponent is 0, >= -4, < precision.
- Use fixed-point notation. */
- {
- size_t ndigits = precision;
- /* Number of trailing zeroes that have to be
- dropped. */
- size_t nzeroes =
- (flags & FLAG_ALT ? 0 : precision - 1);
-
- --ndigits;
- *p++ = '0';
- if ((flags & FLAG_ALT) || ndigits > nzeroes)
- {
- *p++ = decimal_point_char ();
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = '0';
- }
- }
- }
- else
- {
- /* arg > 0.0L. */
- int exponent;
- int adjusted;
- char *digits;
- size_t ndigits;
- size_t nzeroes;
-
- exponent = floorlog10l (arg);
- adjusted = 0;
- for (;;)
- {
- digits =
- scale10_round_decimal_long_double (arg,
- (int)(precision - 1) - exponent);
- if (digits == NULL)
- {
- END_LONG_DOUBLE_ROUNDING ();
- goto out_of_memory;
- }
- ndigits = strlen (digits);
-
- if (ndigits == precision)
- break;
- if (ndigits < precision - 1
- || ndigits > precision + 1)
- /* The exponent was not guessed
- precisely enough. */
- abort ();
- if (adjusted)
- /* None of two values of exponent is
- the right one. Prevent an endless
- loop. */
- abort ();
- free (digits);
- if (ndigits < precision)
- exponent -= 1;
- else
- exponent += 1;
- adjusted = 1;
- }
- /* Here ndigits = precision. */
- if (is_borderline (digits, precision - 1))
- {
- /* Maybe the exponent guess was too high
- and a smaller exponent can be reached
- by turning a 10...0 into 9...9x. */
- char *digits2 =
- scale10_round_decimal_long_double (arg,
- (int)(precision - 1) - exponent + 1);
- if (digits2 == NULL)
- {
- free (digits);
- END_LONG_DOUBLE_ROUNDING ();
- goto out_of_memory;
- }
- if (strlen (digits2) == precision)
- {
- free (digits);
- digits = digits2;
- exponent -= 1;
- }
- else
- free (digits2);
- }
- /* Here ndigits = precision. */
-
- /* Determine the number of trailing zeroes
- that have to be dropped. */
- nzeroes = 0;
- if ((flags & FLAG_ALT) == 0)
- while (nzeroes < ndigits
- && digits[nzeroes] == '0')
- nzeroes++;
-
- /* The exponent is now determined. */
- if (exponent >= -4
- && exponent < (long)precision)
- {
- /* Fixed-point notation:
- max(exponent,0)+1 digits, then the
- decimal point, then the remaining
- digits without trailing zeroes. */
- if (exponent >= 0)
- {
- size_t count = exponent + 1;
- /* Note: count <= precision = ndigits. */
- for (; count > 0; count--)
- *p++ = digits[--ndigits];
- if ((flags & FLAG_ALT) || ndigits > nzeroes)
- {
- *p++ = decimal_point_char ();
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
- }
- else
- {
- size_t count = -exponent - 1;
- *p++ = '0';
- *p++ = decimal_point_char ();
- for (; count > 0; count--)
- *p++ = '0';
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
- }
- else
- {
- /* Exponential notation. */
- *p++ = digits[--ndigits];
- if ((flags & FLAG_ALT) || ndigits > nzeroes)
- {
- *p++ = decimal_point_char ();
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
- *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ if (precision == 0)
+ precision = 1;
+ /* precision >= 1. */
+
+ if (arg == 0.0L)
+ /* The exponent is 0, >= -4, < precision.
+ Use fixed-point notation. */
+ {
+ size_t ndigits = precision;
+ /* Number of trailing zeroes that have to be
+ dropped. */
+ size_t nzeroes =
+ (flags & FLAG_ALT ? 0 : precision - 1);
+
+ --ndigits;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = '0';
+ }
+ }
+ }
+ else
+ {
+ /* arg > 0.0L. */
+ int exponent;
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+ size_t nzeroes;
+
+ exponent = floorlog10l (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_long_double (arg,
+ (int)(precision - 1) - exponent);
+ if (digits == NULL)
+ {
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ ndigits = strlen (digits);
+
+ if (ndigits == precision)
+ break;
+ if (ndigits < precision - 1
+ || ndigits > precision + 1)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits < precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision. */
+ if (is_borderline (digits, precision - 1))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_long_double (arg,
+ (int)(precision - 1) - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision. */
+
+ /* Determine the number of trailing zeroes
+ that have to be dropped. */
+ nzeroes = 0;
+ if ((flags & FLAG_ALT) == 0)
+ while (nzeroes < ndigits
+ && digits[nzeroes] == '0')
+ nzeroes++;
+
+ /* The exponent is now determined. */
+ if (exponent >= -4
+ && exponent < (long)precision)
+ {
+ /* Fixed-point notation:
+ max(exponent,0)+1 digits, then the
+ decimal point, then the remaining
+ digits without trailing zeroes. */
+ if (exponent >= 0)
+ {
+ size_t count = exponent + 1;
+ /* Note: count <= precision = ndigits. */
+ for (; count > 0; count--)
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ size_t count = -exponent - 1;
+ *p++ = '0';
+ *p++ = decimal_point_char ();
+ for (; count > 0; count--)
+ *p++ = '0';
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ /* Exponential notation. */
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
# if WIDE_CHAR_VERSION
- {
- static const wchar_t decimal_format[] =
- { '%', '+', '.', '2', 'd', '\0' };
- SNPRINTF (p, 6 + 1, decimal_format, exponent);
- }
- while (*p != '\0')
- p++;
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', '.', '2', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
# else
- if (sizeof (DCHAR_T) == 1)
- {
- sprintf ((char *) p, "%+.2d", exponent);
- while (*p != '\0')
- p++;
- }
- else
- {
- char expbuf[6 + 1];
- const char *ep;
- sprintf (expbuf, "%+.2d", exponent);
- for (ep = expbuf; (*p = *ep) != '\0'; ep++)
- p++;
- }
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+.2d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+.2d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
# endif
- }
+ }
- free (digits);
- }
- }
- else
- abort ();
+ free (digits);
+ }
+ }
+ else
+ abort ();
# else
- /* arg is finite. */
- if (!(arg == 0.0L))
- abort ();
-
- pad_ptr = p;
-
- if (dp->conversion == 'f' || dp->conversion == 'F')
- {
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- }
- else if (dp->conversion == 'e' || dp->conversion == 'E')
- {
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- *p++ = dp->conversion; /* 'e' or 'E' */
- *p++ = '+';
- *p++ = '0';
- *p++ = '0';
- }
- else if (dp->conversion == 'g' || dp->conversion == 'G')
- {
- *p++ = '0';
- if (flags & FLAG_ALT)
- {
- size_t ndigits =
- (precision > 0 ? precision - 1 : 0);
- *p++ = decimal_point_char ();
- for (; ndigits > 0; --ndigits)
- *p++ = '0';
- }
- }
- else if (dp->conversion == 'a' || dp->conversion == 'A')
- {
- *p++ = '0';
- *p++ = dp->conversion - 'A' + 'X';
- pad_ptr = p;
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- *p++ = dp->conversion - 'A' + 'P';
- *p++ = '+';
- *p++ = '0';
- }
- else
- abort ();
+ /* arg is finite. */
+ if (!(arg == 0.0L))
+ abort ();
+
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ *p++ = dp->conversion; /* 'e' or 'E' */
+ *p++ = '+';
+ *p++ = '0';
+ *p++ = '0';
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ *p++ = '0';
+ if (flags & FLAG_ALT)
+ {
+ size_t ndigits =
+ (precision > 0 ? precision - 1 : 0);
+ *p++ = decimal_point_char ();
+ for (; ndigits > 0; --ndigits)
+ *p++ = '0';
+ }
+ }
+ else if (dp->conversion == 'a' || dp->conversion == 'A')
+ {
+ *p++ = '0';
+ *p++ = dp->conversion - 'A' + 'X';
+ pad_ptr = p;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ *p++ = dp->conversion - 'A' + 'P';
+ *p++ = '+';
+ *p++ = '0';
+ }
+ else
+ abort ();
# endif
- }
+ }
- END_LONG_DOUBLE_ROUNDING ();
- }
- }
+ END_LONG_DOUBLE_ROUNDING ();
+ }
+ }
# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
- else
+ else
# endif
# endif
# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
- {
- double arg = a.arg[dp->arg_index].a.a_double;
-
- if (isnand (arg))
- {
- if (dp->conversion >= 'A' && dp->conversion <= 'Z')
- {
- *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
- }
- else
- {
- *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
- }
- }
- else
- {
- int sign = 0;
-
- if (signbit (arg)) /* arg < 0.0 or negative zero */
- {
- sign = -1;
- arg = -arg;
- }
-
- if (sign < 0)
- *p++ = '-';
- else if (flags & FLAG_SHOWSIGN)
- *p++ = '+';
- else if (flags & FLAG_SPACE)
- *p++ = ' ';
-
- if (arg > 0.0 && arg + arg == arg)
- {
- if (dp->conversion >= 'A' && dp->conversion <= 'Z')
- {
- *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
- }
- else
- {
- *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
- }
- }
- else
- {
+ {
+ double arg = a.arg[dp->arg_index].a.a_double;
+
+ if (isnand (arg))
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+
+ if (signbit (arg)) /* arg < 0.0 or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0 && arg + arg == arg)
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
# if NEED_PRINTF_DOUBLE
- pad_ptr = p;
-
- if (dp->conversion == 'f' || dp->conversion == 'F')
- {
- char *digits;
- size_t ndigits;
-
- digits =
- scale10_round_decimal_double (arg, precision);
- if (digits == NULL)
- goto out_of_memory;
- ndigits = strlen (digits);
-
- if (ndigits > precision)
- do
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- while (ndigits > precision);
- else
- *p++ = '0';
- /* Here ndigits <= precision. */
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > ndigits; precision--)
- *p++ = '0';
- while (ndigits > 0)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
-
- free (digits);
- }
- else if (dp->conversion == 'e' || dp->conversion == 'E')
- {
- int exponent;
-
- if (arg == 0.0)
- {
- exponent = 0;
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- }
- else
- {
- /* arg > 0.0. */
- int adjusted;
- char *digits;
- size_t ndigits;
-
- exponent = floorlog10 (arg);
- adjusted = 0;
- for (;;)
- {
- digits =
- scale10_round_decimal_double (arg,
- (int)precision - exponent);
- if (digits == NULL)
- goto out_of_memory;
- ndigits = strlen (digits);
-
- if (ndigits == precision + 1)
- break;
- if (ndigits < precision
- || ndigits > precision + 2)
- /* The exponent was not guessed
- precisely enough. */
- abort ();
- if (adjusted)
- /* None of two values of exponent is
- the right one. Prevent an endless
- loop. */
- abort ();
- free (digits);
- if (ndigits == precision)
- exponent -= 1;
- else
- exponent += 1;
- adjusted = 1;
- }
- /* Here ndigits = precision+1. */
- if (is_borderline (digits, precision))
- {
- /* Maybe the exponent guess was too high
- and a smaller exponent can be reached
- by turning a 10...0 into 9...9x. */
- char *digits2 =
- scale10_round_decimal_double (arg,
- (int)precision - exponent + 1);
- if (digits2 == NULL)
- {
- free (digits);
- goto out_of_memory;
- }
- if (strlen (digits2) == precision + 1)
- {
- free (digits);
- digits = digits2;
- exponent -= 1;
- }
- else
- free (digits2);
- }
- /* Here ndigits = precision+1. */
-
- *p++ = digits[--ndigits];
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- while (ndigits > 0)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
-
- free (digits);
- }
-
- *p++ = dp->conversion; /* 'e' or 'E' */
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ char *digits;
+ size_t ndigits;
+
+ digits =
+ scale10_round_decimal_double (arg, precision);
+ if (digits == NULL)
+ goto out_of_memory;
+ ndigits = strlen (digits);
+
+ if (ndigits > precision)
+ do
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ while (ndigits > precision);
+ else
+ *p++ = '0';
+ /* Here ndigits <= precision. */
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > ndigits; precision--)
+ *p++ = '0';
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ int exponent;
+
+ if (arg == 0.0)
+ {
+ exponent = 0;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else
+ {
+ /* arg > 0.0. */
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+
+ exponent = floorlog10 (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_double (arg,
+ (int)precision - exponent);
+ if (digits == NULL)
+ goto out_of_memory;
+ ndigits = strlen (digits);
+
+ if (ndigits == precision + 1)
+ break;
+ if (ndigits < precision
+ || ndigits > precision + 2)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits == precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision+1. */
+ if (is_borderline (digits, precision))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_double (arg,
+ (int)precision - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision + 1)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision+1. */
+
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+
+ *p++ = dp->conversion; /* 'e' or 'E' */
# if WIDE_CHAR_VERSION
- {
- static const wchar_t decimal_format[] =
- /* Produce the same number of exponent digits
- as the native printf implementation. */
+ {
+ static const wchar_t decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- { '%', '+', '.', '3', 'd', '\0' };
+ { '%', '+', '.', '3', 'd', '\0' };
# else
- { '%', '+', '.', '2', 'd', '\0' };
+ { '%', '+', '.', '2', 'd', '\0' };
# endif
- SNPRINTF (p, 6 + 1, decimal_format, exponent);
- }
- while (*p != '\0')
- p++;
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
# else
- {
- static const char decimal_format[] =
- /* Produce the same number of exponent digits
- as the native printf implementation. */
+ {
+ static const char decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- "%+.3d";
+ "%+.3d";
# else
- "%+.2d";
+ "%+.2d";
# endif
- if (sizeof (DCHAR_T) == 1)
- {
- sprintf ((char *) p, decimal_format, exponent);
- while (*p != '\0')
- p++;
- }
- else
- {
- char expbuf[6 + 1];
- const char *ep;
- sprintf (expbuf, decimal_format, exponent);
- for (ep = expbuf; (*p = *ep) != '\0'; ep++)
- p++;
- }
- }
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, decimal_format, exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, decimal_format, exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+ }
# endif
- }
- else if (dp->conversion == 'g' || dp->conversion == 'G')
- {
- if (precision == 0)
- precision = 1;
- /* precision >= 1. */
-
- if (arg == 0.0)
- /* The exponent is 0, >= -4, < precision.
- Use fixed-point notation. */
- {
- size_t ndigits = precision;
- /* Number of trailing zeroes that have to be
- dropped. */
- size_t nzeroes =
- (flags & FLAG_ALT ? 0 : precision - 1);
-
- --ndigits;
- *p++ = '0';
- if ((flags & FLAG_ALT) || ndigits > nzeroes)
- {
- *p++ = decimal_point_char ();
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = '0';
- }
- }
- }
- else
- {
- /* arg > 0.0. */
- int exponent;
- int adjusted;
- char *digits;
- size_t ndigits;
- size_t nzeroes;
-
- exponent = floorlog10 (arg);
- adjusted = 0;
- for (;;)
- {
- digits =
- scale10_round_decimal_double (arg,
- (int)(precision - 1) - exponent);
- if (digits == NULL)
- goto out_of_memory;
- ndigits = strlen (digits);
-
- if (ndigits == precision)
- break;
- if (ndigits < precision - 1
- || ndigits > precision + 1)
- /* The exponent was not guessed
- precisely enough. */
- abort ();
- if (adjusted)
- /* None of two values of exponent is
- the right one. Prevent an endless
- loop. */
- abort ();
- free (digits);
- if (ndigits < precision)
- exponent -= 1;
- else
- exponent += 1;
- adjusted = 1;
- }
- /* Here ndigits = precision. */
- if (is_borderline (digits, precision - 1))
- {
- /* Maybe the exponent guess was too high
- and a smaller exponent can be reached
- by turning a 10...0 into 9...9x. */
- char *digits2 =
- scale10_round_decimal_double (arg,
- (int)(precision - 1) - exponent + 1);
- if (digits2 == NULL)
- {
- free (digits);
- goto out_of_memory;
- }
- if (strlen (digits2) == precision)
- {
- free (digits);
- digits = digits2;
- exponent -= 1;
- }
- else
- free (digits2);
- }
- /* Here ndigits = precision. */
-
- /* Determine the number of trailing zeroes
- that have to be dropped. */
- nzeroes = 0;
- if ((flags & FLAG_ALT) == 0)
- while (nzeroes < ndigits
- && digits[nzeroes] == '0')
- nzeroes++;
-
- /* The exponent is now determined. */
- if (exponent >= -4
- && exponent < (long)precision)
- {
- /* Fixed-point notation:
- max(exponent,0)+1 digits, then the
- decimal point, then the remaining
- digits without trailing zeroes. */
- if (exponent >= 0)
- {
- size_t count = exponent + 1;
- /* Note: count <= precision = ndigits. */
- for (; count > 0; count--)
- *p++ = digits[--ndigits];
- if ((flags & FLAG_ALT) || ndigits > nzeroes)
- {
- *p++ = decimal_point_char ();
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
- }
- else
- {
- size_t count = -exponent - 1;
- *p++ = '0';
- *p++ = decimal_point_char ();
- for (; count > 0; count--)
- *p++ = '0';
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
- }
- else
- {
- /* Exponential notation. */
- *p++ = digits[--ndigits];
- if ((flags & FLAG_ALT) || ndigits > nzeroes)
- {
- *p++ = decimal_point_char ();
- while (ndigits > nzeroes)
- {
- --ndigits;
- *p++ = digits[ndigits];
- }
- }
- *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ if (precision == 0)
+ precision = 1;
+ /* precision >= 1. */
+
+ if (arg == 0.0)
+ /* The exponent is 0, >= -4, < precision.
+ Use fixed-point notation. */
+ {
+ size_t ndigits = precision;
+ /* Number of trailing zeroes that have to be
+ dropped. */
+ size_t nzeroes =
+ (flags & FLAG_ALT ? 0 : precision - 1);
+
+ --ndigits;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = '0';
+ }
+ }
+ }
+ else
+ {
+ /* arg > 0.0. */
+ int exponent;
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+ size_t nzeroes;
+
+ exponent = floorlog10 (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_double (arg,
+ (int)(precision - 1) - exponent);
+ if (digits == NULL)
+ goto out_of_memory;
+ ndigits = strlen (digits);
+
+ if (ndigits == precision)
+ break;
+ if (ndigits < precision - 1
+ || ndigits > precision + 1)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits < precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision. */
+ if (is_borderline (digits, precision - 1))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_double (arg,
+ (int)(precision - 1) - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision. */
+
+ /* Determine the number of trailing zeroes
+ that have to be dropped. */
+ nzeroes = 0;
+ if ((flags & FLAG_ALT) == 0)
+ while (nzeroes < ndigits
+ && digits[nzeroes] == '0')
+ nzeroes++;
+
+ /* The exponent is now determined. */
+ if (exponent >= -4
+ && exponent < (long)precision)
+ {
+ /* Fixed-point notation:
+ max(exponent,0)+1 digits, then the
+ decimal point, then the remaining
+ digits without trailing zeroes. */
+ if (exponent >= 0)
+ {
+ size_t count = exponent + 1;
+ /* Note: count <= precision = ndigits. */
+ for (; count > 0; count--)
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ size_t count = -exponent - 1;
+ *p++ = '0';
+ *p++ = decimal_point_char ();
+ for (; count > 0; count--)
+ *p++ = '0';
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ /* Exponential notation. */
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
# if WIDE_CHAR_VERSION
- {
- static const wchar_t decimal_format[] =
- /* Produce the same number of exponent digits
- as the native printf implementation. */
+ {
+ static const wchar_t decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- { '%', '+', '.', '3', 'd', '\0' };
+ { '%', '+', '.', '3', 'd', '\0' };
# else
- { '%', '+', '.', '2', 'd', '\0' };
+ { '%', '+', '.', '2', 'd', '\0' };
# endif
- SNPRINTF (p, 6 + 1, decimal_format, exponent);
- }
- while (*p != '\0')
- p++;
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
# else
- {
- static const char decimal_format[] =
- /* Produce the same number of exponent digits
- as the native printf implementation. */
+ {
+ static const char decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- "%+.3d";
+ "%+.3d";
# else
- "%+.2d";
+ "%+.2d";
# endif
- if (sizeof (DCHAR_T) == 1)
- {
- sprintf ((char *) p, decimal_format, exponent);
- while (*p != '\0')
- p++;
- }
- else
- {
- char expbuf[6 + 1];
- const char *ep;
- sprintf (expbuf, decimal_format, exponent);
- for (ep = expbuf; (*p = *ep) != '\0'; ep++)
- p++;
- }
- }
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, decimal_format, exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, decimal_format, exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+ }
# endif
- }
+ }
- free (digits);
- }
- }
- else
- abort ();
+ free (digits);
+ }
+ }
+ else
+ abort ();
# else
- /* arg is finite. */
- if (!(arg == 0.0))
- abort ();
-
- pad_ptr = p;
-
- if (dp->conversion == 'f' || dp->conversion == 'F')
- {
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- }
- else if (dp->conversion == 'e' || dp->conversion == 'E')
- {
- *p++ = '0';
- if ((flags & FLAG_ALT) || precision > 0)
- {
- *p++ = decimal_point_char ();
- for (; precision > 0; precision--)
- *p++ = '0';
- }
- *p++ = dp->conversion; /* 'e' or 'E' */
- *p++ = '+';
- /* Produce the same number of exponent digits as
- the native printf implementation. */
+ /* arg is finite. */
+ if (!(arg == 0.0))
+ abort ();
+
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ *p++ = dp->conversion; /* 'e' or 'E' */
+ *p++ = '+';
+ /* Produce the same number of exponent digits as
+ the native printf implementation. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- *p++ = '0';
+ *p++ = '0';
# endif
- *p++ = '0';
- *p++ = '0';
- }
- else if (dp->conversion == 'g' || dp->conversion == 'G')
- {
- *p++ = '0';
- if (flags & FLAG_ALT)
- {
- size_t ndigits =
- (precision > 0 ? precision - 1 : 0);
- *p++ = decimal_point_char ();
- for (; ndigits > 0; --ndigits)
- *p++ = '0';
- }
- }
- else
- abort ();
+ *p++ = '0';
+ *p++ = '0';
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ *p++ = '0';
+ if (flags & FLAG_ALT)
+ {
+ size_t ndigits =
+ (precision > 0 ? precision - 1 : 0);
+ *p++ = decimal_point_char ();
+ for (; ndigits > 0; --ndigits)
+ *p++ = '0';
+ }
+ }
+ else
+ abort ();
# endif
- }
- }
- }
+ }
+ }
+ }
# endif
- /* The generated string now extends from tmp to p, with the
- zero padding insertion point being at pad_ptr. */
- if (has_width && p - tmp < width)
- {
- size_t pad = width - (p - tmp);
- DCHAR_T *end = p + pad;
-
- if (flags & FLAG_LEFT)
- {
- /* Pad with spaces on the right. */
- for (; pad > 0; pad--)
- *p++ = ' ';
- }
- else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
- {
- /* Pad with zeroes. */
- DCHAR_T *q = end;
-
- while (p > pad_ptr)
- *--q = *--p;
- for (; pad > 0; pad--)
- *p++ = '0';
- }
- else
- {
- /* Pad with spaces on the left. */
- DCHAR_T *q = end;
-
- while (p > tmp)
- *--q = *--p;
- for (; pad > 0; pad--)
- *p++ = ' ';
- }
-
- p = end;
- }
-
- {
- size_t count = p - tmp;
-
- if (count >= tmp_length)
- /* tmp_length was incorrectly calculated - fix the
- code above! */
- abort ();
-
- /* Make room for the result. */
- if (count >= allocated - length)
- {
- size_t n = xsum (length, count);
-
- ENSURE_ALLOCATION (n);
- }
-
- /* Append the result. */
- memcpy (result + length, tmp, count * sizeof (DCHAR_T));
- if (tmp != tmpbuf)
- free (tmp);
- length += count;
- }
- }
+ /* The generated string now extends from tmp to p, with the
+ zero padding insertion point being at pad_ptr. */
+ if (has_width && p - tmp < width)
+ {
+ size_t pad = width - (p - tmp);
+ DCHAR_T *end = p + pad;
+
+ if (flags & FLAG_LEFT)
+ {
+ /* Pad with spaces on the right. */
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+ {
+ /* Pad with zeroes. */
+ DCHAR_T *q = end;
+
+ while (p > pad_ptr)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = '0';
+ }
+ else
+ {
+ /* Pad with spaces on the left. */
+ DCHAR_T *q = end;
+
+ while (p > tmp)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+
+ p = end;
+ }
+
+ {
+ size_t count = p - tmp;
+
+ if (count >= tmp_length)
+ /* tmp_length was incorrectly calculated - fix the
+ code above! */
+ abort ();
+
+ /* Make room for the result. */
+ if (count >= allocated - length)
+ {
+ size_t n = xsum (length, count);
+
+ ENSURE_ALLOCATION (n);
+ }
+
+ /* Append the result. */
+ memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+ if (tmp != tmpbuf)
+ free (tmp);
+ length += count;
+ }
+ }
#endif
- else
- {
- arg_type type = a.arg[dp->arg_index].type;
- int flags = dp->flags;
+ else
+ {
+ arg_type type = a.arg[dp->arg_index].type;
+ int flags = dp->flags;
#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
- int has_width;
- size_t width;
+ int has_width;
+ size_t width;
#endif
#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
- int has_precision;
- size_t precision;
+ int has_precision;
+ size_t precision;
#endif
#if NEED_PRINTF_UNBOUNDED_PRECISION
- int prec_ourselves;
+ int prec_ourselves;
#else
-# define prec_ourselves 0
+# define prec_ourselves 0
#endif
#if NEED_PRINTF_FLAG_LEFTADJUST
-# define pad_ourselves 1
+# define pad_ourselves 1
#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
- int pad_ourselves;
+ int pad_ourselves;
#else
-# define pad_ourselves 0
+# define pad_ourselves 0
#endif
- TCHAR_T *fbp;
- unsigned int prefix_count;
- int prefixes[2] IF_LINT (= { 0 });
+ TCHAR_T *fbp;
+ unsigned int prefix_count;
+ int prefixes[2] IF_LINT (= { 0 });
#if !USE_SNPRINTF
- size_t tmp_length;
- TCHAR_T tmpbuf[700];
- TCHAR_T *tmp;
+ size_t tmp_length;
+ TCHAR_T tmpbuf[700];
+ TCHAR_T *tmp;
#endif
#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
- has_width = 0;
- width = 0;
- if (dp->width_start != dp->width_end)
- {
- if (dp->width_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->width_arg_index].a.a_int;
- if (arg < 0)
- {
- /* "A negative field width is taken as a '-' flag
- followed by a positive field width." */
- flags |= FLAG_LEFT;
- width = (unsigned int) (-arg);
- }
- else
- width = arg;
- }
- else
- {
- const FCHAR_T *digitp = dp->width_start;
-
- do
- width = xsum (xtimes (width, 10), *digitp++ - '0');
- while (digitp != dp->width_end);
- }
- has_width = 1;
- }
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = (unsigned int) (-arg);
+ }
+ else
+ width = arg;
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
#endif
#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
- has_precision = 0;
- precision = 6;
- if (dp->precision_start != dp->precision_end)
- {
- if (dp->precision_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->precision_arg_index].a.a_int;
- /* "A negative precision is taken as if the precision
- were omitted." */
- if (arg >= 0)
- {
- precision = arg;
- has_precision = 1;
- }
- }
- else
- {
- const FCHAR_T *digitp = dp->precision_start + 1;
-
- precision = 0;
- while (digitp != dp->precision_end)
- precision = xsum (xtimes (precision, 10), *digitp++ - '0');
- has_precision = 1;
- }
- }
+ has_precision = 0;
+ precision = 6;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
#endif
- /* Decide whether to handle the precision ourselves. */
+ /* Decide whether to handle the precision ourselves. */
#if NEED_PRINTF_UNBOUNDED_PRECISION
- switch (dp->conversion)
- {
- case 'd': case 'i': case 'u':
- case 'o':
- case 'x': case 'X': case 'p':
- prec_ourselves = has_precision && (precision > 0);
- break;
- default:
- prec_ourselves = 0;
- break;
- }
+ switch (dp->conversion)
+ {
+ case 'd': case 'i': case 'u':
+ case 'o':
+ case 'x': case 'X': case 'p':
+ prec_ourselves = has_precision && (precision > 0);
+ break;
+ default:
+ prec_ourselves = 0;
+ break;
+ }
#endif
- /* Decide whether to perform the padding ourselves. */
+ /* Decide whether to perform the padding ourselves. */
#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
- switch (dp->conversion)
- {
+ switch (dp->conversion)
+ {
# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
- /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
- to perform the padding after this conversion. Functions
- with unistdio extensions perform the padding based on
- character count rather than element count. */
- case 'c': case 's':
+ /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
+ to perform the padding after this conversion. Functions
+ with unistdio extensions perform the padding based on
+ character count rather than element count. */
+ case 'c': case 's':
# endif
# if NEED_PRINTF_FLAG_ZERO
- case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
- case 'a': case 'A':
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+ case 'a': case 'A':
# endif
- pad_ourselves = 1;
- break;
- default:
- pad_ourselves = prec_ourselves;
- break;
- }
+ pad_ourselves = 1;
+ break;
+ default:
+ pad_ourselves = prec_ourselves;
+ break;
+ }
#endif
#if !USE_SNPRINTF
- /* Allocate a temporary buffer of sufficient size for calling
- sprintf. */
- {
- switch (dp->conversion)
- {
+ /* Allocate a temporary buffer of sufficient size for calling
+ sprintf. */
+ {
+ switch (dp->conversion)
+ {
- case 'd': case 'i': case 'u':
+ case 'd': case 'i': case 'u':
# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- else
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Multiply by 2, as an estimate for FLAG_GROUP. */
- tmp_length = xsum (tmp_length, tmp_length);
- /* Add 1, to account for a leading sign. */
- tmp_length = xsum (tmp_length, 1);
- break;
-
- case 'o':
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Multiply by 2, as an estimate for FLAG_GROUP. */
+ tmp_length = xsum (tmp_length, tmp_length);
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'o':
# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- else
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Add 1, to account for a leading sign. */
- tmp_length = xsum (tmp_length, 1);
- break;
-
- case 'x': case 'X':
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'x': case 'X':
# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Add 2, to account for a leading sign or alternate form. */
- tmp_length = xsum (tmp_length, 2);
- break;
-
- case 'f': case 'F':
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- else
- tmp_length =
- (unsigned int) (DBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'e': case 'E': case 'g': case 'G':
- tmp_length =
- 12; /* sign, decimal point, exponent etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'a': case 'A':
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_DIG
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (DBL_DIG
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Account for sign, decimal point etc. */
- tmp_length = xsum (tmp_length, 12);
- break;
-
- case 'c':
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 2, to account for a leading sign or alternate form. */
+ tmp_length = xsum (tmp_length, 2);
+ break;
+
+ case 'f': case 'F':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ else
+ tmp_length =
+ (unsigned int) (DBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'e': case 'E': case 'g': case 'G':
+ tmp_length =
+ 12; /* sign, decimal point, exponent etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'a': case 'A':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (DBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+ break;
+
+ case 'c':
# if HAVE_WINT_T && !WIDE_CHAR_VERSION
- if (type == TYPE_WIDE_CHAR)
- tmp_length = MB_CUR_MAX;
- else
+ if (type == TYPE_WIDE_CHAR)
+ tmp_length = MB_CUR_MAX;
+ else
# endif
- tmp_length = 1;
- break;
+ tmp_length = 1;
+ break;
- case 's':
+ case 's':
# if HAVE_WCHAR_T
- if (type == TYPE_WIDE_STRING)
- {
+ if (type == TYPE_WIDE_STRING)
+ {
# if WIDE_CHAR_VERSION
- /* ISO C says about %ls in fwprintf:
- "If the precision is not specified or is greater
- than the size of the array, the array shall
- contain a null wide character."
- So if there is a precision, we must not use
- wcslen. */
- const wchar_t *arg =
- a.arg[dp->arg_index].a.a_wide_string;
-
- if (has_precision)
- tmp_length = local_wcsnlen (arg, precision);
- else
- tmp_length = local_wcslen (arg);
+ /* ISO C says about %ls in fwprintf:
+ "If the precision is not specified or is greater
+ than the size of the array, the array shall
+ contain a null wide character."
+ So if there is a precision, we must not use
+ wcslen. */
+ const wchar_t *arg =
+ a.arg[dp->arg_index].a.a_wide_string;
+
+ if (has_precision)
+ tmp_length = local_wcsnlen (arg, precision);
+ else
+ tmp_length = local_wcslen (arg);
# else
- /* ISO C says about %ls in fprintf:
- "If a precision is specified, no more than that
- many bytes are written (including shift
- sequences, if any), and the array shall contain
- a null wide character if, to equal the
- multibyte character sequence length given by
- the precision, the function would need to
- access a wide character one past the end of the
- array."
- So if there is a precision, we must not use
- wcslen. */
- /* This case has already been handled above. */
- abort ();
+ /* ISO C says about %ls in fprintf:
+ "If a precision is specified, no more than that
+ many bytes are written (including shift
+ sequences, if any), and the array shall contain
+ a null wide character if, to equal the
+ multibyte character sequence length given by
+ the precision, the function would need to
+ access a wide character one past the end of the
+ array."
+ So if there is a precision, we must not use
+ wcslen. */
+ /* This case has already been handled above. */
+ abort ();
# endif
- }
- else
+ }
+ else
# endif
- {
+ {
# if WIDE_CHAR_VERSION
- /* ISO C says about %s in fwprintf:
- "If the precision is not specified or is greater
- than the size of the converted array, the
- converted array shall contain a null wide
- character."
- So if there is a precision, we must not use
- strlen. */
- /* This case has already been handled above. */
- abort ();
+ /* ISO C says about %s in fwprintf:
+ "If the precision is not specified or is greater
+ than the size of the converted array, the
+ converted array shall contain a null wide
+ character."
+ So if there is a precision, we must not use
+ strlen. */
+ /* This case has already been handled above. */
+ abort ();
# else
- /* ISO C says about %s in fprintf:
- "If the precision is not specified or greater
- than the size of the array, the array shall
- contain a null character."
- So if there is a precision, we must not use
- strlen. */
- const char *arg = a.arg[dp->arg_index].a.a_string;
-
- if (has_precision)
- tmp_length = local_strnlen (arg, precision);
- else
- tmp_length = strlen (arg);
+ /* ISO C says about %s in fprintf:
+ "If the precision is not specified or greater
+ than the size of the array, the array shall
+ contain a null character."
+ So if there is a precision, we must not use
+ strlen. */
+ const char *arg = a.arg[dp->arg_index].a.a_string;
+
+ if (has_precision)
+ tmp_length = local_strnlen (arg, precision);
+ else
+ tmp_length = strlen (arg);
# endif
- }
- break;
-
- case 'p':
- tmp_length =
- (unsigned int) (sizeof (void *) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading 0x */
- break;
-
- default:
- abort ();
- }
-
- if (!pad_ourselves)
- {
+ }
+ break;
+
+ case 'p':
+ tmp_length =
+ (unsigned int) (sizeof (void *) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1 /* turn floor into ceil */
+ + 2; /* account for leading 0x */
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (!pad_ourselves)
+ {
# if ENABLE_UNISTDIO
- /* Padding considers the number of characters, therefore
- the number of elements after padding may be
- > max (tmp_length, width)
- but is certainly
- <= tmp_length + width. */
- tmp_length = xsum (tmp_length, width);
+ /* Padding considers the number of characters, therefore
+ the number of elements after padding may be
+ > max (tmp_length, width)
+ but is certainly
+ <= tmp_length + width. */
+ tmp_length = xsum (tmp_length, width);
# else
- /* Padding considers the number of elements,
- says POSIX. */
- if (tmp_length < width)
- tmp_length = width;
+ /* Padding considers the number of elements,
+ says POSIX. */
+ if (tmp_length < width)
+ tmp_length = width;
# endif
- }
-
- tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
- }
-
- if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
- tmp = tmpbuf;
- else
- {
- size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T));
-
- if (size_overflow_p (tmp_memsize))
- /* Overflow, would lead to out of memory. */
- goto out_of_memory;
- tmp = (TCHAR_T *) malloc (tmp_memsize);
- if (tmp == NULL)
- /* Out of memory. */
- goto out_of_memory;
- }
+ }
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+ }
+
+ if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
+ tmp = tmpbuf;
+ else
+ {
+ size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T));
+
+ if (size_overflow_p (tmp_memsize))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ tmp = (TCHAR_T *) malloc (tmp_memsize);
+ if (tmp == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ }
#endif
- /* Construct the format string for calling snprintf or
- sprintf. */
- fbp = buf;
- *fbp++ = '%';
+ /* Construct the format string for calling snprintf or
+ sprintf. */
+ fbp = buf;
+ *fbp++ = '%';
#if NEED_PRINTF_FLAG_GROUPING
- /* The underlying implementation doesn't support the ' flag.
- Produce no grouping characters in this case; this is
- acceptable because the grouping is locale dependent. */
+ /* The underlying implementation doesn't support the ' flag.
+ Produce no grouping characters in this case; this is
+ acceptable because the grouping is locale dependent. */
#else
- if (flags & FLAG_GROUP)
- *fbp++ = '\'';
+ if (flags & FLAG_GROUP)
+ *fbp++ = '\'';
#endif
- if (flags & FLAG_LEFT)
- *fbp++ = '-';
- if (flags & FLAG_SHOWSIGN)
- *fbp++ = '+';
- if (flags & FLAG_SPACE)
- *fbp++ = ' ';
- if (flags & FLAG_ALT)
- *fbp++ = '#';
- if (!pad_ourselves)
- {
- if (flags & FLAG_ZERO)
- *fbp++ = '0';
- if (dp->width_start != dp->width_end)
- {
- size_t n = dp->width_end - dp->width_start;
- /* The width specification is known to consist only
- of standard ASCII characters. */
- if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
- {
- memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T));
- fbp += n;
- }
- else
- {
- const FCHAR_T *mp = dp->width_start;
- do
- *fbp++ = (unsigned char) *mp++;
- while (--n > 0);
- }
- }
- }
- if (!prec_ourselves)
- {
- if (dp->precision_start != dp->precision_end)
- {
- size_t n = dp->precision_end - dp->precision_start;
- /* The precision specification is known to consist only
- of standard ASCII characters. */
- if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
- {
- memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T));
- fbp += n;
- }
- else
- {
- const FCHAR_T *mp = dp->precision_start;
- do
- *fbp++ = (unsigned char) *mp++;
- while (--n > 0);
- }
- }
- }
-
- switch (type)
- {
+ if (flags & FLAG_LEFT)
+ *fbp++ = '-';
+ if (flags & FLAG_SHOWSIGN)
+ *fbp++ = '+';
+ if (flags & FLAG_SPACE)
+ *fbp++ = ' ';
+ if (flags & FLAG_ALT)
+ *fbp++ = '#';
+ if (!pad_ourselves)
+ {
+ if (flags & FLAG_ZERO)
+ *fbp++ = '0';
+ if (dp->width_start != dp->width_end)
+ {
+ size_t n = dp->width_end - dp->width_start;
+ /* The width specification is known to consist only
+ of standard ASCII characters. */
+ if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
+ {
+ memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T));
+ fbp += n;
+ }
+ else
+ {
+ const FCHAR_T *mp = dp->width_start;
+ do
+ *fbp++ = (unsigned char) *mp++;
+ while (--n > 0);
+ }
+ }
+ }
+ if (!prec_ourselves)
+ {
+ if (dp->precision_start != dp->precision_end)
+ {
+ size_t n = dp->precision_end - dp->precision_start;
+ /* The precision specification is known to consist only
+ of standard ASCII characters. */
+ if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
+ {
+ memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T));
+ fbp += n;
+ }
+ else
+ {
+ const FCHAR_T *mp = dp->precision_start;
+ do
+ *fbp++ = (unsigned char) *mp++;
+ while (--n > 0);
+ }
+ }
+ }
+
+ switch (type)
+ {
#if HAVE_LONG_LONG_INT
- case TYPE_LONGLONGINT:
- case TYPE_ULONGLONGINT:
+ case TYPE_LONGLONGINT:
+ case TYPE_ULONGLONGINT:
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- *fbp++ = 'I';
- *fbp++ = '6';
- *fbp++ = '4';
- break;
+ *fbp++ = 'I';
+ *fbp++ = '6';
+ *fbp++ = '4';
+ break;
# else
- *fbp++ = 'l';
- /*FALLTHROUGH*/
+ *fbp++ = 'l';
+ /*FALLTHROUGH*/
# endif
#endif
- case TYPE_LONGINT:
- case TYPE_ULONGINT:
+ case TYPE_LONGINT:
+ case TYPE_ULONGINT:
#if HAVE_WINT_T
- case TYPE_WIDE_CHAR:
+ case TYPE_WIDE_CHAR:
#endif
#if HAVE_WCHAR_T
- case TYPE_WIDE_STRING:
+ case TYPE_WIDE_STRING:
#endif
- *fbp++ = 'l';
- break;
- case TYPE_LONGDOUBLE:
- *fbp++ = 'L';
- break;
- default:
- break;
- }
+ *fbp++ = 'l';
+ break;
+ case TYPE_LONGDOUBLE:
+ *fbp++ = 'L';
+ break;
+ default:
+ break;
+ }
#if NEED_PRINTF_DIRECTIVE_F
- if (dp->conversion == 'F')
- *fbp = 'f';
- else
+ if (dp->conversion == 'F')
+ *fbp = 'f';
+ else
#endif
- *fbp = dp->conversion;
+ *fbp = dp->conversion;
#if USE_SNPRINTF
# if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
- fbp[1] = '%';
- fbp[2] = 'n';
- fbp[3] = '\0';
+ fbp[1] = '%';
+ fbp[2] = 'n';
+ fbp[3] = '\0';
# else
- /* On glibc2 systems from glibc >= 2.3 - probably also older
- ones - we know that snprintf's returns value conforms to
- ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes.
- Therefore we can avoid using %n in this situation.
- On glibc2 systems from 2004-10-18 or newer, the use of %n
- in format strings in writable memory may crash the program
- (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
- in this situation. */
- /* On native Win32 systems (such as mingw), we can avoid using
- %n because:
- - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
- snprintf does not write more than the specified number
- of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
- '4', '5', '6' into buf, not '4', '5', '\0'.)
- - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
- allows us to recognize the case of an insufficient
- buffer size: it returns -1 in this case.
- On native Win32 systems (such as mingw) where the OS is
- Windows Vista, the use of %n in format strings by default
- crashes the program. See
- <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
- <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
- So we should avoid %n in this situation. */
- fbp[1] = '\0';
+ /* On glibc2 systems from glibc >= 2.3 - probably also older
+ ones - we know that snprintf's returns value conforms to
+ ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes.
+ Therefore we can avoid using %n in this situation.
+ On glibc2 systems from 2004-10-18 or newer, the use of %n
+ in format strings in writable memory may crash the program
+ (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
+ in this situation. */
+ /* On native Win32 systems (such as mingw), we can avoid using
+ %n because:
+ - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
+ snprintf does not write more than the specified number
+ of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
+ '4', '5', '6' into buf, not '4', '5', '\0'.)
+ - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
+ allows us to recognize the case of an insufficient
+ buffer size: it returns -1 in this case.
+ On native Win32 systems (such as mingw) where the OS is
+ Windows Vista, the use of %n in format strings by default
+ crashes the program. See
+ <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+ <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
+ So we should avoid %n in this situation. */
+ fbp[1] = '\0';
# endif
#else
- fbp[1] = '\0';
+ fbp[1] = '\0';
#endif
- /* Construct the arguments for calling snprintf or sprintf. */
- prefix_count = 0;
- if (!pad_ourselves && dp->width_arg_index != ARG_NONE)
- {
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
- }
- if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
- {
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
- }
+ /* Construct the arguments for calling snprintf or sprintf. */
+ prefix_count = 0;
+ if (!pad_ourselves && dp->width_arg_index != ARG_NONE)
+ {
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
+ }
+ if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
+ {
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
+ }
#if USE_SNPRINTF
- /* The SNPRINTF result is appended after result[0..length].
- The latter is an array of DCHAR_T; SNPRINTF appends an
- array of TCHAR_T to it. This is possible because
- sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
- alignof (TCHAR_T) <= alignof (DCHAR_T). */
+ /* The SNPRINTF result is appended after result[0..length].
+ The latter is an array of DCHAR_T; SNPRINTF appends an
+ array of TCHAR_T to it. This is possible because
+ sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
+ alignof (TCHAR_T) <= alignof (DCHAR_T). */
# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T))
- /* Ensure that maxlen below will be >= 2. Needed on BeOS,
- where an snprintf() with maxlen==1 acts like sprintf(). */
- ENSURE_ALLOCATION (xsum (length,
- (2 + TCHARS_PER_DCHAR - 1)
- / TCHARS_PER_DCHAR));
- /* Prepare checking whether snprintf returns the count
- via %n. */
- *(TCHAR_T *) (result + length) = '\0';
+ /* Ensure that maxlen below will be >= 2. Needed on BeOS,
+ where an snprintf() with maxlen==1 acts like sprintf(). */
+ ENSURE_ALLOCATION (xsum (length,
+ (2 + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR));
+ /* Prepare checking whether snprintf returns the count
+ via %n. */
+ *(TCHAR_T *) (result + length) = '\0';
#endif
- for (;;)
- {
- int count = -1;
+ for (;;)
+ {
+ int count = -1;
#if USE_SNPRINTF
- int retcount = 0;
- size_t maxlen = allocated - length;
- /* SNPRINTF can fail if its second argument is
- > INT_MAX. */
- if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
- maxlen = INT_MAX / TCHARS_PER_DCHAR;
- maxlen = maxlen * TCHARS_PER_DCHAR;
+ int retcount = 0;
+ size_t maxlen = allocated - length;
+ /* SNPRINTF can fail if its second argument is
+ > INT_MAX. */
+ if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
+ maxlen = INT_MAX / TCHARS_PER_DCHAR;
+ maxlen = maxlen * TCHARS_PER_DCHAR;
# define SNPRINTF_BUF(arg) \
- switch (prefix_count) \
- { \
- case 0: \
- retcount = SNPRINTF ((TCHAR_T *) (result + length), \
- maxlen, buf, \
- arg, &count); \
- break; \
- case 1: \
- retcount = SNPRINTF ((TCHAR_T *) (result + length), \
- maxlen, buf, \
- prefixes[0], arg, &count); \
- break; \
- case 2: \
- retcount = SNPRINTF ((TCHAR_T *) (result + length), \
- maxlen, buf, \
- prefixes[0], prefixes[1], arg, \
- &count); \
- break; \
- default: \
- abort (); \
- }
+ switch (prefix_count) \
+ { \
+ case 0: \
+ retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+ maxlen, buf, \
+ arg, &count); \
+ break; \
+ case 1: \
+ retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+ maxlen, buf, \
+ prefixes[0], arg, &count); \
+ break; \
+ case 2: \
+ retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+ maxlen, buf, \
+ prefixes[0], prefixes[1], arg, \
+ &count); \
+ break; \
+ default: \
+ abort (); \
+ }
#else
# define SNPRINTF_BUF(arg) \
- switch (prefix_count) \
- { \
- case 0: \
- count = sprintf (tmp, buf, arg); \
- break; \
- case 1: \
- count = sprintf (tmp, buf, prefixes[0], arg); \
- break; \
- case 2: \
- count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
- arg); \
- break; \
- default: \
- abort (); \
- }
+ switch (prefix_count) \
+ { \
+ case 0: \
+ count = sprintf (tmp, buf, arg); \
+ break; \
+ case 1: \
+ count = sprintf (tmp, buf, prefixes[0], arg); \
+ break; \
+ case 2: \
+ count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
+ arg); \
+ break; \
+ default: \
+ abort (); \
+ }
#endif
- switch (type)
- {
- case TYPE_SCHAR:
- {
- int arg = a.arg[dp->arg_index].a.a_schar;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_UCHAR:
- {
- unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_SHORT:
- {
- int arg = a.arg[dp->arg_index].a.a_short;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_USHORT:
- {
- unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_INT:
- {
- int arg = a.arg[dp->arg_index].a.a_int;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_UINT:
- {
- unsigned int arg = a.arg[dp->arg_index].a.a_uint;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_LONGINT:
- {
- long int arg = a.arg[dp->arg_index].a.a_longint;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_ULONGINT:
- {
- unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
- SNPRINTF_BUF (arg);
- }
- break;
+ switch (type)
+ {
+ case TYPE_SCHAR:
+ {
+ int arg = a.arg[dp->arg_index].a.a_schar;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_UCHAR:
+ {
+ unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_SHORT:
+ {
+ int arg = a.arg[dp->arg_index].a.a_short;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_USHORT:
+ {
+ unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_INT:
+ {
+ int arg = a.arg[dp->arg_index].a.a_int;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_UINT:
+ {
+ unsigned int arg = a.arg[dp->arg_index].a.a_uint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_LONGINT:
+ {
+ long int arg = a.arg[dp->arg_index].a.a_longint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_ULONGINT:
+ {
+ unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
#if HAVE_LONG_LONG_INT
- case TYPE_LONGLONGINT:
- {
- long long int arg = a.arg[dp->arg_index].a.a_longlongint;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_ULONGLONGINT:
- {
- unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
- SNPRINTF_BUF (arg);
- }
- break;
+ case TYPE_LONGLONGINT:
+ {
+ long long int arg = a.arg[dp->arg_index].a.a_longlongint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_ULONGLONGINT:
+ {
+ unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
#endif
- case TYPE_DOUBLE:
- {
- double arg = a.arg[dp->arg_index].a.a_double;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_LONGDOUBLE:
- {
- long double arg = a.arg[dp->arg_index].a.a_longdouble;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_CHAR:
- {
- int arg = a.arg[dp->arg_index].a.a_char;
- SNPRINTF_BUF (arg);
- }
- break;
+ case TYPE_DOUBLE:
+ {
+ double arg = a.arg[dp->arg_index].a.a_double;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_LONGDOUBLE:
+ {
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_CHAR:
+ {
+ int arg = a.arg[dp->arg_index].a.a_char;
+ SNPRINTF_BUF (arg);
+ }
+ break;
#if HAVE_WINT_T
- case TYPE_WIDE_CHAR:
- {
- wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
- SNPRINTF_BUF (arg);
- }
- break;
+ case TYPE_WIDE_CHAR:
+ {
+ wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
+ SNPRINTF_BUF (arg);
+ }
+ break;
#endif
- case TYPE_STRING:
- {
- const char *arg = a.arg[dp->arg_index].a.a_string;
- SNPRINTF_BUF (arg);
- }
- break;
+ case TYPE_STRING:
+ {
+ const char *arg = a.arg[dp->arg_index].a.a_string;
+ SNPRINTF_BUF (arg);
+ }
+ break;
#if HAVE_WCHAR_T
- case TYPE_WIDE_STRING:
- {
- const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
- SNPRINTF_BUF (arg);
- }
- break;
+ case TYPE_WIDE_STRING:
+ {
+ const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+ SNPRINTF_BUF (arg);
+ }
+ break;
#endif
- case TYPE_POINTER:
- {
- void *arg = a.arg[dp->arg_index].a.a_pointer;
- SNPRINTF_BUF (arg);
- }
- break;
- default:
- abort ();
- }
+ case TYPE_POINTER:
+ {
+ void *arg = a.arg[dp->arg_index].a.a_pointer;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ default:
+ abort ();
+ }
#if USE_SNPRINTF
- /* Portability: Not all implementations of snprintf()
- are ISO C 99 compliant. Determine the number of
- bytes that snprintf() has produced or would have
- produced. */
- if (count >= 0)
- {
- /* Verify that snprintf() has NUL-terminated its
- result. */
- if (count < maxlen
- && ((TCHAR_T *) (result + length)) [count] != '\0')
- abort ();
- /* Portability hack. */
- if (retcount > count)
- count = retcount;
- }
- else
- {
- /* snprintf() doesn't understand the '%n'
- directive. */
- if (fbp[1] != '\0')
- {
- /* Don't use the '%n' directive; instead, look
- at the snprintf() return value. */
- fbp[1] = '\0';
- continue;
- }
- else
- {
- /* Look at the snprintf() return value. */
- if (retcount < 0)
- {
- /* HP-UX 10.20 snprintf() is doubly deficient:
- It doesn't understand the '%n' directive,
- *and* it returns -1 (rather than the length
- that would have been required) when the
- buffer is too small. */
- size_t bigger_need =
- xsum (xtimes (allocated, 2), 12);
- ENSURE_ALLOCATION (bigger_need);
- continue;
- }
- else
- count = retcount;
- }
- }
+ /* Portability: Not all implementations of snprintf()
+ are ISO C 99 compliant. Determine the number of
+ bytes that snprintf() has produced or would have
+ produced. */
+ if (count >= 0)
+ {
+ /* Verify that snprintf() has NUL-terminated its
+ result. */
+ if (count < maxlen
+ && ((TCHAR_T *) (result + length)) [count] != '\0')
+ abort ();
+ /* Portability hack. */
+ if (retcount > count)
+ count = retcount;
+ }
+ else
+ {
+ /* snprintf() doesn't understand the '%n'
+ directive. */
+ if (fbp[1] != '\0')
+ {
+ /* Don't use the '%n' directive; instead, look
+ at the snprintf() return value. */
+ fbp[1] = '\0';
+ continue;
+ }
+ else
+ {
+ /* Look at the snprintf() return value. */
+ if (retcount < 0)
+ {
+ /* HP-UX 10.20 snprintf() is doubly deficient:
+ It doesn't understand the '%n' directive,
+ *and* it returns -1 (rather than the length
+ that would have been required) when the
+ buffer is too small. */
+ size_t bigger_need =
+ xsum (xtimes (allocated, 2), 12);
+ ENSURE_ALLOCATION (bigger_need);
+ continue;
+ }
+ else
+ count = retcount;
+ }
+ }
#endif
- /* Attempt to handle failure. */
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EINVAL;
- return NULL;
- }
+ /* Attempt to handle failure. */
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EINVAL;
+ return NULL;
+ }
#if USE_SNPRINTF
- /* Handle overflow of the allocated buffer.
- If such an overflow occurs, a C99 compliant snprintf()
- returns a count >= maxlen. However, a non-compliant
- snprintf() function returns only count = maxlen - 1. To
- cover both cases, test whether count >= maxlen - 1. */
- if ((unsigned int) count + 1 >= maxlen)
- {
- /* If maxlen already has attained its allowed maximum,
- allocating more memory will not increase maxlen.
- Instead of looping, bail out. */
- if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
- goto overflow;
- else
- {
- /* Need at least (count + 1) * sizeof (TCHAR_T)
- bytes. (The +1 is for the trailing NUL.)
- But ask for (count + 2) * sizeof (TCHAR_T)
- bytes, so that in the next round, we likely get
- maxlen > (unsigned int) count + 1
- and so we don't get here again.
- And allocate proportionally, to avoid looping
- eternally if snprintf() reports a too small
- count. */
- size_t n =
- xmax (xsum (length,
- ((unsigned int) count + 2
- + TCHARS_PER_DCHAR - 1)
- / TCHARS_PER_DCHAR),
- xtimes (allocated, 2));
-
- ENSURE_ALLOCATION (n);
- continue;
- }
- }
+ /* Handle overflow of the allocated buffer.
+ If such an overflow occurs, a C99 compliant snprintf()
+ returns a count >= maxlen. However, a non-compliant
+ snprintf() function returns only count = maxlen - 1. To
+ cover both cases, test whether count >= maxlen - 1. */
+ if ((unsigned int) count + 1 >= maxlen)
+ {
+ /* If maxlen already has attained its allowed maximum,
+ allocating more memory will not increase maxlen.
+ Instead of looping, bail out. */
+ if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
+ goto overflow;
+ else
+ {
+ /* Need at least (count + 1) * sizeof (TCHAR_T)
+ bytes. (The +1 is for the trailing NUL.)
+ But ask for (count + 2) * sizeof (TCHAR_T)
+ bytes, so that in the next round, we likely get
+ maxlen > (unsigned int) count + 1
+ and so we don't get here again.
+ And allocate proportionally, to avoid looping
+ eternally if snprintf() reports a too small
+ count. */
+ size_t n =
+ xmax (xsum (length,
+ ((unsigned int) count + 2
+ + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR),
+ xtimes (allocated, 2));
+
+ ENSURE_ALLOCATION (n);
+ continue;
+ }
+ }
#endif
#if NEED_PRINTF_UNBOUNDED_PRECISION
- if (prec_ourselves)
- {
- /* Handle the precision. */
- TCHAR_T *prec_ptr =
+ if (prec_ourselves)
+ {
+ /* Handle the precision. */
+ TCHAR_T *prec_ptr =
# if USE_SNPRINTF
- (TCHAR_T *) (result + length);
+ (TCHAR_T *) (result + length);
# else
- tmp;
+ tmp;
# endif
- size_t prefix_count;
- size_t move;
-
- prefix_count = 0;
- /* Put the additional zeroes after the sign. */
- if (count >= 1
- && (*prec_ptr == '-' || *prec_ptr == '+'
- || *prec_ptr == ' '))
- prefix_count = 1;
- /* Put the additional zeroes after the 0x prefix if
- (flags & FLAG_ALT) || (dp->conversion == 'p'). */
- else if (count >= 2
- && prec_ptr[0] == '0'
- && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'))
- prefix_count = 2;
-
- move = count - prefix_count;
- if (precision > move)
- {
- /* Insert zeroes. */
- size_t insert = precision - move;
- TCHAR_T *prec_end;
+ size_t prefix_count;
+ size_t move;
+
+ prefix_count = 0;
+ /* Put the additional zeroes after the sign. */
+ if (count >= 1
+ && (*prec_ptr == '-' || *prec_ptr == '+'
+ || *prec_ptr == ' '))
+ prefix_count = 1;
+ /* Put the additional zeroes after the 0x prefix if
+ (flags & FLAG_ALT) || (dp->conversion == 'p'). */
+ else if (count >= 2
+ && prec_ptr[0] == '0'
+ && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'))
+ prefix_count = 2;
+
+ move = count - prefix_count;
+ if (precision > move)
+ {
+ /* Insert zeroes. */
+ size_t insert = precision - move;
+ TCHAR_T *prec_end;
# if USE_SNPRINTF
- size_t n =
- xsum (length,
- (count + insert + TCHARS_PER_DCHAR - 1)
- / TCHARS_PER_DCHAR);
- length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
- ENSURE_ALLOCATION (n);
- length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
- prec_ptr = (TCHAR_T *) (result + length);
+ size_t n =
+ xsum (length,
+ (count + insert + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR);
+ length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
+ ENSURE_ALLOCATION (n);
+ length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
+ prec_ptr = (TCHAR_T *) (result + length);
# endif
- prec_end = prec_ptr + count;
- prec_ptr += prefix_count;
+ prec_end = prec_ptr + count;
+ prec_ptr += prefix_count;
- while (prec_end > prec_ptr)
- {
- prec_end--;
- prec_end[insert] = prec_end[0];
- }
+ while (prec_end > prec_ptr)
+ {
+ prec_end--;
+ prec_end[insert] = prec_end[0];
+ }
- prec_end += insert;
- do
- *--prec_end = '0';
- while (prec_end > prec_ptr);
+ prec_end += insert;
+ do
+ *--prec_end = '0';
+ while (prec_end > prec_ptr);
- count += insert;
- }
- }
+ count += insert;
+ }
+ }
#endif
#if !USE_SNPRINTF
- if (count >= tmp_length)
- /* tmp_length was incorrectly calculated - fix the
- code above! */
- abort ();
+ if (count >= tmp_length)
+ /* tmp_length was incorrectly calculated - fix the
+ code above! */
+ abort ();
#endif
#if !DCHAR_IS_TCHAR
- /* Convert from TCHAR_T[] to DCHAR_T[]. */
- if (dp->conversion == 'c' || dp->conversion == 's')
- {
- /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
- TYPE_WIDE_STRING.
- The result string is not certainly ASCII. */
- const TCHAR_T *tmpsrc;
- DCHAR_T *tmpdst;
- size_t tmpdst_len;
- /* This code assumes that TCHAR_T is 'char'. */
- typedef int TCHAR_T_verify
- [2 * (sizeof (TCHAR_T) == 1) - 1];
+ /* Convert from TCHAR_T[] to DCHAR_T[]. */
+ if (dp->conversion == 'c' || dp->conversion == 's')
+ {
+ /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
+ TYPE_WIDE_STRING.
+ The result string is not certainly ASCII. */
+ const TCHAR_T *tmpsrc;
+ DCHAR_T *tmpdst;
+ size_t tmpdst_len;
+ /* This code assumes that TCHAR_T is 'char'. */
+ typedef int TCHAR_T_verify
+ [2 * (sizeof (TCHAR_T) == 1) - 1];
# if USE_SNPRINTF
- tmpsrc = (TCHAR_T *) (result + length);
+ tmpsrc = (TCHAR_T *) (result + length);
# else
- tmpsrc = tmp;
+ tmpsrc = tmp;
# endif
- tmpdst =
- DCHAR_CONV_FROM_ENCODING (locale_charset (),
- iconveh_question_mark,
- tmpsrc, count,
- NULL,
- NULL, &tmpdst_len);
- if (tmpdst == NULL)
- {
- int saved_errno = errno;
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = saved_errno;
- return NULL;
- }
- ENSURE_ALLOCATION (xsum (length, tmpdst_len));
- DCHAR_CPY (result + length, tmpdst, tmpdst_len);
- free (tmpdst);
- count = tmpdst_len;
- }
- else
- {
- /* The result string is ASCII.
- Simple 1:1 conversion. */
+ tmpdst =
+ DCHAR_CONV_FROM_ENCODING (locale_charset (),
+ iconveh_question_mark,
+ tmpsrc, count,
+ NULL,
+ NULL, &tmpdst_len);
+ if (tmpdst == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+ DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+ free (tmpdst);
+ count = tmpdst_len;
+ }
+ else
+ {
+ /* The result string is ASCII.
+ Simple 1:1 conversion. */
# if USE_SNPRINTF
- /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a
- no-op conversion, in-place on the array starting
- at (result + length). */
- if (sizeof (DCHAR_T) != sizeof (TCHAR_T))
+ /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a
+ no-op conversion, in-place on the array starting
+ at (result + length). */
+ if (sizeof (DCHAR_T) != sizeof (TCHAR_T))
# endif
- {
- const TCHAR_T *tmpsrc;
- DCHAR_T *tmpdst;
- size_t n;
+ {
+ const TCHAR_T *tmpsrc;
+ DCHAR_T *tmpdst;
+ size_t n;
# if USE_SNPRINTF
- if (result == resultbuf)
- {
- tmpsrc = (TCHAR_T *) (result + length);
- /* ENSURE_ALLOCATION will not move tmpsrc
- (because it's part of resultbuf). */
- ENSURE_ALLOCATION (xsum (length, count));
- }
- else
- {
- /* ENSURE_ALLOCATION will move the array
- (because it uses realloc(). */
- ENSURE_ALLOCATION (xsum (length, count));
- tmpsrc = (TCHAR_T *) (result + length);
- }
+ if (result == resultbuf)
+ {
+ tmpsrc = (TCHAR_T *) (result + length);
+ /* ENSURE_ALLOCATION will not move tmpsrc
+ (because it's part of resultbuf). */
+ ENSURE_ALLOCATION (xsum (length, count));
+ }
+ else
+ {
+ /* ENSURE_ALLOCATION will move the array
+ (because it uses realloc(). */
+ ENSURE_ALLOCATION (xsum (length, count));
+ tmpsrc = (TCHAR_T *) (result + length);
+ }
# else
- tmpsrc = tmp;
- ENSURE_ALLOCATION (xsum (length, count));
+ tmpsrc = tmp;
+ ENSURE_ALLOCATION (xsum (length, count));
# endif
- tmpdst = result + length;
- /* Copy backwards, because of overlapping. */
- tmpsrc += count;
- tmpdst += count;
- for (n = count; n > 0; n--)
- *--tmpdst = (unsigned char) *--tmpsrc;
- }
- }
+ tmpdst = result + length;
+ /* Copy backwards, because of overlapping. */
+ tmpsrc += count;
+ tmpdst += count;
+ for (n = count; n > 0; n--)
+ *--tmpdst = (unsigned char) *--tmpsrc;
+ }
+ }
#endif
#if DCHAR_IS_TCHAR && !USE_SNPRINTF
- /* Make room for the result. */
- if (count > allocated - length)
- {
- /* Need at least count elements. But allocate
- proportionally. */
- size_t n =
- xmax (xsum (length, count), xtimes (allocated, 2));
-
- ENSURE_ALLOCATION (n);
- }
+ /* Make room for the result. */
+ if (count > allocated - length)
+ {
+ /* Need at least count elements. But allocate
+ proportionally. */
+ size_t n =
+ xmax (xsum (length, count), xtimes (allocated, 2));
+
+ ENSURE_ALLOCATION (n);
+ }
#endif
- /* Here count <= allocated - length. */
+ /* Here count <= allocated - length. */
- /* Perform padding. */
+ /* Perform padding. */
#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
- if (pad_ourselves && has_width)
- {
- size_t w;
+ if (pad_ourselves && has_width)
+ {
+ size_t w;
# if ENABLE_UNISTDIO
- /* Outside POSIX, it's preferrable to compare the width
- against the number of _characters_ of the converted
- value. */
- w = DCHAR_MBSNLEN (result + length, count);
+ /* Outside POSIX, it's preferrable to compare the width
+ against the number of _characters_ of the converted
+ value. */
+ w = DCHAR_MBSNLEN (result + length, count);
# else
- /* The width is compared against the number of _bytes_
- of the converted value, says POSIX. */
- w = count;
+ /* The width is compared against the number of _bytes_
+ of the converted value, says POSIX. */
+ w = count;
# endif
- if (w < width)
- {
- size_t pad = width - w;
-
- /* Make room for the result. */
- if (xsum (count, pad) > allocated - length)
- {
- /* Need at least count + pad elements. But
- allocate proportionally. */
- size_t n =
- xmax (xsum3 (length, count, pad),
- xtimes (allocated, 2));
+ if (w < width)
+ {
+ size_t pad = width - w;
+
+ /* Make room for the result. */
+ if (xsum (count, pad) > allocated - length)
+ {
+ /* Need at least count + pad elements. But
+ allocate proportionally. */
+ size_t n =
+ xmax (xsum3 (length, count, pad),
+ xtimes (allocated, 2));
# if USE_SNPRINTF
- length += count;
- ENSURE_ALLOCATION (n);
- length -= count;
+ length += count;
+ ENSURE_ALLOCATION (n);
+ length -= count;
# else
- ENSURE_ALLOCATION (n);
+ ENSURE_ALLOCATION (n);
# endif
- }
- /* Here count + pad <= allocated - length. */
+ }
+ /* Here count + pad <= allocated - length. */
- {
+ {
# if !DCHAR_IS_TCHAR || USE_SNPRINTF
- DCHAR_T * const rp = result + length;
+ DCHAR_T * const rp = result + length;
# else
- DCHAR_T * const rp = tmp;
+ DCHAR_T * const rp = tmp;
# endif
- DCHAR_T *p = rp + count;
- DCHAR_T *end = p + pad;
- DCHAR_T *pad_ptr;
+ DCHAR_T *p = rp + count;
+ DCHAR_T *end = p + pad;
+ DCHAR_T *pad_ptr;
# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
- if (dp->conversion == 'c'
- || dp->conversion == 's')
- /* No zero-padding for string directives. */
- pad_ptr = NULL;
- else
+ if (dp->conversion == 'c'
+ || dp->conversion == 's')
+ /* No zero-padding for string directives. */
+ pad_ptr = NULL;
+ else
# endif
- {
- pad_ptr = (*rp == '-' ? rp + 1 : rp);
- /* No zero-padding of "inf" and "nan". */
- if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
- || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
- pad_ptr = NULL;
- }
- /* The generated string now extends from rp to p,
- with the zero padding insertion point being at
- pad_ptr. */
-
- count = count + pad; /* = end - rp */
-
- if (flags & FLAG_LEFT)
- {
- /* Pad with spaces on the right. */
- for (; pad > 0; pad--)
- *p++ = ' ';
- }
- else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
- {
- /* Pad with zeroes. */
- DCHAR_T *q = end;
-
- while (p > pad_ptr)
- *--q = *--p;
- for (; pad > 0; pad--)
- *p++ = '0';
- }
- else
- {
- /* Pad with spaces on the left. */
- DCHAR_T *q = end;
-
- while (p > rp)
- *--q = *--p;
- for (; pad > 0; pad--)
- *p++ = ' ';
- }
- }
- }
- }
+ {
+ pad_ptr = (*rp == '-' ? rp + 1 : rp);
+ /* No zero-padding of "inf" and "nan". */
+ if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
+ || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
+ pad_ptr = NULL;
+ }
+ /* The generated string now extends from rp to p,
+ with the zero padding insertion point being at
+ pad_ptr. */
+
+ count = count + pad; /* = end - rp */
+
+ if (flags & FLAG_LEFT)
+ {
+ /* Pad with spaces on the right. */
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+ {
+ /* Pad with zeroes. */
+ DCHAR_T *q = end;
+
+ while (p > pad_ptr)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = '0';
+ }
+ else
+ {
+ /* Pad with spaces on the left. */
+ DCHAR_T *q = end;
+
+ while (p > rp)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ }
+ }
+ }
#endif
- /* Here still count <= allocated - length. */
+ /* Here still count <= allocated - length. */
#if !DCHAR_IS_TCHAR || USE_SNPRINTF
- /* The snprintf() result did fit. */
+ /* The snprintf() result did fit. */
#else
- /* Append the sprintf() result. */
- memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+ /* Append the sprintf() result. */
+ memcpy (result + length, tmp, count * sizeof (DCHAR_T));
#endif
#if !USE_SNPRINTF
- if (tmp != tmpbuf)
- free (tmp);
+ if (tmp != tmpbuf)
+ free (tmp);
#endif
#if NEED_PRINTF_DIRECTIVE_F
- if (dp->conversion == 'F')
- {
- /* Convert the %f result to upper case for %F. */
- DCHAR_T *rp = result + length;
- size_t rc;
- for (rc = count; rc > 0; rc--, rp++)
- if (*rp >= 'a' && *rp <= 'z')
- *rp = *rp - 'a' + 'A';
- }
+ if (dp->conversion == 'F')
+ {
+ /* Convert the %f result to upper case for %F. */
+ DCHAR_T *rp = result + length;
+ size_t rc;
+ for (rc = count; rc > 0; rc--, rp++)
+ if (*rp >= 'a' && *rp <= 'z')
+ *rp = *rp - 'a' + 'A';
+ }
#endif
- length += count;
- break;
- }
- }
- }
+ length += count;
+ break;
+ }
+ }
+ }
}
/* Add the final NUL. */
@@ -5432,12 +5432,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (result != resultbuf && length + 1 < allocated)
{
- /* Shrink the allocated memory if possible. */
- DCHAR_T *memory;
+ /* Shrink the allocated memory if possible. */
+ DCHAR_T *memory;
- memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
- if (memory != NULL)
- result = memory;
+ memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
+ if (memory != NULL)
+ result = memory;
}
if (buf_malloced != NULL)
diff --git a/lib/gl/vasnprintf.h b/lib/gl/vasnprintf.h
index 7f5770aaf4..6bf9c59cd9 100644
--- a/lib/gl/vasnprintf.h
+++ b/lib/gl/vasnprintf.h
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc.
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
@@ -25,15 +25,14 @@
#include <stddef.h>
#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable __attribute__ only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
+# define __attribute__(Spec) /* empty */
# endif
#endif
diff --git a/lib/gl/vasprintf.c b/lib/gl/vasprintf.c
index c74dc76e4f..b8c52a9ec8 100644
--- a/lib/gl/vasprintf.c
+++ b/lib/gl/vasprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006-2010 Free Software Foundation, Inc.
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
diff --git a/lib/gl/vsnprintf.c b/lib/gl/vsnprintf.c
index d487be8996..2ec3cae9d7 100644
--- a/lib/gl/vsnprintf.c
+++ b/lib/gl/vsnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc.
Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
This program is free software; you can redistribute it and/or modify
@@ -52,11 +52,11 @@ vsnprintf (char *str, size_t size, const char *format, va_list args)
if (output != str)
{
if (size)
- {
- size_t pruned_len = (len < size ? len : size - 1);
- memcpy (str, output, pruned_len);
- str[pruned_len] = '\0';
- }
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
free (output);
}
diff --git a/lib/gl/w32sock.h b/lib/gl/w32sock.h
index 12977f7cab..1bcee466d6 100644
--- a/lib/gl/w32sock.h
+++ b/lib/gl/w32sock.h
@@ -1,6 +1,6 @@
/* w32sock.h --- internal auxilliary functions for Windows socket functions
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
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
@@ -32,7 +32,6 @@ static inline void
set_winsock_errno (void)
{
int err = WSAGetLastError ();
- WSASetLastError (0);
/* Map some WSAE* errors to the runtime library's error codes. */
switch (err)
diff --git a/lib/gl/wchar.in.h b/lib/gl/wchar.in.h
index 9f5b963823..c492dd60ef 100644
--- a/lib/gl/wchar.in.h
+++ b/lib/gl/wchar.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
- Copyright (C) 2007-2009 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
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
@@ -30,9 +30,9 @@
@PRAGMA_SYSTEM_HEADER@
#endif
-#if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
+#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
/* Special invocation convention:
- - Inside uClibc header files.
+ - Inside glibc and uClibc header files.
- On HP-UX 11.00 we have a sequence of nested includes
<wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
@@ -55,10 +55,13 @@
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
- included before <wchar.h>. */
-#include <stddef.h>
-#include <stdio.h>
-#include <time.h>
+ included before <wchar.h>.
+ But avoid namespace pollution on glibc systems. */
+#ifndef __GLIBC__
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+#endif
/* Include the original <wchar.h> if it exists.
Some builds of uClibc lack it. */
@@ -72,7 +75,9 @@
#ifndef _GL_WCHAR_H
#define _GL_WCHAR_H
-/* The definition of GL_LINK_WARNING is copied here. */
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
#ifdef __cplusplus
extern "C" {
@@ -110,10 +115,10 @@ extern wint_t btowc (int c);
# endif
#elif defined GNULIB_POSIXCHECK
# undef btowc
-# define btowc(c) \
- (GL_LINK_WARNING ("btowc is unportable - " \
- "use gnulib module btowc for portability"), \
- btowc (c))
+# if HAVE_RAW_DECL_BTOWC
+_GL_WARN_ON_USE (btowc, "btowc is unportable - "
+ "use gnulib module btowc for portability");
+# endif
#endif
@@ -129,10 +134,10 @@ extern int wctob (wint_t wc);
# endif
#elif defined GNULIB_POSIXCHECK
# undef wctob
-# define wctob(w) \
- (GL_LINK_WARNING ("wctob is unportable - " \
- "use gnulib module wctob for portability"), \
- wctob (w))
+# if HAVE_RAW_DECL_WCTOB
+_GL_WARN_ON_USE (wctob, "wctob is unportable - "
+ "use gnulib module wctob for portability");
+# endif
#endif
@@ -147,10 +152,10 @@ extern int mbsinit (const mbstate_t *ps);
# endif
#elif defined GNULIB_POSIXCHECK
# undef mbsinit
-# define mbsinit(p) \
- (GL_LINK_WARNING ("mbsinit is unportable - " \
- "use gnulib module mbsinit for portability"), \
- mbsinit (p))
+# if HAVE_RAW_DECL_MBSINIT
+_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
+ "use gnulib module mbsinit for portability");
+# endif
#endif
@@ -165,10 +170,10 @@ extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
# endif
#elif defined GNULIB_POSIXCHECK
# undef mbrtowc
-# define mbrtowc(w,s,n,p) \
- (GL_LINK_WARNING ("mbrtowc is unportable - " \
- "use gnulib module mbrtowc for portability"), \
- mbrtowc (w, s, n, p))
+# if HAVE_RAW_DECL_MBRTOWC
+_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
+ "use gnulib module mbrtowc for portability");
+# endif
#endif
@@ -183,10 +188,10 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
# endif
#elif defined GNULIB_POSIXCHECK
# undef mbrlen
-# define mbrlen(s,n,p) \
- (GL_LINK_WARNING ("mbrlen is unportable - " \
- "use gnulib module mbrlen for portability"), \
- mbrlen (s, n, p))
+# if HAVE_RAW_DECL_MBRLEN
+_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
+ "use gnulib module mbrlen for portability");
+# endif
#endif
@@ -197,14 +202,15 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
# define mbsrtowcs rpl_mbsrtowcs
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef mbsrtowcs
-# define mbsrtowcs(d,s,l,p) \
- (GL_LINK_WARNING ("mbsrtowcs is unportable - " \
- "use gnulib module mbsrtowcs for portability"), \
- mbsrtowcs (d, s, l, p))
+# if HAVE_RAW_DECL_MBSRTOWCS
+_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
+ "use gnulib module mbsrtowcs for portability");
+# endif
#endif
@@ -215,14 +221,15 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t
# define mbsnrtowcs rpl_mbsnrtowcs
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef mbsnrtowcs
-# define mbsnrtowcs(d,s,n,l,p) \
- (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \
- "use gnulib module mbsnrtowcs for portability"), \
- mbsnrtowcs (d, s, n, l, p))
+# if HAVE_RAW_DECL_MBSNRTOWCS
+_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
+ "use gnulib module mbsnrtowcs for portability");
+# endif
#endif
@@ -237,10 +244,10 @@ extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
# endif
#elif defined GNULIB_POSIXCHECK
# undef wcrtomb
-# define wcrtomb(s,w,p) \
- (GL_LINK_WARNING ("wcrtomb is unportable - " \
- "use gnulib module wcrtomb for portability"), \
- wcrtomb (s, w, p))
+# if HAVE_RAW_DECL_WCRTOMB
+_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
+ "use gnulib module wcrtomb for portability");
+# endif
#endif
@@ -251,14 +258,15 @@ extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
# define wcsrtombs rpl_wcsrtombs
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef wcsrtombs
-# define wcsrtombs(d,s,l,p) \
- (GL_LINK_WARNING ("wcsrtombs is unportable - " \
- "use gnulib module wcsrtombs for portability"), \
- wcsrtombs (d, s, l, p))
+# if HAVE_RAW_DECL_WCSRTOMBS
+_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
+ "use gnulib module wcsrtombs for portability");
+# endif
#endif
@@ -269,14 +277,15 @@ extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t
# define wcsnrtombs rpl_wcsnrtombs
# endif
# 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
#elif defined GNULIB_POSIXCHECK
# undef wcsnrtombs
-# define wcsnrtombs(d,s,n,l,p) \
- (GL_LINK_WARNING ("wcsnrtombs is unportable - " \
- "use gnulib module wcsnrtombs for portability"), \
- wcsnrtombs (d, s, n, l, p))
+# if HAVE_RAW_DECL_WCSNRTOMBS
+_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
+ "use gnulib module wcsnrtombs for portability");
+# endif
#endif
@@ -294,10 +303,10 @@ extern int wcwidth (int /* actually wchar_t */);
# endif
#elif defined GNULIB_POSIXCHECK
# undef wcwidth
-# define wcwidth(w) \
- (GL_LINK_WARNING ("wcwidth is unportable - " \
- "use gnulib module wcwidth for portability"), \
- wcwidth (w))
+# if HAVE_RAW_DECL_WCWIDTH
+_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
+ "use gnulib module wcwidth for portability");
+# endif
#endif
diff --git a/lib/gl/xsize.h b/lib/gl/xsize.h
index 42db052f8f..1d43dfe4c2 100644
--- a/lib/gl/xsize.h
+++ b/lib/gl/xsize.h
@@ -1,6 +1,6 @@
/* xsize.h -- Checked size_t computations.
- Copyright (C) 2003, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2008, 2009, 2010 Free Software Foundation, Inc.
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