about summary refs log tree commit diff
path: root/posix/regex_internal.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2010-01-22 10:17:45 -0800
committerUlrich Drepper <drepper@redhat.com>2010-01-22 10:17:45 -0800
commit4f08104cbf07d87a42c389f2af17f87c445e59d5 (patch)
treeb325641b1cb5a2cd1f7b8eb485c4e81a71b35d78 /posix/regex_internal.c
parent0dae5d4ec1740b511af97c600df1ceea37ada73d (diff)
downloadglibc-4f08104cbf07d87a42c389f2af17f87c445e59d5.tar.gz
glibc-4f08104cbf07d87a42c389f2af17f87c445e59d5.tar.xz
glibc-4f08104cbf07d87a42c389f2af17f87c445e59d5.zip
regex_internal.c: don't assume WEOF fits in wchar_t
Diffstat (limited to 'posix/regex_internal.c')
-rw-r--r--posix/regex_internal.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index 95f2a0e405..976dbfc465 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -489,16 +489,16 @@ re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
   mbstate_t prev_st;
   int rawbuf_idx;
   size_t mbclen;
-  wchar_t wc = WEOF;
+  wint_t wc = WEOF;
 
   /* Skip the characters which are not necessary to check.  */
   for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
        rawbuf_idx < new_raw_idx;)
     {
-      int remain_len;
-      remain_len = pstr->len - rawbuf_idx;
+      wchar_t wc2;
+      int remain_len = pstr->len - rawbuf_idx;
       prev_st = pstr->cur_state;
-      mbclen = __mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx,
+      mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
 			  remain_len, &pstr->cur_state);
       if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
 	{
@@ -510,10 +510,12 @@ re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
 	  mbclen = 1;
 	  pstr->cur_state = prev_st;
 	}
+      else
+	wc = (wint_t) wc2;
       /* Then proceed the next character.  */
       rawbuf_idx += mbclen;
     }
-  *last_wc = (wint_t) wc;
+  *last_wc = wc;
   return rawbuf_idx;
 }
 #endif /* RE_ENABLE_I18N  */