diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-11-30 14:20:43 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-11-30 14:20:43 +0200 |
commit | f2d137e07671bb1158f81e5a772c3f994c69953f (patch) | |
tree | 06ff04a1ef159073a9672c22475c9da54fc05155 | |
parent | 880d9f5b287a8d44227aed80f53395f19c2283a2 (diff) | |
download | egawk-f2d137e07671bb1158f81e5a772c3f994c69953f.tar.gz egawk-f2d137e07671bb1158f81e5a772c3f994c69953f.tar.bz2 egawk-f2d137e07671bb1158f81e5a772c3f994c69953f.zip |
Sync regex routines with GLIBC.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | regcomp.c | 15 | ||||
-rw-r--r-- | regex.c | 5 | ||||
-rw-r--r-- | regex_internal.h | 4 | ||||
-rw-r--r-- | regexec.c | 8 |
5 files changed, 25 insertions, 12 deletions
@@ -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 @@ -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, @@ -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) @@ -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; } |