aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-11-30 14:20:43 +0200
committerArnold D. Robbins <arnold@skeeve.com>2012-11-30 14:20:43 +0200
commitf2d137e07671bb1158f81e5a772c3f994c69953f (patch)
tree06ff04a1ef159073a9672c22475c9da54fc05155
parent880d9f5b287a8d44227aed80f53395f19c2283a2 (diff)
downloadegawk-f2d137e07671bb1158f81e5a772c3f994c69953f.tar.gz
egawk-f2d137e07671bb1158f81e5a772c3f994c69953f.tar.bz2
egawk-f2d137e07671bb1158f81e5a772c3f994c69953f.zip
Sync regex routines with GLIBC.
-rw-r--r--ChangeLog5
-rw-r--r--regcomp.c15
-rw-r--r--regex.c5
-rw-r--r--regex_internal.h4
-rw-r--r--regexec.c8
5 files changed, 25 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 352d9da1..00369398 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * regcomp.c, regex.c, regex_internal.h, regexec.c: Sync
+ with GLIBC. Why not.
+
2012-01-30 Andrew J. Schorr <aschorr@telemetry-investments.com>
Further cleanups of macros in awk.h
diff --git a/regcomp.c b/regcomp.c
index f83e454d..f6a7fdf6 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -573,8 +573,12 @@ regerror (errcode, preg, errbuf, errbuf_size)
{
if (BE (msg_size > errbuf_size, 0))
{
+#if defined HAVE_MEMPCPY || defined _LIBC
+ *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
+#else
memcpy (errbuf, msg, errbuf_size - 1);
errbuf[errbuf_size - 1] = 0;
+#endif
}
else
memcpy (errbuf, msg, msg_size);
@@ -896,7 +900,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
# endif
/* strcasecmp isn't a standard interface. brute force check */
-#if 0
+#ifndef GAWK
if (strcasecmp (codeset_name, "UTF-8") == 0
|| strcasecmp (codeset_name, "UTF8") == 0)
dfa->is_utf8 = 1;
@@ -978,8 +982,12 @@ init_word_char (re_dfa_t *dfa)
{
if (sizeof (dfa->word_char[0]) == 8)
{
- dfa->word_char[0] = UINT64_C (0x03ff000000000000);
- dfa->word_char[1] = UINT64_C (0x07fffffe87fffffe);
+ /* The extra temporaries here avoid "implicitly truncated"
+ warnings in the case when this is dead code, i.e. 32-bit. */
+ const uint64_t wc0 = UINT64_C (0x03ff000000000000);
+ const uint64_t wc1 = UINT64_C (0x07fffffe87fffffe);
+ dfa->word_char[0] = wc0;
+ dfa->word_char[1] = wc1;
i = 2;
}
else if (sizeof (dfa->word_char[0]) == 4)
@@ -2679,7 +2687,6 @@ build_range_exp (reg_syntax_t syntax, bitset_t sbcset,
# endif /* not RE_ENABLE_I18N */
{
unsigned int start_ch, end_ch;
-
/* Equivalence Classes and Character Classes can't be a range start/end. */
if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
|| end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
diff --git a/regex.c b/regex.c
index 3abc7585..5ce79e09 100644
--- a/regex.c
+++ b/regex.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -56,6 +56,9 @@
#undefs RE_DUP_MAX and sets it to the right value. */
#include <limits.h>
+/* This header defines the MIN and MAX macros. */
+#include <sys/param.h>
+
#ifdef GAWK
#undef alloca
#define alloca alloca_is_bad_you_should_never_use_it
diff --git a/regex_internal.h b/regex_internal.h
index f38a13b0..36f29e47 100644
--- a/regex_internal.h
+++ b/regex_internal.h
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2005, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -92,7 +92,7 @@ is_blank (int c)
# ifdef _LIBC
# undef gettext
# define gettext(msgid) \
- INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
+ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
# endif
#else
# define gettext(msgid) (msgid)
diff --git a/regexec.c b/regexec.c
index ea4a02f7..ff90fe31 100644
--- a/regexec.c
+++ b/regexec.c
@@ -375,7 +375,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
const char *str;
int rval;
int len = length1 + length2;
- int free_str = 0;
+ char *s = NULL;
if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
return -2;
@@ -384,7 +384,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
if (length2 > 0)
if (length1 > 0)
{
- char *s = re_malloc (char, len);
+ s = re_malloc (char, len);
if (BE (s == NULL, 0))
return -2;
@@ -395,7 +395,6 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
memcpy (s + length1, string2, length2);
#endif
str = s;
- free_str = 1;
}
else
str = string2;
@@ -403,8 +402,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
str = string1;
rval = re_search_stub (bufp, str, len, start, range, stop, regs, ret_len);
- if (free_str)
- re_free ((char *) str);
+ re_free (s);
return rval;
}