summaryrefslogtreecommitdiff
path: root/gnulib
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-08-01 08:12:37 +0200
committerGuido Günther <agx@sigxcpu.org>2014-08-01 08:12:37 +0200
commit16575d9886c474a5c35308e4900a7fcf0d57dea7 (patch)
tree9b396828329b529101e05f3694cbcceda56b6114 /gnulib
parentab710a4bc80b419b99089e71eb5b1a3e32adc7a5 (diff)
New upstream version 1.2.7~rc2
Diffstat (limited to 'gnulib')
-rw-r--r--gnulib/lib/isatty.c8
-rw-r--r--gnulib/lib/langinfo.in.h18
-rw-r--r--gnulib/lib/mktime.c4
-rw-r--r--gnulib/lib/nl_langinfo.c233
-rw-r--r--gnulib/lib/poll.c8
-rw-r--r--gnulib/lib/regcomp.c14
-rw-r--r--gnulib/lib/regex.h2
-rw-r--r--gnulib/lib/regex_internal.h4
-rw-r--r--gnulib/lib/select.c36
9 files changed, 224 insertions, 103 deletions
diff --git a/gnulib/lib/isatty.c b/gnulib/lib/isatty.c
index cc305f534..8c1b0ced5 100644
--- a/gnulib/lib/isatty.c
+++ b/gnulib/lib/isatty.c
@@ -32,9 +32,11 @@
/* Get _get_osfhandle(). */
#include "msvc-nothrow.h"
-/* 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) (((intptr_t) (h) & 3) == 3)
+static BOOL IsConsoleHandle (HANDLE h)
+{
+ DWORD mode;
+ return GetConsoleMode (h, &mode) != 0;
+}
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
diff --git a/gnulib/lib/langinfo.in.h b/gnulib/lib/langinfo.in.h
index 79ac8aa40..cc56f4d37 100644
--- a/gnulib/lib/langinfo.in.h
+++ b/gnulib/lib/langinfo.in.h
@@ -49,7 +49,10 @@ typedef int nl_item;
# define CODESET 10000
/* nl_langinfo items of the LC_NUMERIC category */
# define RADIXCHAR 10001
+# define DECIMAL_POINT RADIXCHAR
# define THOUSEP 10002
+# define THOUSANDS_SEP THOUSEP
+# define GROUPING 10114
/* nl_langinfo items of the LC_TIME category */
# define D_T_FMT 10003
# define D_FMT 10004
@@ -102,6 +105,21 @@ typedef int nl_item;
# define ALT_DIGITS 10051
/* nl_langinfo items of the LC_MONETARY category */
# define CRNCYSTR 10052
+# define CURRENCY_SYMBOL CRNCYSTR
+# define INT_CURR_SYMBOL 10100
+# define MON_DECIMAL_POINT 10101
+# define MON_THOUSANDS_SEP 10102
+# define MON_GROUPING 10103
+# define POSITIVE_SIGN 10104
+# define NEGATIVE_SIGN 10105
+# define FRAC_DIGITS 10106
+# define INT_FRAC_DIGITS 10107
+# define P_CS_PRECEDES 10108
+# define N_CS_PRECEDES 10109
+# define P_SEP_BY_SPACE 10110
+# define N_SEP_BY_SPACE 10111
+# define P_SIGN_POSN 10112
+# define N_SIGN_POSN 10113
/* nl_langinfo items of the LC_MESSAGES category */
# define YESEXPR 10053
# define NOEXPR 10054
diff --git a/gnulib/lib/mktime.c b/gnulib/lib/mktime.c
index f10e5301d..a52933e0e 100644
--- a/gnulib/lib/mktime.c
+++ b/gnulib/lib/mktime.c
@@ -38,7 +38,7 @@
#include <string.h> /* For the real memcpy prototype. */
-#if DEBUG
+#if defined DEBUG && DEBUG
# include <stdio.h>
# include <stdlib.h>
/* Make it work even if the system's libc has its own mktime routine. */
@@ -600,7 +600,7 @@ libc_hidden_def (mktime)
libc_hidden_weak (timelocal)
#endif
-#if DEBUG
+#if defined DEBUG && DEBUG
static int
not_equal_tm (const struct tm *a, const struct tm *b)
diff --git a/gnulib/lib/nl_langinfo.c b/gnulib/lib/nl_langinfo.c
index 17c996625..2b87ee323 100644
--- a/gnulib/lib/nl_langinfo.c
+++ b/gnulib/lib/nl_langinfo.c
@@ -20,13 +20,71 @@
/* Specification. */
#include <langinfo.h>
+#include <locale.h>
+#include <string.h>
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# include <windows.h>
+# include <stdio.h>
+#endif
+
+/* Return the codeset of the current locale, if this is easily deducible.
+ Otherwise, return "". */
+static char *
+ctype_codeset (void)
+{
+ static char buf[2 + 10 + 1];
+ size_t buflen = 0;
+ char const *locale = setlocale (LC_CTYPE, NULL);
+ char *codeset = buf;
+ size_t codesetlen;
+ codeset[0] = '\0';
+
+ if (locale && locale[0])
+ {
+ /* If the locale name contains an encoding after the dot, return it. */
+ char *dot = strchr (locale, '.');
+
+ if (dot)
+ {
+ /* Look for the possible @... trailer and remove it, if any. */
+ char *codeset_start = dot + 1;
+ char const *modifier = strchr (codeset_start, '@');
+
+ if (! modifier)
+ codeset = codeset_start;
+ else
+ {
+ codesetlen = modifier - codeset_start;
+ if (codesetlen < sizeof buf)
+ {
+ codeset = memcpy (buf, codeset_start, codesetlen);
+ codeset[codesetlen] = '\0';
+ }
+ }
+ }
+ }
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* If setlocale is successful, it returns the number of the
+ codepage, as a string. Otherwise, fall back on Windows API
+ GetACP, which returns the locale's codepage as a number (although
+ this doesn't change according to what the 'setlocale' call specified).
+ Either way, prepend "CP" to make it a valid codeset name. */
+ codesetlen = strlen (codeset);
+ if (0 < codesetlen && codesetlen < sizeof buf - 2)
+ memmove (buf + 2, codeset, codesetlen + 1);
+ else
+ sprintf (buf + 2, "%u", GetACP ());
+ codeset = memcpy (buf, "CP", 2);
+#endif
+ return codeset;
+}
+
+
#if REPLACE_NL_LANGINFO
/* Override nl_langinfo with support for added nl_item values. */
-# include <locale.h>
-# include <string.h>
-
# undef nl_langinfo
char *
@@ -36,36 +94,7 @@ rpl_nl_langinfo (nl_item item)
{
# if GNULIB_defined_CODESET
case CODESET:
- {
- const char *locale;
- static char buf[2 + 10 + 1];
-
- locale = setlocale (LC_CTYPE, NULL);
- if (locale != NULL && locale[0] != '\0')
- {
- /* If the locale name contains an encoding after the dot, return
- it. */
- const char *dot = strchr (locale, '.');
-
- if (dot != NULL)
- {
- const char *modifier;
-
- dot++;
- /* Look for the possible @... trailer and remove it, if any. */
- modifier = strchr (dot, '@');
- if (modifier == NULL)
- return dot;
- if (modifier - dot < sizeof (buf))
- {
- memcpy (buf, dot, modifier - dot);
- buf [modifier - dot] = '\0';
- return buf;
- }
- }
- }
- return "";
- }
+ return ctype_codeset ();
# endif
# if GNULIB_defined_T_FMT_AMPM
case T_FMT_AMPM:
@@ -128,25 +157,24 @@ rpl_nl_langinfo (nl_item item)
# endif
-# include <locale.h>
+# include <time.h>
char *
nl_langinfo (nl_item item)
{
+ static char nlbuf[100];
+ struct tm tmm = { 0 };
+
switch (item)
{
/* nl_langinfo items of the LC_CTYPE category */
case CODESET:
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
{
- static char buf[2 + 10 + 1];
-
- /* The Windows API has a function returning the locale's codepage as
- a number. */
- sprintf (buf, "CP%u", GetACP ());
- return buf;
+ char *codeset = ctype_codeset ();
+ if (*codeset)
+ return codeset;
}
-# elif defined __BEOS__
+# ifdef __BEOS__
return "UTF-8";
# else
return "ISO-8859-1";
@@ -156,6 +184,8 @@ nl_langinfo (nl_item item)
return localeconv () ->decimal_point;
case THOUSEP:
return localeconv () ->thousands_sep;
+ case GROUPING:
+ return localeconv () ->grouping;
/* nl_langinfo items of the LC_TIME category.
TODO: Really use the locale. */
case D_T_FMT:
@@ -170,93 +200,126 @@ nl_langinfo (nl_item item)
case T_FMT_AMPM:
return "%I:%M:%S %p";
case AM_STR:
- return "AM";
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return "AM";
+ return nlbuf;
case PM_STR:
- return "PM";
+ tmm.tm_hour = 12;
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return "PM";
+ return nlbuf;
case DAY_1:
- return "Sunday";
case DAY_2:
- return "Monday";
case DAY_3:
- return "Tuesday";
case DAY_4:
- return "Wednesday";
case DAY_5:
- return "Thursday";
case DAY_6:
- return "Friday";
case DAY_7:
- return "Saturday";
+ {
+ static char const days[][sizeof "Wednesday"] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday"
+ };
+ tmm.tm_wday = item - DAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%A", &tmm))
+ return (char *) days[item - DAY_1];
+ return nlbuf;
+ }
case ABDAY_1:
- return "Sun";
case ABDAY_2:
- return "Mon";
case ABDAY_3:
- return "Tue";
case ABDAY_4:
- return "Wed";
case ABDAY_5:
- return "Thu";
case ABDAY_6:
- return "Fri";
case ABDAY_7:
- return "Sat";
+ {
+ static char const abdays[][sizeof "Sun"] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ tmm.tm_wday = item - ABDAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%a", &tmm))
+ return (char *) abdays[item - ABDAY_1];
+ return nlbuf;
+ }
case MON_1:
- return "January";
case MON_2:
- return "February";
case MON_3:
- return "March";
case MON_4:
- return "April";
case MON_5:
- return "May";
case MON_6:
- return "June";
case MON_7:
- return "July";
case MON_8:
- return "August";
case MON_9:
- return "September";
case MON_10:
- return "October";
case MON_11:
- return "November";
case MON_12:
- return "December";
+ {
+ static char const months[][sizeof "September"] = {
+ "January", "February", "March", "April", "May", "June", "July",
+ "September", "October", "November", "December"
+ };
+ tmm.tm_mon = item - MON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%B", &tmm))
+ return (char *) months[item - MON_1];
+ return nlbuf;
+ }
case ABMON_1:
- return "Jan";
case ABMON_2:
- return "Feb";
case ABMON_3:
- return "Mar";
case ABMON_4:
- return "Apr";
case ABMON_5:
- return "May";
case ABMON_6:
- return "Jun";
case ABMON_7:
- return "Jul";
case ABMON_8:
- return "Aug";
case ABMON_9:
- return "Sep";
case ABMON_10:
- return "Oct";
case ABMON_11:
- return "Nov";
case ABMON_12:
- return "Dec";
+ {
+ static char const abmonths[][sizeof "Jan"] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Sep", "Oct", "Nov", "Dec"
+ };
+ tmm.tm_mon = item - ABMON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%b", &tmm))
+ return (char *) abmonths[item - ABMON_1];
+ return nlbuf;
+ }
case ERA:
return "";
case ALT_DIGITS:
return "\0\0\0\0\0\0\0\0\0\0";
- /* nl_langinfo items of the LC_MONETARY category
- TODO: Really use the locale. */
+ /* nl_langinfo items of the LC_MONETARY category. */
case CRNCYSTR:
- return "-";
+ return localeconv () ->currency_symbol;
+ case INT_CURR_SYMBOL:
+ return localeconv () ->int_curr_symbol;
+ case MON_DECIMAL_POINT:
+ return localeconv () ->mon_decimal_point;
+ case MON_THOUSANDS_SEP:
+ return localeconv () ->mon_thousands_sep;
+ case MON_GROUPING:
+ return localeconv () ->mon_grouping;
+ case POSITIVE_SIGN:
+ return localeconv () ->positive_sign;
+ case NEGATIVE_SIGN:
+ return localeconv () ->negative_sign;
+ case FRAC_DIGITS:
+ return & localeconv () ->frac_digits;
+ case INT_FRAC_DIGITS:
+ return & localeconv () ->int_frac_digits;
+ case P_CS_PRECEDES:
+ return & localeconv () ->p_cs_precedes;
+ case N_CS_PRECEDES:
+ return & localeconv () ->n_cs_precedes;
+ case P_SEP_BY_SPACE:
+ return & localeconv () ->p_sep_by_space;
+ case N_SEP_BY_SPACE:
+ return & localeconv () ->n_sep_by_space;
+ case P_SIGN_POSN:
+ return & localeconv () ->p_sign_posn;
+ case N_SIGN_POSN:
+ return & localeconv () ->n_sign_posn;
/* nl_langinfo items of the LC_MESSAGES category
TODO: Really use the locale. */
case YESEXPR:
diff --git a/gnulib/lib/poll.c b/gnulib/lib/poll.c
index 58d22e527..040c8892b 100644
--- a/gnulib/lib/poll.c
+++ b/gnulib/lib/poll.c
@@ -70,9 +70,11 @@
#ifdef WINDOWS_NATIVE
-/* 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) (((intptr_t) (h) & 3) == 3)
+static BOOL IsConsoleHandle (HANDLE h)
+{
+ DWORD mode;
+ return GetConsoleMode (h, &mode) != 0;
+}
static BOOL
IsSocketHandle (HANDLE h)
diff --git a/gnulib/lib/regcomp.c b/gnulib/lib/regcomp.c
index 56faf11c4..16d0e2159 100644
--- a/gnulib/lib/regcomp.c
+++ b/gnulib/lib/regcomp.c
@@ -2460,14 +2460,22 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
|| token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
{
- tree = parse_dup_op (tree, regexp, dfa, token, syntax, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
+ bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
+ syntax, err);
+ if (BE (*err != REG_NOERROR && dup_tree == NULL, 0))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ tree = dup_tree;
/* In BRE consecutive duplications are not allowed. */
if ((syntax & RE_CONTEXT_INVALID_DUP)
&& (token->type == OP_DUP_ASTERISK
|| token->type == OP_OPEN_DUP_NUM))
{
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
*err = REG_BADRPT;
return NULL;
}
diff --git a/gnulib/lib/regex.h b/gnulib/lib/regex.h
index 54327c69e..45ac1a0da 100644
--- a/gnulib/lib/regex.h
+++ b/gnulib/lib/regex.h
@@ -608,7 +608,7 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,
regoff_t *__starts, regoff_t *__ends);
#endif /* Use GNU */
-#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
+#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC)
# ifndef _CRAY
/* 4.2 bsd compatibility. */
extern char *re_comp (const char *);
diff --git a/gnulib/lib/regex_internal.h b/gnulib/lib/regex_internal.h
index a0eae33e9..bfce99f31 100644
--- a/gnulib/lib/regex_internal.h
+++ b/gnulib/lib/regex_internal.h
@@ -40,7 +40,7 @@
# define lock_fini(lock) 0
# define lock_lock(lock) __libc_lock_lock (lock)
# define lock_unlock(lock) __libc_lock_unlock (lock)
-#elif defined GNULIB_LOCK
+#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
# include "glthread/lock.h"
/* Use gl_lock_define if empty macro arguments are known to work.
Otherwise, fall back on less-portable substitutes. */
@@ -62,7 +62,7 @@
# define lock_fini(lock) glthread_lock_destroy (&(lock))
# define lock_lock(lock) glthread_lock_lock (&(lock))
# define lock_unlock(lock) glthread_lock_unlock (&(lock))
-#elif defined GNULIB_PTHREAD
+#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO
# include <pthread.h>
# define lock_define(name) pthread_mutex_t name;
# define lock_init(lock) pthread_mutex_init (&(lock), 0)
diff --git a/gnulib/lib/select.c b/gnulib/lib/select.c
index 1c8fd70c5..1bc359e14 100644
--- a/gnulib/lib/select.c
+++ b/gnulib/lib/select.c
@@ -82,9 +82,11 @@ typedef DWORD (WINAPI *PNtQueryInformationFile)
#define PIPE_BUF 512
#endif
-/* 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) (((intptr_t) (h) & 3) == 3)
+static BOOL IsConsoleHandle (HANDLE h)
+{
+ DWORD mode;
+ return GetConsoleMode (h, &mode) != 0;
+}
static BOOL
IsSocketHandle (HANDLE h)
@@ -252,6 +254,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
DWORD ret, wait_timeout, nhandles, nsock, nbuffer;
MSG msg;
int i, fd, rc;
+ clock_t tend;
if (nfds > FD_SETSIZE)
nfds = FD_SETSIZE;
@@ -388,6 +391,10 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
/* Place a sentinel at the end of the array. */
handle_array[nhandles] = NULL;
+ /* When will the waiting period expire? */
+ if (wait_timeout != INFINITE)
+ tend = clock () + wait_timeout;
+
restart:
if (wait_timeout == 0 || nsock == 0)
rc = 0;
@@ -408,6 +415,16 @@ restart:
wait_timeout = 0;
}
+ /* How much is left to wait? */
+ if (wait_timeout != INFINITE)
+ {
+ clock_t tnow = clock ();
+ if (tend >= tnow)
+ wait_timeout = tend - tnow;
+ else
+ wait_timeout = 0;
+ }
+
for (;;)
{
ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
@@ -453,7 +470,16 @@ restart:
}
}
- if (rc == 0 && wait_timeout == INFINITE)
+ if (rc == 0
+ && (wait_timeout == INFINITE
+ /* If NHANDLES > 1, but no bits are set, it means we've
+ been told incorrectly that some handle was signaled.
+ This happens with anonymous pipes, which always cause
+ MsgWaitForMultipleObjects to exit immediately, but no
+ data is found ready to be read by windows_poll_handle.
+ To avoid a total failure (whereby we return zero and
+ don't wait at all), let's poll in a more busy loop. */
+ || (wait_timeout != 0 && nhandles > 1)))
{
/* Sleep 1 millisecond to avoid busy wait and retry with the
original fd_sets. */
@@ -463,6 +489,8 @@ restart:
SleepEx (1, TRUE);
goto restart;
}
+ if (timeout && wait_timeout == 0 && rc == 0)
+ timeout->tv_sec = timeout->tv_usec = 0;
}
/* Now fill in the results. */