diff options
Diffstat (limited to 'gl')
46 files changed, 1487 insertions, 987 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index e2dc38b7..7954b034 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | # the same distribution terms as the rest of that program. | 9 | # the same distribution terms as the rest of that program. |
| 10 | # | 10 | # |
| 11 | # Generated by gnulib-tool. | 11 | # Generated by gnulib-tool. |
| 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf | 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf |
| 13 | 13 | ||
| 14 | AUTOMAKE_OPTIONS = 1.5 gnits | 14 | AUTOMAKE_OPTIONS = 1.5 gnits |
| 15 | 15 | ||
| @@ -44,17 +44,6 @@ EXTRA_DIST += alignof.h | |||
| 44 | 44 | ||
| 45 | ## end gnulib module alignof | 45 | ## end gnulib module alignof |
| 46 | 46 | ||
| 47 | ## begin gnulib module alloca | ||
| 48 | |||
| 49 | |||
| 50 | EXTRA_DIST += alloca.c | ||
| 51 | |||
| 52 | EXTRA_libgnu_a_SOURCES += alloca.c | ||
| 53 | |||
| 54 | libgnu_a_LIBADD += @ALLOCA@ | ||
| 55 | libgnu_a_DEPENDENCIES += @ALLOCA@ | ||
| 56 | ## end gnulib module alloca | ||
| 57 | |||
| 58 | ## begin gnulib module alloca-opt | 47 | ## begin gnulib module alloca-opt |
| 59 | 48 | ||
| 60 | BUILT_SOURCES += $(ALLOCA_H) | 49 | BUILT_SOURCES += $(ALLOCA_H) |
| @@ -253,6 +242,15 @@ CLEANFILES += configmake.h configmake.h-t | |||
| 253 | 242 | ||
| 254 | ## end gnulib module configmake | 243 | ## end gnulib module configmake |
| 255 | 244 | ||
| 245 | ## begin gnulib module crypto/sha1 | ||
| 246 | |||
| 247 | |||
| 248 | EXTRA_DIST += sha1.c sha1.h | ||
| 249 | |||
| 250 | EXTRA_libgnu_a_SOURCES += sha1.c | ||
| 251 | |||
| 252 | ## end gnulib module crypto/sha1 | ||
| 253 | |||
| 256 | ## begin gnulib module dirname | 254 | ## begin gnulib module dirname |
| 257 | 255 | ||
| 258 | 256 | ||
| @@ -833,11 +831,11 @@ EXTRA_libgnu_a_SOURCES += mountlist.c | |||
| 833 | 831 | ||
| 834 | ## begin gnulib module netdb | 832 | ## begin gnulib module netdb |
| 835 | 833 | ||
| 836 | BUILT_SOURCES += $(NETDB_H) | 834 | BUILT_SOURCES += netdb.h |
| 837 | 835 | ||
| 838 | # We need the following in order to create <netdb.h> when the system | 836 | # We need the following in order to create <netdb.h> when the system |
| 839 | # doesn't have one that works with the given compiler. | 837 | # doesn't have one that works with the given compiler. |
| 840 | netdb.h: netdb.in.h $(ARG_NONNULL_H) | 838 | netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H) |
| 841 | $(AM_V_GEN)rm -f $@-t $@ && \ | 839 | $(AM_V_GEN)rm -f $@-t $@ && \ |
| 842 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ | 840 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ |
| 843 | sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | 841 | sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ |
| @@ -851,6 +849,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) | |||
| 851 | -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ | 849 | -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ |
| 852 | -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ | 850 | -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ |
| 853 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | 851 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ |
| 852 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ | ||
| 854 | < $(srcdir)/netdb.in.h; \ | 853 | < $(srcdir)/netdb.in.h; \ |
| 855 | } > $@-t && \ | 854 | } > $@-t && \ |
| 856 | mv $@-t $@ | 855 | mv $@-t $@ |
| @@ -1140,6 +1139,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 1140 | -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ | 1139 | -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ |
| 1141 | -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ | 1140 | -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ |
| 1142 | -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ | 1141 | -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ |
| 1142 | -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \ | ||
| 1143 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ | 1143 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ |
| 1144 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | 1144 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ |
| 1145 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ | 1145 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ |
| @@ -1333,6 +1333,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 1333 | -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ | 1333 | -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ |
| 1334 | -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ | 1334 | -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ |
| 1335 | -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ | 1335 | -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ |
| 1336 | -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ | ||
| 1336 | -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ | 1337 | -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ |
| 1337 | -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ | 1338 | -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ |
| 1338 | -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ | 1339 | -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ |
| @@ -1506,6 +1507,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 1506 | -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ | 1507 | -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ |
| 1507 | -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ | 1508 | -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ |
| 1508 | -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ | 1509 | -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ |
| 1510 | -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ | ||
| 1509 | -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ | 1511 | -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ |
| 1510 | -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ | 1512 | -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ |
| 1511 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ | 1513 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ |
| @@ -1577,6 +1579,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 1577 | -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ | 1579 | -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ |
| 1578 | -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ | 1580 | -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ |
| 1579 | -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ | 1581 | -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ |
| 1582 | -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \ | ||
| 1580 | -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ | 1583 | -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ |
| 1581 | -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ | 1584 | -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ |
| 1582 | -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ | 1585 | -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ |
| @@ -1611,6 +1614,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 1611 | -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ | 1614 | -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ |
| 1612 | -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ | 1615 | -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ |
| 1613 | -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ | 1616 | -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ |
| 1617 | -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ | ||
| 1614 | -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ | 1618 | -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ |
| 1615 | -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ | 1619 | -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ |
| 1616 | -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ | 1620 | -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ |
| @@ -1638,10 +1642,12 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 1638 | -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ | 1642 | -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ |
| 1639 | -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ | 1643 | -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ |
| 1640 | -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ | 1644 | -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ |
| 1645 | -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ | ||
| 1641 | -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ | 1646 | -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ |
| 1642 | -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ | 1647 | -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ |
| 1643 | -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ | 1648 | -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ |
| 1644 | -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ | 1649 | -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ |
| 1650 | -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ | ||
| 1645 | -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ | 1651 | -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ |
| 1646 | -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ | 1652 | -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ |
| 1647 | -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ | 1653 | -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ |
diff --git a/gl/alloca.c b/gl/alloca.c deleted file mode 100644 index 75afdb96..00000000 --- a/gl/alloca.c +++ /dev/null | |||
| @@ -1,489 +0,0 @@ | |||
| 1 | /* alloca.c -- allocate automatically reclaimed memory | ||
| 2 | (Mostly) portable public-domain implementation -- D A Gwyn | ||
| 3 | |||
| 4 | This implementation of the PWB library alloca function, | ||
| 5 | which is used to allocate space off the run-time stack so | ||
| 6 | that it is automatically reclaimed upon procedure exit, | ||
| 7 | was inspired by discussions with J. Q. Johnson of Cornell. | ||
| 8 | J.Otto Tennant <jot@cray.com> contributed the Cray support. | ||
| 9 | |||
| 10 | There are some preprocessor constants that can | ||
| 11 | be defined when compiling for your specific system, for | ||
| 12 | improved efficiency; however, the defaults should be okay. | ||
| 13 | |||
| 14 | The general concept of this implementation is to keep | ||
| 15 | track of all alloca-allocated blocks, and reclaim any | ||
| 16 | that are found to be deeper in the stack than the current | ||
| 17 | invocation. This heuristic does not reclaim storage as | ||
| 18 | soon as it becomes invalid, but it will do so eventually. | ||
| 19 | |||
| 20 | As a special case, alloca(0) reclaims storage without | ||
| 21 | allocating any. It is a good idea to use alloca(0) in | ||
| 22 | your main control loop, etc. to force garbage collection. */ | ||
| 23 | |||
| 24 | #include <config.h> | ||
| 25 | |||
| 26 | #include <alloca.h> | ||
| 27 | |||
| 28 | #include <string.h> | ||
| 29 | #include <stdlib.h> | ||
| 30 | |||
| 31 | #ifdef emacs | ||
| 32 | # include "lisp.h" | ||
| 33 | # include "blockinput.h" | ||
| 34 | # ifdef EMACS_FREE | ||
| 35 | # undef free | ||
| 36 | # define free EMACS_FREE | ||
| 37 | # endif | ||
| 38 | #else | ||
| 39 | # define memory_full() abort () | ||
| 40 | #endif | ||
| 41 | |||
| 42 | /* If compiling with GCC 2, this file's not needed. */ | ||
| 43 | #if !defined (__GNUC__) || __GNUC__ < 2 | ||
| 44 | |||
| 45 | /* If someone has defined alloca as a macro, | ||
| 46 | there must be some other way alloca is supposed to work. */ | ||
| 47 | # ifndef alloca | ||
| 48 | |||
| 49 | # ifdef emacs | ||
| 50 | # ifdef static | ||
| 51 | /* actually, only want this if static is defined as "" | ||
| 52 | -- this is for usg, in which emacs must undefine static | ||
| 53 | in order to make unexec workable | ||
| 54 | */ | ||
| 55 | # ifndef STACK_DIRECTION | ||
| 56 | you | ||
| 57 | lose | ||
| 58 | -- must know STACK_DIRECTION at compile-time | ||
| 59 | /* Using #error here is not wise since this file should work for | ||
| 60 | old and obscure compilers. */ | ||
| 61 | # endif /* STACK_DIRECTION undefined */ | ||
| 62 | # endif /* static */ | ||
| 63 | # endif /* emacs */ | ||
| 64 | |||
| 65 | /* If your stack is a linked list of frames, you have to | ||
| 66 | provide an "address metric" ADDRESS_FUNCTION macro. */ | ||
| 67 | |||
| 68 | # if defined (CRAY) && defined (CRAY_STACKSEG_END) | ||
| 69 | long i00afunc (); | ||
| 70 | # define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) | ||
| 71 | # else | ||
| 72 | # define ADDRESS_FUNCTION(arg) &(arg) | ||
| 73 | # endif | ||
| 74 | |||
| 75 | /* Define STACK_DIRECTION if you know the direction of stack | ||
| 76 | growth for your system; otherwise it will be automatically | ||
| 77 | deduced at run-time. | ||
| 78 | |||
| 79 | STACK_DIRECTION > 0 => grows toward higher addresses | ||
| 80 | STACK_DIRECTION < 0 => grows toward lower addresses | ||
| 81 | STACK_DIRECTION = 0 => direction of growth unknown */ | ||
| 82 | |||
| 83 | # ifndef STACK_DIRECTION | ||
| 84 | # define STACK_DIRECTION 0 /* Direction unknown. */ | ||
| 85 | # endif | ||
| 86 | |||
| 87 | # if STACK_DIRECTION != 0 | ||
| 88 | |||
| 89 | # define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ | ||
| 90 | |||
| 91 | # else /* STACK_DIRECTION == 0; need run-time code. */ | ||
| 92 | |||
| 93 | static int stack_dir; /* 1 or -1 once known. */ | ||
| 94 | # define STACK_DIR stack_dir | ||
| 95 | |||
| 96 | static void | ||
| 97 | find_stack_direction (void) | ||
| 98 | { | ||
| 99 | static char *addr = NULL; /* Address of first `dummy', once known. */ | ||
| 100 | auto char dummy; /* To get stack address. */ | ||
| 101 | |||
| 102 | if (addr == NULL) | ||
| 103 | { /* Initial entry. */ | ||
| 104 | addr = ADDRESS_FUNCTION (dummy); | ||
| 105 | |||
| 106 | find_stack_direction (); /* Recurse once. */ | ||
| 107 | } | ||
| 108 | else | ||
| 109 | { | ||
| 110 | /* Second entry. */ | ||
| 111 | if (ADDRESS_FUNCTION (dummy) > addr) | ||
| 112 | stack_dir = 1; /* Stack grew upward. */ | ||
| 113 | else | ||
| 114 | stack_dir = -1; /* Stack grew downward. */ | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | # endif /* STACK_DIRECTION == 0 */ | ||
| 119 | |||
| 120 | /* An "alloca header" is used to: | ||
| 121 | (a) chain together all alloca'ed blocks; | ||
| 122 | (b) keep track of stack depth. | ||
| 123 | |||
| 124 | It is very important that sizeof(header) agree with malloc | ||
| 125 | alignment chunk size. The following default should work okay. */ | ||
| 126 | |||
| 127 | # ifndef ALIGN_SIZE | ||
| 128 | # define ALIGN_SIZE sizeof(double) | ||
| 129 | # endif | ||
| 130 | |||
| 131 | typedef union hdr | ||
| 132 | { | ||
| 133 | char align[ALIGN_SIZE]; /* To force sizeof(header). */ | ||
| 134 | struct | ||
| 135 | { | ||
| 136 | union hdr *next; /* For chaining headers. */ | ||
| 137 | char *deep; /* For stack depth measure. */ | ||
| 138 | } h; | ||
| 139 | } header; | ||
| 140 | |||
| 141 | static header *last_alloca_header = NULL; /* -> last alloca header. */ | ||
| 142 | |||
| 143 | /* Return a pointer to at least SIZE bytes of storage, | ||
| 144 | which will be automatically reclaimed upon exit from | ||
| 145 | the procedure that called alloca. Originally, this space | ||
| 146 | was supposed to be taken from the current stack frame of the | ||
| 147 | caller, but that method cannot be made to work for some | ||
| 148 | implementations of C, for example under Gould's UTX/32. */ | ||
| 149 | |||
| 150 | void * | ||
| 151 | alloca (size_t size) | ||
| 152 | { | ||
| 153 | auto char probe; /* Probes stack depth: */ | ||
| 154 | register char *depth = ADDRESS_FUNCTION (probe); | ||
| 155 | |||
| 156 | # if STACK_DIRECTION == 0 | ||
| 157 | if (STACK_DIR == 0) /* Unknown growth direction. */ | ||
| 158 | find_stack_direction (); | ||
| 159 | # endif | ||
| 160 | |||
| 161 | /* Reclaim garbage, defined as all alloca'd storage that | ||
| 162 | was allocated from deeper in the stack than currently. */ | ||
| 163 | |||
| 164 | { | ||
| 165 | register header *hp; /* Traverses linked list. */ | ||
| 166 | |||
| 167 | # ifdef emacs | ||
| 168 | BLOCK_INPUT; | ||
| 169 | # endif | ||
| 170 | |||
| 171 | for (hp = last_alloca_header; hp != NULL;) | ||
| 172 | if ((STACK_DIR > 0 && hp->h.deep > depth) | ||
| 173 | || (STACK_DIR < 0 && hp->h.deep < depth)) | ||
| 174 | { | ||
| 175 | register header *np = hp->h.next; | ||
| 176 | |||
| 177 | free (hp); /* Collect garbage. */ | ||
| 178 | |||
| 179 | hp = np; /* -> next header. */ | ||
| 180 | } | ||
| 181 | else | ||
| 182 | break; /* Rest are not deeper. */ | ||
| 183 | |||
| 184 | last_alloca_header = hp; /* -> last valid storage. */ | ||
| 185 | |||
| 186 | # ifdef emacs | ||
| 187 | UNBLOCK_INPUT; | ||
| 188 | # endif | ||
| 189 | } | ||
| 190 | |||
| 191 | if (size == 0) | ||
| 192 | return NULL; /* No allocation required. */ | ||
| 193 | |||
| 194 | /* Allocate combined header + user data storage. */ | ||
| 195 | |||
| 196 | { | ||
| 197 | /* Address of header. */ | ||
| 198 | register header *new; | ||
| 199 | |||
| 200 | size_t combined_size = sizeof (header) + size; | ||
| 201 | if (combined_size < sizeof (header)) | ||
| 202 | memory_full (); | ||
| 203 | |||
| 204 | new = malloc (combined_size); | ||
| 205 | |||
| 206 | if (! new) | ||
| 207 | memory_full (); | ||
| 208 | |||
| 209 | new->h.next = last_alloca_header; | ||
| 210 | new->h.deep = depth; | ||
| 211 | |||
| 212 | last_alloca_header = new; | ||
| 213 | |||
| 214 | /* User storage begins just after header. */ | ||
| 215 | |||
| 216 | return (void *) (new + 1); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | # if defined (CRAY) && defined (CRAY_STACKSEG_END) | ||
| 221 | |||
| 222 | # ifdef DEBUG_I00AFUNC | ||
| 223 | # include <stdio.h> | ||
| 224 | # endif | ||
| 225 | |||
| 226 | # ifndef CRAY_STACK | ||
| 227 | # define CRAY_STACK | ||
| 228 | # ifndef CRAY2 | ||
| 229 | /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ | ||
| 230 | struct stack_control_header | ||
| 231 | { | ||
| 232 | long shgrow:32; /* Number of times stack has grown. */ | ||
| 233 | long shaseg:32; /* Size of increments to stack. */ | ||
| 234 | long shhwm:32; /* High water mark of stack. */ | ||
| 235 | long shsize:32; /* Current size of stack (all segments). */ | ||
| 236 | }; | ||
| 237 | |||
| 238 | /* The stack segment linkage control information occurs at | ||
| 239 | the high-address end of a stack segment. (The stack | ||
| 240 | grows from low addresses to high addresses.) The initial | ||
| 241 | part of the stack segment linkage control information is | ||
| 242 | 0200 (octal) words. This provides for register storage | ||
| 243 | for the routine which overflows the stack. */ | ||
| 244 | |||
| 245 | struct stack_segment_linkage | ||
| 246 | { | ||
| 247 | long ss[0200]; /* 0200 overflow words. */ | ||
| 248 | long sssize:32; /* Number of words in this segment. */ | ||
| 249 | long ssbase:32; /* Offset to stack base. */ | ||
| 250 | long:32; | ||
| 251 | long sspseg:32; /* Offset to linkage control of previous | ||
| 252 | segment of stack. */ | ||
| 253 | long:32; | ||
| 254 | long sstcpt:32; /* Pointer to task common address block. */ | ||
| 255 | long sscsnm; /* Private control structure number for | ||
| 256 | microtasking. */ | ||
| 257 | long ssusr1; /* Reserved for user. */ | ||
| 258 | long ssusr2; /* Reserved for user. */ | ||
| 259 | long sstpid; /* Process ID for pid based multi-tasking. */ | ||
| 260 | long ssgvup; /* Pointer to multitasking thread giveup. */ | ||
| 261 | long sscray[7]; /* Reserved for Cray Research. */ | ||
| 262 | long ssa0; | ||
| 263 | long ssa1; | ||
| 264 | long ssa2; | ||
| 265 | long ssa3; | ||
| 266 | long ssa4; | ||
| 267 | long ssa5; | ||
| 268 | long ssa6; | ||
| 269 | long ssa7; | ||
| 270 | long sss0; | ||
| 271 | long sss1; | ||
| 272 | long sss2; | ||
| 273 | long sss3; | ||
| 274 | long sss4; | ||
| 275 | long sss5; | ||
| 276 | long sss6; | ||
| 277 | long sss7; | ||
| 278 | }; | ||
| 279 | |||
| 280 | # else /* CRAY2 */ | ||
| 281 | /* The following structure defines the vector of words | ||
| 282 | returned by the STKSTAT library routine. */ | ||
| 283 | struct stk_stat | ||
| 284 | { | ||
| 285 | long now; /* Current total stack size. */ | ||
| 286 | long maxc; /* Amount of contiguous space which would | ||
| 287 | be required to satisfy the maximum | ||
| 288 | stack demand to date. */ | ||
| 289 | long high_water; /* Stack high-water mark. */ | ||
| 290 | long overflows; /* Number of stack overflow ($STKOFEN) calls. */ | ||
| 291 | long hits; /* Number of internal buffer hits. */ | ||
| 292 | long extends; /* Number of block extensions. */ | ||
| 293 | long stko_mallocs; /* Block allocations by $STKOFEN. */ | ||
| 294 | long underflows; /* Number of stack underflow calls ($STKRETN). */ | ||
| 295 | long stko_free; /* Number of deallocations by $STKRETN. */ | ||
| 296 | long stkm_free; /* Number of deallocations by $STKMRET. */ | ||
| 297 | long segments; /* Current number of stack segments. */ | ||
| 298 | long maxs; /* Maximum number of stack segments so far. */ | ||
| 299 | long pad_size; /* Stack pad size. */ | ||
| 300 | long current_address; /* Current stack segment address. */ | ||
| 301 | long current_size; /* Current stack segment size. This | ||
| 302 | number is actually corrupted by STKSTAT to | ||
| 303 | include the fifteen word trailer area. */ | ||
| 304 | long initial_address; /* Address of initial segment. */ | ||
| 305 | long initial_size; /* Size of initial segment. */ | ||
| 306 | }; | ||
| 307 | |||
| 308 | /* The following structure describes the data structure which trails | ||
| 309 | any stack segment. I think that the description in 'asdef' is | ||
| 310 | out of date. I only describe the parts that I am sure about. */ | ||
| 311 | |||
| 312 | struct stk_trailer | ||
| 313 | { | ||
| 314 | long this_address; /* Address of this block. */ | ||
| 315 | long this_size; /* Size of this block (does not include | ||
| 316 | this trailer). */ | ||
| 317 | long unknown2; | ||
| 318 | long unknown3; | ||
| 319 | long link; /* Address of trailer block of previous | ||
| 320 | segment. */ | ||
| 321 | long unknown5; | ||
| 322 | long unknown6; | ||
| 323 | long unknown7; | ||
| 324 | long unknown8; | ||
| 325 | long unknown9; | ||
| 326 | long unknown10; | ||
| 327 | long unknown11; | ||
| 328 | long unknown12; | ||
| 329 | long unknown13; | ||
| 330 | long unknown14; | ||
| 331 | }; | ||
| 332 | |||
| 333 | # endif /* CRAY2 */ | ||
| 334 | # endif /* not CRAY_STACK */ | ||
| 335 | |||
| 336 | # ifdef CRAY2 | ||
| 337 | /* Determine a "stack measure" for an arbitrary ADDRESS. | ||
| 338 | I doubt that "lint" will like this much. */ | ||
| 339 | |||
| 340 | static long | ||
| 341 | i00afunc (long *address) | ||
| 342 | { | ||
| 343 | struct stk_stat status; | ||
| 344 | struct stk_trailer *trailer; | ||
| 345 | long *block, size; | ||
| 346 | long result = 0; | ||
| 347 | |||
| 348 | /* We want to iterate through all of the segments. The first | ||
| 349 | step is to get the stack status structure. We could do this | ||
| 350 | more quickly and more directly, perhaps, by referencing the | ||
| 351 | $LM00 common block, but I know that this works. */ | ||
| 352 | |||
| 353 | STKSTAT (&status); | ||
| 354 | |||
| 355 | /* Set up the iteration. */ | ||
| 356 | |||
| 357 | trailer = (struct stk_trailer *) (status.current_address | ||
| 358 | + status.current_size | ||
| 359 | - 15); | ||
| 360 | |||
| 361 | /* There must be at least one stack segment. Therefore it is | ||
| 362 | a fatal error if "trailer" is null. */ | ||
| 363 | |||
| 364 | if (trailer == 0) | ||
| 365 | abort (); | ||
| 366 | |||
| 367 | /* Discard segments that do not contain our argument address. */ | ||
| 368 | |||
| 369 | while (trailer != 0) | ||
| 370 | { | ||
| 371 | block = (long *) trailer->this_address; | ||
| 372 | size = trailer->this_size; | ||
| 373 | if (block == 0 || size == 0) | ||
| 374 | abort (); | ||
| 375 | trailer = (struct stk_trailer *) trailer->link; | ||
| 376 | if ((block <= address) && (address < (block + size))) | ||
| 377 | break; | ||
| 378 | } | ||
| 379 | |||
| 380 | /* Set the result to the offset in this segment and add the sizes | ||
| 381 | of all predecessor segments. */ | ||
| 382 | |||
| 383 | result = address - block; | ||
| 384 | |||
| 385 | if (trailer == 0) | ||
| 386 | { | ||
| 387 | return result; | ||
| 388 | } | ||
| 389 | |||
| 390 | do | ||
| 391 | { | ||
| 392 | if (trailer->this_size <= 0) | ||
| 393 | abort (); | ||
| 394 | result += trailer->this_size; | ||
| 395 | trailer = (struct stk_trailer *) trailer->link; | ||
| 396 | } | ||
| 397 | while (trailer != 0); | ||
| 398 | |||
| 399 | /* We are done. Note that if you present a bogus address (one | ||
| 400 | not in any segment), you will get a different number back, formed | ||
| 401 | from subtracting the address of the first block. This is probably | ||
| 402 | not what you want. */ | ||
| 403 | |||
| 404 | return (result); | ||
| 405 | } | ||
| 406 | |||
| 407 | # else /* not CRAY2 */ | ||
| 408 | /* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. | ||
| 409 | Determine the number of the cell within the stack, | ||
| 410 | given the address of the cell. The purpose of this | ||
| 411 | routine is to linearize, in some sense, stack addresses | ||
| 412 | for alloca. */ | ||
| 413 | |||
| 414 | static long | ||
| 415 | i00afunc (long address) | ||
| 416 | { | ||
| 417 | long stkl = 0; | ||
| 418 | |||
| 419 | long size, pseg, this_segment, stack; | ||
| 420 | long result = 0; | ||
| 421 | |||
| 422 | struct stack_segment_linkage *ssptr; | ||
| 423 | |||
| 424 | /* Register B67 contains the address of the end of the | ||
| 425 | current stack segment. If you (as a subprogram) store | ||
| 426 | your registers on the stack and find that you are past | ||
| 427 | the contents of B67, you have overflowed the segment. | ||
| 428 | |||
| 429 | B67 also points to the stack segment linkage control | ||
| 430 | area, which is what we are really interested in. */ | ||
| 431 | |||
| 432 | stkl = CRAY_STACKSEG_END (); | ||
| 433 | ssptr = (struct stack_segment_linkage *) stkl; | ||
| 434 | |||
| 435 | /* If one subtracts 'size' from the end of the segment, | ||
| 436 | one has the address of the first word of the segment. | ||
| 437 | |||
| 438 | If this is not the first segment, 'pseg' will be | ||
| 439 | nonzero. */ | ||
| 440 | |||
| 441 | pseg = ssptr->sspseg; | ||
| 442 | size = ssptr->sssize; | ||
| 443 | |||
| 444 | this_segment = stkl - size; | ||
| 445 | |||
| 446 | /* It is possible that calling this routine itself caused | ||
| 447 | a stack overflow. Discard stack segments which do not | ||
| 448 | contain the target address. */ | ||
| 449 | |||
| 450 | while (!(this_segment <= address && address <= stkl)) | ||
| 451 | { | ||
| 452 | # ifdef DEBUG_I00AFUNC | ||
| 453 | fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); | ||
| 454 | # endif | ||
| 455 | if (pseg == 0) | ||
| 456 | break; | ||
| 457 | stkl = stkl - pseg; | ||
| 458 | ssptr = (struct stack_segment_linkage *) stkl; | ||
| 459 | size = ssptr->sssize; | ||
| 460 | pseg = ssptr->sspseg; | ||
| 461 | this_segment = stkl - size; | ||
| 462 | } | ||
| 463 | |||
| 464 | result = address - this_segment; | ||
| 465 | |||
| 466 | /* If you subtract pseg from the current end of the stack, | ||
| 467 | you get the address of the previous stack segment's end. | ||
| 468 | This seems a little convoluted to me, but I'll bet you save | ||
| 469 | a cycle somewhere. */ | ||
| 470 | |||
| 471 | while (pseg != 0) | ||
| 472 | { | ||
| 473 | # ifdef DEBUG_I00AFUNC | ||
| 474 | fprintf (stderr, "%011o %011o\n", pseg, size); | ||
| 475 | # endif | ||
| 476 | stkl = stkl - pseg; | ||
| 477 | ssptr = (struct stack_segment_linkage *) stkl; | ||
| 478 | size = ssptr->sssize; | ||
| 479 | pseg = ssptr->sspseg; | ||
| 480 | result += size; | ||
| 481 | } | ||
| 482 | return (result); | ||
| 483 | } | ||
| 484 | |||
| 485 | # endif /* not CRAY2 */ | ||
| 486 | # endif /* CRAY */ | ||
| 487 | |||
| 488 | # endif /* no alloca */ | ||
| 489 | #endif /* not GCC version 3 */ | ||
diff --git a/gl/config.charset b/gl/config.charset index 2959df89..aa7d00db 100644 --- a/gl/config.charset +++ b/gl/config.charset | |||
| @@ -30,21 +30,21 @@ | |||
| 30 | # The current list of GNU canonical charset names is as follows. | 30 | # The current list of GNU canonical charset names is as follows. |
| 31 | # | 31 | # |
| 32 | # name MIME? used by which systems | 32 | # name MIME? used by which systems |
| 33 | # ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin | 33 | # ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin |
| 34 | # ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin | 34 | # ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin |
| 35 | # ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin | 35 | # ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin |
| 36 | # ISO-8859-3 Y glibc solaris | 36 | # ISO-8859-3 Y glibc solaris cygwin |
| 37 | # ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin | 37 | # ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin |
| 38 | # ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin | 38 | # ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin |
| 39 | # ISO-8859-6 Y glibc aix hpux solaris | 39 | # ISO-8859-6 Y glibc aix hpux solaris cygwin |
| 40 | # ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin | 40 | # ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin |
| 41 | # ISO-8859-8 Y glibc aix hpux osf solaris | 41 | # ISO-8859-8 Y glibc aix hpux osf solaris cygwin |
| 42 | # ISO-8859-9 Y glibc aix hpux irix osf solaris darwin | 42 | # ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin |
| 43 | # ISO-8859-13 glibc netbsd openbsd darwin | 43 | # ISO-8859-13 glibc netbsd openbsd darwin cygwin |
| 44 | # ISO-8859-14 glibc | 44 | # ISO-8859-14 glibc cygwin |
| 45 | # ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin | 45 | # ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin |
| 46 | # KOI8-R Y glibc solaris freebsd netbsd openbsd darwin | 46 | # KOI8-R Y glibc solaris freebsd netbsd openbsd darwin |
| 47 | # KOI8-U Y glibc freebsd netbsd openbsd darwin | 47 | # KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin |
| 48 | # KOI8-T glibc | 48 | # KOI8-T glibc |
| 49 | # CP437 dos | 49 | # CP437 dos |
| 50 | # CP775 dos | 50 | # CP775 dos |
| @@ -61,7 +61,7 @@ | |||
| 61 | # CP869 dos | 61 | # CP869 dos |
| 62 | # CP874 woe32 dos | 62 | # CP874 woe32 dos |
| 63 | # CP922 aix | 63 | # CP922 aix |
| 64 | # CP932 aix woe32 dos | 64 | # CP932 aix cygwin woe32 dos |
| 65 | # CP943 aix | 65 | # CP943 aix |
| 66 | # CP949 osf darwin woe32 dos | 66 | # CP949 osf darwin woe32 dos |
| 67 | # CP950 woe32 dos | 67 | # CP950 woe32 dos |
| @@ -71,7 +71,7 @@ | |||
| 71 | # CP1129 aix | 71 | # CP1129 aix |
| 72 | # CP1131 darwin | 72 | # CP1131 darwin |
| 73 | # CP1250 woe32 | 73 | # CP1250 woe32 |
| 74 | # CP1251 glibc solaris netbsd openbsd darwin woe32 | 74 | # CP1251 glibc solaris netbsd openbsd darwin cygwin woe32 |
| 75 | # CP1252 aix woe32 | 75 | # CP1252 aix woe32 |
| 76 | # CP1253 woe32 | 76 | # CP1253 woe32 |
| 77 | # CP1254 woe32 | 77 | # CP1254 woe32 |
| @@ -80,19 +80,19 @@ | |||
| 80 | # CP1257 woe32 | 80 | # CP1257 woe32 |
| 81 | # GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin | 81 | # GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin |
| 82 | # EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin | 82 | # EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin |
| 83 | # EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin | 83 | # EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin |
| 84 | # EUC-TW glibc aix hpux irix osf solaris netbsd | 84 | # EUC-TW glibc aix hpux irix osf solaris netbsd |
| 85 | # BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin | 85 | # BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin |
| 86 | # BIG5-HKSCS glibc solaris darwin | 86 | # BIG5-HKSCS glibc solaris darwin |
| 87 | # GBK glibc aix osf solaris darwin woe32 dos | 87 | # GBK glibc aix osf solaris darwin cygwin woe32 dos |
| 88 | # GB18030 glibc solaris netbsd darwin | 88 | # GB18030 glibc solaris netbsd darwin |
| 89 | # SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin | 89 | # SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin |
| 90 | # JOHAB glibc solaris woe32 | 90 | # JOHAB glibc solaris woe32 |
| 91 | # TIS-620 glibc aix hpux osf solaris | 91 | # TIS-620 glibc aix hpux osf solaris cygwin |
| 92 | # VISCII Y glibc | 92 | # VISCII Y glibc |
| 93 | # TCVN5712-1 glibc | 93 | # TCVN5712-1 glibc |
| 94 | # ARMSCII-8 glibc darwin | 94 | # ARMSCII-8 glibc darwin |
| 95 | # GEORGIAN-PS glibc | 95 | # GEORGIAN-PS glibc cygwin |
| 96 | # PT154 glibc | 96 | # PT154 glibc |
| 97 | # HP-ROMAN8 hpux | 97 | # HP-ROMAN8 hpux |
| 98 | # HP-ARABIC8 hpux | 98 | # HP-ARABIC8 hpux |
| @@ -102,7 +102,7 @@ | |||
| 102 | # HP-KANA8 hpux | 102 | # HP-KANA8 hpux |
| 103 | # DEC-KANJI osf | 103 | # DEC-KANJI osf |
| 104 | # DEC-HANYU osf | 104 | # DEC-HANYU osf |
| 105 | # UTF-8 Y glibc aix hpux osf solaris netbsd darwin | 105 | # UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin |
| 106 | # | 106 | # |
| 107 | # Note: Names which are not marked as being a MIME name should not be used in | 107 | # Note: Names which are not marked as being a MIME name should not be used in |
| 108 | # Internet protocols for information interchange (mail, news, etc.). | 108 | # Internet protocols for information interchange (mail, news, etc.). |
| @@ -88,6 +88,15 @@ extern void __error_at_line (int status, int errnum, const char *file_name, | |||
| 88 | # include <fcntl.h> | 88 | # include <fcntl.h> |
| 89 | # include <unistd.h> | 89 | # include <unistd.h> |
| 90 | 90 | ||
| 91 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 92 | /* Get declarations of the Win32 API functions. */ | ||
| 93 | # define WIN32_LEAN_AND_MEAN | ||
| 94 | # include <windows.h> | ||
| 95 | # endif | ||
| 96 | |||
| 97 | /* The gnulib override of fcntl is not needed in this file. */ | ||
| 98 | # undef fcntl | ||
| 99 | |||
| 91 | # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P | 100 | # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P |
| 92 | # ifndef HAVE_DECL_STRERROR_R | 101 | # ifndef HAVE_DECL_STRERROR_R |
| 93 | "this configure-time declaration test was not run" | 102 | "this configure-time declaration test was not run" |
| @@ -104,10 +113,29 @@ extern char *program_name; | |||
| 104 | # endif /* HAVE_STRERROR_R || defined strerror_r */ | 113 | # endif /* HAVE_STRERROR_R || defined strerror_r */ |
| 105 | #endif /* not _LIBC */ | 114 | #endif /* not _LIBC */ |
| 106 | 115 | ||
| 116 | #if !_LIBC | ||
| 117 | /* Return non-zero if FD is open. */ | ||
| 118 | static inline int | ||
| 119 | is_open (int fd) | ||
| 120 | { | ||
| 121 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 122 | /* On Win32: The initial state of unassigned standard file descriptors is | ||
| 123 | that they are open but point to an INVALID_HANDLE_VALUE. There is no | ||
| 124 | fcntl, and the gnulib replacement fcntl does not support F_GETFL. */ | ||
| 125 | return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; | ||
| 126 | # else | ||
| 127 | # ifndef F_GETFL | ||
| 128 | # error Please port fcntl to your platform | ||
| 129 | # endif | ||
| 130 | return 0 <= fcntl (fd, F_GETFL); | ||
| 131 | # endif | ||
| 132 | } | ||
| 133 | #endif | ||
| 134 | |||
| 107 | static inline void | 135 | static inline void |
| 108 | flush_stdout (void) | 136 | flush_stdout (void) |
| 109 | { | 137 | { |
| 110 | #if !_LIBC && defined F_GETFL | 138 | #if !_LIBC |
| 111 | int stdout_fd; | 139 | int stdout_fd; |
| 112 | 140 | ||
| 113 | # if GNULIB_FREOPEN_SAFER | 141 | # if GNULIB_FREOPEN_SAFER |
| @@ -124,7 +152,7 @@ flush_stdout (void) | |||
| 124 | /* POSIX states that fflush (stdout) after fclose is unspecified; it | 152 | /* POSIX states that fflush (stdout) after fclose is unspecified; it |
| 125 | is safe in glibc, but not on all other platforms. fflush (NULL) | 153 | is safe in glibc, but not on all other platforms. fflush (NULL) |
| 126 | is always defined, but too draconian. */ | 154 | is always defined, but too draconian. */ |
| 127 | if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL)) | 155 | if (0 <= stdout_fd && is_open (stdout_fd)) |
| 128 | #endif | 156 | #endif |
| 129 | fflush (stdout); | 157 | fflush (stdout); |
| 130 | } | 158 | } |
diff --git a/gl/getopt.c b/gl/getopt.c index aaabc8d1..3791f129 100644 --- a/gl/getopt.c +++ b/gl/getopt.c | |||
| @@ -348,8 +348,6 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 348 | int long_only, struct _getopt_data *d, int posixly_correct) | 348 | int long_only, struct _getopt_data *d, int posixly_correct) |
| 349 | { | 349 | { |
| 350 | int print_errors = d->opterr; | 350 | int print_errors = d->opterr; |
| 351 | if (optstring[0] == ':') | ||
| 352 | print_errors = 0; | ||
| 353 | 351 | ||
| 354 | if (argc < 1) | 352 | if (argc < 1) |
| 355 | return -1; | 353 | return -1; |
| @@ -364,6 +362,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 364 | posixly_correct); | 362 | posixly_correct); |
| 365 | d->__initialized = 1; | 363 | d->__initialized = 1; |
| 366 | } | 364 | } |
| 365 | else if (optstring[0] == '-' || optstring[0] == '+') | ||
| 366 | optstring++; | ||
| 367 | if (optstring[0] == ':') | ||
| 368 | print_errors = 0; | ||
| 367 | 369 | ||
| 368 | /* Test whether ARGV[optind] points to a non-option argument. | 370 | /* Test whether ARGV[optind] points to a non-option argument. |
| 369 | Either it does not have option syntax, or there is an environment flag | 371 | Either it does not have option syntax, or there is an environment flag |
| @@ -633,8 +635,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 633 | char *buf; | 635 | char *buf; |
| 634 | 636 | ||
| 635 | if (__asprintf (&buf, _("\ | 637 | if (__asprintf (&buf, _("\ |
| 636 | %s: option '%s' requires an argument\n"), | 638 | %s: option '--%s' requires an argument\n"), |
| 637 | argv[0], argv[d->optind - 1]) >= 0) | 639 | argv[0], pfound->name) >= 0) |
| 638 | { | 640 | { |
| 639 | _IO_flockfile (stderr); | 641 | _IO_flockfile (stderr); |
| 640 | 642 | ||
| @@ -651,8 +653,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 651 | } | 653 | } |
| 652 | #else | 654 | #else |
| 653 | fprintf (stderr, | 655 | fprintf (stderr, |
| 654 | _("%s: option '%s' requires an argument\n"), | 656 | _("%s: option '--%s' requires an argument\n"), |
| 655 | argv[0], argv[d->optind - 1]); | 657 | argv[0], pfound->name); |
| 656 | #endif | 658 | #endif |
| 657 | } | 659 | } |
| 658 | d->__nextchar += strlen (d->__nextchar); | 660 | d->__nextchar += strlen (d->__nextchar); |
| @@ -736,13 +738,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 736 | 738 | ||
| 737 | { | 739 | { |
| 738 | char c = *d->__nextchar++; | 740 | char c = *d->__nextchar++; |
| 739 | char *temp = strchr (optstring, c); | 741 | const char *temp = strchr (optstring, c); |
| 740 | 742 | ||
| 741 | /* Increment `optind' when we start to process its last character. */ | 743 | /* Increment `optind' when we start to process its last character. */ |
| 742 | if (*d->__nextchar == '\0') | 744 | if (*d->__nextchar == '\0') |
| 743 | ++d->optind; | 745 | ++d->optind; |
| 744 | 746 | ||
| 745 | if (temp == NULL || c == ':') | 747 | if (temp == NULL || c == ':' || c == ';') |
| 746 | { | 748 | { |
| 747 | if (print_errors) | 749 | if (print_errors) |
| 748 | { | 750 | { |
| @@ -864,7 +866,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 864 | pfound = p; | 866 | pfound = p; |
| 865 | indfound = option_index; | 867 | indfound = option_index; |
| 866 | } | 868 | } |
| 867 | else | 869 | else if (long_only |
| 870 | || pfound->has_arg != p->has_arg | ||
| 871 | || pfound->flag != p->flag | ||
| 872 | || pfound->val != p->val) | ||
| 868 | /* Second or later nonexact match found. */ | 873 | /* Second or later nonexact match found. */ |
| 869 | ambig = 1; | 874 | ambig = 1; |
| 870 | } | 875 | } |
| @@ -876,7 +881,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 876 | char *buf; | 881 | char *buf; |
| 877 | 882 | ||
| 878 | if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), | 883 | if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), |
| 879 | argv[0], argv[d->optind]) >= 0) | 884 | argv[0], d->optarg) >= 0) |
| 880 | { | 885 | { |
| 881 | _IO_flockfile (stderr); | 886 | _IO_flockfile (stderr); |
| 882 | 887 | ||
| @@ -892,7 +897,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 892 | } | 897 | } |
| 893 | #else | 898 | #else |
| 894 | fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), | 899 | fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), |
| 895 | argv[0], argv[d->optind]); | 900 | argv[0], d->optarg); |
| 896 | #endif | 901 | #endif |
| 897 | } | 902 | } |
| 898 | d->__nextchar += strlen (d->__nextchar); | 903 | d->__nextchar += strlen (d->__nextchar); |
| @@ -955,8 +960,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 955 | char *buf; | 960 | char *buf; |
| 956 | 961 | ||
| 957 | if (__asprintf (&buf, _("\ | 962 | if (__asprintf (&buf, _("\ |
| 958 | %s: option '%s' requires an argument\n"), | 963 | %s: option '-W %s' requires an argument\n"), |
| 959 | argv[0], argv[d->optind - 1]) >= 0) | 964 | argv[0], pfound->name) >= 0) |
| 960 | { | 965 | { |
| 961 | _IO_flockfile (stderr); | 966 | _IO_flockfile (stderr); |
| 962 | 967 | ||
| @@ -972,15 +977,17 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 972 | free (buf); | 977 | free (buf); |
| 973 | } | 978 | } |
| 974 | #else | 979 | #else |
| 975 | fprintf (stderr, | 980 | fprintf (stderr, _("\ |
| 976 | _("%s: option '%s' requires an argument\n"), | 981 | %s: option '-W %s' requires an argument\n"), |
| 977 | argv[0], argv[d->optind - 1]); | 982 | argv[0], pfound->name); |
| 978 | #endif | 983 | #endif |
| 979 | } | 984 | } |
| 980 | d->__nextchar += strlen (d->__nextchar); | 985 | d->__nextchar += strlen (d->__nextchar); |
| 981 | return optstring[0] == ':' ? ':' : '?'; | 986 | return optstring[0] == ':' ? ':' : '?'; |
| 982 | } | 987 | } |
| 983 | } | 988 | } |
| 989 | else | ||
| 990 | d->optarg = NULL; | ||
| 984 | d->__nextchar += strlen (d->__nextchar); | 991 | d->__nextchar += strlen (d->__nextchar); |
| 985 | if (longind != NULL) | 992 | if (longind != NULL) |
| 986 | *longind = option_index; | 993 | *longind = option_index; |
diff --git a/gl/getopt_int.h b/gl/getopt_int.h index 169def5b..980b7507 100644 --- a/gl/getopt_int.h +++ b/gl/getopt_int.h | |||
| @@ -30,6 +30,40 @@ extern int _getopt_internal (int ___argc, char **___argv, | |||
| 30 | /* Reentrant versions which can handle parsing multiple argument | 30 | /* Reentrant versions which can handle parsing multiple argument |
| 31 | vectors at the same time. */ | 31 | vectors at the same time. */ |
| 32 | 32 | ||
| 33 | /* Describe how to deal with options that follow non-option ARGV-elements. | ||
| 34 | |||
| 35 | If the caller did not specify anything, | ||
| 36 | the default is REQUIRE_ORDER if the environment variable | ||
| 37 | POSIXLY_CORRECT is defined, PERMUTE otherwise. | ||
| 38 | |||
| 39 | REQUIRE_ORDER means don't recognize them as options; | ||
| 40 | stop option processing when the first non-option is seen. | ||
| 41 | This is what Unix does. | ||
| 42 | This mode of operation is selected by either setting the environment | ||
| 43 | variable POSIXLY_CORRECT, or using `+' as the first character | ||
| 44 | of the list of option characters, or by calling getopt. | ||
| 45 | |||
| 46 | PERMUTE is the default. We permute the contents of ARGV as we | ||
| 47 | scan, so that eventually all the non-options are at the end. | ||
| 48 | This allows options to be given in any order, even with programs | ||
| 49 | that were not written to expect this. | ||
| 50 | |||
| 51 | RETURN_IN_ORDER is an option available to programs that were | ||
| 52 | written to expect options and other ARGV-elements in any order | ||
| 53 | and that care about the ordering of the two. We describe each | ||
| 54 | non-option ARGV-element as if it were the argument of an option | ||
| 55 | with character code 1. Using `-' as the first character of the | ||
| 56 | list of option characters selects this mode of operation. | ||
| 57 | |||
| 58 | The special argument `--' forces an end of option-scanning regardless | ||
| 59 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only | ||
| 60 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */ | ||
| 61 | |||
| 62 | enum __ord | ||
| 63 | { | ||
| 64 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER | ||
| 65 | }; | ||
| 66 | |||
| 33 | /* Data type for reentrant functions. */ | 67 | /* Data type for reentrant functions. */ |
| 34 | struct _getopt_data | 68 | struct _getopt_data |
| 35 | { | 69 | { |
| @@ -54,39 +88,8 @@ struct _getopt_data | |||
| 54 | by advancing to the next ARGV-element. */ | 88 | by advancing to the next ARGV-element. */ |
| 55 | char *__nextchar; | 89 | char *__nextchar; |
| 56 | 90 | ||
| 57 | /* Describe how to deal with options that follow non-option ARGV-elements. | 91 | /* See __ord above. */ |
| 58 | 92 | enum __ord __ordering; | |
| 59 | If the caller did not specify anything, | ||
| 60 | the default is REQUIRE_ORDER if the environment variable | ||
| 61 | POSIXLY_CORRECT is defined, PERMUTE otherwise. | ||
| 62 | |||
| 63 | REQUIRE_ORDER means don't recognize them as options; | ||
| 64 | stop option processing when the first non-option is seen. | ||
| 65 | This is what Unix does. | ||
| 66 | This mode of operation is selected by either setting the environment | ||
| 67 | variable POSIXLY_CORRECT, or using `+' as the first character | ||
| 68 | of the list of option characters, or by calling getopt. | ||
| 69 | |||
| 70 | PERMUTE is the default. We permute the contents of ARGV as we | ||
| 71 | scan, so that eventually all the non-options are at the end. | ||
| 72 | This allows options to be given in any order, even with programs | ||
| 73 | that were not written to expect this. | ||
| 74 | |||
| 75 | RETURN_IN_ORDER is an option available to programs that were | ||
| 76 | written to expect options and other ARGV-elements in any order | ||
| 77 | and that care about the ordering of the two. We describe each | ||
| 78 | non-option ARGV-element as if it were the argument of an option | ||
| 79 | with character code 1. Using `-' as the first character of the | ||
| 80 | list of option characters selects this mode of operation. | ||
| 81 | |||
| 82 | The special argument `--' forces an end of option-scanning regardless | ||
| 83 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only | ||
| 84 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */ | ||
| 85 | |||
| 86 | enum | ||
| 87 | { | ||
| 88 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER | ||
| 89 | } __ordering; | ||
| 90 | 93 | ||
| 91 | /* If the POSIXLY_CORRECT environment variable is set | 94 | /* If the POSIXLY_CORRECT environment variable is set |
| 92 | or getopt was called. */ | 95 | or getopt was called. */ |
diff --git a/gl/localcharset.c b/gl/localcharset.c index a04dc446..fa2207fe 100644 --- a/gl/localcharset.c +++ b/gl/localcharset.c | |||
| @@ -369,10 +369,9 @@ locale_charset (void) | |||
| 369 | codeset = nl_langinfo (CODESET); | 369 | codeset = nl_langinfo (CODESET); |
| 370 | 370 | ||
| 371 | # ifdef __CYGWIN__ | 371 | # ifdef __CYGWIN__ |
| 372 | /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always | 372 | /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always |
| 373 | returns "US-ASCII". As long as this is not fixed, return the suffix | 373 | returns "US-ASCII". Return the suffix of the locale name from the |
| 374 | of the locale name from the environment variables (if present) or | 374 | environment variables (if present) or the codepage as a number. */ |
| 375 | the codepage as a number. */ | ||
| 376 | if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) | 375 | if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) |
| 377 | { | 376 | { |
| 378 | const char *locale; | 377 | const char *locale; |
diff --git a/gl/m4/asm-underscore.m4 b/gl/m4/asm-underscore.m4 new file mode 100644 index 00000000..1736cc43 --- /dev/null +++ b/gl/m4/asm-underscore.m4 | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | # asm-underscore.m4 serial 1 | ||
| 2 | dnl Copyright (C) 2010 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp. | ||
| 8 | |||
| 9 | # gl_ASM_SYMBOL_PREFIX | ||
| 10 | # Tests for the prefix of C symbols at the assembly language level and the | ||
| 11 | # linker level. This prefix is either an underscore or empty. Defines the | ||
| 12 | # C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to | ||
| 13 | # a stringified variant of this prefix. | ||
| 14 | |||
| 15 | AC_DEFUN([gl_ASM_SYMBOL_PREFIX], | ||
| 16 | [ | ||
| 17 | dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because | ||
| 18 | dnl 1. It works only for GCC. | ||
| 19 | dnl 2. It is incorrectly defined on some platforms, in some GCC versions. | ||
| 20 | AC_CACHE_CHECK( | ||
| 21 | [whether C symbols are prefixed with underscore at the linker level], | ||
| 22 | [gl_cv_prog_as_underscore], | ||
| 23 | [cat > conftest.c <<EOF | ||
| 24 | #ifdef __cplusplus | ||
| 25 | extern "C" int foo (void); | ||
| 26 | #endif | ||
| 27 | int foo(void) { return 0; } | ||
| 28 | EOF | ||
| 29 | # Look for the assembly language name in the .s file. | ||
| 30 | AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1 | ||
| 31 | if grep _foo conftest.s >/dev/null ; then | ||
| 32 | gl_cv_prog_as_underscore=yes | ||
| 33 | else | ||
| 34 | gl_cv_prog_as_underscore=no | ||
| 35 | fi | ||
| 36 | rm -f conftest* | ||
| 37 | ]) | ||
| 38 | if test $gl_cv_prog_as_underscore = yes; then | ||
| 39 | USER_LABEL_PREFIX=_ | ||
| 40 | else | ||
| 41 | USER_LABEL_PREFIX= | ||
| 42 | fi | ||
| 43 | AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX], | ||
| 44 | [Define to the prefix of C symbols at the assembler and linker level, | ||
| 45 | either an underscore or empty.]) | ||
| 46 | ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' | ||
| 47 | AC_SUBST([ASM_SYMBOL_PREFIX]) | ||
| 48 | ]) | ||
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4 index a19805ea..5b211e56 100644 --- a/gl/m4/getopt.m4 +++ b/gl/m4/getopt.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # getopt.m4 serial 24 | 1 | # getopt.m4 serial 28 |
| 2 | dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -79,8 +79,13 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | |||
| 79 | dnl Existence of the variable, in and of itself, is not a reason to replace | 79 | dnl Existence of the variable, in and of itself, is not a reason to replace |
| 80 | dnl getopt, but knowledge of the variable is needed to determine how to | 80 | dnl getopt, but knowledge of the variable is needed to determine how to |
| 81 | dnl reset and whether a reset reparses the environment. | 81 | dnl reset and whether a reset reparses the environment. |
| 82 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | 82 | dnl Solaris supports neither optreset nor optind=0, but keeps no state that |
| 83 | AC_CHECK_DECLS([optreset], [], [], | 83 | dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip. |
| 84 | if test -z "$gl_replace_getopt"; then | ||
| 85 | AC_CHECK_DECLS([optreset], [], | ||
| 86 | [AC_CHECK_DECLS([getopt_clip], [], [], | ||
| 87 | [[#include <getopt.h>]]) | ||
| 88 | ], | ||
| 84 | [[#include <getopt.h>]]) | 89 | [[#include <getopt.h>]]) |
| 85 | fi | 90 | fi |
| 86 | 91 | ||
| @@ -89,6 +94,10 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | |||
| 89 | dnl is left over from earlier calls, and neither setting optind = 0 nor | 94 | dnl is left over from earlier calls, and neither setting optind = 0 nor |
| 90 | dnl setting optreset = 1 get rid of this internal state. | 95 | dnl setting optreset = 1 get rid of this internal state. |
| 91 | dnl POSIX is silent on optind vs. optreset, so we allow either behavior. | 96 | dnl POSIX is silent on optind vs. optreset, so we allow either behavior. |
| 97 | dnl POSIX 2008 does not specify leading '+' behavior, but see | ||
| 98 | dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on | ||
| 99 | dnl the next version of POSIX. For now, we only guarantee leading '+' | ||
| 100 | dnl behavior with getopt-gnu. | ||
| 92 | if test -z "$gl_replace_getopt"; then | 101 | if test -z "$gl_replace_getopt"; then |
| 93 | AC_CACHE_CHECK([whether getopt is POSIX compatible], | 102 | AC_CACHE_CHECK([whether getopt is POSIX compatible], |
| 94 | [gl_cv_func_getopt_posix], | 103 | [gl_cv_func_getopt_posix], |
| @@ -99,7 +108,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | |||
| 99 | #include <stdlib.h> | 108 | #include <stdlib.h> |
| 100 | #include <string.h> | 109 | #include <string.h> |
| 101 | 110 | ||
| 102 | #if !HAVE_DECL_OPTRESET | 111 | #if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP |
| 103 | # define OPTIND_MIN 0 | 112 | # define OPTIND_MIN 0 |
| 104 | #else | 113 | #else |
| 105 | # define OPTIND_MIN 1 | 114 | # define OPTIND_MIN 1 |
| @@ -167,6 +176,20 @@ main () | |||
| 167 | if (!(optind == 1)) | 176 | if (!(optind == 1)) |
| 168 | return 12; | 177 | return 12; |
| 169 | } | 178 | } |
| 179 | /* Detect MacOS 10.5 bug. */ | ||
| 180 | { | ||
| 181 | char *argv[3] = { "program", "-ab", NULL }; | ||
| 182 | optind = OPTIND_MIN; | ||
| 183 | opterr = 0; | ||
| 184 | if (getopt (2, argv, "ab:") != 'a') | ||
| 185 | return 13; | ||
| 186 | if (getopt (2, argv, "ab:") != '?') | ||
| 187 | return 14; | ||
| 188 | if (optopt != 'b') | ||
| 189 | return 15; | ||
| 190 | if (optind != 2) | ||
| 191 | return 16; | ||
| 192 | } | ||
| 170 | 193 | ||
| 171 | return 0; | 194 | return 0; |
| 172 | } | 195 | } |
| @@ -174,6 +197,7 @@ main () | |||
| 174 | [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no], | 197 | [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no], |
| 175 | [case "$host_os" in | 198 | [case "$host_os" in |
| 176 | mingw*) gl_cv_func_getopt_posix="guessing no";; | 199 | mingw*) gl_cv_func_getopt_posix="guessing no";; |
| 200 | darwin*) gl_cv_func_getopt_posix="guessing no";; | ||
| 177 | *) gl_cv_func_getopt_posix="guessing yes";; | 201 | *) gl_cv_func_getopt_posix="guessing yes";; |
| 178 | esac | 202 | esac |
| 179 | ]) | 203 | ]) |
| @@ -234,6 +258,15 @@ main () | |||
| 234 | if (getopt (3, argv, "-p") != 'p') | 258 | if (getopt (3, argv, "-p") != 'p') |
| 235 | return 7; | 259 | return 7; |
| 236 | } | 260 | } |
| 261 | /* This code fails on glibc 2.11. */ | ||
| 262 | { | ||
| 263 | char *argv[] = { "program", "-b", "-a", NULL }; | ||
| 264 | optind = opterr = 0; | ||
| 265 | if (getopt (3, argv, "+:a:b") != 'b') | ||
| 266 | return 8; | ||
| 267 | if (getopt (3, argv, "+:a:b") != ':') | ||
| 268 | return 9; | ||
| 269 | } | ||
| 237 | return 0; | 270 | return 0; |
| 238 | ]])], | 271 | ]])], |
| 239 | [gl_cv_func_getopt_gnu=yes], | 272 | [gl_cv_func_getopt_gnu=yes], |
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4 index d6dc3fe2..f84e6a5d 100644 --- a/gl/m4/gettext.m4 +++ b/gl/m4/gettext.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # gettext.m4 serial 62 (gettext-0.18) | 1 | # gettext.m4 serial 63 (gettext-0.18) |
| 2 | dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -15,7 +15,7 @@ dnl They are *not* in the public domain. | |||
| 15 | 15 | ||
| 16 | dnl Authors: | 16 | dnl Authors: |
| 17 | dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. | 17 | dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. |
| 18 | dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006. | 18 | dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010. |
| 19 | 19 | ||
| 20 | dnl Macro to add for using GNU gettext. | 20 | dnl Macro to add for using GNU gettext. |
| 21 | 21 | ||
| @@ -60,6 +60,8 @@ AC_DEFUN([AM_GNU_GETTEXT], | |||
| 60 | ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , | 60 | ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , |
| 61 | [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT | 61 | [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT |
| 62 | ])])])])]) | 62 | ])])])])]) |
| 63 | ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], | ||
| 64 | [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) | ||
| 63 | ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , | 65 | ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , |
| 64 | [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT | 66 | [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT |
| 65 | ])])])]) | 67 | ])])])]) |
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 0ac6b969..97b1849b 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 | |||
| @@ -15,12 +15,13 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | # Specification in the form of a command-line invocation: | 17 | # Specification in the form of a command-line invocation: |
| 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf | 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf |
| 19 | 19 | ||
| 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: |
| 21 | gl_LOCAL_DIR([]) | 21 | gl_LOCAL_DIR([]) |
| 22 | gl_MODULES([ | 22 | gl_MODULES([ |
| 23 | base64 | 23 | base64 |
| 24 | crypto/sha1 | ||
| 24 | dirname | 25 | dirname |
| 25 | floorf | 26 | floorf |
| 26 | fsusage | 27 | fsusage |
| @@ -45,3 +46,4 @@ gl_LIB([libgnu]) | |||
| 45 | gl_MAKEFILE_NAME([]) | 46 | gl_MAKEFILE_NAME([]) |
| 46 | gl_MACRO_PREFIX([gl]) | 47 | gl_MACRO_PREFIX([gl]) |
| 47 | gl_PO_DOMAIN([]) | 48 | gl_PO_DOMAIN([]) |
| 49 | gl_VC_FILES([false]) | ||
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index 9cc519e7..4c7ac30d 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # gnulib-common.m4 serial 18 | 1 | # gnulib-common.m4 serial 20 |
| 2 | dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -35,6 +35,12 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 35 | is a misnomer outside of parameter lists. */ | 35 | is a misnomer outside of parameter lists. */ |
| 36 | #define _UNUSED_PARAMETER_ _GL_UNUSED | 36 | #define _UNUSED_PARAMETER_ _GL_UNUSED |
| 37 | ]) | 37 | ]) |
| 38 | dnl Preparation for running test programs: | ||
| 39 | dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not | ||
| 40 | dnl to /dev/tty, so they can be redirected to log files. Such diagnostics | ||
| 41 | dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. | ||
| 42 | LIBC_FATAL_STDERR_=1 | ||
| 43 | export LIBC_FATAL_STDERR_ | ||
| 38 | ]) | 44 | ]) |
| 39 | 45 | ||
| 40 | # gl_MODULE_INDICATOR_CONDITION | 46 | # gl_MODULE_INDICATOR_CONDITION |
| @@ -132,6 +138,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [ | |||
| 132 | # so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ | 138 | # so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ |
| 133 | # works. | 139 | # works. |
| 134 | # This definition can be removed once autoconf >= 2.62 can be assumed. | 140 | # This definition can be removed once autoconf >= 2.62 can be assumed. |
| 141 | m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[ | ||
| 135 | AC_DEFUN([AC_C_RESTRICT], | 142 | AC_DEFUN([AC_C_RESTRICT], |
| 136 | [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], | 143 | [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], |
| 137 | [ac_cv_c_restrict=no | 144 | [ac_cv_c_restrict=no |
| @@ -169,6 +176,7 @@ AC_DEFUN([AC_C_RESTRICT], | |||
| 169 | *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; | 176 | *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; |
| 170 | esac | 177 | esac |
| 171 | ]) | 178 | ]) |
| 179 | ]) | ||
| 172 | 180 | ||
| 173 | # gl_BIGENDIAN | 181 | # gl_BIGENDIAN |
| 174 | # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. | 182 | # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. |
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 4a956e44..f4031cc7 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 | |||
| @@ -26,7 +26,6 @@ AC_DEFUN([gl_EARLY], | |||
| 26 | m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable | 26 | m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable |
| 27 | AC_REQUIRE([AC_PROG_RANLIB]) | 27 | AC_REQUIRE([AC_PROG_RANLIB]) |
| 28 | # Code from module alignof: | 28 | # Code from module alignof: |
| 29 | # Code from module alloca: | ||
| 30 | # Code from module alloca-opt: | 29 | # Code from module alloca-opt: |
| 31 | # Code from module arg-nonnull: | 30 | # Code from module arg-nonnull: |
| 32 | # Code from module arpa_inet: | 31 | # Code from module arpa_inet: |
| @@ -37,6 +36,7 @@ AC_DEFUN([gl_EARLY], | |||
| 37 | # Code from module cloexec: | 36 | # Code from module cloexec: |
| 38 | # Code from module close-hook: | 37 | # Code from module close-hook: |
| 39 | # Code from module configmake: | 38 | # Code from module configmake: |
| 39 | # Code from module crypto/sha1: | ||
| 40 | # Code from module dirname: | 40 | # Code from module dirname: |
| 41 | # Code from module dirname-lgpl: | 41 | # Code from module dirname-lgpl: |
| 42 | # Code from module double-slash-root: | 42 | # Code from module double-slash-root: |
| @@ -146,7 +146,6 @@ AC_DEFUN([gl_INIT], | |||
| 146 | gl_COMMON | 146 | gl_COMMON |
| 147 | gl_source_base='gl' | 147 | gl_source_base='gl' |
| 148 | # Code from module alignof: | 148 | # Code from module alignof: |
| 149 | # Code from module alloca: | ||
| 150 | # Code from module alloca-opt: | 149 | # Code from module alloca-opt: |
| 151 | gl_FUNC_ALLOCA | 150 | gl_FUNC_ALLOCA |
| 152 | # Code from module arg-nonnull: | 151 | # Code from module arg-nonnull: |
| @@ -166,6 +165,8 @@ AC_DEFUN([gl_INIT], | |||
| 166 | gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) | 165 | gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) |
| 167 | # Code from module close-hook: | 166 | # Code from module close-hook: |
| 168 | # Code from module configmake: | 167 | # Code from module configmake: |
| 168 | # Code from module crypto/sha1: | ||
| 169 | gl_SHA1 | ||
| 169 | # Code from module dirname: | 170 | # Code from module dirname: |
| 170 | gl_DIRNAME | 171 | gl_DIRNAME |
| 171 | gl_MODULE_INDICATOR([dirname]) | 172 | gl_MODULE_INDICATOR([dirname]) |
| @@ -222,7 +223,7 @@ AC_DEFUN([gl_INIT], | |||
| 222 | gl_FUNC_GETOPT_POSIX | 223 | gl_FUNC_GETOPT_POSIX |
| 223 | # Code from module gettext: | 224 | # Code from module gettext: |
| 224 | dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. | 225 | dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. |
| 225 | AM_GNU_GETTEXT_VERSION([0.17]) | 226 | AM_GNU_GETTEXT_VERSION([0.18.1]) |
| 226 | # Code from module gettext-h: | 227 | # Code from module gettext-h: |
| 227 | AC_SUBST([LIBINTL]) | 228 | AC_SUBST([LIBINTL]) |
| 228 | AC_SUBST([LTLIBINTL]) | 229 | AC_SUBST([LTLIBINTL]) |
| @@ -522,7 +523,6 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 522 | build-aux/config.rpath | 523 | build-aux/config.rpath |
| 523 | build-aux/warn-on-use.h | 524 | build-aux/warn-on-use.h |
| 524 | lib/alignof.h | 525 | lib/alignof.h |
| 525 | lib/alloca.c | ||
| 526 | lib/alloca.in.h | 526 | lib/alloca.in.h |
| 527 | lib/arpa_inet.in.h | 527 | lib/arpa_inet.in.h |
| 528 | lib/asnprintf.c | 528 | lib/asnprintf.c |
| @@ -613,6 +613,8 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 613 | lib/safe-read.h | 613 | lib/safe-read.h |
| 614 | lib/safe-write.c | 614 | lib/safe-write.c |
| 615 | lib/safe-write.h | 615 | lib/safe-write.h |
| 616 | lib/sha1.c | ||
| 617 | lib/sha1.h | ||
| 616 | lib/size_max.h | 618 | lib/size_max.h |
| 617 | lib/snprintf.c | 619 | lib/snprintf.c |
| 618 | lib/sockets.c | 620 | lib/sockets.c |
| @@ -660,6 +662,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 660 | m4/00gnulib.m4 | 662 | m4/00gnulib.m4 |
| 661 | m4/alloca.m4 | 663 | m4/alloca.m4 |
| 662 | m4/arpa_inet_h.m4 | 664 | m4/arpa_inet_h.m4 |
| 665 | m4/asm-underscore.m4 | ||
| 663 | m4/base64.m4 | 666 | m4/base64.m4 |
| 664 | m4/btowc.m4 | 667 | m4/btowc.m4 |
| 665 | m4/c-strtod.m4 | 668 | m4/c-strtod.m4 |
| @@ -740,6 +743,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 740 | m4/safe-read.m4 | 743 | m4/safe-read.m4 |
| 741 | m4/safe-write.m4 | 744 | m4/safe-write.m4 |
| 742 | m4/servent.m4 | 745 | m4/servent.m4 |
| 746 | m4/sha1.m4 | ||
| 743 | m4/size_max.m4 | 747 | m4/size_max.m4 |
| 744 | m4/snprintf.m4 | 748 | m4/snprintf.m4 |
| 745 | m4/sockets.m4 | 749 | m4/sockets.m4 |
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4 index f46ff142..e2041b9b 100644 --- a/gl/m4/iconv.m4 +++ b/gl/m4/iconv.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # iconv.m4 serial 9 (gettext-0.18) | 1 | # iconv.m4 serial 11 (gettext-0.18.1) |
| 2 | dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -170,7 +170,22 @@ int main () | |||
| 170 | AC_SUBST([LTLIBICONV]) | 170 | AC_SUBST([LTLIBICONV]) |
| 171 | ]) | 171 | ]) |
| 172 | 172 | ||
| 173 | AC_DEFUN([AM_ICONV], | 173 | dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to |
| 174 | dnl avoid warnings like | ||
| 175 | dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". | ||
| 176 | dnl This is tricky because of the way 'aclocal' is implemented: | ||
| 177 | dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. | ||
| 178 | dnl Otherwise aclocal's initial scan pass would miss the macro definition. | ||
| 179 | dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. | ||
| 180 | dnl Otherwise aclocal would emit many "Use of uninitialized value $1" | ||
| 181 | dnl warnings. | ||
| 182 | m4_define([gl_iconv_AC_DEFUN], | ||
| 183 | m4_version_prereq([2.64], | ||
| 184 | [[AC_DEFUN_ONCE( | ||
| 185 | [$1], [$2])]], | ||
| 186 | [[AC_DEFUN( | ||
| 187 | [$1], [$2])]])) | ||
| 188 | gl_iconv_AC_DEFUN([AM_ICONV], | ||
| 174 | [ | 189 | [ |
| 175 | AM_ICONV_LINK | 190 | AM_ICONV_LINK |
| 176 | if test "$am_cv_func_iconv" = yes; then | 191 | if test "$am_cv_func_iconv" = yes; then |
diff --git a/gl/m4/intl.m4 b/gl/m4/intl.m4 index 5e17fea9..335b23c2 100644 --- a/gl/m4/intl.m4 +++ b/gl/m4/intl.m4 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # intl.m4 serial 8 (gettext-0.17) | 1 | # intl.m4 serial 17 (gettext-0.18) |
| 2 | dnl Copyright (C) 1995-2007, 2009-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1995-2009 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| @@ -15,9 +15,9 @@ dnl They are *not* in the public domain. | |||
| 15 | 15 | ||
| 16 | dnl Authors: | 16 | dnl Authors: |
| 17 | dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. | 17 | dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. |
| 18 | dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006. | 18 | dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009. |
| 19 | 19 | ||
| 20 | AC_PREREQ(2.52) | 20 | AC_PREREQ([2.52]) |
| 21 | 21 | ||
| 22 | dnl Checks for all prerequisites of the intl subdirectory, | 22 | dnl Checks for all prerequisites of the intl subdirectory, |
| 23 | dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, | 23 | dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, |
| @@ -40,14 +40,24 @@ AC_DEFUN([AM_INTL_SUBDIR], | |||
| 40 | AC_REQUIRE([gt_PRINTF_POSIX]) | 40 | AC_REQUIRE([gt_PRINTF_POSIX]) |
| 41 | AC_REQUIRE([gl_GLIBC21])dnl | 41 | AC_REQUIRE([gl_GLIBC21])dnl |
| 42 | AC_REQUIRE([gl_XSIZE])dnl | 42 | AC_REQUIRE([gl_XSIZE])dnl |
| 43 | AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl | ||
| 43 | AC_REQUIRE([gt_INTL_MACOSX])dnl | 44 | AC_REQUIRE([gt_INTL_MACOSX])dnl |
| 44 | 45 | ||
| 46 | dnl Support for automake's --enable-silent-rules. | ||
| 47 | case "$enable_silent_rules" in | ||
| 48 | yes) INTL_DEFAULT_VERBOSITY=0;; | ||
| 49 | no) INTL_DEFAULT_VERBOSITY=1;; | ||
| 50 | *) INTL_DEFAULT_VERBOSITY=1;; | ||
| 51 | esac | ||
| 52 | AC_SUBST([INTL_DEFAULT_VERBOSITY]) | ||
| 53 | |||
| 45 | AC_CHECK_TYPE([ptrdiff_t], , | 54 | AC_CHECK_TYPE([ptrdiff_t], , |
| 46 | [AC_DEFINE([ptrdiff_t], [long], | 55 | [AC_DEFINE([ptrdiff_t], [long], |
| 47 | [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) | 56 | [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) |
| 48 | ]) | 57 | ]) |
| 49 | AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) | 58 | AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) |
| 50 | AC_CHECK_FUNCS([asprintf fwprintf putenv setenv setlocale snprintf wcslen]) | 59 | AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \ |
| 60 | snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) | ||
| 51 | 61 | ||
| 52 | dnl Use the _snprintf function only if it is declared (because on NetBSD it | 62 | dnl Use the _snprintf function only if it is declared (because on NetBSD it |
| 53 | dnl is defined as a weak alias of snprintf; we prefer to use the latter). | 63 | dnl is defined as a weak alias of snprintf; we prefer to use the latter). |
| @@ -78,6 +88,12 @@ AC_DEFUN([AM_INTL_SUBDIR], | |||
| 78 | HAVE_SNPRINTF=0 | 88 | HAVE_SNPRINTF=0 |
| 79 | fi | 89 | fi |
| 80 | AC_SUBST([HAVE_SNPRINTF]) | 90 | AC_SUBST([HAVE_SNPRINTF]) |
| 91 | if test "$ac_cv_func_newlocale" = yes; then | ||
| 92 | HAVE_NEWLOCALE=1 | ||
| 93 | else | ||
| 94 | HAVE_NEWLOCALE=0 | ||
| 95 | fi | ||
| 96 | AC_SUBST([HAVE_NEWLOCALE]) | ||
| 81 | if test "$ac_cv_func_wprintf" = yes; then | 97 | if test "$ac_cv_func_wprintf" = yes; then |
| 82 | HAVE_WPRINTF=1 | 98 | HAVE_WPRINTF=1 |
| 83 | else | 99 | else |
| @@ -146,22 +162,31 @@ AC_DEFUN([AM_INTL_SUBDIR], | |||
| 146 | #define __libc_lock_lock_recursive gl_recursive_lock_lock | 162 | #define __libc_lock_lock_recursive gl_recursive_lock_lock |
| 147 | #define __libc_lock_unlock_recursive gl_recursive_lock_unlock | 163 | #define __libc_lock_unlock_recursive gl_recursive_lock_unlock |
| 148 | #define glthread_in_use libintl_thread_in_use | 164 | #define glthread_in_use libintl_thread_in_use |
| 149 | #define glthread_lock_init libintl_lock_init | 165 | #define glthread_lock_init_func libintl_lock_init_func |
| 150 | #define glthread_lock_lock libintl_lock_lock | 166 | #define glthread_lock_lock_func libintl_lock_lock_func |
| 151 | #define glthread_lock_unlock libintl_lock_unlock | 167 | #define glthread_lock_unlock_func libintl_lock_unlock_func |
| 152 | #define glthread_lock_destroy libintl_lock_destroy | 168 | #define glthread_lock_destroy_func libintl_lock_destroy_func |
| 153 | #define glthread_rwlock_init libintl_rwlock_init | 169 | #define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded |
| 154 | #define glthread_rwlock_rdlock libintl_rwlock_rdlock | 170 | #define glthread_rwlock_init_func libintl_rwlock_init_func |
| 155 | #define glthread_rwlock_wrlock libintl_rwlock_wrlock | 171 | #define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded |
| 156 | #define glthread_rwlock_unlock libintl_rwlock_unlock | 172 | #define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func |
| 157 | #define glthread_rwlock_destroy libintl_rwlock_destroy | 173 | #define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded |
| 158 | #define glthread_recursive_lock_init libintl_recursive_lock_init | 174 | #define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func |
| 159 | #define glthread_recursive_lock_lock libintl_recursive_lock_lock | 175 | #define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded |
| 160 | #define glthread_recursive_lock_unlock libintl_recursive_lock_unlock | 176 | #define glthread_rwlock_unlock_func libintl_rwlock_unlock_func |
| 161 | #define glthread_recursive_lock_destroy libintl_recursive_lock_destroy | 177 | #define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded |
| 162 | #define glthread_once libintl_once | 178 | #define glthread_rwlock_destroy_func libintl_rwlock_destroy_func |
| 163 | #define glthread_once_call libintl_once_call | 179 | #define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded |
| 180 | #define glthread_recursive_lock_init_func libintl_recursive_lock_init_func | ||
| 181 | #define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded | ||
| 182 | #define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func | ||
| 183 | #define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded | ||
| 184 | #define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func | ||
| 185 | #define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded | ||
| 186 | #define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func | ||
| 187 | #define glthread_once_func libintl_once_func | ||
| 164 | #define glthread_once_singlethreaded libintl_once_singlethreaded | 188 | #define glthread_once_singlethreaded libintl_once_singlethreaded |
| 189 | #define glthread_once_multithreaded libintl_once_multithreaded | ||
| 165 | ]) | 190 | ]) |
| 166 | ]) | 191 | ]) |
| 167 | 192 | ||
| @@ -198,40 +223,24 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE], | |||
| 198 | AC_TRY_LINK( | 223 | AC_TRY_LINK( |
| 199 | [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], | 224 | [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], |
| 200 | [], | 225 | [], |
| 201 | [AC_DEFINE([HAVE_BUILTIN_EXPECT], 1, | 226 | [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], |
| 202 | [Define to 1 if the compiler understands __builtin_expect.])]) | 227 | [Define to 1 if the compiler understands __builtin_expect.])]) |
| 203 | 228 | ||
| 204 | AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) | 229 | AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) |
| 205 | AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ | 230 | AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ |
| 206 | stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \ | 231 | stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \ |
| 207 | argz_next __fsetlocking]) | 232 | argz_stringify argz_next __fsetlocking]) |
| 208 | 233 | ||
| 209 | dnl Use the *_unlocked functions only if they are declared. | 234 | dnl Use the *_unlocked functions only if they are declared. |
| 210 | dnl (because some of them were defined without being declared in Solaris | 235 | dnl (because some of them were defined without being declared in Solaris |
| 211 | dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built | 236 | dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built |
| 212 | dnl on Solaris 2.5.1 to run on Solaris 2.6). | 237 | dnl on Solaris 2.5.1 to run on Solaris 2.6). |
| 213 | dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. | 238 | dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. |
| 214 | gt_CHECK_DECL(feof_unlocked, [#include <stdio.h>]) | 239 | gt_CHECK_DECL([feof_unlocked], [#include <stdio.h>]) |
| 215 | gt_CHECK_DECL(fgets_unlocked, [#include <stdio.h>]) | 240 | gt_CHECK_DECL([fgets_unlocked], [#include <stdio.h>]) |
| 216 | 241 | ||
| 217 | AM_ICONV | 242 | AM_ICONV |
| 218 | 243 | ||
| 219 | dnl glibc >= 2.4 has a NL_LOCALE_NAME macro when _GNU_SOURCE is defined, | ||
| 220 | dnl and a _NL_LOCALE_NAME macro always. | ||
| 221 | AC_CACHE_CHECK([for NL_LOCALE_NAME macro], gt_cv_nl_locale_name, | ||
| 222 | [AC_TRY_LINK([#include <langinfo.h> | ||
| 223 | #include <locale.h>], | ||
| 224 | [char* cs = nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES)); | ||
| 225 | return !cs; | ||
| 226 | ], | ||
| 227 | gt_cv_nl_locale_name=yes, | ||
| 228 | gt_cv_nl_locale_name=no) | ||
| 229 | ]) | ||
| 230 | if test $gt_cv_nl_locale_name = yes; then | ||
| 231 | AC_DEFINE(HAVE_NL_LOCALE_NAME, 1, | ||
| 232 | [Define if you have <langinfo.h> and it defines the NL_LOCALE_NAME macro if _GNU_SOURCE is defined.]) | ||
| 233 | fi | ||
| 234 | |||
| 235 | dnl intl/plural.c is generated from intl/plural.y. It requires bison, | 244 | dnl intl/plural.c is generated from intl/plural.y. It requires bison, |
| 236 | dnl because plural.y uses bison specific features. It requires at least | 245 | dnl because plural.y uses bison specific features. It requires at least |
| 237 | dnl bison-1.26 because earlier versions generate a plural.c that doesn't | 246 | dnl bison-1.26 because earlier versions generate a plural.c that doesn't |
| @@ -269,7 +278,7 @@ dnl gt_CHECK_DECL(FUNC, INCLUDES) | |||
| 269 | dnl Check whether a function is declared. | 278 | dnl Check whether a function is declared. |
| 270 | AC_DEFUN([gt_CHECK_DECL], | 279 | AC_DEFUN([gt_CHECK_DECL], |
| 271 | [ | 280 | [ |
| 272 | AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, | 281 | AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1], |
| 273 | [AC_TRY_COMPILE([$2], [ | 282 | [AC_TRY_COMPILE([$2], [ |
| 274 | #ifndef $1 | 283 | #ifndef $1 |
| 275 | char *p = (char *) $1; | 284 | char *p = (char *) $1; |
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4 index 90e1ac91..59b367df 100644 --- a/gl/m4/lib-link.m4 +++ b/gl/m4/lib-link.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # lib-link.m4 serial 20 (gettext-0.18) | 1 | # lib-link.m4 serial 23 (gettext-0.18.2) |
| 2 | dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -18,9 +18,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS], | |||
| 18 | [ | 18 | [ |
| 19 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) | 19 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
| 20 | AC_REQUIRE([AC_LIB_RPATH]) | 20 | AC_REQUIRE([AC_LIB_RPATH]) |
| 21 | pushdef([Name],[translit([$1],[./-], [___])]) | 21 | pushdef([Name],[m4_translit([$1],[./+-], [____])]) |
| 22 | pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], | 22 | pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], |
| 23 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 23 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
| 24 | AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ | 24 | AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ |
| 25 | AC_LIB_LINKFLAGS_BODY([$1], [$2]) | 25 | AC_LIB_LINKFLAGS_BODY([$1], [$2]) |
| 26 | ac_cv_lib[]Name[]_libs="$LIB[]NAME" | 26 | ac_cv_lib[]Name[]_libs="$LIB[]NAME" |
| @@ -58,9 +58,9 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], | |||
| 58 | [ | 58 | [ |
| 59 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) | 59 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
| 60 | AC_REQUIRE([AC_LIB_RPATH]) | 60 | AC_REQUIRE([AC_LIB_RPATH]) |
| 61 | pushdef([Name],[translit([$1],[./-], [___])]) | 61 | pushdef([Name],[m4_translit([$1],[./+-], [____])]) |
| 62 | pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], | 62 | pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], |
| 63 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 63 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
| 64 | 64 | ||
| 65 | dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME | 65 | dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME |
| 66 | dnl accordingly. | 66 | dnl accordingly. |
| @@ -74,7 +74,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], | |||
| 74 | 74 | ||
| 75 | AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ | 75 | AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ |
| 76 | ac_save_LIBS="$LIBS" | 76 | ac_save_LIBS="$LIBS" |
| 77 | LIBS="$LIBS $LIB[]NAME" | 77 | dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, |
| 78 | dnl because these -l options might require -L options that are present in | ||
| 79 | dnl LIBS. -l options benefit only from the -L options listed before it. | ||
| 80 | dnl Otherwise, add it to the front of LIBS, because it may be a static | ||
| 81 | dnl library that depends on another static library that is present in LIBS. | ||
| 82 | dnl Static libraries benefit only from the static libraries listed after | ||
| 83 | dnl it. | ||
| 84 | case " $LIB[]NAME" in | ||
| 85 | *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; | ||
| 86 | *) LIBS="$LIB[]NAME $LIBS" ;; | ||
| 87 | esac | ||
| 78 | AC_TRY_LINK([$3], [$4], | 88 | AC_TRY_LINK([$3], [$4], |
| 79 | [ac_cv_lib[]Name=yes], | 89 | [ac_cv_lib[]Name=yes], |
| 80 | [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) | 90 | [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) |
| @@ -147,13 +157,13 @@ dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar | |||
| 147 | dnl macro call that searches for libname. | 157 | dnl macro call that searches for libname. |
| 148 | AC_DEFUN([AC_LIB_FROMPACKAGE], | 158 | AC_DEFUN([AC_LIB_FROMPACKAGE], |
| 149 | [ | 159 | [ |
| 150 | pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], | 160 | pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], |
| 151 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 161 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
| 152 | define([acl_frompackage_]NAME, [$2]) | 162 | define([acl_frompackage_]NAME, [$2]) |
| 153 | popdef([NAME]) | 163 | popdef([NAME]) |
| 154 | pushdef([PACK],[$2]) | 164 | pushdef([PACK],[$2]) |
| 155 | pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], | 165 | pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], |
| 156 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 166 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
| 157 | define([acl_libsinpackage_]PACKUP, | 167 | define([acl_libsinpackage_]PACKUP, |
| 158 | m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) | 168 | m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) |
| 159 | popdef([PACKUP]) | 169 | popdef([PACKUP]) |
| @@ -168,14 +178,14 @@ dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. | |||
| 168 | AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | 178 | AC_DEFUN([AC_LIB_LINKFLAGS_BODY], |
| 169 | [ | 179 | [ |
| 170 | AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) | 180 | AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) |
| 171 | pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], | 181 | pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], |
| 172 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 182 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
| 173 | pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) | 183 | pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) |
| 174 | pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], | 184 | pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], |
| 175 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 185 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) |
| 176 | pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) | 186 | pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) |
| 177 | dnl Autoconf >= 2.61 supports dots in --with options. | 187 | dnl Autoconf >= 2.61 supports dots in --with options. |
| 178 | pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) | 188 | pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) |
| 179 | dnl By default, look in $includedir and $libdir. | 189 | dnl By default, look in $includedir and $libdir. |
| 180 | use_additional=yes | 190 | use_additional=yes |
| 181 | AC_LIB_WITH_FINAL_PREFIX([ | 191 | AC_LIB_WITH_FINAL_PREFIX([ |
| @@ -232,7 +242,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
| 232 | names_already_handled="$names_already_handled $name" | 242 | names_already_handled="$names_already_handled $name" |
| 233 | dnl See if it was already located by an earlier AC_LIB_LINKFLAGS | 243 | dnl See if it was already located by an earlier AC_LIB_LINKFLAGS |
| 234 | dnl or AC_LIB_HAVE_LINKFLAGS call. | 244 | dnl or AC_LIB_HAVE_LINKFLAGS call. |
| 235 | uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` | 245 | uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` |
| 236 | eval value=\"\$HAVE_LIB$uppername\" | 246 | eval value=\"\$HAVE_LIB$uppername\" |
| 237 | if test -n "$value"; then | 247 | if test -n "$value"; then |
| 238 | if test "$value" = yes; then | 248 | if test "$value" = yes; then |
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4 index 40ba8f66..c870fb61 100644 --- a/gl/m4/netdb_h.m4 +++ b/gl/m4/netdb_h.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # netdb_h.m4 serial 7 | 1 | # netdb_h.m4 serial 9 |
| 2 | dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -10,21 +10,16 @@ AC_DEFUN([gl_HEADER_NETDB], | |||
| 10 | AC_CHECK_HEADERS_ONCE([netdb.h]) | 10 | AC_CHECK_HEADERS_ONCE([netdb.h]) |
| 11 | gl_CHECK_NEXT_HEADERS([netdb.h]) | 11 | gl_CHECK_NEXT_HEADERS([netdb.h]) |
| 12 | if test $ac_cv_header_netdb_h = yes; then | 12 | if test $ac_cv_header_netdb_h = yes; then |
| 13 | AC_COMPILE_IFELSE( | ||
| 14 | [AC_LANG_PROGRAM([[ | ||
| 15 | #include <netdb.h> | ||
| 16 | struct addrinfo a; | ||
| 17 | int b = EAI_OVERFLOW; | ||
| 18 | int c = AI_NUMERICSERV; | ||
| 19 | ]])], | ||
| 20 | [NETDB_H=''], [NETDB_H='netdb.h']) | ||
| 21 | HAVE_NETDB_H=1 | 13 | HAVE_NETDB_H=1 |
| 22 | else | 14 | else |
| 23 | NETDB_H='netdb.h' | ||
| 24 | HAVE_NETDB_H=0 | 15 | HAVE_NETDB_H=0 |
| 25 | fi | 16 | fi |
| 26 | AC_SUBST([HAVE_NETDB_H]) | 17 | AC_SUBST([HAVE_NETDB_H]) |
| 27 | AC_SUBST([NETDB_H]) | 18 | |
| 19 | dnl Check for declarations of anything we want to poison if the | ||
| 20 | dnl corresponding gnulib module is not in use. | ||
| 21 | gl_WARN_ON_USE_PREPARE([[#include <netdb.h>]], | ||
| 22 | [getaddrinfo freeaddrinfo gai_strerror getnameinfo]) | ||
| 28 | ]) | 23 | ]) |
| 29 | 24 | ||
| 30 | AC_DEFUN([gl_NETDB_MODULE_INDICATOR], | 25 | AC_DEFUN([gl_NETDB_MODULE_INDICATOR], |
diff --git a/gl/m4/onceonly.m4 b/gl/m4/onceonly.m4 index 4a3cd84d..6a9c87b7 100644 --- a/gl/m4/onceonly.m4 +++ b/gl/m4/onceonly.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # onceonly.m4 serial 6 | 1 | # onceonly.m4 serial 7 |
| 2 | dnl Copyright (C) 2002-2003, 2005-2006, 2008-2010 Free Software Foundation, | 2 | dnl Copyright (C) 2002-2003, 2005-2006, 2008-2010 Free Software Foundation, |
| 3 | dnl Inc. | 3 | dnl Inc. |
| 4 | dnl This file is free software, distributed under the terms of the GNU | 4 | dnl This file is free software, distributed under the terms of the GNU |
| @@ -39,16 +39,16 @@ AC_PREREQ([2.59]) | |||
| 39 | AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ | 39 | AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ |
| 40 | : | 40 | : |
| 41 | m4_foreach_w([gl_HEADER_NAME], [$1], [ | 41 | m4_foreach_w([gl_HEADER_NAME], [$1], [ |
| 42 | AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, | 42 | AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, |
| 43 | [./-], [___])), [ | 43 | [./-], [___])), [ |
| 44 | m4_divert_text([INIT_PREPARE], | 44 | m4_divert_text([INIT_PREPARE], |
| 45 | [gl_header_list="$gl_header_list gl_HEADER_NAME"]) | 45 | [gl_header_list="$gl_header_list gl_HEADER_NAME"]) |
| 46 | gl_HEADERS_EXPANSION | 46 | gl_HEADERS_EXPANSION |
| 47 | AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), | 47 | AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), |
| 48 | [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) | 48 | [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) |
| 49 | ]) | 49 | ]) |
| 50 | AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, | 50 | AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, |
| 51 | [./-], [___]))) | 51 | [./-], [___]))) |
| 52 | ]) | 52 | ]) |
| 53 | ]) | 53 | ]) |
| 54 | m4_define([gl_HEADERS_EXPANSION], [ | 54 | m4_define([gl_HEADERS_EXPANSION], [ |
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4 index 960efe15..47f36a41 100644 --- a/gl/m4/po.m4 +++ b/gl/m4/po.m4 | |||
| @@ -29,7 +29,7 @@ AC_DEFUN([AM_PO_SUBDIRS], | |||
| 29 | 29 | ||
| 30 | dnl Release version of the gettext macros. This is used to ensure that | 30 | dnl Release version of the gettext macros. This is used to ensure that |
| 31 | dnl the gettext macros and po/Makefile.in.in are in sync. | 31 | dnl the gettext macros and po/Makefile.in.in are in sync. |
| 32 | AC_SUBST([GETTEXT_MACRO_VERSION], [0.17]) | 32 | AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) |
| 33 | 33 | ||
| 34 | dnl Perform the following tests also if --disable-nls has been given, | 34 | dnl Perform the following tests also if --disable-nls has been given, |
| 35 | dnl because they are needed for "make dist" to work. | 35 | dnl because they are needed for "make dist" to work. |
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4 index ebca5364..b31efe3e 100644 --- a/gl/m4/printf.m4 +++ b/gl/m4/printf.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # printf.m4 serial 33 | 1 | # printf.m4 serial 34 |
| 2 | dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -1101,7 +1101,7 @@ dnl } | |||
| 1101 | dnl --------------------------------------------------------------------- | 1101 | dnl --------------------------------------------------------------------- |
| 1102 | dnl Result is gl_cv_func_snprintf_retval_c99. | 1102 | dnl Result is gl_cv_func_snprintf_retval_c99. |
| 1103 | 1103 | ||
| 1104 | AC_DEFUN([gl_SNPRINTF_RETVAL_C99], | 1104 | AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], |
| 1105 | [ | 1105 | [ |
| 1106 | AC_REQUIRE([AC_PROG_CC]) | 1106 | AC_REQUIRE([AC_PROG_CC]) |
| 1107 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 1107 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
diff --git a/gl/m4/sha1.m4 b/gl/m4/sha1.m4 new file mode 100644 index 00000000..0d18d857 --- /dev/null +++ b/gl/m4/sha1.m4 | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | # sha1.m4 serial 9 | ||
| 2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software | ||
| 3 | dnl Foundation, Inc. | ||
| 4 | dnl This file is free software; the Free Software Foundation | ||
| 5 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 6 | dnl with or without modifications, as long as this notice is preserved. | ||
| 7 | |||
| 8 | AC_DEFUN([gl_SHA1], | ||
| 9 | [ | ||
| 10 | AC_LIBOBJ([sha1]) | ||
| 11 | |||
| 12 | dnl Prerequisites of lib/sha1.c. | ||
| 13 | AC_REQUIRE([gl_BIGENDIAN]) | ||
| 14 | AC_REQUIRE([AC_C_INLINE]) | ||
| 15 | : | ||
| 16 | ]) | ||
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4 index 8a0c2360..8806705a 100644 --- a/gl/m4/sockpfaf.m4 +++ b/gl/m4/sockpfaf.m4 | |||
| @@ -47,6 +47,9 @@ AC_DEFUN([gl_SOCKET_FAMILIES], | |||
| 47 | #endif | 47 | #endif |
| 48 | #ifdef HAVE_WINSOCK2_H | 48 | #ifdef HAVE_WINSOCK2_H |
| 49 | #include <winsock2.h> | 49 | #include <winsock2.h> |
| 50 | #endif | ||
| 51 | #ifdef HAVE_WS2TCPIP_H | ||
| 52 | #include <ws2tcpip.h> | ||
| 50 | #endif]], | 53 | #endif]], |
| 51 | [[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; | 54 | [[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; |
| 52 | if (&x && &y && &z) return 0;]])], | 55 | if (&x && &y && &z) return 0;]])], |
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4 index 1cc57e6e..c5e813a9 100644 --- a/gl/m4/stdint.m4 +++ b/gl/m4/stdint.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # stdint.m4 serial 34 | 1 | # stdint.m4 serial 35 |
| 2 | dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -309,7 +309,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], | |||
| 309 | dnl config.h.in, | 309 | dnl config.h.in, |
| 310 | dnl - extra AC_SUBST calls, so that the right substitutions are made. | 310 | dnl - extra AC_SUBST calls, so that the right substitutions are made. |
| 311 | m4_foreach_w([gltype], [$1], | 311 | m4_foreach_w([gltype], [$1], |
| 312 | [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), | 312 | [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), |
| 313 | [Define to the number of bits in type ']gltype['.])]) | 313 | [Define to the number of bits in type ']gltype['.])]) |
| 314 | for gltype in $1 ; do | 314 | for gltype in $1 ; do |
| 315 | AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], | 315 | AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], |
| @@ -334,7 +334,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], | |||
| 334 | eval BITSIZEOF_${GLTYPE}=\$result | 334 | eval BITSIZEOF_${GLTYPE}=\$result |
| 335 | done | 335 | done |
| 336 | m4_foreach_w([gltype], [$1], | 336 | m4_foreach_w([gltype], [$1], |
| 337 | [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) | 337 | [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) |
| 338 | ]) | 338 | ]) |
| 339 | 339 | ||
| 340 | dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) | 340 | dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) |
| @@ -347,7 +347,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], | |||
| 347 | dnl config.h.in, | 347 | dnl config.h.in, |
| 348 | dnl - extra AC_SUBST calls, so that the right substitutions are made. | 348 | dnl - extra AC_SUBST calls, so that the right substitutions are made. |
| 349 | m4_foreach_w([gltype], [$1], | 349 | m4_foreach_w([gltype], [$1], |
| 350 | [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), | 350 | [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), |
| 351 | [Define to 1 if ']gltype[' is a signed integer type.])]) | 351 | [Define to 1 if ']gltype[' is a signed integer type.])]) |
| 352 | for gltype in $1 ; do | 352 | for gltype in $1 ; do |
| 353 | AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], | 353 | AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], |
| @@ -367,7 +367,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], | |||
| 367 | fi | 367 | fi |
| 368 | done | 368 | done |
| 369 | m4_foreach_w([gltype], [$1], | 369 | m4_foreach_w([gltype], [$1], |
| 370 | [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) | 370 | [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) |
| 371 | ]) | 371 | ]) |
| 372 | 372 | ||
| 373 | dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) | 373 | dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) |
| @@ -380,7 +380,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], | |||
| 380 | dnl config.h.in, | 380 | dnl config.h.in, |
| 381 | dnl - extra AC_SUBST calls, so that the right substitutions are made. | 381 | dnl - extra AC_SUBST calls, so that the right substitutions are made. |
| 382 | m4_foreach_w([gltype], [$1], | 382 | m4_foreach_w([gltype], [$1], |
| 383 | [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], | 383 | [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], |
| 384 | [Define to l, ll, u, ul, ull, etc., as suitable for | 384 | [Define to l, ll, u, ul, ull, etc., as suitable for |
| 385 | constants of type ']gltype['.])]) | 385 | constants of type ']gltype['.])]) |
| 386 | for gltype in $1 ; do | 386 | for gltype in $1 ; do |
| @@ -419,7 +419,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], | |||
| 419 | AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) | 419 | AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) |
| 420 | done | 420 | done |
| 421 | m4_foreach_w([gltype], [$1], | 421 | m4_foreach_w([gltype], [$1], |
| 422 | [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) | 422 | [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) |
| 423 | ]) | 423 | ]) |
| 424 | 424 | ||
| 425 | dnl gl_STDINT_INCLUDES | 425 | dnl gl_STDINT_INCLUDES |
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4 index 1d1d95e5..f5650cde 100644 --- a/gl/m4/stdio_h.m4 +++ b/gl/m4/stdio_h.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # stdio_h.m4 serial 30 | 1 | # stdio_h.m4 serial 31 |
| 2 | dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -8,6 +8,7 @@ AC_DEFUN([gl_STDIO_H], | |||
| 8 | [ | 8 | [ |
| 9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | 9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) |
| 10 | AC_REQUIRE([AC_C_INLINE]) | 10 | AC_REQUIRE([AC_C_INLINE]) |
| 11 | AC_REQUIRE([gl_ASM_SYMBOL_PREFIX]) | ||
| 11 | gl_CHECK_NEXT_HEADERS([stdio.h]) | 12 | gl_CHECK_NEXT_HEADERS([stdio.h]) |
| 12 | dnl No need to create extra modules for these functions. Everyone who uses | 13 | dnl No need to create extra modules for these functions. Everyone who uses |
| 13 | dnl <stdio.h> likely needs them. | 14 | dnl <stdio.h> likely needs them. |
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 index cf26123e..1977aecf 100644 --- a/gl/m4/string_h.m4 +++ b/gl/m4/string_h.m4 | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | # gives unlimited permission to copy and/or distribute it, | 5 | # gives unlimited permission to copy and/or distribute it, |
| 6 | # with or without modifications, as long as this notice is preserved. | 6 | # with or without modifications, as long as this notice is preserved. |
| 7 | 7 | ||
| 8 | # serial 16 | 8 | # serial 17 |
| 9 | 9 | ||
| 10 | # Written by Paul Eggert. | 10 | # Written by Paul Eggert. |
| 11 | 11 | ||
| @@ -105,6 +105,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], | |||
| 105 | REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) | 105 | REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) |
| 106 | REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) | 106 | REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) |
| 107 | REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) | 107 | REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) |
| 108 | REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) | ||
| 108 | REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) | 109 | REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) |
| 109 | REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) | 110 | REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) |
| 110 | UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) | 111 | UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) |
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4 index cd48948f..52bb838f 100644 --- a/gl/m4/strnlen.m4 +++ b/gl/m4/strnlen.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # strnlen.m4 serial 10 | 1 | # strnlen.m4 serial 12 |
| 2 | dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, | 2 | dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, |
| 3 | dnl Inc. | 3 | dnl Inc. |
| 4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| @@ -7,23 +7,23 @@ dnl with or without modifications, as long as this notice is preserved. | |||
| 7 | 7 | ||
| 8 | AC_DEFUN([gl_FUNC_STRNLEN], | 8 | AC_DEFUN([gl_FUNC_STRNLEN], |
| 9 | [ | 9 | [ |
| 10 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
| 11 | |||
| 10 | dnl Persuade glibc <string.h> to declare strnlen(). | 12 | dnl Persuade glibc <string.h> to declare strnlen(). |
| 11 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | 13 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 12 | 14 | ||
| 13 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
| 14 | AC_CHECK_DECLS_ONCE([strnlen]) | 15 | AC_CHECK_DECLS_ONCE([strnlen]) |
| 15 | if test $ac_cv_have_decl_strnlen = no; then | 16 | if test $ac_cv_have_decl_strnlen = no; then |
| 16 | HAVE_DECL_STRNLEN=0 | 17 | HAVE_DECL_STRNLEN=0 |
| 18 | else | ||
| 19 | AC_FUNC_STRNLEN | ||
| 20 | dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]). | ||
| 21 | if test $ac_cv_func_strnlen_working = no; then | ||
| 22 | REPLACE_STRNLEN=1 | ||
| 23 | fi | ||
| 17 | fi | 24 | fi |
| 18 | 25 | if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then | |
| 19 | AC_FUNC_STRNLEN | 26 | AC_LIBOBJ([strnlen]) |
| 20 | if test $ac_cv_func_strnlen_working = no; then | ||
| 21 | # This is necessary because automake-1.6.1 doesn't understand | ||
| 22 | # that the above use of AC_FUNC_STRNLEN means we may have to use | ||
| 23 | # lib/strnlen.c. | ||
| 24 | #AC_LIBOBJ([strnlen]) | ||
| 25 | AC_DEFINE([strnlen], [rpl_strnlen], | ||
| 26 | [Define to rpl_strnlen if the replacement function should be used.]) | ||
| 27 | gl_PREREQ_STRNLEN | 27 | gl_PREREQ_STRNLEN |
| 28 | fi | 28 | fi |
| 29 | ]) | 29 | ]) |
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4 index b88ba94d..a45a10a9 100644 --- a/gl/m4/time_h.m4 +++ b/gl/m4/time_h.m4 | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. | 3 | # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | # serial 2 | ||
| 6 | |||
| 5 | # This file is free software; the Free Software Foundation | 7 | # This file is free software; the Free Software Foundation |
| 6 | # gives unlimited permission to copy and/or distribute it, | 8 | # gives unlimited permission to copy and/or distribute it, |
| 7 | # with or without modifications, as long as this notice is preserved. | 9 | # with or without modifications, as long as this notice is preserved. |
| @@ -24,7 +26,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY], | |||
| 24 | ]) | 26 | ]) |
| 25 | 27 | ||
| 26 | dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared | 28 | dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared |
| 27 | dnl in time.h or sys/time.h. | 29 | dnl in time.h, sys/time.h, or pthread.h. |
| 28 | 30 | ||
| 29 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], | 31 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], |
| 30 | [ | 32 | [ |
| @@ -41,6 +43,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], | |||
| 41 | 43 | ||
| 42 | TIME_H_DEFINES_STRUCT_TIMESPEC=0 | 44 | TIME_H_DEFINES_STRUCT_TIMESPEC=0 |
| 43 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 | 45 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 |
| 46 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 | ||
| 44 | if test $gl_cv_sys_struct_timespec_in_time_h = yes; then | 47 | if test $gl_cv_sys_struct_timespec_in_time_h = yes; then |
| 45 | TIME_H_DEFINES_STRUCT_TIMESPEC=1 | 48 | TIME_H_DEFINES_STRUCT_TIMESPEC=1 |
| 46 | else | 49 | else |
| @@ -55,10 +58,24 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], | |||
| 55 | [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) | 58 | [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) |
| 56 | if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then | 59 | if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then |
| 57 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 | 60 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 |
| 61 | else | ||
| 62 | AC_CACHE_CHECK([for struct timespec in <pthread.h>], | ||
| 63 | [gl_cv_sys_struct_timespec_in_pthread_h], | ||
| 64 | [AC_COMPILE_IFELSE( | ||
| 65 | [AC_LANG_PROGRAM( | ||
| 66 | [[#include <pthread.h> | ||
| 67 | ]], | ||
| 68 | [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], | ||
| 69 | [gl_cv_sys_struct_timespec_in_pthread_h=yes], | ||
| 70 | [gl_cv_sys_struct_timespec_in_pthread_h=no])]) | ||
| 71 | if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then | ||
| 72 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 | ||
| 73 | fi | ||
| 58 | fi | 74 | fi |
| 59 | fi | 75 | fi |
| 60 | AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) | 76 | AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) |
| 61 | AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) | 77 | AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) |
| 78 | AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) | ||
| 62 | ]) | 79 | ]) |
| 63 | 80 | ||
| 64 | AC_DEFUN([gl_TIME_MODULE_INDICATOR], | 81 | AC_DEFUN([gl_TIME_MODULE_INDICATOR], |
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index 8c2eec64..48d06c74 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # unistd_h.m4 serial 45 | 1 | # unistd_h.m4 serial 46 |
| 2 | dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -38,8 +38,9 @@ AC_DEFUN([gl_UNISTD_H], | |||
| 38 | ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat | 38 | ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat |
| 39 | fsync ftruncate getcwd getdomainname getdtablesize getgroups | 39 | fsync ftruncate getcwd getdomainname getdtablesize getgroups |
| 40 | gethostname getlogin getlogin_r getpagesize getusershell setusershell | 40 | gethostname getlogin getlogin_r getpagesize getusershell setusershell |
| 41 | endusershell lchown link linkat lseek pipe2 pread readlink readlinkat | 41 | endusershell lchown link linkat lseek pipe2 pread pwrite readlink |
| 42 | rmdir sleep symlink symlinkat ttyname_r unlink unlinkat usleep]) | 42 | readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat |
| 43 | usleep]) | ||
| 43 | ]) | 44 | ]) |
| 44 | 45 | ||
| 45 | AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], | 46 | AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], |
| @@ -79,6 +80,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], | |||
| 79 | GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) | 80 | GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) |
| 80 | GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) | 81 | GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) |
| 81 | GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) | 82 | GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) |
| 83 | GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE]) | ||
| 82 | GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) | 84 | GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) |
| 83 | GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) | 85 | GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) |
| 84 | GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) | 86 | GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) |
| @@ -113,6 +115,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], | |||
| 113 | HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) | 115 | HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) |
| 114 | HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) | 116 | HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) |
| 115 | HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) | 117 | HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) |
| 118 | HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) | ||
| 116 | HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) | 119 | HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) |
| 117 | HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) | 120 | HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) |
| 118 | HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) | 121 | HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) |
| @@ -140,10 +143,12 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], | |||
| 140 | REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) | 143 | REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) |
| 141 | REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) | 144 | REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) |
| 142 | REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) | 145 | REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) |
| 146 | REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) | ||
| 143 | REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) | 147 | REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) |
| 144 | REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) | 148 | REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) |
| 145 | REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) | 149 | REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) |
| 146 | REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) | 150 | REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) |
| 151 | REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) | ||
| 147 | REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) | 152 | REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) |
| 148 | REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) | 153 | REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) |
| 149 | REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) | 154 | REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) |
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4 index 50a20cca..ebe3c52c 100644 --- a/gl/m4/vasnprintf.m4 +++ b/gl/m4/vasnprintf.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # vasnprintf.m4 serial 29 | 1 | # vasnprintf.m4 serial 31 |
| 2 | dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -54,6 +54,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE], | |||
| 54 | # Prerequisites of lib/vasnprintf.c. | 54 | # Prerequisites of lib/vasnprintf.c. |
| 55 | AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], | 55 | AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], |
| 56 | [ | 56 | [ |
| 57 | AC_REQUIRE([AC_C_INLINE]) | ||
| 57 | AC_REQUIRE([AC_FUNC_ALLOCA]) | 58 | AC_REQUIRE([AC_FUNC_ALLOCA]) |
| 58 | AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) | 59 | AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) |
| 59 | AC_REQUIRE([gt_TYPE_WCHAR_T]) | 60 | AC_REQUIRE([gt_TYPE_WCHAR_T]) |
| @@ -62,6 +63,17 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], | |||
| 62 | dnl Use the _snprintf function only if it is declared (because on NetBSD it | 63 | dnl Use the _snprintf function only if it is declared (because on NetBSD it |
| 63 | dnl is defined as a weak alias of snprintf; we prefer to use the latter). | 64 | dnl is defined as a weak alias of snprintf; we prefer to use the latter). |
| 64 | AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>]) | 65 | AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>]) |
| 66 | dnl We can avoid a lot of code by assuming that snprintf's return value | ||
| 67 | dnl conforms to ISO C99. So check that. | ||
| 68 | AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) | ||
| 69 | case "$gl_cv_func_snprintf_retval_c99" in | ||
| 70 | *yes) | ||
| 71 | AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1], | ||
| 72 | [Define if the return value of the snprintf function is the number of | ||
| 73 | of bytes (excluding the terminating NUL) that would have been produced | ||
| 74 | if the buffer had been large enough.]) | ||
| 75 | ;; | ||
| 76 | esac | ||
| 65 | ]) | 77 | ]) |
| 66 | 78 | ||
| 67 | # Extra prerequisites of lib/vasnprintf.c for supporting 'long double' | 79 | # Extra prerequisites of lib/vasnprintf.c for supporting 'long double' |
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4 index 6d3f9c9d..077c4765 100644 --- a/gl/m4/visibility.m4 +++ b/gl/m4/visibility.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # visibility.m4 serial 2 (gettext-0.18) | 1 | # visibility.m4 serial 3 (gettext-0.18) |
| 2 | dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -26,15 +26,37 @@ AC_DEFUN([gl_VISIBILITY], | |||
| 26 | CFLAG_VISIBILITY= | 26 | CFLAG_VISIBILITY= |
| 27 | HAVE_VISIBILITY=0 | 27 | HAVE_VISIBILITY=0 |
| 28 | if test -n "$GCC"; then | 28 | if test -n "$GCC"; then |
| 29 | dnl First, check whether -Werror can be added to the command line, or | ||
| 30 | dnl whether it leads to an error because of some other option that the | ||
| 31 | dnl user has put into $CC $CFLAGS $CPPFLAGS. | ||
| 32 | AC_MSG_CHECKING([whether the -Werror option is usable]) | ||
| 33 | AC_CACHE_VAL([gl_cv_cc_vis_werror], [ | ||
| 34 | gl_save_CFLAGS="$CFLAGS" | ||
| 35 | CFLAGS="$CFLAGS -Werror" | ||
| 36 | AC_TRY_COMPILE([], [], | ||
| 37 | [gl_cv_cc_vis_werror=yes], | ||
| 38 | [gl_cv_cc_vis_werror=no]) | ||
| 39 | CFLAGS="$gl_save_CFLAGS"]) | ||
| 40 | AC_MSG_RESULT([$gl_cv_cc_vis_werror]) | ||
| 41 | dnl Now check whether visibility declarations are supported. | ||
| 29 | AC_MSG_CHECKING([for simple visibility declarations]) | 42 | AC_MSG_CHECKING([for simple visibility declarations]) |
| 30 | AC_CACHE_VAL([gl_cv_cc_visibility], [ | 43 | AC_CACHE_VAL([gl_cv_cc_visibility], [ |
| 31 | gl_save_CFLAGS="$CFLAGS" | 44 | gl_save_CFLAGS="$CFLAGS" |
| 32 | CFLAGS="$CFLAGS -fvisibility=hidden" | 45 | CFLAGS="$CFLAGS -fvisibility=hidden" |
| 46 | dnl We use the option -Werror and a function dummyfunc, because on some | ||
| 47 | dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning | ||
| 48 | dnl "visibility attribute not supported in this configuration; ignored" | ||
| 49 | dnl at the first function definition in every compilation unit, and we | ||
| 50 | dnl don't want to use the option in this case. | ||
| 51 | if test $gl_cv_cc_vis_werror = yes; then | ||
| 52 | CFLAGS="$CFLAGS -Werror" | ||
| 53 | fi | ||
| 33 | AC_TRY_COMPILE( | 54 | AC_TRY_COMPILE( |
| 34 | [extern __attribute__((__visibility__("hidden"))) int hiddenvar; | 55 | [extern __attribute__((__visibility__("hidden"))) int hiddenvar; |
| 35 | extern __attribute__((__visibility__("default"))) int exportedvar; | 56 | extern __attribute__((__visibility__("default"))) int exportedvar; |
| 36 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); | 57 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); |
| 37 | extern __attribute__((__visibility__("default"))) int exportedfunc (void);], | 58 | extern __attribute__((__visibility__("default"))) int exportedfunc (void); |
| 59 | void dummyfunc (void) {}], | ||
| 38 | [], | 60 | [], |
| 39 | [gl_cv_cc_visibility=yes], | 61 | [gl_cv_cc_visibility=yes], |
| 40 | [gl_cv_cc_visibility=no]) | 62 | [gl_cv_cc_visibility=no]) |
diff --git a/gl/netdb.in.h b/gl/netdb.in.h index 73db46a5..f800cac8 100644 --- a/gl/netdb.in.h +++ b/gl/netdb.in.h | |||
| @@ -41,6 +41,8 @@ | |||
| 41 | 41 | ||
| 42 | /* The definition of _GL_ARG_NONNULL is copied here. */ | 42 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
| 43 | 43 | ||
| 44 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
| 45 | |||
| 44 | /* Declarations for a platform that lacks <netdb.h>, or where it is | 46 | /* Declarations for a platform that lacks <netdb.h>, or where it is |
| 45 | incomplete. */ | 47 | incomplete. */ |
| 46 | 48 | ||
| @@ -186,7 +188,33 @@ extern int getnameinfo (const struct sockaddr *restrict sa, socklen_t salen, | |||
| 186 | # define NI_NUMERICSERV 2 | 188 | # define NI_NUMERICSERV 2 |
| 187 | # endif | 189 | # endif |
| 188 | 190 | ||
| 189 | #endif /* @GNULIB_GETADDRINFO@ */ | 191 | #elif defined GNULIB_POSIXCHECK |
| 192 | |||
| 193 | # undef getaddrinfo | ||
| 194 | # if HAVE_RAW_DECL_GETADDRINFO | ||
| 195 | _GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - " | ||
| 196 | "use gnulib module getaddrinfo for portability"); | ||
| 197 | # endif | ||
| 198 | |||
| 199 | # undef freeaddrinfo | ||
| 200 | # if HAVE_RAW_DECL_FREEADDRINFO | ||
| 201 | _GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - " | ||
| 202 | "use gnulib module getaddrinfo for portability"); | ||
| 203 | # endif | ||
| 204 | |||
| 205 | # undef gai_strerror | ||
| 206 | # if HAVE_RAW_DECL_GAI_STRERROR | ||
| 207 | _GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - " | ||
| 208 | "use gnulib module getaddrinfo for portability"); | ||
| 209 | # endif | ||
| 210 | |||
| 211 | # undef getnameinfo | ||
| 212 | # if HAVE_RAW_DECL_GETNAMEINFO | ||
| 213 | _GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - " | ||
| 214 | "use gnulib module getaddrinfo for portability"); | ||
| 215 | # endif | ||
| 216 | |||
| 217 | #endif | ||
| 190 | 218 | ||
| 191 | #endif /* _GL_NETDB_H */ | 219 | #endif /* _GL_NETDB_H */ |
| 192 | #endif /* _GL_NETDB_H */ | 220 | #endif /* _GL_NETDB_H */ |
diff --git a/gl/regex_internal.c b/gl/regex_internal.c index 17eafaa9..98b8d5d2 100644 --- a/gl/regex_internal.c +++ b/gl/regex_internal.c | |||
| @@ -733,15 +733,17 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) | |||
| 733 | mbstate_t cur_state; | 733 | mbstate_t cur_state; |
| 734 | wchar_t wc2; | 734 | wchar_t wc2; |
| 735 | Idx mlen = raw + pstr->len - p; | 735 | Idx mlen = raw + pstr->len - p; |
| 736 | unsigned char buf[6]; | ||
| 737 | size_t mbclen; | 736 | size_t mbclen; |
| 738 | 737 | ||
| 738 | #if 0 /* dead code: buf is set but never used */ | ||
| 739 | unsigned char buf[6]; | ||
| 739 | if (BE (pstr->trans != NULL, 0)) | 740 | if (BE (pstr->trans != NULL, 0)) |
| 740 | { | 741 | { |
| 741 | int i = mlen < 6 ? mlen : 6; | 742 | int i = mlen < 6 ? mlen : 6; |
| 742 | while (--i >= 0) | 743 | while (--i >= 0) |
| 743 | buf[i] = pstr->trans[p[i]]; | 744 | buf[i] = pstr->trans[p[i]]; |
| 744 | } | 745 | } |
| 746 | #endif | ||
| 745 | /* XXX Don't use mbrtowc, we know which conversion | 747 | /* XXX Don't use mbrtowc, we know which conversion |
| 746 | to use (UTF-8 -> UCS4). */ | 748 | to use (UTF-8 -> UCS4). */ |
| 747 | memset (&cur_state, 0, sizeof (cur_state)); | 749 | memset (&cur_state, 0, sizeof (cur_state)); |
diff --git a/gl/regex_internal.h b/gl/regex_internal.h index 2cb8c4d0..5aa5aa28 100644 --- a/gl/regex_internal.h +++ b/gl/regex_internal.h | |||
| @@ -467,6 +467,8 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx, | |||
| 467 | # else | 467 | # else |
| 468 | /* alloca is implemented with malloc, so just use malloc. */ | 468 | /* alloca is implemented with malloc, so just use malloc. */ |
| 469 | # define __libc_use_alloca(n) 0 | 469 | # define __libc_use_alloca(n) 0 |
| 470 | # undef alloca | ||
| 471 | # define alloca(n) malloc (n) | ||
| 470 | # endif | 472 | # endif |
| 471 | #endif | 473 | #endif |
| 472 | 474 | ||
diff --git a/gl/sha1.c b/gl/sha1.c new file mode 100644 index 00000000..7251ca80 --- /dev/null +++ b/gl/sha1.c | |||
| @@ -0,0 +1,428 @@ | |||
| 1 | /* sha1.c - Functions to compute SHA1 message digest of files or | ||
| 2 | memory blocks according to the NIST specification FIPS-180-1. | ||
| 3 | |||
| 4 | Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free | ||
| 5 | Software Foundation, Inc. | ||
| 6 | |||
| 7 | This program is free software; you can redistribute it and/or modify it | ||
| 8 | under the terms of the GNU General Public License as published by the | ||
| 9 | Free Software Foundation; either version 3, or (at your option) any | ||
| 10 | later version. | ||
| 11 | |||
| 12 | This program is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with this program; if not, write to the Free Software Foundation, | ||
| 19 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 20 | |||
| 21 | /* Written by Scott G. Miller | ||
| 22 | Credits: | ||
| 23 | Robert Klep <robert@ilse.nl> -- Expansion function fix | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <config.h> | ||
| 27 | |||
| 28 | #include "sha1.h" | ||
| 29 | |||
| 30 | #include <stddef.h> | ||
| 31 | #include <stdlib.h> | ||
| 32 | #include <string.h> | ||
| 33 | |||
| 34 | #if USE_UNLOCKED_IO | ||
| 35 | # include "unlocked-io.h" | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #ifdef WORDS_BIGENDIAN | ||
| 39 | # define SWAP(n) (n) | ||
| 40 | #else | ||
| 41 | # define SWAP(n) \ | ||
| 42 | (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #define BLOCKSIZE 32768 | ||
| 46 | #if BLOCKSIZE % 64 != 0 | ||
| 47 | # error "invalid BLOCKSIZE" | ||
| 48 | #endif | ||
| 49 | |||
| 50 | /* This array contains the bytes used to pad the buffer to the next | ||
| 51 | 64-byte boundary. (RFC 1321, 3.1: Step 1) */ | ||
| 52 | static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; | ||
| 53 | |||
| 54 | |||
| 55 | /* Take a pointer to a 160 bit block of data (five 32 bit ints) and | ||
| 56 | initialize it to the start constants of the SHA1 algorithm. This | ||
| 57 | must be called before using hash in the call to sha1_hash. */ | ||
| 58 | void | ||
| 59 | sha1_init_ctx (struct sha1_ctx *ctx) | ||
| 60 | { | ||
| 61 | ctx->A = 0x67452301; | ||
| 62 | ctx->B = 0xefcdab89; | ||
| 63 | ctx->C = 0x98badcfe; | ||
| 64 | ctx->D = 0x10325476; | ||
| 65 | ctx->E = 0xc3d2e1f0; | ||
| 66 | |||
| 67 | ctx->total[0] = ctx->total[1] = 0; | ||
| 68 | ctx->buflen = 0; | ||
| 69 | } | ||
| 70 | |||
| 71 | /* Copy the 4 byte value from v into the memory location pointed to by *cp, | ||
| 72 | If your architecture allows unaligned access this is equivalent to | ||
| 73 | * (uint32_t *) cp = v */ | ||
| 74 | static inline void | ||
| 75 | set_uint32 (char *cp, uint32_t v) | ||
| 76 | { | ||
| 77 | memcpy (cp, &v, sizeof v); | ||
| 78 | } | ||
| 79 | |||
| 80 | /* Put result from CTX in first 20 bytes following RESBUF. The result | ||
| 81 | must be in little endian byte order. */ | ||
| 82 | void * | ||
| 83 | sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) | ||
| 84 | { | ||
| 85 | char *r = resbuf; | ||
| 86 | set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); | ||
| 87 | set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); | ||
| 88 | set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); | ||
| 89 | set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); | ||
| 90 | set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E)); | ||
| 91 | |||
| 92 | return resbuf; | ||
| 93 | } | ||
| 94 | |||
| 95 | /* Process the remaining bytes in the internal buffer and the usual | ||
| 96 | prolog according to the standard and write the result to RESBUF. */ | ||
| 97 | void * | ||
| 98 | sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) | ||
| 99 | { | ||
| 100 | /* Take yet unprocessed bytes into account. */ | ||
| 101 | uint32_t bytes = ctx->buflen; | ||
| 102 | size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; | ||
| 103 | |||
| 104 | /* Now count remaining bytes. */ | ||
| 105 | ctx->total[0] += bytes; | ||
| 106 | if (ctx->total[0] < bytes) | ||
| 107 | ++ctx->total[1]; | ||
| 108 | |||
| 109 | /* Put the 64-bit file length in *bits* at the end of the buffer. */ | ||
| 110 | ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); | ||
| 111 | ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3); | ||
| 112 | |||
| 113 | memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); | ||
| 114 | |||
| 115 | /* Process last bytes. */ | ||
| 116 | sha1_process_block (ctx->buffer, size * 4, ctx); | ||
| 117 | |||
| 118 | return sha1_read_ctx (ctx, resbuf); | ||
| 119 | } | ||
| 120 | |||
| 121 | /* Compute SHA1 message digest for bytes read from STREAM. The | ||
| 122 | resulting message digest number will be written into the 16 bytes | ||
| 123 | beginning at RESBLOCK. */ | ||
| 124 | int | ||
| 125 | sha1_stream (FILE *stream, void *resblock) | ||
| 126 | { | ||
| 127 | struct sha1_ctx ctx; | ||
| 128 | size_t sum; | ||
| 129 | |||
| 130 | char *buffer = malloc (BLOCKSIZE + 72); | ||
| 131 | if (!buffer) | ||
| 132 | return 1; | ||
| 133 | |||
| 134 | /* Initialize the computation context. */ | ||
| 135 | sha1_init_ctx (&ctx); | ||
| 136 | |||
| 137 | /* Iterate over full file contents. */ | ||
| 138 | while (1) | ||
| 139 | { | ||
| 140 | /* We read the file in blocks of BLOCKSIZE bytes. One call of the | ||
| 141 | computation function processes the whole buffer so that with the | ||
| 142 | next round of the loop another block can be read. */ | ||
| 143 | size_t n; | ||
| 144 | sum = 0; | ||
| 145 | |||
| 146 | /* Read block. Take care for partial reads. */ | ||
| 147 | while (1) | ||
| 148 | { | ||
| 149 | n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); | ||
| 150 | |||
| 151 | sum += n; | ||
| 152 | |||
| 153 | if (sum == BLOCKSIZE) | ||
| 154 | break; | ||
| 155 | |||
| 156 | if (n == 0) | ||
| 157 | { | ||
| 158 | /* Check for the error flag IFF N == 0, so that we don't | ||
| 159 | exit the loop after a partial read due to e.g., EAGAIN | ||
| 160 | or EWOULDBLOCK. */ | ||
| 161 | if (ferror (stream)) | ||
| 162 | { | ||
| 163 | free (buffer); | ||
| 164 | return 1; | ||
| 165 | } | ||
| 166 | goto process_partial_block; | ||
| 167 | } | ||
| 168 | |||
| 169 | /* We've read at least one byte, so ignore errors. But always | ||
| 170 | check for EOF, since feof may be true even though N > 0. | ||
| 171 | Otherwise, we could end up calling fread after EOF. */ | ||
| 172 | if (feof (stream)) | ||
| 173 | goto process_partial_block; | ||
| 174 | } | ||
| 175 | |||
| 176 | /* Process buffer with BLOCKSIZE bytes. Note that | ||
| 177 | BLOCKSIZE % 64 == 0 | ||
| 178 | */ | ||
| 179 | sha1_process_block (buffer, BLOCKSIZE, &ctx); | ||
| 180 | } | ||
| 181 | |||
| 182 | process_partial_block:; | ||
| 183 | |||
| 184 | /* Process any remaining bytes. */ | ||
| 185 | if (sum > 0) | ||
| 186 | sha1_process_bytes (buffer, sum, &ctx); | ||
| 187 | |||
| 188 | /* Construct result in desired memory. */ | ||
| 189 | sha1_finish_ctx (&ctx, resblock); | ||
| 190 | free (buffer); | ||
| 191 | return 0; | ||
| 192 | } | ||
| 193 | |||
| 194 | /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The | ||
| 195 | result is always in little endian byte order, so that a byte-wise | ||
| 196 | output yields to the wanted ASCII representation of the message | ||
| 197 | digest. */ | ||
| 198 | void * | ||
| 199 | sha1_buffer (const char *buffer, size_t len, void *resblock) | ||
| 200 | { | ||
| 201 | struct sha1_ctx ctx; | ||
| 202 | |||
| 203 | /* Initialize the computation context. */ | ||
| 204 | sha1_init_ctx (&ctx); | ||
| 205 | |||
| 206 | /* Process whole buffer but last len % 64 bytes. */ | ||
| 207 | sha1_process_bytes (buffer, len, &ctx); | ||
| 208 | |||
| 209 | /* Put result in desired memory area. */ | ||
| 210 | return sha1_finish_ctx (&ctx, resblock); | ||
| 211 | } | ||
| 212 | |||
| 213 | void | ||
| 214 | sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) | ||
| 215 | { | ||
| 216 | /* When we already have some bits in our internal buffer concatenate | ||
| 217 | both inputs first. */ | ||
| 218 | if (ctx->buflen != 0) | ||
| 219 | { | ||
| 220 | size_t left_over = ctx->buflen; | ||
| 221 | size_t add = 128 - left_over > len ? len : 128 - left_over; | ||
| 222 | |||
| 223 | memcpy (&((char *) ctx->buffer)[left_over], buffer, add); | ||
| 224 | ctx->buflen += add; | ||
| 225 | |||
| 226 | if (ctx->buflen > 64) | ||
| 227 | { | ||
| 228 | sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); | ||
| 229 | |||
| 230 | ctx->buflen &= 63; | ||
| 231 | /* The regions in the following copy operation cannot overlap. */ | ||
| 232 | memcpy (ctx->buffer, | ||
| 233 | &((char *) ctx->buffer)[(left_over + add) & ~63], | ||
| 234 | ctx->buflen); | ||
| 235 | } | ||
| 236 | |||
| 237 | buffer = (const char *) buffer + add; | ||
| 238 | len -= add; | ||
| 239 | } | ||
| 240 | |||
| 241 | /* Process available complete blocks. */ | ||
| 242 | if (len >= 64) | ||
| 243 | { | ||
| 244 | #if !_STRING_ARCH_unaligned | ||
| 245 | # define alignof(type) offsetof (struct { char c; type x; }, x) | ||
| 246 | # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) | ||
| 247 | if (UNALIGNED_P (buffer)) | ||
| 248 | while (len > 64) | ||
| 249 | { | ||
| 250 | sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); | ||
| 251 | buffer = (const char *) buffer + 64; | ||
| 252 | len -= 64; | ||
| 253 | } | ||
| 254 | else | ||
| 255 | #endif | ||
| 256 | { | ||
| 257 | sha1_process_block (buffer, len & ~63, ctx); | ||
| 258 | buffer = (const char *) buffer + (len & ~63); | ||
| 259 | len &= 63; | ||
| 260 | } | ||
| 261 | } | ||
| 262 | |||
| 263 | /* Move remaining bytes in internal buffer. */ | ||
| 264 | if (len > 0) | ||
| 265 | { | ||
| 266 | size_t left_over = ctx->buflen; | ||
| 267 | |||
| 268 | memcpy (&((char *) ctx->buffer)[left_over], buffer, len); | ||
| 269 | left_over += len; | ||
| 270 | if (left_over >= 64) | ||
| 271 | { | ||
| 272 | sha1_process_block (ctx->buffer, 64, ctx); | ||
| 273 | left_over -= 64; | ||
| 274 | memcpy (ctx->buffer, &ctx->buffer[16], left_over); | ||
| 275 | } | ||
| 276 | ctx->buflen = left_over; | ||
| 277 | } | ||
| 278 | } | ||
| 279 | |||
| 280 | /* --- Code below is the primary difference between md5.c and sha1.c --- */ | ||
| 281 | |||
| 282 | /* SHA1 round constants */ | ||
| 283 | #define K1 0x5a827999 | ||
| 284 | #define K2 0x6ed9eba1 | ||
| 285 | #define K3 0x8f1bbcdc | ||
| 286 | #define K4 0xca62c1d6 | ||
| 287 | |||
| 288 | /* Round functions. Note that F2 is the same as F4. */ | ||
| 289 | #define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) ) | ||
| 290 | #define F2(B,C,D) (B ^ C ^ D) | ||
| 291 | #define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) ) | ||
| 292 | #define F4(B,C,D) (B ^ C ^ D) | ||
| 293 | |||
| 294 | /* Process LEN bytes of BUFFER, accumulating context into CTX. | ||
| 295 | It is assumed that LEN % 64 == 0. | ||
| 296 | Most of this code comes from GnuPG's cipher/sha1.c. */ | ||
| 297 | |||
| 298 | void | ||
| 299 | sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) | ||
| 300 | { | ||
| 301 | const uint32_t *words = buffer; | ||
| 302 | size_t nwords = len / sizeof (uint32_t); | ||
| 303 | const uint32_t *endp = words + nwords; | ||
| 304 | uint32_t x[16]; | ||
| 305 | uint32_t a = ctx->A; | ||
| 306 | uint32_t b = ctx->B; | ||
| 307 | uint32_t c = ctx->C; | ||
| 308 | uint32_t d = ctx->D; | ||
| 309 | uint32_t e = ctx->E; | ||
| 310 | |||
| 311 | /* First increment the byte count. RFC 1321 specifies the possible | ||
| 312 | length of the file up to 2^64 bits. Here we only compute the | ||
| 313 | number of bytes. Do a double word increment. */ | ||
| 314 | ctx->total[0] += len; | ||
| 315 | if (ctx->total[0] < len) | ||
| 316 | ++ctx->total[1]; | ||
| 317 | |||
| 318 | #define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) | ||
| 319 | |||
| 320 | #define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \ | ||
| 321 | ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \ | ||
| 322 | , (x[I&0x0f] = rol(tm, 1)) ) | ||
| 323 | |||
| 324 | #define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \ | ||
| 325 | + F( B, C, D ) \ | ||
| 326 | + K \ | ||
| 327 | + M; \ | ||
| 328 | B = rol( B, 30 ); \ | ||
| 329 | } while(0) | ||
| 330 | |||
| 331 | while (words < endp) | ||
| 332 | { | ||
| 333 | uint32_t tm; | ||
| 334 | int t; | ||
| 335 | for (t = 0; t < 16; t++) | ||
| 336 | { | ||
| 337 | x[t] = SWAP (*words); | ||
| 338 | words++; | ||
| 339 | } | ||
| 340 | |||
| 341 | R( a, b, c, d, e, F1, K1, x[ 0] ); | ||
| 342 | R( e, a, b, c, d, F1, K1, x[ 1] ); | ||
| 343 | R( d, e, a, b, c, F1, K1, x[ 2] ); | ||
| 344 | R( c, d, e, a, b, F1, K1, x[ 3] ); | ||
| 345 | R( b, c, d, e, a, F1, K1, x[ 4] ); | ||
| 346 | R( a, b, c, d, e, F1, K1, x[ 5] ); | ||
| 347 | R( e, a, b, c, d, F1, K1, x[ 6] ); | ||
| 348 | R( d, e, a, b, c, F1, K1, x[ 7] ); | ||
| 349 | R( c, d, e, a, b, F1, K1, x[ 8] ); | ||
| 350 | R( b, c, d, e, a, F1, K1, x[ 9] ); | ||
| 351 | R( a, b, c, d, e, F1, K1, x[10] ); | ||
| 352 | R( e, a, b, c, d, F1, K1, x[11] ); | ||
| 353 | R( d, e, a, b, c, F1, K1, x[12] ); | ||
| 354 | R( c, d, e, a, b, F1, K1, x[13] ); | ||
| 355 | R( b, c, d, e, a, F1, K1, x[14] ); | ||
| 356 | R( a, b, c, d, e, F1, K1, x[15] ); | ||
| 357 | R( e, a, b, c, d, F1, K1, M(16) ); | ||
| 358 | R( d, e, a, b, c, F1, K1, M(17) ); | ||
| 359 | R( c, d, e, a, b, F1, K1, M(18) ); | ||
| 360 | R( b, c, d, e, a, F1, K1, M(19) ); | ||
| 361 | R( a, b, c, d, e, F2, K2, M(20) ); | ||
| 362 | R( e, a, b, c, d, F2, K2, M(21) ); | ||
| 363 | R( d, e, a, b, c, F2, K2, M(22) ); | ||
| 364 | R( c, d, e, a, b, F2, K2, M(23) ); | ||
| 365 | R( b, c, d, e, a, F2, K2, M(24) ); | ||
| 366 | R( a, b, c, d, e, F2, K2, M(25) ); | ||
| 367 | R( e, a, b, c, d, F2, K2, M(26) ); | ||
| 368 | R( d, e, a, b, c, F2, K2, M(27) ); | ||
| 369 | R( c, d, e, a, b, F2, K2, M(28) ); | ||
| 370 | R( b, c, d, e, a, F2, K2, M(29) ); | ||
| 371 | R( a, b, c, d, e, F2, K2, M(30) ); | ||
| 372 | R( e, a, b, c, d, F2, K2, M(31) ); | ||
| 373 | R( d, e, a, b, c, F2, K2, M(32) ); | ||
| 374 | R( c, d, e, a, b, F2, K2, M(33) ); | ||
| 375 | R( b, c, d, e, a, F2, K2, M(34) ); | ||
| 376 | R( a, b, c, d, e, F2, K2, M(35) ); | ||
| 377 | R( e, a, b, c, d, F2, K2, M(36) ); | ||
| 378 | R( d, e, a, b, c, F2, K2, M(37) ); | ||
| 379 | R( c, d, e, a, b, F2, K2, M(38) ); | ||
| 380 | R( b, c, d, e, a, F2, K2, M(39) ); | ||
| 381 | R( a, b, c, d, e, F3, K3, M(40) ); | ||
| 382 | R( e, a, b, c, d, F3, K3, M(41) ); | ||
| 383 | R( d, e, a, b, c, F3, K3, M(42) ); | ||
| 384 | R( c, d, e, a, b, F3, K3, M(43) ); | ||
| 385 | R( b, c, d, e, a, F3, K3, M(44) ); | ||
| 386 | R( a, b, c, d, e, F3, K3, M(45) ); | ||
| 387 | R( e, a, b, c, d, F3, K3, M(46) ); | ||
| 388 | R( d, e, a, b, c, F3, K3, M(47) ); | ||
| 389 | R( c, d, e, a, b, F3, K3, M(48) ); | ||
| 390 | R( b, c, d, e, a, F3, K3, M(49) ); | ||
| 391 | R( a, b, c, d, e, F3, K3, M(50) ); | ||
| 392 | R( e, a, b, c, d, F3, K3, M(51) ); | ||
| 393 | R( d, e, a, b, c, F3, K3, M(52) ); | ||
| 394 | R( c, d, e, a, b, F3, K3, M(53) ); | ||
| 395 | R( b, c, d, e, a, F3, K3, M(54) ); | ||
| 396 | R( a, b, c, d, e, F3, K3, M(55) ); | ||
| 397 | R( e, a, b, c, d, F3, K3, M(56) ); | ||
| 398 | R( d, e, a, b, c, F3, K3, M(57) ); | ||
| 399 | R( c, d, e, a, b, F3, K3, M(58) ); | ||
| 400 | R( b, c, d, e, a, F3, K3, M(59) ); | ||
| 401 | R( a, b, c, d, e, F4, K4, M(60) ); | ||
| 402 | R( e, a, b, c, d, F4, K4, M(61) ); | ||
| 403 | R( d, e, a, b, c, F4, K4, M(62) ); | ||
| 404 | R( c, d, e, a, b, F4, K4, M(63) ); | ||
| 405 | R( b, c, d, e, a, F4, K4, M(64) ); | ||
| 406 | R( a, b, c, d, e, F4, K4, M(65) ); | ||
| 407 | R( e, a, b, c, d, F4, K4, M(66) ); | ||
| 408 | R( d, e, a, b, c, F4, K4, M(67) ); | ||
| 409 | R( c, d, e, a, b, F4, K4, M(68) ); | ||
| 410 | R( b, c, d, e, a, F4, K4, M(69) ); | ||
| 411 | R( a, b, c, d, e, F4, K4, M(70) ); | ||
| 412 | R( e, a, b, c, d, F4, K4, M(71) ); | ||
| 413 | R( d, e, a, b, c, F4, K4, M(72) ); | ||
| 414 | R( c, d, e, a, b, F4, K4, M(73) ); | ||
| 415 | R( b, c, d, e, a, F4, K4, M(74) ); | ||
| 416 | R( a, b, c, d, e, F4, K4, M(75) ); | ||
| 417 | R( e, a, b, c, d, F4, K4, M(76) ); | ||
| 418 | R( d, e, a, b, c, F4, K4, M(77) ); | ||
| 419 | R( c, d, e, a, b, F4, K4, M(78) ); | ||
| 420 | R( b, c, d, e, a, F4, K4, M(79) ); | ||
| 421 | |||
| 422 | a = ctx->A += a; | ||
| 423 | b = ctx->B += b; | ||
| 424 | c = ctx->C += c; | ||
| 425 | d = ctx->D += d; | ||
| 426 | e = ctx->E += e; | ||
| 427 | } | ||
| 428 | } | ||
diff --git a/gl/sha1.h b/gl/sha1.h new file mode 100644 index 00000000..de209b28 --- /dev/null +++ b/gl/sha1.h | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | /* Declarations of functions and data types used for SHA1 sum | ||
| 2 | library functions. | ||
| 3 | Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008, 2009, 2010 Free Software | ||
| 4 | Foundation, Inc. | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify it | ||
| 7 | under the terms of the GNU General Public License as published by the | ||
| 8 | Free Software Foundation; either version 3, or (at your option) any | ||
| 9 | later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software Foundation, | ||
| 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 19 | |||
| 20 | #ifndef SHA1_H | ||
| 21 | # define SHA1_H 1 | ||
| 22 | |||
| 23 | # include <stdio.h> | ||
| 24 | # include <stdint.h> | ||
| 25 | |||
| 26 | # ifdef __cplusplus | ||
| 27 | extern "C" { | ||
| 28 | # endif | ||
| 29 | |||
| 30 | #define SHA1_DIGEST_SIZE 20 | ||
| 31 | |||
| 32 | /* Structure to save state of computation between the single steps. */ | ||
| 33 | struct sha1_ctx | ||
| 34 | { | ||
| 35 | uint32_t A; | ||
| 36 | uint32_t B; | ||
| 37 | uint32_t C; | ||
| 38 | uint32_t D; | ||
| 39 | uint32_t E; | ||
| 40 | |||
| 41 | uint32_t total[2]; | ||
| 42 | uint32_t buflen; | ||
| 43 | uint32_t buffer[32]; | ||
| 44 | }; | ||
| 45 | |||
| 46 | |||
| 47 | /* Initialize structure containing state of computation. */ | ||
| 48 | extern void sha1_init_ctx (struct sha1_ctx *ctx); | ||
| 49 | |||
| 50 | /* Starting with the result of former calls of this function (or the | ||
| 51 | initialization function update the context for the next LEN bytes | ||
| 52 | starting at BUFFER. | ||
| 53 | It is necessary that LEN is a multiple of 64!!! */ | ||
| 54 | extern void sha1_process_block (const void *buffer, size_t len, | ||
| 55 | struct sha1_ctx *ctx); | ||
| 56 | |||
| 57 | /* Starting with the result of former calls of this function (or the | ||
| 58 | initialization function update the context for the next LEN bytes | ||
| 59 | starting at BUFFER. | ||
| 60 | It is NOT required that LEN is a multiple of 64. */ | ||
| 61 | extern void sha1_process_bytes (const void *buffer, size_t len, | ||
| 62 | struct sha1_ctx *ctx); | ||
| 63 | |||
| 64 | /* Process the remaining bytes in the buffer and put result from CTX | ||
| 65 | in first 20 bytes following RESBUF. The result is always in little | ||
| 66 | endian byte order, so that a byte-wise output yields to the wanted | ||
| 67 | ASCII representation of the message digest. */ | ||
| 68 | extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); | ||
| 69 | |||
| 70 | |||
| 71 | /* Put result from CTX in first 20 bytes following RESBUF. The result is | ||
| 72 | always in little endian byte order, so that a byte-wise output yields | ||
| 73 | to the wanted ASCII representation of the message digest. */ | ||
| 74 | extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); | ||
| 75 | |||
| 76 | |||
| 77 | /* Compute SHA1 message digest for bytes read from STREAM. The | ||
| 78 | resulting message digest number will be written into the 20 bytes | ||
| 79 | beginning at RESBLOCK. */ | ||
| 80 | extern int sha1_stream (FILE *stream, void *resblock); | ||
| 81 | |||
| 82 | /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The | ||
| 83 | result is always in little endian byte order, so that a byte-wise | ||
| 84 | output yields to the wanted ASCII representation of the message | ||
| 85 | digest. */ | ||
| 86 | extern void *sha1_buffer (const char *buffer, size_t len, void *resblock); | ||
| 87 | |||
| 88 | # ifdef __cplusplus | ||
| 89 | } | ||
| 90 | # endif | ||
| 91 | |||
| 92 | #endif | ||
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h index e2312ecb..574c281a 100644 --- a/gl/stdbool.in.h +++ b/gl/stdbool.in.h | |||
| @@ -50,6 +50,9 @@ | |||
| 50 | with this substitute. With this substitute, only the values 0 and 1 | 50 | with this substitute. With this substitute, only the values 0 and 1 |
| 51 | give the expected result when converted to _Bool' or 'bool'. | 51 | give the expected result when converted to _Bool' or 'bool'. |
| 52 | 52 | ||
| 53 | - C99 allows the use of (_Bool)0.0 in constant expressions, but | ||
| 54 | this substitute cannot always provide this property. | ||
| 55 | |||
| 53 | Also, it is suggested that programs use 'bool' rather than '_Bool'; | 56 | Also, it is suggested that programs use 'bool' rather than '_Bool'; |
| 54 | this isn't required, but 'bool' is more common. */ | 57 | this isn't required, but 'bool' is more common. */ |
| 55 | 58 | ||
diff --git a/gl/stdio-write.c b/gl/stdio-write.c index f7da9e42..a6a0eb14 100644 --- a/gl/stdio-write.c +++ b/gl/stdio-write.c | |||
| @@ -63,7 +63,6 @@ | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | # if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ | 65 | # if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ |
| 66 | # if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */ | ||
| 67 | int | 66 | int |
| 68 | printf (const char *format, ...) | 67 | printf (const char *format, ...) |
| 69 | { | 68 | { |
| @@ -76,7 +75,6 @@ printf (const char *format, ...) | |||
| 76 | 75 | ||
| 77 | return retval; | 76 | return retval; |
| 78 | } | 77 | } |
| 79 | # endif | ||
| 80 | # endif | 78 | # endif |
| 81 | 79 | ||
| 82 | # if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ | 80 | # if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ |
diff --git a/gl/stdio.in.h b/gl/stdio.in.h index dcb8ee57..80b9dbfd 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h | |||
| @@ -63,6 +63,10 @@ | |||
| 63 | 63 | ||
| 64 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 64 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| 65 | 65 | ||
| 66 | /* Macros for stringification. */ | ||
| 67 | #define _GL_STDIO_STRINGIZE(token) #token | ||
| 68 | #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) | ||
| 69 | |||
| 66 | 70 | ||
| 67 | #if @GNULIB_DPRINTF@ | 71 | #if @GNULIB_DPRINTF@ |
| 68 | # if @REPLACE_DPRINTF@ | 72 | # if @REPLACE_DPRINTF@ |
| @@ -640,16 +644,26 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " | |||
| 640 | #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ | 644 | #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ |
| 641 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ | 645 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ |
| 642 | || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) | 646 | || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) |
| 643 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 647 | # if defined __GNUC__ |
| 648 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 644 | /* Don't break __attribute__((format(printf,M,N))). */ | 649 | /* Don't break __attribute__((format(printf,M,N))). */ |
| 645 | # define printf __printf__ | 650 | # define printf __printf__ |
| 646 | # endif | 651 | # endif |
| 647 | # define GNULIB_overrides_printf 1 | ||
| 648 | _GL_FUNCDECL_RPL_1 (__printf__, int, | 652 | _GL_FUNCDECL_RPL_1 (__printf__, int, |
| 649 | (const char *format, ...) | 653 | (const char *format, ...) |
| 654 | __asm__ (@ASM_SYMBOL_PREFIX@ | ||
| 655 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) | ||
| 650 | __attribute__ ((__format__ (__printf__, 1, 2))) | 656 | __attribute__ ((__format__ (__printf__, 1, 2))) |
| 651 | _GL_ARG_NONNULL ((1))); | 657 | _GL_ARG_NONNULL ((1))); |
| 652 | _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); | 658 | _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); |
| 659 | # else | ||
| 660 | _GL_FUNCDECL_RPL (printf, int, | ||
| 661 | (const char *format, ...) | ||
| 662 | __attribute__ ((__format__ (__printf__, 1, 2))) | ||
| 663 | _GL_ARG_NONNULL ((1))); | ||
| 664 | _GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); | ||
| 665 | # endif | ||
| 666 | # define GNULIB_overrides_printf 1 | ||
| 653 | # else | 667 | # else |
| 654 | _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); | 668 | _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); |
| 655 | # endif | 669 | # endif |
diff --git a/gl/strerror.c b/gl/strerror.c index b0df7784..46153abf 100644 --- a/gl/strerror.c +++ b/gl/strerror.c | |||
| @@ -32,6 +32,9 @@ | |||
| 32 | 32 | ||
| 33 | # include "intprops.h" | 33 | # include "intprops.h" |
| 34 | 34 | ||
| 35 | /* Use the system functions, not the gnulib overrides in this file. */ | ||
| 36 | # undef sprintf | ||
| 37 | |||
| 35 | # undef strerror | 38 | # undef strerror |
| 36 | # if ! HAVE_DECL_STRERROR | 39 | # if ! HAVE_DECL_STRERROR |
| 37 | # define strerror(n) NULL | 40 | # define strerror(n) NULL |
diff --git a/gl/string.in.h b/gl/string.in.h index eb8d7588..13c0f095 100644 --- a/gl/string.in.h +++ b/gl/string.in.h | |||
| @@ -372,12 +372,23 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " | |||
| 372 | MAXLEN bytes. If no '\0' terminator is found in that many bytes, | 372 | MAXLEN bytes. If no '\0' terminator is found in that many bytes, |
| 373 | return MAXLEN. */ | 373 | return MAXLEN. */ |
| 374 | #if @GNULIB_STRNLEN@ | 374 | #if @GNULIB_STRNLEN@ |
| 375 | # if ! @HAVE_DECL_STRNLEN@ | 375 | # if @REPLACE_STRNLEN@ |
| 376 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 377 | # undef strnlen | ||
| 378 | # define strnlen rpl_strnlen | ||
| 379 | # endif | ||
| 380 | _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) | ||
| 381 | __attribute__ ((__pure__)) | ||
| 382 | _GL_ARG_NONNULL ((1))); | ||
| 383 | _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); | ||
| 384 | # else | ||
| 385 | # if ! @HAVE_DECL_STRNLEN@ | ||
| 376 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) | 386 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) |
| 377 | __attribute__ ((__pure__)) | 387 | __attribute__ ((__pure__)) |
| 378 | _GL_ARG_NONNULL ((1))); | 388 | _GL_ARG_NONNULL ((1))); |
| 379 | # endif | 389 | # endif |
| 380 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); | 390 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); |
| 391 | # endif | ||
| 381 | _GL_CXXALIASWARN (strnlen); | 392 | _GL_CXXALIASWARN (strnlen); |
| 382 | #elif defined GNULIB_POSIXCHECK | 393 | #elif defined GNULIB_POSIXCHECK |
| 383 | # undef strnlen | 394 | # undef strnlen |
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h index a64bf029..dc7ef511 100644 --- a/gl/sys_stat.in.h +++ b/gl/sys_stat.in.h | |||
| @@ -56,7 +56,8 @@ | |||
| 56 | /* Before doing "#define mkdir rpl_mkdir" below, we need to include all | 56 | /* Before doing "#define mkdir rpl_mkdir" below, we need to include all |
| 57 | headers that may declare mkdir(). */ | 57 | headers that may declare mkdir(). */ |
| 58 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | 58 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
| 59 | # include <io.h> | 59 | # include <io.h> /* mingw32, mingw64 */ |
| 60 | # include <direct.h> /* mingw64 */ | ||
| 60 | #endif | 61 | #endif |
| 61 | 62 | ||
| 62 | #ifndef S_IFMT | 63 | #ifndef S_IFMT |
| @@ -455,7 +456,8 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); | |||
| 455 | #else | 456 | #else |
| 456 | /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. | 457 | /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. |
| 457 | Additionally, it declares _mkdir (and depending on compile flags, an | 458 | Additionally, it declares _mkdir (and depending on compile flags, an |
| 458 | alias mkdir), only in the nonstandard <io.h>, which is included above. */ | 459 | alias mkdir), only in the nonstandard includes <direct.h> and <io.h>, |
| 460 | which are included above. */ | ||
| 459 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | 461 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
| 460 | 462 | ||
| 461 | static inline int | 463 | static inline int |
diff --git a/gl/time.in.h b/gl/time.in.h index 8e364feb..6fb4fd71 100644 --- a/gl/time.in.h +++ b/gl/time.in.h | |||
| @@ -48,10 +48,20 @@ | |||
| 48 | 48 | ||
| 49 | /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). | 49 | /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). |
| 50 | Or they define it with the wrong member names or define it in <sys/time.h> | 50 | Or they define it with the wrong member names or define it in <sys/time.h> |
| 51 | (e.g., FreeBSD circa 1997). */ | 51 | (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the |
| 52 | pthreads-win32 library defines it in <pthread.h>. */ | ||
| 52 | # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ | 53 | # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ |
| 53 | # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ | 54 | # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ |
| 54 | # include <sys/time.h> | 55 | # include <sys/time.h> |
| 56 | # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ | ||
| 57 | # include <pthread.h> | ||
| 58 | /* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */ | ||
| 59 | # undef asctime_r | ||
| 60 | # undef ctime_r | ||
| 61 | # undef gmtime_r | ||
| 62 | # undef localtime_r | ||
| 63 | # undef rand_r | ||
| 64 | # undef strtok_r | ||
| 55 | # else | 65 | # else |
| 56 | 66 | ||
| 57 | # ifdef __cplusplus | 67 | # ifdef __cplusplus |
diff --git a/gl/unistd.in.h b/gl/unistd.in.h index 45fc5dcf..7914f228 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h | |||
| @@ -86,7 +86,7 @@ | |||
| 86 | #endif | 86 | #endif |
| 87 | 87 | ||
| 88 | #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ | 88 | #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ |
| 89 | || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK) | 89 | || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) |
| 90 | /* Get ssize_t. */ | 90 | /* Get ssize_t. */ |
| 91 | # include <sys/types.h> | 91 | # include <sys/types.h> |
| 92 | #endif | 92 | #endif |
| @@ -1016,6 +1016,40 @@ _GL_WARN_ON_USE (pread, "pread is unportable - " | |||
| 1016 | #endif | 1016 | #endif |
| 1017 | 1017 | ||
| 1018 | 1018 | ||
| 1019 | #if @GNULIB_PWRITE@ | ||
| 1020 | /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. | ||
| 1021 | Return the number of bytes written if successful, otherwise | ||
| 1022 | set errno and return -1. 0 indicates nothing written. See the | ||
| 1023 | POSIX:2001 specification | ||
| 1024 | <http://www.opengroup.org/susv3xsh/pwrite.html>. */ | ||
| 1025 | # if @REPLACE_PWRITE@ | ||
| 1026 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1027 | # define pwrite rpl_pwrite | ||
| 1028 | # endif | ||
| 1029 | _GL_FUNCDECL_RPL (pwrite, ssize_t, | ||
| 1030 | (int fd, const void *buf, size_t bufsize, off_t offset) | ||
| 1031 | _GL_ARG_NONNULL ((2))); | ||
| 1032 | _GL_CXXALIAS_RPL (pwrite, ssize_t, | ||
| 1033 | (int fd, const void *buf, size_t bufsize, off_t offset)); | ||
| 1034 | # else | ||
| 1035 | # if !@HAVE_PWRITE@ | ||
| 1036 | _GL_FUNCDECL_SYS (pwrite, ssize_t, | ||
| 1037 | (int fd, const void *buf, size_t bufsize, off_t offset) | ||
| 1038 | _GL_ARG_NONNULL ((2))); | ||
| 1039 | # endif | ||
| 1040 | _GL_CXXALIAS_SYS (pwrite, ssize_t, | ||
| 1041 | (int fd, const void *buf, size_t bufsize, off_t offset)); | ||
| 1042 | # endif | ||
| 1043 | _GL_CXXALIASWARN (pwrite); | ||
| 1044 | #elif defined GNULIB_POSIXCHECK | ||
| 1045 | # undef pwrite | ||
| 1046 | # if HAVE_RAW_DECL_PWRITE | ||
| 1047 | _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " | ||
| 1048 | "use gnulib module pwrite for portability"); | ||
| 1049 | # endif | ||
| 1050 | #endif | ||
| 1051 | |||
| 1052 | |||
| 1019 | #if @GNULIB_READLINK@ | 1053 | #if @GNULIB_READLINK@ |
| 1020 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE | 1054 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE |
| 1021 | bytes of it into BUF. Return the number of bytes placed into BUF if | 1055 | bytes of it into BUF. Return the number of bytes placed into BUF if |
| @@ -1164,12 +1198,23 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " | |||
| 1164 | #if @GNULIB_TTYNAME_R@ | 1198 | #if @GNULIB_TTYNAME_R@ |
| 1165 | /* Store at most BUFLEN characters of the pathname of the terminal FD is | 1199 | /* Store at most BUFLEN characters of the pathname of the terminal FD is |
| 1166 | open on in BUF. Return 0 on success, otherwise an error number. */ | 1200 | open on in BUF. Return 0 on success, otherwise an error number. */ |
| 1167 | # if !@HAVE_TTYNAME_R@ | 1201 | # if @REPLACE_TTYNAME_R@ |
| 1202 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1203 | # undef ttyname_r | ||
| 1204 | # define ttyname_r rpl_ttyname_r | ||
| 1205 | # endif | ||
| 1206 | _GL_FUNCDECL_RPL (ttyname_r, int, | ||
| 1207 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); | ||
| 1208 | _GL_CXXALIAS_RPL (ttyname_r, int, | ||
| 1209 | (int fd, char *buf, size_t buflen)); | ||
| 1210 | # else | ||
| 1211 | # if !@HAVE_TTYNAME_R@ | ||
| 1168 | _GL_FUNCDECL_SYS (ttyname_r, int, | 1212 | _GL_FUNCDECL_SYS (ttyname_r, int, |
| 1169 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); | 1213 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); |
| 1170 | # endif | 1214 | # endif |
| 1171 | _GL_CXXALIAS_SYS (ttyname_r, int, | 1215 | _GL_CXXALIAS_SYS (ttyname_r, int, |
| 1172 | (int fd, char *buf, size_t buflen)); | 1216 | (int fd, char *buf, size_t buflen)); |
| 1217 | # endif | ||
| 1173 | _GL_CXXALIASWARN (ttyname_r); | 1218 | _GL_CXXALIASWARN (ttyname_r); |
| 1174 | #elif defined GNULIB_POSIXCHECK | 1219 | #elif defined GNULIB_POSIXCHECK |
| 1175 | # undef ttyname_r | 1220 | # undef ttyname_r |
| @@ -1268,7 +1313,10 @@ _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) | |||
| 1268 | _GL_ARG_NONNULL ((2))); | 1313 | _GL_ARG_NONNULL ((2))); |
| 1269 | _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); | 1314 | _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); |
| 1270 | # else | 1315 | # else |
| 1271 | _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); | 1316 | /* Need to cast, because on mingw, the third parameter is |
| 1317 | unsigned int count | ||
| 1318 | and the return type is 'int'. */ | ||
| 1319 | _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); | ||
| 1272 | # endif | 1320 | # endif |
| 1273 | _GL_CXXALIASWARN (write); | 1321 | _GL_CXXALIASWARN (write); |
| 1274 | #endif | 1322 | #endif |
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c index 99d921e9..e618901b 100644 --- a/gl/vasnprintf.c +++ b/gl/vasnprintf.c | |||
| @@ -148,8 +148,14 @@ | |||
| 148 | # define USE_SNPRINTF 1 | 148 | # define USE_SNPRINTF 1 |
| 149 | # if HAVE_DECL__SNWPRINTF | 149 | # if HAVE_DECL__SNWPRINTF |
| 150 | /* On Windows, the function swprintf() has a different signature than | 150 | /* On Windows, the function swprintf() has a different signature than |
| 151 | on Unix; we use the _snwprintf() function instead. */ | 151 | on Unix; we use the function _snwprintf() or - on mingw - snwprintf() |
| 152 | # define SNPRINTF _snwprintf | 152 | instead. The mingw function snwprintf() has fewer bugs than the |
| 153 | MSVCRT function _snwprintf(), so prefer that. */ | ||
| 154 | # if defined __MINGW32__ | ||
| 155 | # define SNPRINTF snwprintf | ||
| 156 | # else | ||
| 157 | # define SNPRINTF _snwprintf | ||
| 158 | # endif | ||
| 153 | # else | 159 | # else |
| 154 | /* Unix. */ | 160 | /* Unix. */ |
| 155 | # define SNPRINTF swprintf | 161 | # define SNPRINTF swprintf |
| @@ -167,8 +173,15 @@ | |||
| 167 | # define USE_SNPRINTF 0 | 173 | # define USE_SNPRINTF 0 |
| 168 | # endif | 174 | # endif |
| 169 | # if HAVE_DECL__SNPRINTF | 175 | # if HAVE_DECL__SNPRINTF |
| 170 | /* Windows. */ | 176 | /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT |
| 171 | # define SNPRINTF _snprintf | 177 | function _snprintf(), so prefer that. */ |
| 178 | # if defined __MINGW32__ | ||
| 179 | # define SNPRINTF snprintf | ||
| 180 | /* Here we need to call the native snprintf, not rpl_snprintf. */ | ||
| 181 | # undef snprintf | ||
| 182 | # else | ||
| 183 | # define SNPRINTF _snprintf | ||
| 184 | # endif | ||
| 172 | # else | 185 | # else |
| 173 | /* Unix. */ | 186 | /* Unix. */ |
| 174 | # define SNPRINTF snprintf | 187 | # define SNPRINTF snprintf |
| @@ -194,7 +207,7 @@ | |||
| 194 | #undef remainder | 207 | #undef remainder |
| 195 | #define remainder rem | 208 | #define remainder rem |
| 196 | 209 | ||
| 197 | #if !USE_SNPRINTF && !WIDE_CHAR_VERSION | 210 | #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION |
| 198 | # if (HAVE_STRNLEN && !defined _AIX) | 211 | # if (HAVE_STRNLEN && !defined _AIX) |
| 199 | # define local_strnlen strnlen | 212 | # define local_strnlen strnlen |
| 200 | # else | 213 | # else |
| @@ -210,7 +223,7 @@ local_strnlen (const char *string, size_t maxlen) | |||
| 210 | # endif | 223 | # endif |
| 211 | #endif | 224 | #endif |
| 212 | 225 | ||
| 213 | #if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR) | 226 | #if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T |
| 214 | # if HAVE_WCSLEN | 227 | # if HAVE_WCSLEN |
| 215 | # define local_wcslen wcslen | 228 | # define local_wcslen wcslen |
| 216 | # else | 229 | # else |
| @@ -233,7 +246,7 @@ local_wcslen (const wchar_t *s) | |||
| 233 | # endif | 246 | # endif |
| 234 | #endif | 247 | #endif |
| 235 | 248 | ||
| 236 | #if !USE_SNPRINTF && HAVE_WCHAR_T && WIDE_CHAR_VERSION | 249 | #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION |
| 237 | # if HAVE_WCSNLEN | 250 | # if HAVE_WCSNLEN |
| 238 | # define local_wcsnlen wcsnlen | 251 | # define local_wcsnlen wcsnlen |
| 239 | # else | 252 | # else |
| @@ -1474,6 +1487,258 @@ is_borderline (const char *digits, size_t precision) | |||
| 1474 | 1487 | ||
| 1475 | #endif | 1488 | #endif |
| 1476 | 1489 | ||
| 1490 | #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 | ||
| 1491 | |||
| 1492 | /* Use a different function name, to make it possible that the 'wchar_t' | ||
| 1493 | parametrization and the 'char' parametrization get compiled in the same | ||
| 1494 | translation unit. */ | ||
| 1495 | # if WIDE_CHAR_VERSION | ||
| 1496 | # define MAX_ROOM_NEEDED wmax_room_needed | ||
| 1497 | # else | ||
| 1498 | # define MAX_ROOM_NEEDED max_room_needed | ||
| 1499 | # endif | ||
| 1500 | |||
| 1501 | /* Returns the number of TCHAR_T units needed as temporary space for the result | ||
| 1502 | of sprintf or SNPRINTF of a single conversion directive. */ | ||
| 1503 | static inline size_t | ||
| 1504 | MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, | ||
| 1505 | arg_type type, int flags, size_t width, int has_precision, | ||
| 1506 | size_t precision, int pad_ourselves) | ||
| 1507 | { | ||
| 1508 | size_t tmp_length; | ||
| 1509 | |||
| 1510 | switch (conversion) | ||
| 1511 | { | ||
| 1512 | case 'd': case 'i': case 'u': | ||
| 1513 | # if HAVE_LONG_LONG_INT | ||
| 1514 | if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
| 1515 | tmp_length = | ||
| 1516 | (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
| 1517 | * 0.30103 /* binary -> decimal */ | ||
| 1518 | ) | ||
| 1519 | + 1; /* turn floor into ceil */ | ||
| 1520 | else | ||
| 1521 | # endif | ||
| 1522 | if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
| 1523 | tmp_length = | ||
| 1524 | (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
| 1525 | * 0.30103 /* binary -> decimal */ | ||
| 1526 | ) | ||
| 1527 | + 1; /* turn floor into ceil */ | ||
| 1528 | else | ||
| 1529 | tmp_length = | ||
| 1530 | (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
| 1531 | * 0.30103 /* binary -> decimal */ | ||
| 1532 | ) | ||
| 1533 | + 1; /* turn floor into ceil */ | ||
| 1534 | if (tmp_length < precision) | ||
| 1535 | tmp_length = precision; | ||
| 1536 | /* Multiply by 2, as an estimate for FLAG_GROUP. */ | ||
| 1537 | tmp_length = xsum (tmp_length, tmp_length); | ||
| 1538 | /* Add 1, to account for a leading sign. */ | ||
| 1539 | tmp_length = xsum (tmp_length, 1); | ||
| 1540 | break; | ||
| 1541 | |||
| 1542 | case 'o': | ||
| 1543 | # if HAVE_LONG_LONG_INT | ||
| 1544 | if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
| 1545 | tmp_length = | ||
| 1546 | (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
| 1547 | * 0.333334 /* binary -> octal */ | ||
| 1548 | ) | ||
| 1549 | + 1; /* turn floor into ceil */ | ||
| 1550 | else | ||
| 1551 | # endif | ||
| 1552 | if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
| 1553 | tmp_length = | ||
| 1554 | (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
| 1555 | * 0.333334 /* binary -> octal */ | ||
| 1556 | ) | ||
| 1557 | + 1; /* turn floor into ceil */ | ||
| 1558 | else | ||
| 1559 | tmp_length = | ||
| 1560 | (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
| 1561 | * 0.333334 /* binary -> octal */ | ||
| 1562 | ) | ||
| 1563 | + 1; /* turn floor into ceil */ | ||
| 1564 | if (tmp_length < precision) | ||
| 1565 | tmp_length = precision; | ||
| 1566 | /* Add 1, to account for a leading sign. */ | ||
| 1567 | tmp_length = xsum (tmp_length, 1); | ||
| 1568 | break; | ||
| 1569 | |||
| 1570 | case 'x': case 'X': | ||
| 1571 | # if HAVE_LONG_LONG_INT | ||
| 1572 | if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
| 1573 | tmp_length = | ||
| 1574 | (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
| 1575 | * 0.25 /* binary -> hexadecimal */ | ||
| 1576 | ) | ||
| 1577 | + 1; /* turn floor into ceil */ | ||
| 1578 | else | ||
| 1579 | # endif | ||
| 1580 | if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
| 1581 | tmp_length = | ||
| 1582 | (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
| 1583 | * 0.25 /* binary -> hexadecimal */ | ||
| 1584 | ) | ||
| 1585 | + 1; /* turn floor into ceil */ | ||
| 1586 | else | ||
| 1587 | tmp_length = | ||
| 1588 | (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
| 1589 | * 0.25 /* binary -> hexadecimal */ | ||
| 1590 | ) | ||
| 1591 | + 1; /* turn floor into ceil */ | ||
| 1592 | if (tmp_length < precision) | ||
| 1593 | tmp_length = precision; | ||
| 1594 | /* Add 2, to account for a leading sign or alternate form. */ | ||
| 1595 | tmp_length = xsum (tmp_length, 2); | ||
| 1596 | break; | ||
| 1597 | |||
| 1598 | case 'f': case 'F': | ||
| 1599 | if (type == TYPE_LONGDOUBLE) | ||
| 1600 | tmp_length = | ||
| 1601 | (unsigned int) (LDBL_MAX_EXP | ||
| 1602 | * 0.30103 /* binary -> decimal */ | ||
| 1603 | * 2 /* estimate for FLAG_GROUP */ | ||
| 1604 | ) | ||
| 1605 | + 1 /* turn floor into ceil */ | ||
| 1606 | + 10; /* sign, decimal point etc. */ | ||
| 1607 | else | ||
| 1608 | tmp_length = | ||
| 1609 | (unsigned int) (DBL_MAX_EXP | ||
| 1610 | * 0.30103 /* binary -> decimal */ | ||
| 1611 | * 2 /* estimate for FLAG_GROUP */ | ||
| 1612 | ) | ||
| 1613 | + 1 /* turn floor into ceil */ | ||
| 1614 | + 10; /* sign, decimal point etc. */ | ||
| 1615 | tmp_length = xsum (tmp_length, precision); | ||
| 1616 | break; | ||
| 1617 | |||
| 1618 | case 'e': case 'E': case 'g': case 'G': | ||
| 1619 | tmp_length = | ||
| 1620 | 12; /* sign, decimal point, exponent etc. */ | ||
| 1621 | tmp_length = xsum (tmp_length, precision); | ||
| 1622 | break; | ||
| 1623 | |||
| 1624 | case 'a': case 'A': | ||
| 1625 | if (type == TYPE_LONGDOUBLE) | ||
| 1626 | tmp_length = | ||
| 1627 | (unsigned int) (LDBL_DIG | ||
| 1628 | * 0.831 /* decimal -> hexadecimal */ | ||
| 1629 | ) | ||
| 1630 | + 1; /* turn floor into ceil */ | ||
| 1631 | else | ||
| 1632 | tmp_length = | ||
| 1633 | (unsigned int) (DBL_DIG | ||
| 1634 | * 0.831 /* decimal -> hexadecimal */ | ||
| 1635 | ) | ||
| 1636 | + 1; /* turn floor into ceil */ | ||
| 1637 | if (tmp_length < precision) | ||
| 1638 | tmp_length = precision; | ||
| 1639 | /* Account for sign, decimal point etc. */ | ||
| 1640 | tmp_length = xsum (tmp_length, 12); | ||
| 1641 | break; | ||
| 1642 | |||
| 1643 | case 'c': | ||
| 1644 | # if HAVE_WINT_T && !WIDE_CHAR_VERSION | ||
| 1645 | if (type == TYPE_WIDE_CHAR) | ||
| 1646 | tmp_length = MB_CUR_MAX; | ||
| 1647 | else | ||
| 1648 | # endif | ||
| 1649 | tmp_length = 1; | ||
| 1650 | break; | ||
| 1651 | |||
| 1652 | case 's': | ||
| 1653 | # if HAVE_WCHAR_T | ||
| 1654 | if (type == TYPE_WIDE_STRING) | ||
| 1655 | { | ||
| 1656 | # if WIDE_CHAR_VERSION | ||
| 1657 | /* ISO C says about %ls in fwprintf: | ||
| 1658 | "If the precision is not specified or is greater than the size | ||
| 1659 | of the array, the array shall contain a null wide character." | ||
| 1660 | So if there is a precision, we must not use wcslen. */ | ||
| 1661 | const wchar_t *arg = ap->arg[arg_index].a.a_wide_string; | ||
| 1662 | |||
| 1663 | if (has_precision) | ||
| 1664 | tmp_length = local_wcsnlen (arg, precision); | ||
| 1665 | else | ||
| 1666 | tmp_length = local_wcslen (arg); | ||
| 1667 | # else | ||
| 1668 | /* ISO C says about %ls in fprintf: | ||
| 1669 | "If a precision is specified, no more than that many bytes are | ||
| 1670 | written (including shift sequences, if any), and the array | ||
| 1671 | shall contain a null wide character if, to equal the multibyte | ||
| 1672 | character sequence length given by the precision, the function | ||
| 1673 | would need to access a wide character one past the end of the | ||
| 1674 | array." | ||
| 1675 | So if there is a precision, we must not use wcslen. */ | ||
| 1676 | /* This case has already been handled separately in VASNPRINTF. */ | ||
| 1677 | abort (); | ||
| 1678 | # endif | ||
| 1679 | } | ||
| 1680 | else | ||
| 1681 | # endif | ||
| 1682 | { | ||
| 1683 | # if WIDE_CHAR_VERSION | ||
| 1684 | /* ISO C says about %s in fwprintf: | ||
| 1685 | "If the precision is not specified or is greater than the size | ||
| 1686 | of the converted array, the converted array shall contain a | ||
| 1687 | null wide character." | ||
| 1688 | So if there is a precision, we must not use strlen. */ | ||
| 1689 | /* This case has already been handled separately in VASNPRINTF. */ | ||
| 1690 | abort (); | ||
| 1691 | # else | ||
| 1692 | /* ISO C says about %s in fprintf: | ||
| 1693 | "If the precision is not specified or greater than the size of | ||
| 1694 | the array, the array shall contain a null character." | ||
| 1695 | So if there is a precision, we must not use strlen. */ | ||
| 1696 | const char *arg = ap->arg[arg_index].a.a_string; | ||
| 1697 | |||
| 1698 | if (has_precision) | ||
| 1699 | tmp_length = local_strnlen (arg, precision); | ||
| 1700 | else | ||
| 1701 | tmp_length = strlen (arg); | ||
| 1702 | # endif | ||
| 1703 | } | ||
| 1704 | break; | ||
| 1705 | |||
| 1706 | case 'p': | ||
| 1707 | tmp_length = | ||
| 1708 | (unsigned int) (sizeof (void *) * CHAR_BIT | ||
| 1709 | * 0.25 /* binary -> hexadecimal */ | ||
| 1710 | ) | ||
| 1711 | + 1 /* turn floor into ceil */ | ||
| 1712 | + 2; /* account for leading 0x */ | ||
| 1713 | break; | ||
| 1714 | |||
| 1715 | default: | ||
| 1716 | abort (); | ||
| 1717 | } | ||
| 1718 | |||
| 1719 | if (!pad_ourselves) | ||
| 1720 | { | ||
| 1721 | # if ENABLE_UNISTDIO | ||
| 1722 | /* Padding considers the number of characters, therefore the number of | ||
| 1723 | elements after padding may be | ||
| 1724 | > max (tmp_length, width) | ||
| 1725 | but is certainly | ||
| 1726 | <= tmp_length + width. */ | ||
| 1727 | tmp_length = xsum (tmp_length, width); | ||
| 1728 | # else | ||
| 1729 | /* Padding considers the number of elements, says POSIX. */ | ||
| 1730 | if (tmp_length < width) | ||
| 1731 | tmp_length = width; | ||
| 1732 | # endif | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ | ||
| 1736 | |||
| 1737 | return tmp_length; | ||
| 1738 | } | ||
| 1739 | |||
| 1740 | #endif | ||
| 1741 | |||
| 1477 | DCHAR_T * | 1742 | DCHAR_T * |
| 1478 | VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | 1743 | VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, |
| 1479 | const FCHAR_T *format, va_list args) | 1744 | const FCHAR_T *format, va_list args) |
| @@ -2103,7 +2368,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 2103 | } | 2368 | } |
| 2104 | } | 2369 | } |
| 2105 | #endif | 2370 | #endif |
| 2106 | #if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T | 2371 | #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T |
| 2107 | else if (dp->conversion == 's' | 2372 | else if (dp->conversion == 's' |
| 2108 | # if WIDE_CHAR_VERSION | 2373 | # if WIDE_CHAR_VERSION |
| 2109 | && a.arg[dp->arg_index].type != TYPE_WIDE_STRING | 2374 | && a.arg[dp->arg_index].type != TYPE_WIDE_STRING |
| @@ -2592,8 +2857,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 2592 | count = wctomb (cbuf, *arg); | 2857 | count = wctomb (cbuf, *arg); |
| 2593 | # endif | 2858 | # endif |
| 2594 | if (count <= 0) | 2859 | if (count <= 0) |
| 2595 | /* Inconsistency. */ | 2860 | { |
| 2596 | abort (); | 2861 | /* Cannot convert. */ |
| 2862 | if (!(result == resultbuf || result == NULL)) | ||
| 2863 | free (result); | ||
| 2864 | if (buf_malloced != NULL) | ||
| 2865 | free (buf_malloced); | ||
| 2866 | CLEANUP (); | ||
| 2867 | errno = EILSEQ; | ||
| 2868 | return NULL; | ||
| 2869 | } | ||
| 2597 | ENSURE_ALLOCATION (xsum (length, count)); | 2870 | ENSURE_ALLOCATION (xsum (length, count)); |
| 2598 | memcpy (result + length, cbuf, count); | 2871 | memcpy (result + length, cbuf, count); |
| 2599 | length += count; | 2872 | length += count; |
| @@ -2616,8 +2889,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 2616 | length += n; | 2889 | length += n; |
| 2617 | } | 2890 | } |
| 2618 | } | 2891 | } |
| 2619 | } | ||
| 2620 | # endif | 2892 | # endif |
| 2893 | } | ||
| 2621 | #endif | 2894 | #endif |
| 2622 | #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL | 2895 | #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL |
| 2623 | else if ((dp->conversion == 'a' || dp->conversion == 'A') | 2896 | else if ((dp->conversion == 'a' || dp->conversion == 'A') |
| @@ -4301,11 +4574,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 4301 | { | 4574 | { |
| 4302 | arg_type type = a.arg[dp->arg_index].type; | 4575 | arg_type type = a.arg[dp->arg_index].type; |
| 4303 | int flags = dp->flags; | 4576 | int flags = dp->flags; |
| 4304 | #if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | 4577 | #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION |
| 4305 | int has_width; | 4578 | int has_width; |
| 4306 | size_t width; | 4579 | size_t width; |
| 4307 | #endif | 4580 | #endif |
| 4308 | #if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION | 4581 | #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION |
| 4309 | int has_precision; | 4582 | int has_precision; |
| 4310 | size_t precision; | 4583 | size_t precision; |
| 4311 | #endif | 4584 | #endif |
| @@ -4330,7 +4603,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 4330 | TCHAR_T *tmp; | 4603 | TCHAR_T *tmp; |
| 4331 | #endif | 4604 | #endif |
| 4332 | 4605 | ||
| 4333 | #if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | 4606 | #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION |
| 4334 | has_width = 0; | 4607 | has_width = 0; |
| 4335 | width = 0; | 4608 | width = 0; |
| 4336 | if (dp->width_start != dp->width_end) | 4609 | if (dp->width_start != dp->width_end) |
| @@ -4364,7 +4637,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 4364 | } | 4637 | } |
| 4365 | #endif | 4638 | #endif |
| 4366 | 4639 | ||
| 4367 | #if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION | 4640 | #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION |
| 4368 | has_precision = 0; | 4641 | has_precision = 0; |
| 4369 | precision = 6; | 4642 | precision = 6; |
| 4370 | if (dp->precision_start != dp->precision_end) | 4643 | if (dp->precision_start != dp->precision_end) |
| @@ -4437,246 +4710,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 4437 | #if !USE_SNPRINTF | 4710 | #if !USE_SNPRINTF |
| 4438 | /* Allocate a temporary buffer of sufficient size for calling | 4711 | /* Allocate a temporary buffer of sufficient size for calling |
| 4439 | sprintf. */ | 4712 | sprintf. */ |
| 4440 | { | 4713 | tmp_length = |
| 4441 | switch (dp->conversion) | 4714 | MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, |
| 4442 | { | 4715 | flags, width, has_precision, precision, |
| 4443 | 4716 | pad_ourselves); | |
| 4444 | case 'd': case 'i': case 'u': | ||
| 4445 | # if HAVE_LONG_LONG_INT | ||
| 4446 | if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
| 4447 | tmp_length = | ||
| 4448 | (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
| 4449 | * 0.30103 /* binary -> decimal */ | ||
| 4450 | ) | ||
| 4451 | + 1; /* turn floor into ceil */ | ||
| 4452 | else | ||
| 4453 | # endif | ||
| 4454 | if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
| 4455 | tmp_length = | ||
| 4456 | (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
| 4457 | * 0.30103 /* binary -> decimal */ | ||
| 4458 | ) | ||
| 4459 | + 1; /* turn floor into ceil */ | ||
| 4460 | else | ||
| 4461 | tmp_length = | ||
| 4462 | (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
| 4463 | * 0.30103 /* binary -> decimal */ | ||
| 4464 | ) | ||
| 4465 | + 1; /* turn floor into ceil */ | ||
| 4466 | if (tmp_length < precision) | ||
| 4467 | tmp_length = precision; | ||
| 4468 | /* Multiply by 2, as an estimate for FLAG_GROUP. */ | ||
| 4469 | tmp_length = xsum (tmp_length, tmp_length); | ||
| 4470 | /* Add 1, to account for a leading sign. */ | ||
| 4471 | tmp_length = xsum (tmp_length, 1); | ||
| 4472 | break; | ||
| 4473 | |||
| 4474 | case 'o': | ||
| 4475 | # if HAVE_LONG_LONG_INT | ||
| 4476 | if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
| 4477 | tmp_length = | ||
| 4478 | (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
| 4479 | * 0.333334 /* binary -> octal */ | ||
| 4480 | ) | ||
| 4481 | + 1; /* turn floor into ceil */ | ||
| 4482 | else | ||
| 4483 | # endif | ||
| 4484 | if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
| 4485 | tmp_length = | ||
| 4486 | (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
| 4487 | * 0.333334 /* binary -> octal */ | ||
| 4488 | ) | ||
| 4489 | + 1; /* turn floor into ceil */ | ||
| 4490 | else | ||
| 4491 | tmp_length = | ||
| 4492 | (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
| 4493 | * 0.333334 /* binary -> octal */ | ||
| 4494 | ) | ||
| 4495 | + 1; /* turn floor into ceil */ | ||
| 4496 | if (tmp_length < precision) | ||
| 4497 | tmp_length = precision; | ||
| 4498 | /* Add 1, to account for a leading sign. */ | ||
| 4499 | tmp_length = xsum (tmp_length, 1); | ||
| 4500 | break; | ||
| 4501 | |||
| 4502 | case 'x': case 'X': | ||
| 4503 | # if HAVE_LONG_LONG_INT | ||
| 4504 | if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
| 4505 | tmp_length = | ||
| 4506 | (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
| 4507 | * 0.25 /* binary -> hexadecimal */ | ||
| 4508 | ) | ||
| 4509 | + 1; /* turn floor into ceil */ | ||
| 4510 | else | ||
| 4511 | # endif | ||
| 4512 | if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
| 4513 | tmp_length = | ||
| 4514 | (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
| 4515 | * 0.25 /* binary -> hexadecimal */ | ||
| 4516 | ) | ||
| 4517 | + 1; /* turn floor into ceil */ | ||
| 4518 | else | ||
| 4519 | tmp_length = | ||
| 4520 | (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
| 4521 | * 0.25 /* binary -> hexadecimal */ | ||
| 4522 | ) | ||
| 4523 | + 1; /* turn floor into ceil */ | ||
| 4524 | if (tmp_length < precision) | ||
| 4525 | tmp_length = precision; | ||
| 4526 | /* Add 2, to account for a leading sign or alternate form. */ | ||
| 4527 | tmp_length = xsum (tmp_length, 2); | ||
| 4528 | break; | ||
| 4529 | |||
| 4530 | case 'f': case 'F': | ||
| 4531 | if (type == TYPE_LONGDOUBLE) | ||
| 4532 | tmp_length = | ||
| 4533 | (unsigned int) (LDBL_MAX_EXP | ||
| 4534 | * 0.30103 /* binary -> decimal */ | ||
| 4535 | * 2 /* estimate for FLAG_GROUP */ | ||
| 4536 | ) | ||
| 4537 | + 1 /* turn floor into ceil */ | ||
| 4538 | + 10; /* sign, decimal point etc. */ | ||
| 4539 | else | ||
| 4540 | tmp_length = | ||
| 4541 | (unsigned int) (DBL_MAX_EXP | ||
| 4542 | * 0.30103 /* binary -> decimal */ | ||
| 4543 | * 2 /* estimate for FLAG_GROUP */ | ||
| 4544 | ) | ||
| 4545 | + 1 /* turn floor into ceil */ | ||
| 4546 | + 10; /* sign, decimal point etc. */ | ||
| 4547 | tmp_length = xsum (tmp_length, precision); | ||
| 4548 | break; | ||
| 4549 | |||
| 4550 | case 'e': case 'E': case 'g': case 'G': | ||
| 4551 | tmp_length = | ||
| 4552 | 12; /* sign, decimal point, exponent etc. */ | ||
| 4553 | tmp_length = xsum (tmp_length, precision); | ||
| 4554 | break; | ||
| 4555 | |||
| 4556 | case 'a': case 'A': | ||
| 4557 | if (type == TYPE_LONGDOUBLE) | ||
| 4558 | tmp_length = | ||
| 4559 | (unsigned int) (LDBL_DIG | ||
| 4560 | * 0.831 /* decimal -> hexadecimal */ | ||
| 4561 | ) | ||
| 4562 | + 1; /* turn floor into ceil */ | ||
| 4563 | else | ||
| 4564 | tmp_length = | ||
| 4565 | (unsigned int) (DBL_DIG | ||
| 4566 | * 0.831 /* decimal -> hexadecimal */ | ||
| 4567 | ) | ||
| 4568 | + 1; /* turn floor into ceil */ | ||
| 4569 | if (tmp_length < precision) | ||
| 4570 | tmp_length = precision; | ||
| 4571 | /* Account for sign, decimal point etc. */ | ||
| 4572 | tmp_length = xsum (tmp_length, 12); | ||
| 4573 | break; | ||
| 4574 | |||
| 4575 | case 'c': | ||
| 4576 | # if HAVE_WINT_T && !WIDE_CHAR_VERSION | ||
| 4577 | if (type == TYPE_WIDE_CHAR) | ||
| 4578 | tmp_length = MB_CUR_MAX; | ||
| 4579 | else | ||
| 4580 | # endif | ||
| 4581 | tmp_length = 1; | ||
| 4582 | break; | ||
| 4583 | |||
| 4584 | case 's': | ||
| 4585 | # if HAVE_WCHAR_T | ||
| 4586 | if (type == TYPE_WIDE_STRING) | ||
| 4587 | { | ||
| 4588 | # if WIDE_CHAR_VERSION | ||
| 4589 | /* ISO C says about %ls in fwprintf: | ||
| 4590 | "If the precision is not specified or is greater | ||
| 4591 | than the size of the array, the array shall | ||
| 4592 | contain a null wide character." | ||
| 4593 | So if there is a precision, we must not use | ||
| 4594 | wcslen. */ | ||
| 4595 | const wchar_t *arg = | ||
| 4596 | a.arg[dp->arg_index].a.a_wide_string; | ||
| 4597 | |||
| 4598 | if (has_precision) | ||
| 4599 | tmp_length = local_wcsnlen (arg, precision); | ||
| 4600 | else | ||
| 4601 | tmp_length = local_wcslen (arg); | ||
| 4602 | # else | ||
| 4603 | /* ISO C says about %ls in fprintf: | ||
| 4604 | "If a precision is specified, no more than that | ||
| 4605 | many bytes are written (including shift | ||
| 4606 | sequences, if any), and the array shall contain | ||
| 4607 | a null wide character if, to equal the | ||
| 4608 | multibyte character sequence length given by | ||
| 4609 | the precision, the function would need to | ||
| 4610 | access a wide character one past the end of the | ||
| 4611 | array." | ||
| 4612 | So if there is a precision, we must not use | ||
| 4613 | wcslen. */ | ||
| 4614 | /* This case has already been handled above. */ | ||
| 4615 | abort (); | ||
| 4616 | # endif | ||
| 4617 | } | ||
| 4618 | else | ||
| 4619 | # endif | ||
| 4620 | { | ||
| 4621 | # if WIDE_CHAR_VERSION | ||
| 4622 | /* ISO C says about %s in fwprintf: | ||
| 4623 | "If the precision is not specified or is greater | ||
| 4624 | than the size of the converted array, the | ||
| 4625 | converted array shall contain a null wide | ||
| 4626 | character." | ||
| 4627 | So if there is a precision, we must not use | ||
| 4628 | strlen. */ | ||
| 4629 | /* This case has already been handled above. */ | ||
| 4630 | abort (); | ||
| 4631 | # else | ||
| 4632 | /* ISO C says about %s in fprintf: | ||
| 4633 | "If the precision is not specified or greater | ||
| 4634 | than the size of the array, the array shall | ||
| 4635 | contain a null character." | ||
| 4636 | So if there is a precision, we must not use | ||
| 4637 | strlen. */ | ||
| 4638 | const char *arg = a.arg[dp->arg_index].a.a_string; | ||
| 4639 | |||
| 4640 | if (has_precision) | ||
| 4641 | tmp_length = local_strnlen (arg, precision); | ||
| 4642 | else | ||
| 4643 | tmp_length = strlen (arg); | ||
| 4644 | # endif | ||
| 4645 | } | ||
| 4646 | break; | ||
| 4647 | |||
| 4648 | case 'p': | ||
| 4649 | tmp_length = | ||
| 4650 | (unsigned int) (sizeof (void *) * CHAR_BIT | ||
| 4651 | * 0.25 /* binary -> hexadecimal */ | ||
| 4652 | ) | ||
| 4653 | + 1 /* turn floor into ceil */ | ||
| 4654 | + 2; /* account for leading 0x */ | ||
| 4655 | break; | ||
| 4656 | |||
| 4657 | default: | ||
| 4658 | abort (); | ||
| 4659 | } | ||
| 4660 | |||
| 4661 | if (!pad_ourselves) | ||
| 4662 | { | ||
| 4663 | # if ENABLE_UNISTDIO | ||
| 4664 | /* Padding considers the number of characters, therefore | ||
| 4665 | the number of elements after padding may be | ||
| 4666 | > max (tmp_length, width) | ||
| 4667 | but is certainly | ||
| 4668 | <= tmp_length + width. */ | ||
| 4669 | tmp_length = xsum (tmp_length, width); | ||
| 4670 | # else | ||
| 4671 | /* Padding considers the number of elements, | ||
| 4672 | says POSIX. */ | ||
| 4673 | if (tmp_length < width) | ||
| 4674 | tmp_length = width; | ||
| 4675 | # endif | ||
| 4676 | } | ||
| 4677 | |||
| 4678 | tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ | ||
| 4679 | } | ||
| 4680 | 4717 | ||
| 4681 | if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) | 4718 | if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) |
| 4682 | tmp = tmpbuf; | 4719 | tmp = tmpbuf; |
| @@ -4916,6 +4953,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 4916 | } | 4953 | } |
| 4917 | #endif | 4954 | #endif |
| 4918 | 4955 | ||
| 4956 | errno = 0; | ||
| 4919 | switch (type) | 4957 | switch (type) |
| 4920 | { | 4958 | { |
| 4921 | case TYPE_SCHAR: | 4959 | case TYPE_SCHAR: |
| @@ -5062,15 +5100,44 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 5062 | /* Look at the snprintf() return value. */ | 5100 | /* Look at the snprintf() return value. */ |
| 5063 | if (retcount < 0) | 5101 | if (retcount < 0) |
| 5064 | { | 5102 | { |
| 5103 | # if !HAVE_SNPRINTF_RETVAL_C99 | ||
| 5065 | /* HP-UX 10.20 snprintf() is doubly deficient: | 5104 | /* HP-UX 10.20 snprintf() is doubly deficient: |
| 5066 | It doesn't understand the '%n' directive, | 5105 | It doesn't understand the '%n' directive, |
| 5067 | *and* it returns -1 (rather than the length | 5106 | *and* it returns -1 (rather than the length |
| 5068 | that would have been required) when the | 5107 | that would have been required) when the |
| 5069 | buffer is too small. */ | 5108 | buffer is too small. |
| 5070 | size_t bigger_need = | 5109 | But a failure at this point can also come |
| 5071 | xsum (xtimes (allocated, 2), 12); | 5110 | from other reasons than a too small buffer, |
| 5072 | ENSURE_ALLOCATION (bigger_need); | 5111 | such as an invalid wide string argument to |
| 5073 | continue; | 5112 | the %ls directive, or possibly an invalid |
| 5113 | floating-point argument. */ | ||
| 5114 | size_t tmp_length = | ||
| 5115 | MAX_ROOM_NEEDED (&a, dp->arg_index, | ||
| 5116 | dp->conversion, type, flags, | ||
| 5117 | width, has_precision, | ||
| 5118 | precision, pad_ourselves); | ||
| 5119 | |||
| 5120 | if (maxlen < tmp_length) | ||
| 5121 | { | ||
| 5122 | /* Make more room. But try to do through | ||
| 5123 | this reallocation only once. */ | ||
| 5124 | size_t bigger_need = | ||
| 5125 | xsum (length, | ||
| 5126 | xsum (tmp_length, | ||
| 5127 | TCHARS_PER_DCHAR - 1) | ||
| 5128 | / TCHARS_PER_DCHAR); | ||
| 5129 | /* And always grow proportionally. | ||
| 5130 | (There may be several arguments, each | ||
| 5131 | needing a little more room than the | ||
| 5132 | previous one.) */ | ||
| 5133 | size_t bigger_need2 = | ||
| 5134 | xsum (xtimes (allocated, 2), 12); | ||
| 5135 | if (bigger_need < bigger_need2) | ||
| 5136 | bigger_need = bigger_need2; | ||
| 5137 | ENSURE_ALLOCATION (bigger_need); | ||
| 5138 | continue; | ||
| 5139 | } | ||
| 5140 | # endif | ||
| 5074 | } | 5141 | } |
| 5075 | else | 5142 | else |
| 5076 | count = retcount; | 5143 | count = retcount; |
| @@ -5081,12 +5148,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 5081 | /* Attempt to handle failure. */ | 5148 | /* Attempt to handle failure. */ |
| 5082 | if (count < 0) | 5149 | if (count < 0) |
| 5083 | { | 5150 | { |
| 5151 | /* SNPRINTF or sprintf failed. Save and use the errno | ||
| 5152 | that it has set, if any. */ | ||
| 5153 | int saved_errno = errno; | ||
| 5154 | |||
| 5084 | if (!(result == resultbuf || result == NULL)) | 5155 | if (!(result == resultbuf || result == NULL)) |
| 5085 | free (result); | 5156 | free (result); |
| 5086 | if (buf_malloced != NULL) | 5157 | if (buf_malloced != NULL) |
| 5087 | free (buf_malloced); | 5158 | free (buf_malloced); |
| 5088 | CLEANUP (); | 5159 | CLEANUP (); |
| 5089 | errno = EINVAL; | 5160 | errno = |
| 5161 | (saved_errno != 0 | ||
| 5162 | ? saved_errno | ||
| 5163 | : (dp->conversion == 'c' || dp->conversion == 's' | ||
| 5164 | ? EILSEQ | ||
| 5165 | : EINVAL)); | ||
| 5090 | return NULL; | 5166 | return NULL; |
| 5091 | } | 5167 | } |
| 5092 | 5168 | ||
| @@ -5422,6 +5498,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 5422 | length += count; | 5498 | length += count; |
| 5423 | break; | 5499 | break; |
| 5424 | } | 5500 | } |
| 5501 | #undef pad_ourselves | ||
| 5502 | #undef prec_ourselves | ||
| 5425 | } | 5503 | } |
| 5426 | } | 5504 | } |
| 5427 | } | 5505 | } |
| @@ -5473,6 +5551,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | |||
| 5473 | } | 5551 | } |
| 5474 | } | 5552 | } |
| 5475 | 5553 | ||
| 5554 | #undef MAX_ROOM_NEEDED | ||
| 5476 | #undef TCHARS_PER_DCHAR | 5555 | #undef TCHARS_PER_DCHAR |
| 5477 | #undef SNPRINTF | 5556 | #undef SNPRINTF |
| 5478 | #undef USE_SNPRINTF | 5557 | #undef USE_SNPRINTF |
diff --git a/gl/verify.h b/gl/verify.h index bcd3f5a0..4ad780c8 100644 --- a/gl/verify.h +++ b/gl/verify.h | |||
| @@ -69,13 +69,14 @@ | |||
| 69 | if the entity names are not disambiguated. A workaround is to | 69 | if the entity names are not disambiguated. A workaround is to |
| 70 | attach the current line number to the entity name: | 70 | attach the current line number to the entity name: |
| 71 | 71 | ||
| 72 | #define GL_CONCAT0(x, y) x##y | 72 | #define _GL_CONCAT0(x, y) x##y |
| 73 | #define GL_CONCAT(x, y) GL_CONCAT0 (x, y) | 73 | #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) |
| 74 | extern struct {...} * GL_CONCAT(dummy,__LINE__); | 74 | extern struct {...} * _GL_CONCAT (dummy, __LINE__); |
| 75 | 75 | ||
| 76 | But this has the problem that two invocations of verify from | 76 | But this has the problem that two invocations of verify from |
| 77 | within the same macro would collide, since the __LINE__ value | 77 | within the same macro would collide, since the __LINE__ value |
| 78 | would be the same for both invocations. | 78 | would be the same for both invocations. (The GCC __COUNTER__ |
| 79 | macro solves this problem, but is not portable.) | ||
| 79 | 80 | ||
| 80 | A solution is to use the sizeof operator. It yields a number, | 81 | A solution is to use the sizeof operator. It yields a number, |
| 81 | getting rid of the identity of the type. Declarations like | 82 | getting rid of the identity of the type. Declarations like |
| @@ -103,20 +104,41 @@ | |||
| 103 | 104 | ||
| 104 | extern int (*dummy (void)) [sizeof (struct {...})]; | 105 | extern int (*dummy (void)) [sizeof (struct {...})]; |
| 105 | 106 | ||
| 107 | * GCC warns about duplicate declarations of the dummy function if | ||
| 108 | -Wredundant_decls is used. GCC 4.3 and later have a builtin | ||
| 109 | __COUNTER__ macro that can let us generate unique identifiers for | ||
| 110 | each dummy function, to suppress this warning. | ||
| 111 | |||
| 106 | * This implementation exploits the fact that GCC does not warn about | 112 | * This implementation exploits the fact that GCC does not warn about |
| 107 | the last declaration mentioned above. If a future version of GCC | 113 | the last declaration mentioned above. If a future version of GCC |
| 108 | introduces a warning for this, the problem could be worked around | 114 | introduces a warning for this, the problem could be worked around |
| 109 | by using code specialized to GCC, e.g.,: | 115 | by using code specialized to GCC, just as __COUNTER__ is already |
| 116 | being used if available. | ||
| 110 | 117 | ||
| 111 | #if 4 <= __GNUC__ | 118 | #if 4 <= __GNUC__ |
| 112 | # define verify(R) \ | 119 | # define verify(R) [another version to keep GCC happy] |
| 113 | extern int (* verify_function__ (void)) \ | ||
| 114 | [__builtin_constant_p (R) && (R) ? 1 : -1] | ||
| 115 | #endif | 120 | #endif |
| 116 | 121 | ||
| 117 | * In C++, any struct definition inside sizeof is invalid. | 122 | * In C++, any struct definition inside sizeof is invalid. |
| 118 | Use a template type to work around the problem. */ | 123 | Use a template type to work around the problem. */ |
| 119 | 124 | ||
| 125 | /* Concatenate two preprocessor tokens. */ | ||
| 126 | # define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) | ||
| 127 | # define _GL_CONCAT0(x, y) x##y | ||
| 128 | |||
| 129 | /* _GL_COUNTER is an integer, preferably one that changes each time we | ||
| 130 | use it. Use __COUNTER__ if it works, falling back on __LINE__ | ||
| 131 | otherwise. __LINE__ isn't perfect, but it's better than a | ||
| 132 | constant. */ | ||
| 133 | # if defined __COUNTER__ && __COUNTER__ != __COUNTER__ | ||
| 134 | # define _GL_COUNTER __COUNTER__ | ||
| 135 | # else | ||
| 136 | # define _GL_COUNTER __LINE__ | ||
| 137 | # endif | ||
| 138 | |||
| 139 | /* Generate a symbol with the given prefix, making it unique if | ||
| 140 | possible. */ | ||
| 141 | # define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) | ||
| 120 | 142 | ||
| 121 | /* Verify requirement R at compile-time, as an integer constant expression. | 143 | /* Verify requirement R at compile-time, as an integer constant expression. |
| 122 | Return 1. */ | 144 | Return 1. */ |
| @@ -135,6 +157,7 @@ template <int w> | |||
| 135 | /* Verify requirement R at compile-time, as a declaration without a | 157 | /* Verify requirement R at compile-time, as a declaration without a |
| 136 | trailing ';'. */ | 158 | trailing ';'. */ |
| 137 | 159 | ||
| 138 | # define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] | 160 | # define verify(R) \ |
| 161 | extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)] | ||
| 139 | 162 | ||
| 140 | #endif | 163 | #endif |
diff --git a/gl/wchar.in.h b/gl/wchar.in.h index dd41d353..88d47dbc 100644 --- a/gl/wchar.in.h +++ b/gl/wchar.in.h | |||
| @@ -407,7 +407,7 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " | |||
| 407 | _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t)); | 407 | _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t)); |
| 408 | _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); | 408 | _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); |
| 409 | # else | 409 | # else |
| 410 | # if !defined wcwidth && !@HAVE_DECL_WCWIDTH@ | 410 | # if !@HAVE_DECL_WCWIDTH@ |
| 411 | /* wcwidth exists but is not declared. */ | 411 | /* wcwidth exists but is not declared. */ |
| 412 | _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t)); | 412 | _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t)); |
| 413 | # endif | 413 | # endif |
