about summary refs log tree commit diff
path: root/posix/regex_internal.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-12-29 17:32:25 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-01-04 08:38:52 -0300
commitc2a150d089fa096cb5f9e342da80fb30dc0d1953 (patch)
tree9fc88708b64fb0d2d4a2d5647e865922223cb898 /posix/regex_internal.c
parentfee3b889d88193eb3cebaab2bcf60e39ce84d369 (diff)
downloadglibc-c2a150d089fa096cb5f9e342da80fb30dc0d1953.tar.gz
glibc-c2a150d089fa096cb5f9e342da80fb30dc0d1953.tar.xz
glibc-c2a150d089fa096cb5f9e342da80fb30dc0d1953.zip
posix: Sync regex code with gnulib
It sync with gnulib commit 43ee1a6bf.  The main change is 9682f18e9.
(which does not have a meaniful description).

Checked on x86_64-linux-gnu.
Diffstat (limited to 'posix/regex_internal.c')
-rw-r--r--posix/regex_internal.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index 1351c46023..9dd387ef85 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -300,18 +300,20 @@ build_wcs_upper_buffer (re_string_t *pstr)
       while (byte_idx < end_idx)
 	{
 	  wchar_t wc;
+	  unsigned char ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
 
-	  if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
-	      && mbsinit (&pstr->cur_state))
+	  if (isascii (ch) && mbsinit (&pstr->cur_state))
 	    {
-	      /* In case of a singlebyte character.  */
-	      pstr->mbs[byte_idx]
-		= toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
 	      /* The next step uses the assumption that wchar_t is encoded
 		 ASCII-safe: all ASCII values can be converted like this.  */
-	      pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
-	      ++byte_idx;
-	      continue;
+	      wchar_t wcu = __towupper (ch);
+	      if (isascii (wcu))
+		{
+		  pstr->mbs[byte_idx] = wcu;
+		  pstr->wcs[byte_idx] = wcu;
+		  byte_idx++;
+		  continue;
+		}
 	    }
 
 	  remain_len = end_idx - byte_idx;
@@ -348,7 +350,6 @@ build_wcs_upper_buffer (re_string_t *pstr)
 	    {
 	      /* It is an invalid character, an incomplete character
 		 at the end of the string, or '\0'.  Just use the byte.  */
-	      int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
 	      pstr->mbs[byte_idx] = ch;
 	      /* And also cast it to wide char.  */
 	      pstr->wcs[byte_idx++] = (wchar_t) ch;