changeset 18093:00853c226336

regex: merge patches from libc 2015-09-08 Joseph Myers <joseph@codesourcery.com> Move bits/libc-lock.h and bits/libc-lockP.h out of bits/ (bug 14912). * lib/regex_internal.h: Include <libc-lock.h> instead of <bits/libc-lock.h>. 2015-06-09 Joseph Myers <joseph@codesourcery.com> Fix regcomp wcscoll, wcscmp namespace (bug 18497). * lib/regcomp.c (build_range_exp): Call __wcscoll instead of wcscoll. * lib/regexec.c (check_node_accept_bytes): Likewise. 2015-06-05 Joseph Myers <joseph@codesourcery.com> Fix regex wcrtomb namespace (bug 18496). * lib/regex_internal.c (build_wcs_upper_buffer): Call __wcrtomb instead of wcrtomb. 2015-06-05 Joseph Myers <joseph@codesourcery.com> Fix regex wctype namespace (bug 18495). * lib/regcomp.c (re_compile_fastmap_iter): Call __towlower instead of towlower. * lib/regex_internal.c (build_wcs_upper_buffer): Call __iswlower instead of iswlower. Call __towupper instead of towupper. * lib/regex_internal.h (IS_WIDE_WORD_CHAR): Call __iswalnum instead of iswalnum. 2015-01-07 Chris Metcalf <cmetcalf@ezchip.com> * lib/regcomp.c (parse_bracket_exp): Initialize type to COLL_SYM in a couple of places to avoid uninitialized variable wanings on tilegx gcc 4.8.2. 2014-11-24 Siddhesh Poyarekar <siddhesh@redhat.com> * lib/regex_internal.h: Remove NOT_IN_libc. 2014-11-17 Andreas Schwab <schwab@suse.de> * lib/regex_internal.h: Don't include <locale/elem-hash.h>. 2014-09-11 Roland McGrath <roland@hack.frob.com> Move findidx nested functions to top-level. * lib/regcomp.c [_LIBC]: #include <locale/weight.h>. (build_equiv_class) [_LIBC]: Don't #include it inside the function. Pass new arguments to findidx. * lib/regexec.c [RE_ENABLE_I18N] [_LIBC]: #include <locale/weight.h>. [RE_ENABLE_I18N] (check_node_accept_bytes) [_LIBC]: Don't #include it inside the function. Pass new arguments to findidx. * lib/regex_internal.h: [!NOT_IN_libc] [_LIBC]: #include <locale/weight.h>. (re_string_elem_size_at): Don't #include it inside the function. Pass new arguments to findidx. 2014-08-01 Siddhesh Poyarekar <siddhesh@redhat.com> Check if DEBUG is defined in regex_internal.c * lib/regex_internal.c: Check if DEBUG is defined and is set.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 19 Sep 2015 09:21:47 -0700
parents 3b681ffb6097
children a13474110cea
files ChangeLog lib/regcomp.c lib/regex_internal.c lib/regex_internal.h lib/regexec.c
diffstat 5 files changed, 91 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Sep 15 09:11:15 2015 -0700
+++ b/ChangeLog	Sat Sep 19 09:21:47 2015 -0700
@@ -1,3 +1,60 @@
+2015-09-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+	regex: merge patches from libc
+
+	2015-09-08  Joseph Myers  <joseph@codesourcery.com>
+	Move bits/libc-lock.h and bits/libc-lockP.h out of bits/ (bug 14912).
+	* lib/regex_internal.h:
+	Include <libc-lock.h> instead of <bits/libc-lock.h>.
+
+	2015-06-09  Joseph Myers  <joseph@codesourcery.com>
+	Fix regcomp wcscoll, wcscmp namespace (bug 18497).
+	* lib/regcomp.c (build_range_exp): Call __wcscoll instead of
+	wcscoll.
+	* lib/regexec.c (check_node_accept_bytes): Likewise.
+
+	2015-06-05  Joseph Myers  <joseph@codesourcery.com>
+	Fix regex wcrtomb namespace (bug 18496).
+	* lib/regex_internal.c (build_wcs_upper_buffer): Call __wcrtomb
+	instead of wcrtomb.
+
+	2015-06-05  Joseph Myers  <joseph@codesourcery.com>
+	Fix regex wctype namespace (bug 18495).
+	* lib/regcomp.c (re_compile_fastmap_iter): Call __towlower
+	instead of towlower.
+	* lib/regex_internal.c (build_wcs_upper_buffer): Call __iswlower
+	instead of iswlower.  Call __towupper instead of towupper.
+	* lib/regex_internal.h (IS_WIDE_WORD_CHAR): Call __iswalnum
+	instead of iswalnum.
+
+	2015-01-07  Chris Metcalf  <cmetcalf@ezchip.com>
+	* lib/regcomp.c (parse_bracket_exp): Initialize type to
+	COLL_SYM in a couple of places to avoid uninitialized variable
+	wanings on tilegx gcc 4.8.2.
+
+	2014-11-24  Siddhesh Poyarekar  <siddhesh@redhat.com>
+	* lib/regex_internal.h: Remove NOT_IN_libc.
+
+	2014-11-17  Andreas Schwab  <schwab@suse.de>
+	* lib/regex_internal.h: Don't include <locale/elem-hash.h>.
+
+	2014-09-11  Roland McGrath  <roland@hack.frob.com>
+	Move findidx nested functions to top-level.
+	* lib/regcomp.c [_LIBC]: #include <locale/weight.h>.
+	(build_equiv_class) [_LIBC]: Don't #include it inside the function.
+	Pass new arguments to findidx.
+	* lib/regexec.c [RE_ENABLE_I18N] [_LIBC]: #include <locale/weight.h>.
+	[RE_ENABLE_I18N] (check_node_accept_bytes) [_LIBC]:
+	Don't #include it inside the function.  Pass new arguments to findidx.
+	* lib/regex_internal.h:
+	[!NOT_IN_libc] [_LIBC]: #include <locale/weight.h>.
+	(re_string_elem_size_at): Don't #include it inside the function.
+	Pass new arguments to findidx.
+
+	2014-08-01  Siddhesh Poyarekar  <siddhesh@redhat.com>
+	Check if DEBUG is defined in regex_internal.c
+	* lib/regex_internal.c: Check if DEBUG is defined and is set.
+
 2015-09-08   Assaf Gordon  <assafgordon@gmail.com>
 
 	ceill: detect buggy OpenBSD implementation
