Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174680276
D18302.id50941.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D18302.id50941.diff
View Options
Index: lib/libc/regex/regcomp.c
===================================================================
--- lib/libc/regex/regcomp.c
+++ lib/libc/regex/regcomp.c
@@ -132,7 +132,7 @@
static void p_b_eclass(struct parse *p, cset *cs);
static wint_t p_b_symbol(struct parse *p);
static wint_t p_b_coll_elem(struct parse *p, wint_t endc);
-static wint_t othercase(wint_t ch);
+static bool hasothercase(wint_t ch);
static void bothcases(struct parse *p, wint_t ch);
static void ordinary(struct parse *p, wint_t ch);
static void nonnewline(struct parse *p);
@@ -1101,19 +1101,34 @@
}
/*
- - othercase - return the case counterpart of an alphabetic
- == static wint_t othercase(wint_t ch);
+ * Check if alphabetic character has bidirectional case mapping.
*/
-static wint_t /* if no counterpart, return ch */
-othercase(wint_t ch)
+static bool
+hasothercase(wint_t ch)
{
+ wint_t other, back;
+
assert(iswalpha(ch));
- if (iswupper(ch))
- return(towlower(ch));
- else if (iswlower(ch))
- return(towupper(ch));
- else /* peculiar, but could happen */
- return(ch);
+
+ /*
+ * It is possible for alphabetic character to not have other case
+ * mapping, or case mapping could be unidirectional. For example,
+ * 0x00B5 (MICRO SIGN) has unidirectional case mapping to
+ * 0x039C (GREEK CAPITAL LETTER MU), which in turn bidirectionally maps
+ * to 0x03BC (GREEK SMALL LETTER MU). Currently we don't have a way to
+ * tie all three together, and treat characters with unidirectional
+ * mappings as not having them.
+ */
+ other = back = ch;
+ if (iswupper(ch)) {
+ other = towlower(ch);
+ back = towupper(other);
+ } else if (iswlower(ch)) {
+ other = towupper(ch);
+ back = towlower(other);
+ }
+
+ return (back == ch);
}
/*
@@ -1131,7 +1146,7 @@
size_t n;
mbstate_t mbs;
- assert(othercase(ch) != ch); /* p_bracket() would recurse */
+ assert(hasothercase(ch)); /* p_bracket() would recurse */
p->next = bracket;
memset(&mbs, 0, sizeof(mbs));
n = wcrtomb(bracket, ch, &mbs);
@@ -1154,7 +1169,7 @@
{
cset *cs;
- if ((p->g->cflags®_ICASE) && iswalpha(ch) && othercase(ch) != ch)
+ if ((p->g->cflags®_ICASE) && iswalpha(ch) && hasothercase(ch))
bothcases(p, ch);
else if ((ch & OPDMASK) == ch)
EMIT(OCHAR, ch);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 6, 3:52 AM (3 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40278415
Default Alt Text
D18302.id50941.diff (2 KB)
Attached To
Mode
D18302: regcomp() recurses infinitely on a case-insensitive pattern containing wide characters in 128-255 range
Attached
Detach File
Event Timeline
Log In to Comment