mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
tr: fix class handling in unicode world
toupper/tolower logic was only handled for CCLASS_TOUPPER and CCLASS_TOLOWER, add support for CCLASS ([:alpha:]) PR: 219900 MFC After: 1 week (cherry picked from commit625dc44832) (cherry picked from commit45d84c2f06)
This commit is contained in:
1 parent
28b5b653a5
commit
65338ff41f
1 file changed
+34
@@ -253,6 +253,40 @@ main(int argc, char **argv)
|
||||
break;
|
||||
} while (s2.state == CCLASS_LOWER && s2.cnt > 1);
|
||||
goto again;
|
||||
} else if (s1.state == CCLASS &&
|
||||
s2.state == CCLASS_UPPER &&
|
||||
s1.cnt == 1 && s2.cnt == 1) {
|
||||
do {
|
||||
ch = towupper(s1.lastch);
|
||||
cmap_add(map, s1.lastch, ch);
|
||||
if (sflag && iswupper(ch))
|
||||
cset_add(squeeze, ch);
|
||||
if (!next(&s1))
|
||||
goto endloop;
|
||||
} while (s1.state == CCLASS && s1.cnt > 1);
|
||||
/* skip upper set */
|
||||
do {
|
||||
if (!next(&s2))
|
||||
break;
|
||||
} while (s2.state == CCLASS_UPPER && s2.cnt > 1);
|
||||
goto again;
|
||||
} else if (s1.state == CCLASS &&
|
||||
s2.state == CCLASS_LOWER &&
|
||||
s1.cnt == 1 && s2.cnt == 1) {
|
||||
do {
|
||||
ch = towlower(s1.lastch);
|
||||
cmap_add(map, s1.lastch, ch);
|
||||
if (sflag && iswlower(ch))
|
||||
cset_add(squeeze, ch);
|
||||
if (!next(&s1))
|
||||
goto endloop;
|
||||
} while (s1.state == CCLASS && s1.cnt > 1);
|
||||
/* skip lower set */
|
||||
do {
|
||||
if (!next(&s2))
|
||||
break;
|
||||
} while (s2.state == CCLASS_LOWER && s2.cnt > 1);
|
||||
goto again;
|
||||
} else {
|
||||
cmap_add(map, s1.lastch, s2.lastch);
|
||||
if (sflag)
|
||||
|
||||
Reference in new issue
Block a user