[PATCH] First step for tr_TR regex fix
Jakub Jelinek
jakub@redhat.com
Tue Nov 11 17:30:00 GMT 2003
Hi!
I'm posting this mainly for archival purposes, I'm not sure
if it needs to be applied till the problem is solved fully.
This patch just makes fastmap work right for the testcase,
such that check_matching will be called at all in the tr_TR.UTF-8
testcase. What still needs solving what to do when multi-byte
uppercase sequence is longer than multi-byte lowercase sequence
and perhaps other bugs.
2003-11-11 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c (re_compile_fastmap_iter): Handle RE_ICASE
with MB_CUR_MAX > 1 locales in the fastmap.
--- libc/posix/regcomp.c.jj 2003-10-29 00:18:45.000000000 +0100
+++ libc/posix/regcomp.c 2003-11-11 16:04:43.000000000 +0100
@@ -319,7 +319,29 @@ re_compile_fastmap_iter (bufp, init_stat
re_token_type_t type = dfa->nodes[node].type;
if (type == CHARACTER)
- re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
+ {
+ re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
+#ifdef RE_ENABLE_I18N
+ if ((bufp->syntax & RE_ICASE) && !icase)
+ {
+ unsigned char *buf = alloca (MB_CUR_MAX), *p;
+ wchar_t wc;
+ mbstate_t state;
+
+ p = buf;
+ *p++ = dfa->nodes[node].opr.c;
+ while (++node < dfa->nodes_len
+ && dfa->nodes[node].type == CHARACTER
+ && dfa->nodes[node].mb_partial)
+ *p++ = dfa->nodes[node].opr.c;
+ memset (&state, 0, sizeof (state));
+ if (mbrtowc (&wc, (const char *) buf, p - buf,
+ &state) == p - buf
+ && __wcrtomb ((char *) buf, towlower (wc), &state) > 0)
+ re_set_fastmap (fastmap, 0, buf[0]);
+ }
+#endif
+ }
else if (type == SIMPLE_BRACKET)
{
int i, j, ch;
@@ -367,6 +389,11 @@ re_compile_fastmap_iter (bufp, init_stat
memset (&state, '\0', sizeof (state));
__wcrtomb (buf, cset->mbchars[i], &state);
re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
+ if ((bufp->syntax & RE_ICASE) && !icase)
+ {
+ __wcrtomb (buf, towlower (cset->mbchars[i]), &state);
+ re_set_fastmap (fastmap, 0, *(unsigned char *) buf);
+ }
}
}
#endif /* RE_ENABLE_I18N */
Jakub
More information about the Libc-hacker
mailing list