[PATCH] Merge regex portability/bug fixes from gawk
Bonzini
bonzini@gnu.org
Wed Jan 28 12:59:00 GMT 2004
2004-01-28 Paolo Bonzini <bonzini@gnu.org>
Merge regex changes in gawk.
* posix/regcomp.c (build_range_exp) [!_LIBC]: Check validity
of collation elements.
* posix/regex.c: Include limits.h.
[_MSC_VER]: Get size_t from stdio.h.
* posix/regex.h: Document REG_ECOLLATE correctly.
[__APPLE_CC__]: Define __restrict to nothing.
* posix/regex_internal.h [!_LIBC && !ENABLE_NLS]:
Disable NLS.
Paolo
--
Index: regcomp.c
===================================================================
RCS file: /cvs/glibc/libc/posix/regcomp.c,v
retrieving revision 1.76
diff -u -r1.76 regcomp.c
--- regcomp.c 14 Jan 2004 02:40:57 -0000 1.76
+++ regcomp.c 28 Jan 2004 11:58:19 -0000
@@ -2560,6 +2560,8 @@
? __btowc (start_ch) : start_elem->opr.wch);
end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
? __btowc (end_ch) : end_elem->opr.wch);
+ if (start_wc == WEOF || end_wc == WEOF)
+ return REG_ECOLLATE;
cmp_buf[0] = start_wc;
cmp_buf[4] = end_wc;
if (wcscoll (cmp_buf, cmp_buf + 4) > 0)
Index: regex.c
===================================================================
RCS file: /cvs/glibc/libc/posix/regex.c,v
retrieving revision 1.125
diff -u -r1.125 regex.c
--- regex.c 14 Jan 2004 04:10:07 -0000 1.125
+++ regex.c 28 Jan 2004 11:58:19 -0000
@@ -74,6 +74,17 @@
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#include <sys/types.h>
+
+/* This is needed for size_t. */
+#ifdef _MSC_VER
+#include <stdio.h>
+#endif
+
+/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
+ GNU regex allows. Include it before <regex.h>, which correctly
+ #undefs RE_DUP_MAX and sets it to the right value. */
+#include <limits.h>
+
#include <regex.h>
#include "regex_internal.h"
Index: regex.h
===================================================================
RCS file: /cvs/glibc/libc/posix/regex.h,v
retrieving revision 1.30
diff -u -r1.30 regex.h
--- regex.h 13 Nov 2003 05:58:44 -0000 1.30
+++ regex.h 28 Jan 2004 11:58:19 -0000
@@ -313,7 +313,7 @@
/* POSIX regcomp return error codes. (In the order listed in the
standard.) */
REG_BADPAT, /* Invalid pattern. */
- REG_ECOLLATE, /* Not implemented. */
+ REG_ECOLLATE, /* Inalid collating element. */
REG_ECTYPE, /* Invalid character class name. */
REG_EESCAPE, /* Trailing backslash. */
REG_ESUBREG, /* Invalid back reference. */
@@ -543,6 +543,8 @@
# else
# define __restrict
# endif
+# elif defined __APPLE_CC__
+# define __restrict
# endif
#endif
/* gcc 3.1 and up support the [restrict] syntax. */
Index: regex_internal.h
===================================================================
RCS file: /cvs/glibc/libc/posix/regex_internal.h,v
retrieving revision 1.45
diff -u -r1.45 regex_internal.h
--- regex_internal.h 14 Jan 2004 04:10:08 -0000 1.45
+++ regex_internal.h 28 Jan 2004 11:58:19 -0000
@@ -23,7 +23,6 @@
#include <assert.h>
#include <ctype.h>
-#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -53,7 +52,7 @@
#endif
/* This is for other GNU distributions with internationalized messages. */
-#if HAVE_LIBINTL_H || defined _LIBC
+#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef gettext
More information about the Libc-alpha
mailing list