--- a/lib/regcomp.c	Tue Sep 15 09:11:15 2015 -0700
+++ b/lib/regcomp.c	Sat Sep 19 09:21:47 2015 -0700
@@ -17,6 +17,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifdef _LIBC
+# include <locale/weight.h>
+#endif
+
 static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
 					  size_t length, reg_syntax_t syntax);
 static void re_compile_fastmap_iter (regex_t *bufp,
@@ -335,7 +339,7 @@
 	      memset (&state, '\0', sizeof (state));
 	      if (__mbrtowc (&wc, (const char *) buf, p - buf,
 			     &state) == p - buf
-		  && (__wcrtomb ((char *) buf, towlower (wc), &state)
+		  && (__wcrtomb ((char *) buf, __towlower (wc), &state)
 		      != (size_t) -1))
 		re_set_fastmap (fastmap, false, buf[0]);
 	    }
@@ -411,7 +415,7 @@
 		    re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
 		  if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
 		    {
-		      if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
+		      if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state)
 			  != (size_t) -1)
 			re_set_fastmap (fastmap, false, *(unsigned char *) buf);
 		    }
@@ -3175,6 +3179,7 @@
       re_token_t token2;
 
       start_elem.opr.name = start_name_buf;
+      start_elem.type = COLL_SYM;
       ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
 				   syntax, first_round);
       if (BE (ret != REG_NOERROR, 0))
@@ -3218,6 +3223,7 @@
       if (is_range_exp == true)
 	{
 	  end_elem.opr.name = end_name_buf;
+	  end_elem.type = COLL_SYM;
 	  ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
 				       dfa, syntax, true);
 	  if (BE (ret != REG_NOERROR, 0))
@@ -3492,8 +3498,6 @@
       int32_t idx1, idx2;
       unsigned int ch;
       size_t len;
-      /* This #include defines a local function!  */
-# include <locale/weight.h>
       /* Calculate the index for equivalence class.  */
       cp = name;
       table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
@@ -3503,7 +3507,7 @@
 						   _NL_COLLATE_EXTRAMB);
       indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
 						_NL_COLLATE_INDIRECTMB);
-      idx1 = findidx (&cp, -1);
+      idx1 = findidx (table, indirect, extra, &cp, -1);
       if (BE (idx1 == 0 || *cp != '\0', 0))
 	/* This isn't a valid character.  */
 	return REG_ECOLLATE;
