diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-02-08 10:42:37 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-02-08 10:43:12 +0100 |
commit | bdafbb24bc2d4beda71faa87036ace0dcab474fb (patch) | |
tree | 8d591fa1309a8537654262deebea781156fbbbb4 /gl | |
parent | 673a79027c04eaa8aa68353990753cf32dc7774a (diff) | |
download | gnutls-bdafbb24bc2d4beda71faa87036ace0dcab474fb.tar.gz |
added strndup and updated gnulib.
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 3 | ||||
-rw-r--r-- | gl/argp-help.c | 18 | ||||
-rw-r--r-- | gl/argp-parse.c | 6 | ||||
-rw-r--r-- | gl/argp.h | 6 | ||||
-rw-r--r-- | gl/base64.c | 24 | ||||
-rw-r--r-- | gl/fseeko.c | 3 | ||||
-rw-r--r-- | gl/fseterr.c | 3 | ||||
-rw-r--r-- | gl/gettimeofday.c | 11 | ||||
-rw-r--r-- | gl/m4/exponentd.m4 | 5 | ||||
-rw-r--r-- | gl/m4/gettimeofday.m4 | 6 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | gl/m4/po.m4 | 8 | ||||
-rw-r--r-- | gl/m4/stdalign.m4 | 7 | ||||
-rw-r--r-- | gl/m4/sys_time_h.m4 | 32 | ||||
-rw-r--r-- | gl/m4/vasnprintf.m4 | 6 | ||||
-rw-r--r-- | gl/select.c | 8 | ||||
-rw-r--r-- | gl/sleep.c | 2 | ||||
-rw-r--r-- | gl/stdio-impl.h | 2 | ||||
-rw-r--r-- | gl/stdio.in.h | 2 | ||||
-rw-r--r-- | gl/sys_select.in.h | 23 | ||||
-rw-r--r-- | gl/sys_socket.in.h | 2 | ||||
-rw-r--r-- | gl/sys_stat.in.h | 27 | ||||
-rw-r--r-- | gl/sys_time.in.h | 14 | ||||
-rw-r--r-- | gl/tests/init.sh | 5 | ||||
-rw-r--r-- | gl/tests/ioctl.c | 7 | ||||
-rw-r--r-- | gl/tests/test-base64.c | 4 | ||||
-rwxr-xr-x | gl/tests/test-init.sh | 19 | ||||
-rw-r--r-- | gl/tests/test-strerror.c | 2 | ||||
-rw-r--r-- | gl/tests/test-sys_select.c | 5 | ||||
-rw-r--r-- | gl/tests/test-sys_time.c | 4 | ||||
-rw-r--r-- | gl/tests/w32sock.h | 4 | ||||
-rw-r--r-- | gl/vasnprintf.c | 4 | ||||
-rw-r--r-- | gl/version-etc.h | 2 | ||||
-rw-r--r-- | gl/w32sock.h | 4 |
34 files changed, 205 insertions, 76 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index 1da9139353..e21e58596d 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime havelib inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto setsockopt shutdown snprintf socket sockets socklen stdint strcase strtok_r strverscmp sys_socket sys_stat time_r timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime havelib inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings AUTOMAKE_OPTIONS = 1.5 gnits @@ -2071,6 +2071,7 @@ sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ + -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ diff --git a/gl/argp-help.c b/gl/argp-help.c index 6d2903e507..a126acb9ba 100644 --- a/gl/argp-help.c +++ b/gl/argp-help.c @@ -1,4 +1,4 @@ -/* Hierarchial argument parsing help output +/* Hierarchical argument parsing help output Copyright (C) 1995-2005, 2007, 2009-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu>. @@ -154,7 +154,7 @@ ARGP_HELP_FMT: %s value is less than or equal to %s"), uparams.valid = 1; } -/* Read user options from the environment, and fill in UPARAMS appropiately. */ +/* Read user options from the environment, and fill in UPARAMS appropriately. */ static void fill_in_uparams (const struct argp_state *state) { @@ -277,11 +277,11 @@ fill_in_uparams (const struct argp_state *state) -xARG, -yARG, --long1=ARG, --long2=ARG Documentation... Where ARG will be omitted if there's no argument, for this option, or - will be surrounded by "[" and "]" appropiately if the argument is - optional. The documentation string is word-wrapped appropiately, and if + will be surrounded by "[" and "]" appropriately if the argument is + optional. The documentation string is word-wrapped appropriately, and if the list of options is long enough, it will be started on a separate line. If there are no short options for a given option, the first long option is - indented slighly in a way that's supposed to make most long options appear + indented slightly in a way that's supposed to make most long options appear to be in a separate column. For example, the following output (from ps): @@ -753,7 +753,7 @@ hol_entry_cmp (const struct hol_entry *entry1, if (entry1->cluster != entry2->cluster) { /* The entries are not within the same cluster, so we can't compare them - directly, we have to use the appropiate clustering level too. */ + directly, we have to use the appropriate clustering level too. */ if (! entry1->cluster) /* ENTRY1 is at the "base level", not in a cluster, so we have to compare it's group number with that of the base cluster in which @@ -1023,7 +1023,7 @@ filter_doc (const char *doc, int key, const struct argp *argp, return doc; } -/* Prints STR as a header line, with the margin lines set appropiately, and +/* Prints STR as a header line, with the margin lines set appropriately, and notes the fact that groups should be separated with a blank line. ARGP is the argp that should dictate any user doc filtering to take place. Note that the previous wrap margin isn't restored, but the left margin is reset @@ -1480,7 +1480,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state, } /* Print the documentation for ARGP to STREAM; if POST is false, then - everything preceeding a '\v' character in the documentation strings (or + everything preceding a '\v' character in the documentation strings (or the whole string, for those with none) is printed, otherwise, everything following the '\v' character (nothing for strings without). Each separate bit of documentation is separated a blank line, and if PRE_BLANK is true, @@ -1579,7 +1579,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state, } /* Output a usage message for ARGP to STREAM. If called from - argp_state_help, STATE is the relevent parsing state. FLAGS are from the + argp_state_help, STATE is the relevant parsing state. FLAGS are from the set ARGP_HELP_*. NAME is what to use wherever a "program name" is needed. */ static void diff --git a/gl/argp-parse.c b/gl/argp-parse.c index 09558b4f8f..3b411d407b 100644 --- a/gl/argp-parse.c +++ b/gl/argp-parse.c @@ -1,4 +1,4 @@ -/* Hierarchial argument parsing, layered over getopt +/* Hierarchical argument parsing, layered over getopt Copyright (C) 1995-2000, 2002-2004, 2009-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu>. @@ -204,7 +204,7 @@ struct group particular short options is from. */ char *short_end; - /* The number of non-option args sucessfully handled by this parser. */ + /* The number of non-option args successfully handled by this parser. */ unsigned args_processed; /* This group's parser's parent's group. */ @@ -386,7 +386,7 @@ convert_options (const struct argp *argp, return group; } -/* Find the merged set of getopt options, with keys appropiately prefixed. */ +/* Find the merged set of getopt options, with keys appropriately prefixed. */ static void parser_convert (struct parser *parser, const struct argp *argp, int flags) { @@ -1,4 +1,4 @@ -/* Hierarchial argument parsing, layered over getopt. +/* Hierarchical argument parsing, layered over getopt. Copyright (C) 1995-1999, 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu>. @@ -278,7 +278,7 @@ struct argp }; /* Possible KEY arguments to a help filter function. */ -#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */ +#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceding options. */ #define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */ #define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */ #define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation; @@ -506,7 +506,7 @@ extern void __argp_help (const struct argp *__restrict __argp, parsing routine (thus taking an argp_state structure as the first argument). They may or may not print an error message and exit, depending on the flags in STATE -- in any case, the caller should be prepared for - them *not* to exit, and should return an appropiate error after calling + them *not* to exit, and should return an appropriate error after calling them. [argp_usage & argp_error should probably be called argp_state_..., but they're used often enough that they should be short] */ diff --git a/gl/base64.c b/gl/base64.c index acf49c8985..e1731b612e 100644 --- a/gl/base64.c +++ b/gl/base64.c @@ -308,6 +308,24 @@ base64_decode_ctx_init (struct base64_decode_context *ctx) ctx->i = 0; } +inline static int is_nl(char c) +{ + if (c == ' ' || c == '\t' || c == '\n' || c == '\r') + return 1; + return 0; +} + +inline static int search_for_nl(char const *t, size_t t_size) +{ +int i; + + for (i=0;i<t_size;i++) + if (t[i] == ' ' || t[i] == '\t' || t[i] == '\n' || t[i] == '\r') + return 1; + + return 0; +} + /* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and none of those four is a newline, then return *IN. Otherwise, copy up to 4 - CTX->i non-newline bytes from that range into CTX->buf, starting at @@ -326,7 +344,7 @@ get_4 (struct base64_decode_context *ctx, if (ctx->i == 0) { char const *t = *in; - if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL) + if (4 <= in_end - *in && search_for_nl(t, 4) == 0) { /* This is the common case: no newline. */ *in += 4; @@ -341,7 +359,7 @@ get_4 (struct base64_decode_context *ctx, while (p < in_end) { char c = *p++; - if (c != '\n') + if (!is_nl(c)) { ctx->buf[ctx->i++] = c; if (ctx->i == 4) @@ -494,7 +512,7 @@ base64_decode_ctx (struct base64_decode_context *ctx, /* Handle the common case of 72-byte wrapped lines. This also handles any other multiple-of-4-byte wrapping. */ - if (inlen && *in == '\n' && ignore_newlines) + if (inlen && is_nl(*in) && ignore_newlines) { ++in; --inlen; diff --git a/gl/fseeko.c b/gl/fseeko.c index eae1b72683..08e1f710b1 100644 --- a/gl/fseeko.c +++ b/gl/fseeko.c @@ -89,6 +89,9 @@ fseeko (FILE *fp, off_t offset, int whence) && fp->__get_limit == fp->__bufp && fp->__put_limit == fp->__bufp && !fp->__pushed_back) +#elif defined EPLAN9 /* Plan9 */ + if (fp->rp == fp->buf + && fp->wp == fp->buf) #else #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." #endif diff --git a/gl/fseterr.c b/gl/fseterr.c index 30b41e11ea..78791af3dc 100644 --- a/gl/fseterr.c +++ b/gl/fseterr.c @@ -45,6 +45,9 @@ fseterr (FILE *fp) fp->_Mode |= 0x200 /* _MERR */; #elif defined __MINT__ /* Atari FreeMiNT */ fp->__error = 1; +#elif defined EPLAN9 /* Plan9 */ + if (fp->state != 0 /* CLOSED */) + fp->state = 5 /* ERR */; #elif 0 /* unknown */ /* Portable fallback, based on an idea by Rich Felker. Wow! 6 system calls for something that is just a bit operation! diff --git a/gl/gettimeofday.c b/gl/gettimeofday.c index 3c0fdd9572..d18606a7e9 100644 --- a/gl/gettimeofday.c +++ b/gl/gettimeofday.c @@ -110,7 +110,18 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) struct tm save = *localtime_buffer_addr; # endif +# if defined timeval /* 'struct timeval' overridden by gnulib? */ +# undef timeval + struct timeval otv; + int result = gettimeofday (&otv, (struct timezone *) tz); + if (result == 0) + { + tv->tv_sec = otv.tv_sec; + tv->tv_usec = otv.tv_usec; + } +# else int result = gettimeofday (tv, (struct timezone *) tz); +# endif # if GETTIMEOFDAY_CLOBBERS_LOCALTIME *localtime_buffer_addr = save; diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4 index 48df999ab5..0ae4ccfac9 100644 --- a/gl/m4/exponentd.m4 +++ b/gl/m4/exponentd.m4 @@ -1,4 +1,4 @@ -# exponentd.m4 serial 2 +# exponentd.m4 serial 3 dnl Copyright (C) 2007-2008, 2010-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -80,7 +80,8 @@ int main () dnl different sets of instructions: The older FPA instructions assume dnl that they are stored in big-endian word order, while the words dnl (like integer types) are stored in little-endian byte order. - dnl The newer VFP instructions assume little-endian order consistenly. + dnl The newer VFP instructions assume little-endian order + dnl consistently. AC_EGREP_CPP([mixed_endianness], [ #if defined arm || defined __arm || defined __arm__ mixed_endianness diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4 index 2385e39579..dc68c43ae3 100644 --- a/gl/m4/gettimeofday.m4 +++ b/gl/m4/gettimeofday.m4 @@ -1,4 +1,4 @@ -# serial 17 +# serial 18 # Copyright (C) 2001-2003, 2005, 2007, 2009-2012 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -50,6 +50,10 @@ int gettimeofday (struct timeval *restrict, struct timezone *restrict); elif test $gl_cv_func_gettimeofday_posix_signature != yes; then REPLACE_GETTIMEOFDAY=1 fi + dnl If we override 'struct timeval', we also have to override gettimeofday. + if test $REPLACE_STRUCT_TIMEVAL = 1; then + REPLACE_GETTIMEOFDAY=1 + fi m4_ifdef([gl_FUNC_TZSET_CLOBBER], [ gl_FUNC_TZSET_CLOBBER if test $gl_cv_func_tzset_clobber = yes; then diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 4c8191678e..0e41084123 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -27,7 +27,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime havelib inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto setsockopt shutdown snprintf socket sockets socklen stdint strcase strtok_r strverscmp sys_socket sys_stat time_r timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings +# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettime havelib inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r timespec u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gl/override]) @@ -80,6 +80,7 @@ gl_MODULES([ socklen stdint strcase + strndup strtok_r strverscmp sys_socket diff --git a/gl/m4/po.m4 b/gl/m4/po.m4 index 6bf122a245..05d8f7be47 100644 --- a/gl/m4/po.m4 +++ b/gl/m4/po.m4 @@ -1,4 +1,4 @@ -# po.m4 serial 17a +# po.m4 serial 17b dnl Copyright (C) 1995-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -130,12 +130,12 @@ changequote([,])dnl test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assigment from automake < 1.5. + # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. - # Hide the ALL_LINGUAS assigment from automake < 1.5. + # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' fi # Compute POFILES @@ -317,7 +317,7 @@ changequote([,])dnl sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'` ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"` fi - # Hide the ALL_LINGUAS assigment from automake < 1.5. + # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4 index d78a589808..6659c9c3ec 100644 --- a/gl/m4/stdalign.m4 +++ b/gl/m4/stdalign.m4 @@ -25,15 +25,16 @@ AC_DEFUN([gl_STDALIGN_H], #else # define ao(type) offsetof (struct { char a; type b; }, b) #endif - char test1[_Alignof (double) == ao (double) ? 1 : -1]; - char test2[alignof (long int) == ao (long int) ? 1 : -1]; + char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1]; + char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; + char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; /* Test _Alignas only on platforms where gnulib can help. */ #if \ (__GNUC__ || __IBMC__ || __IBMCPP__ \ || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) int alignas (8) alignas_int = 1; - char test3[8 <= _Alignof (alignas_int) ? 1 : -1]; + char test_alignas[_Alignof (alignas_int) == 8 ? 1 : -1]; #endif ]])], [gl_cv_header_working_stdalign_h=yes], diff --git a/gl/m4/sys_time_h.m4 b/gl/m4/sys_time_h.m4 index bed379785e..26eaf8ea7f 100644 --- a/gl/m4/sys_time_h.m4 +++ b/gl/m4/sys_time_h.m4 @@ -1,5 +1,5 @@ # Configure a replacement for <sys/time.h>. -# serial 7 +# serial 8 # Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -43,9 +43,36 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], ]], [[static struct timeval x; x.tv_sec = x.tv_usec;]])], [gl_cv_sys_struct_timeval=yes], - [gl_cv_sys_struct_timeval=no])]) + [gl_cv_sys_struct_timeval=no]) + ]) if test $gl_cv_sys_struct_timeval != yes; then HAVE_STRUCT_TIMEVAL=0 + else + dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined + dnl (in <sys/time.h> and <winsock2.h> for mingw64, in <winsock2.h> only + dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is + dnl smaller than the 'time_t' type mandated by POSIX. + AC_CACHE_CHECK([for correct struct timeval.tv_sec member], + [gl_cv_sys_struct_timeval_tv_sec], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SYS_TIME_H + #include <sys/time.h> + #endif + #include <time.h> + #if HAVE_WINSOCK2_H + # include <winsock2.h> + #endif + ]], + [[static struct timeval x; + typedef int verify_tv_sec_type[sizeof (x.tv_sec) == sizeof (time_t) ? 1 : -1]; + ]])], + [gl_cv_sys_struct_timeval_tv_sec=yes], + [gl_cv_sys_struct_timeval_tv_sec=no]) + ]) + if test $gl_cv_sys_struct_timeval_tv_sec != yes; then + REPLACE_STRUCT_TIMEVAL=1 + fi fi dnl Check for declarations of anything we want to poison if the @@ -75,4 +102,5 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) + REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) ]) diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4 index 61fe49928b..0ce11da13b 100644 --- a/gl/m4/vasnprintf.m4 +++ b/gl/m4/vasnprintf.m4 @@ -1,4 +1,4 @@ -# vasnprintf.m4 serial 34 +# vasnprintf.m4 serial 35 dnl Copyright (C) 2002-2004, 2006-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -29,7 +29,7 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF], gl_PREREQ_ASNPRINTF ]) -# Prequisites of lib/printf-args.h, lib/printf-args.c. +# Prerequisites of lib/printf-args.h, lib/printf-args.c. AC_DEFUN([gl_PREREQ_PRINTF_ARGS], [ AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) @@ -37,7 +37,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS], AC_REQUIRE([gt_TYPE_WINT_T]) ]) -# Prequisites of lib/printf-parse.h, lib/printf-parse.c. +# Prerequisites of lib/printf-parse.h, lib/printf-parse.c. AC_DEFUN([gl_PREREQ_PRINTF_PARSE], [ AC_REQUIRE([gl_FEATURES_H]) diff --git a/gl/select.c b/gl/select.c index e933094c6d..0c821ddf53 100644 --- a/gl/select.c +++ b/gl/select.c @@ -37,8 +37,13 @@ #include <conio.h> #include <time.h> +/* Get the overridden 'struct timeval'. */ +#include <sys/time.h> + #include "msvc-nothrow.h" +#undef select + struct bitset { unsigned char in[FD_SETSIZE / CHAR_BIT]; unsigned char out[FD_SETSIZE / CHAR_BIT]; @@ -80,7 +85,7 @@ typedef DWORD (WINAPI *PNtQueryInformationFile) /* Optimized test whether a HANDLE refers to a console. See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>. */ -#define IsConsoleHandle(h) (((long) (h) & 3) == 3) +#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3) static BOOL IsSocketHandle (HANDLE h) @@ -237,6 +242,7 @@ windows_poll_handle (HANDLE h, int fd, int rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, struct timeval *timeout) +#undef timeval { static struct timeval tv0; static HANDLE hEvent; diff --git a/gl/sleep.c b/gl/sleep.c index e5d329906c..9a4b9400cc 100644 --- a/gl/sleep.c +++ b/gl/sleep.c @@ -35,7 +35,7 @@ sleep (unsigned int seconds) unsigned int remaining; /* Sleep for 1 second many times, because - 1. Sleep is not interruptiple by Ctrl-C, + 1. Sleep is not interruptible by Ctrl-C, 2. we want to avoid arithmetic overflow while multiplying with 1000. */ for (remaining = seconds; remaining > 0; remaining--) Sleep (1000); diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h index a065c1a61a..4935795374 100644 --- a/gl/stdio-impl.h +++ b/gl/stdio-impl.h @@ -26,6 +26,8 @@ # include <sys/param.h> #endif +#include <errno.h> /* For detecting Plan9. */ + #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ # if defined __DragonFly__ /* DragonFly */ diff --git a/gl/stdio.in.h b/gl/stdio.in.h index 04819306e6..06d978065f 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h @@ -779,7 +779,7 @@ _GL_CXXALIASWARN (pclose); #elif defined GNULIB_POSIXCHECK # undef pclose # if HAVE_RAW_DECL_PCLOSE -_GL_WARN_ON_USE (pclose, "popen is unportable - " +_GL_WARN_ON_USE (pclose, "pclose is unportable - " "use gnulib module pclose for more portability"); # endif #endif diff --git a/gl/sys_select.in.h b/gl/sys_select.in.h index 5f93fb1b3f..4b35d19e03 100644 --- a/gl/sys_select.in.h +++ b/gl/sys_select.in.h @@ -42,6 +42,15 @@ # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ +/* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes + <sys/select.h>. At this point we cannot include <signal.h>, because that + includes gnulib's pthread.h override, which gives a syntax error because + /usr/include/pthread.h has not been completely processed. Simply delegate + to the system's header in this case. */ +#elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER) + +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ + #else #ifndef _@GUARD_PREFIX@_SYS_SELECT_H @@ -51,12 +60,6 @@ in <signal.h> where it belongs. */ #include <sys/types.h> -/* Get definition of 'sigset_t'. - But avoid namespace pollution on glibc systems. */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include <signal.h> -#endif - #if @HAVE_SYS_SELECT_H@ /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration @@ -81,6 +84,14 @@ #endif +/* Get definition of 'sigset_t'. + But avoid namespace pollution on glibc systems. + Do this after the include_next (for the sake of OpenBSD 5.0) but before + the split double-inclusion guard (for the sake of Solaris). */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include <signal.h> +#endif + #ifndef _@GUARD_PREFIX@_SYS_SELECT_H #define _@GUARD_PREFIX@_SYS_SELECT_H diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h index 49b61de614..819aff1085 100644 --- a/gl/sys_socket.in.h +++ b/gl/sys_socket.in.h @@ -143,7 +143,7 @@ struct sockaddr_storage that you can influence which definitions you get by setting the WINVER symbol before including these two files. For example, getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that - symbol is set indiriectly through WINVER). You can set this by + symbol is set indirectly through WINVER). You can set this by adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your code may not run on older Windows releases then. My Windows 2000 box was not able to run the code, for example. The situation is diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h index 44b6a1bd26..6d159f0768 100644 --- a/gl/sys_stat.in.h +++ b/gl/sys_stat.in.h @@ -616,14 +616,33 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - " /* We can't use the object-like #define stat rpl_stat, because of struct stat. This means that rpl_stat will not be used if the user does (stat)(a,b). Oh well. */ -# undef stat -# ifdef _LARGE_FILES +# if defined _AIX && defined stat && defined _LARGE_FILES /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, so we have to replace stat64() instead of stat(). */ -# define stat stat64 # undef stat64 # define stat64(name, st) rpl_stat (name, st) -# else /* !_LARGE_FILES */ +# elif defined __MINGW32__ && defined stat +# ifdef _USE_32BIT_TIME_T + /* The system headers define stat to _stat32i64. */ +# undef _stat32i64 +# define _stat32i64(name, st) rpl_stat (name, st) +# else + /* The system headers define stat to _stat64. */ +# undef _stat64 +# define _stat64(name, st) rpl_stat (name, st) +# endif +# elif defined _MSC_VER && defined stat +# ifdef _USE_32BIT_TIME_T + /* The system headers define stat to _stat32. */ +# undef _stat32 +# define _stat32(name, st) rpl_stat (name, st) +# else + /* The system headers define stat to _stat64i32. */ +# undef _stat64i32 +# define _stat64i32(name, st) rpl_stat (name, st) +# endif +# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */ +# undef stat # define stat(name, st) rpl_stat (name, st) # endif /* !_LARGE_FILES */ _GL_EXTERN_C int stat (const char *name, struct stat *buf) diff --git a/gl/sys_time.in.h b/gl/sys_time.in.h index c9ee5653da..ee86ccc216 100644 --- a/gl/sys_time.in.h +++ b/gl/sys_time.in.h @@ -40,9 +40,11 @@ # include <time.h> # endif -/* On native Windows with MSVC: - Get the 'struct timeval' type. */ -# if defined _MSC_VER && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H +/* On native Windows with MSVC, get the 'struct timeval' type. + Also, on native Windows with a 64-bit time_t, where we are overriding the + 'struct timeval' type, get all declarations of system functions whose + signature contains 'struct timeval'. */ +# if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H # define _GL_INCLUDING_WINSOCK2_H # include <winsock2.h> # undef _GL_INCLUDING_WINSOCK2_H @@ -58,7 +60,11 @@ extern "C" { # endif -# if ! @HAVE_STRUCT_TIMEVAL@ +# if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ + +# if @REPLACE_STRUCT_TIMEVAL@ +# define timeval rpl_timeval +# endif # if !GNULIB_defined_struct_timeval struct timeval diff --git a/gl/tests/init.sh b/gl/tests/init.sh index 5985552acf..ae867144d0 100644 --- a/gl/tests/init.sh +++ b/gl/tests/init.sh @@ -255,7 +255,10 @@ compare_dev_null_ () return 2 } -if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null`; then +if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null` \ + && diff -u Makefile "$0" 2>/dev/null | grep '^[+]#!' >/dev/null; then + # diff accepts the -u option and does not (like AIX 7 'diff') produce an + # extra space on column 1 of every content line. if test -z "$diff_out_"; then compare_ () { diff -u "$@"; } else diff --git a/gl/tests/ioctl.c b/gl/tests/ioctl.c index 8701b7a7ef..2e51c92d9a 100644 --- a/gl/tests/ioctl.c +++ b/gl/tests/ioctl.c @@ -47,6 +47,8 @@ rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */) # include <errno.h> # include "fd-hook.h" +/* Get _get_osfhandle. */ +# include "msvc-nothrow.h" static int primary_ioctl (int fd, int request, void *arg) @@ -55,7 +57,10 @@ primary_ioctl (int fd, int request, void *arg) fds non-blocking, use the gnulib 'nonblocking' module, until gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK. */ - errno = ENOSYS; + if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE) + errno = ENOSYS; + else + errno = EBADF; return -1; } diff --git a/gl/tests/test-base64.c b/gl/tests/test-base64.c index 9a533c521a..a71ffbae1d 100644 --- a/gl/tests/test-base64.c +++ b/gl/tests/test-base64.c @@ -153,7 +153,7 @@ main (void) { struct base64_decode_context ctx; - const char *newlineb64 = "YWJjZG\nVmZ2hp\namtsbW5vcA=="; + const char *newlineb64 = "YWJjZG\nVmZ2hp\r\n\tamtsbW5vcA=="; base64_decode_ctx_init (&ctx); @@ -168,7 +168,7 @@ main (void) struct base64_decode_context ctx; base64_decode_ctx_init (&ctx); - ok = base64_decode_alloc_ctx (&ctx, "YW\nJjZGVmZ2hp", 13, &p, &len); + ok = base64_decode_alloc_ctx (&ctx, "YW\n JjZGVmZ2hp", 14, &p, &len); ASSERT (ok); ASSERT (len == 9); ASSERT (memcmp (p, "abcdefghi", len) == 0); diff --git a/gl/tests/test-init.sh b/gl/tests/test-init.sh index c644609fe6..a2825cc769 100755 --- a/gl/tests/test-init.sh +++ b/gl/tests/test-init.sh @@ -50,20 +50,19 @@ EOF case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac compare empty in >out 2>err && fail=1 - # Remove the TAB-date suffix on each --- and +++ line, - # for both the expected and the actual output files. - # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: - # -@@ -0,0 +1 @@ - # +@@ -1,0 +1,1 @@ - cat <<\EOF > exp + # Compare against expected output only if compare is using diff -u. + if grep @ out >/dev/null; then + # Remove the TAB-date suffix on each --- and +++ line, + # for both the expected and the actual output files. + # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: + # -@@ -0,0 +1 @@ + # +@@ -1,0 +1,1 @@ + sed 's/ .*//;/^@@/d' out > k && mv k out + cat <<\EOF > exp --- empty +++ in +xyz EOF - sed 's/ .*//;/^@@/d' out > k && mv k out - - # Compare against expected output only if compare is using diff -u. - if diff -u out out < /dev/null > /dev/null 2>&1; then compare exp out || fail=1 fi case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac diff --git a/gl/tests/test-strerror.c b/gl/tests/test-strerror.c index a40c07923c..14673f2083 100644 --- a/gl/tests/test-strerror.c +++ b/gl/tests/test-strerror.c @@ -64,7 +64,7 @@ main (void) ASSERT (strstr (str, "ndefined") == NULL); /* POSIX requires strerror to produce a non-NULL result for all - inputs; as an extension, we also guarantee a non-empty reseult. + inputs; as an extension, we also guarantee a non-empty result. Reporting EINVAL is optional. */ errno = 0; str = strerror (-3); diff --git a/gl/tests/test-sys_select.c b/gl/tests/test-sys_select.c index a473eba238..78f66eddc9 100644 --- a/gl/tests/test-sys_select.c +++ b/gl/tests/test-sys_select.c @@ -38,7 +38,10 @@ SIGNATURE_CHECK (FD_ZERO, void, (fd_set *)); #endif /* Check that the 'struct timeval' type is defined. */ -struct timeval t1; +struct timeval a; + +/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues. */ +typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1]; /* Check that sigset_t is defined. */ sigset_t t2; diff --git a/gl/tests/test-sys_time.c b/gl/tests/test-sys_time.c index a9ac5e3894..44e21a2771 100644 --- a/gl/tests/test-sys_time.c +++ b/gl/tests/test-sys_time.c @@ -20,8 +20,12 @@ #include <sys/time.h> +/* Check that the 'struct timeval' type is defined. */ struct timeval a; +/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues. */ +typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1]; + int main (void) { diff --git a/gl/tests/w32sock.h b/gl/tests/w32sock.h index 846c342756..ef0b5937e1 100644 --- a/gl/tests/w32sock.h +++ b/gl/tests/w32sock.h @@ -1,4 +1,4 @@ -/* w32sock.h --- internal auxilliary functions for Windows socket functions +/* w32sock.h --- internal auxiliary functions for Windows socket functions Copyright (C) 2008-2012 Free Software Foundation, Inc. @@ -29,7 +29,7 @@ #include "msvc-nothrow.h" #define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) -#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) +#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) static inline void set_winsock_errno (void) diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c index 16fca49fd6..297eb2045e 100644 --- a/gl/vasnprintf.c +++ b/gl/vasnprintf.c @@ -2814,7 +2814,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (has_width) { # if ENABLE_UNISTDIO - /* Outside POSIX, it's preferrable to compare the width + /* Outside POSIX, it's preferable to compare the width against the number of _characters_ of the converted value. */ w = DCHAR_MBSNLEN (result + length, characters); @@ -5417,7 +5417,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { size_t w; # if ENABLE_UNISTDIO - /* Outside POSIX, it's preferrable to compare the width + /* Outside POSIX, it's preferable to compare the width against the number of _characters_ of the converted value. */ w = DCHAR_MBSNLEN (result + length, count); diff --git a/gl/version-etc.h b/gl/version-etc.h index c62704cd42..5548c023c3 100644 --- a/gl/version-etc.h +++ b/gl/version-etc.h @@ -37,7 +37,7 @@ extern const char version_etc_copyright[]; standard way: command and package names, package version, followed by a short GPLv3+ notice and a list of up to 10 author names. - If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of + If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of the program. The formats are therefore: PACKAGE VERSION diff --git a/gl/w32sock.h b/gl/w32sock.h index 846c342756..ef0b5937e1 100644 --- a/gl/w32sock.h +++ b/gl/w32sock.h @@ -1,4 +1,4 @@ -/* w32sock.h --- internal auxilliary functions for Windows socket functions +/* w32sock.h --- internal auxiliary functions for Windows socket functions Copyright (C) 2008-2012 Free Software Foundation, Inc. @@ -29,7 +29,7 @@ #include "msvc-nothrow.h" #define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) -#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) +#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) static inline void set_winsock_errno (void) |