diff lib/regcomp.c @ 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 ab58d4870664
children bc194644f292
line wrap: on
line diff
--- 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];
 */