@@ -3514,7 +3518,7 @@
 	{
 	  char_buf[0] = ch;
 	  cp = char_buf;
-	  idx2 = findidx (&cp, 1);
+	  idx2 = findidx (table, indirect, extra, &cp, 1);
 /*
 	  idx2 = table[ch];
 */
--- a/lib/regex_internal.c	Tue Sep 15 09:11:15 2015 -0700
+++ b/lib/regex_internal.c	Sat Sep 19 09:21:47 2015 -0700
@@ -311,12 +311,12 @@
 			       + byte_idx), remain_len, &pstr->cur_state);
 	  if (BE (mbclen < (size_t) -2, 1))
 	    {
-	      wchar_t wcu = towupper (wc);
+	      wchar_t wcu = __towupper (wc);
 	      if (wcu != wc)
 		{
 		  size_t mbcdlen;
 
-		  mbcdlen = wcrtomb (buf, wcu, &prev_st);
+		  mbcdlen = __wcrtomb (buf, wcu, &prev_st);
 		  if (BE (mbclen == mbcdlen, 1))
 		    memcpy (pstr->mbs + byte_idx, buf, mbclen);
 		  else
@@ -380,7 +380,7 @@
 	mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
 	if (BE (mbclen < (size_t) -2, 1))
 	  {
-	    wchar_t wcu = towupper (wc);
+	    wchar_t wcu = __towupper (wc);
 	    if (wcu != wc)
 	      {
 		size_t mbcdlen;
--- a/lib/regex_internal.h	Tue Sep 15 09:11:15 2015 -0700
+++ b/lib/regex_internal.h	Sat Sep 19 09:21:47 2015 -0700
@@ -34,7 +34,7 @@
 #include <stdint.h>
 
 #ifdef _LIBC
-# include <bits/libc-lock.h>
+# include <libc-lock.h>
 # define lock_define(name) __libc_lock_define (, name)
 # define lock_init(lock) (__libc_lock_init (lock), 0)
 # define lock_fini(lock) 0
@@ -87,7 +87,6 @@
 # ifndef _RE_DEFINE_LOCALE_FUNCTIONS
 #  define _RE_DEFINE_LOCALE_FUNCTIONS 1
 #   include <locale/localeinfo.h>
-#   include <locale/elem-hash.h>
 #   include <locale/coll-lookup.h>
 # endif
 #endif
@@ -137,7 +136,10 @@
 # undef __wctype
 # undef __iswctype
 # define __wctype wctype
+# define __iswalnum iswalnum
 # define __iswctype iswctype
+# define __towlower towlower
+# define __towupper towupper
 # define __btowc btowc
 # define __mbrtowc mbrtowc
 # define __wcrtomb wcrtomb
@@ -447,23 +449,23 @@
 
 #ifndef _LIBC
 # define internal_function
+# define IS_IN(libc) false
 #endif
 
-#ifndef NOT_IN_libc
 static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
 						Idx new_buf_len)
      internal_function;
-# ifdef RE_ENABLE_I18N
+#ifdef RE_ENABLE_I18N
 static void build_wcs_buffer (re_string_t *pstr) internal_function;
 static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
   internal_function;
-# endif /* RE_ENABLE_I18N */
+#endif /* RE_ENABLE_I18N */
 static void build_upper_buffer (re_string_t *pstr) internal_function;
 static void re_string_translate_buffer (re_string_t *pstr) internal_function;
 static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
 					  int eflags)
      internal_function __attribute__ ((pure));
-#endif
+
 #define re_string_peek_byte(pstr, offset) \
   ((pstr)->mbs[(pstr)->cur_idx + offset])
 #define re_string_fetch_byte(pstr) \
@@ -556,7 +558,7 @@
 
 #define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
 #define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
-#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
+#define IS_WIDE_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_')
 #define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
 
 #define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
@@ -860,15 +862,17 @@
   return (wint_t) pstr->wcs[idx];
 }
 
-# ifndef NOT_IN_libc
+# ifdef _LIBC
+#  include <locale/weight.h>
+# endif
+
 static int
 internal_function __attribute__ ((pure, unused))
 re_string_elem_size_at (const re_string_t *pstr, Idx idx)
 {
-#  ifdef _LIBC
+# ifdef _LIBC
   const unsigned char *p, *extra;
   const int32_t *table, *indirect;
-#   include <locale/weight.h>
   uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
 
   if (nrules != 0)
@@ -879,14 +883,13 @@
       indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
 						_NL_COLLATE_INDIRECTMB);
       p = pstr->mbs + idx;
-      findidx (&p, pstr->len - idx);
+      findidx (table, indirect, extra, &p, pstr->len - idx);
       return p - pstr->mbs - idx;
     }
   else
-#  endif /* _LIBC */
+# endif /* _LIBC */
     return 1;
 }
-# endif
 #endif /* RE_ENABLE_I18N */
 
 #ifndef __GNUC_PREREQ
--- a/lib/regexec.c	Tue Sep 15 09:11:15 2015 -0700
+++ b/lib/regexec.c	Sat Sep 19 09:21:47 2015 -0700
@@ -3776,6 +3776,10 @@
    one collating element like '.', '[a-z]', opposite to the other nodes
    can only accept one byte.  */
 
+# ifdef _LIBC
+#  include <locale/weight.h>
+# endif
+
 static int
 internal_function
 check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
@@ -3895,8 +3899,6 @@
 	  const int32_t *table, *indirect;
 	  const unsigned char *weights, *extra;
 	  const char *collseqwc;
-	  /* This #include defines a local function!  */
-#  include <locale/weight.h>
 
 	  /* match with collating_symbol?  */
 	  if (cset->ncoll_syms)
@@ -3953,7 +3955,7 @@
 		_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
 	      indirect = (const int32_t *)
 		_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
-	      int32_t idx = findidx (&cp, elem_len);
+	      int32_t idx = findidx (table, indirect, extra, &cp, elem_len);
 	      if (idx > 0)
 		for (i = 0; i < cset->nequiv_classes; ++i)
 		  {