Change 12601 by jhi@alpha on 2001/10/23 12:26:12
Fix multicharacter titlecase (ucfirst).
Affected files ...
... //depot/perl/pod/perlunicode.pod#41 edit
... //depot/perl/pp.c#307 edit
... //depot/perl/t/op/lc.t#3 edit
Differences ...
==== //depot/perl/pod/perlunicode.pod#41 (text) ====
Index: perl/pod/perlunicode.pod
--- perl/pod/perlunicode.pod.~1~ Tue Oct 23 06:30:05 2001
+++ perl/pod/perlunicode.pod Tue Oct 23 06:30:05 2001
@@ -505,10 +505,11 @@
=item *
Case translation operators use the Unicode case translation tables
-when provided character input. Note that C<uc()> translates to
-uppercase, while C<ucfirst> translates to titlecase (for languages
-that make the distinction). Naturally the corresponding backslash
-sequences have the same semantics.
+when provided character input. Note that C<uc()> (also known as C<\U>
+in doublequoted strings) translates to uppercase, while C<ucfirst>
+(also known as C<\u> in doublequoted strings) translates to titlecase
+(for languages that make the distinction). Naturally the
+corresponding backslash sequences have the same semantics.
=item *
==== //depot/perl/pp.c#307 (text) ====
Index: perl/pp.c
--- perl/pp.c.~1~ Tue Oct 23 06:30:05 2001
+++ perl/pp.c Tue Oct 23 06:30:05 2001
@@ -3149,27 +3149,27 @@
register U8 *s;
STRLEN slen;
- if (DO_UTF8(sv) && (s = (U8*)SvPV(sv, slen)) && slen && UTF8_IS_START(*s)) {
+ if (DO_UTF8(sv)) {
+ U8 tmpbuf[UTF8_MAXLEN*2+1];
STRLEN ulen;
- U8 tmpbuf[UTF8_MAXLEN*2+1];
- U8 *tend;
- UV uv;
+ STRLEN tculen;
+
+ s = (U8*)SvPV(sv, slen);
+ utf8_to_uvchr(s, &ulen);
- toTITLE_utf8(s, tmpbuf, &ulen); /* XXX --jhi */
- uv = utf8_to_uvchr(tmpbuf, 0);
-
- tend = uvchr_to_utf8(tmpbuf, uv);
+ toTITLE_utf8(s, tmpbuf, &tculen);
+ utf8_to_uvchr(tmpbuf, 0);
- if (!SvPADTMP(sv) || tend - tmpbuf != ulen || SvREADONLY(sv)) {
+ if (!SvPADTMP(sv) || SvREADONLY(sv)) {
dTARGET;
- sv_setpvn(TARG, (char*)tmpbuf, tend - tmpbuf);
+ sv_setpvn(TARG, (char*)tmpbuf, tculen);
sv_catpvn(TARG, (char*)(s + ulen), slen - ulen);
SvUTF8_on(TARG);
SETs(TARG);
}
else {
s = (U8*)SvPV_force(sv, slen);
- Copy(tmpbuf, s, ulen, U8);
+ Copy(tmpbuf, s, tculen, U8);
}
}
else {
@@ -3209,7 +3209,7 @@
U8 *tend;
UV uv;
- toLOWER_utf8(s, tmpbuf, &ulen); /* XXX --jhi */
+ toLOWER_utf8(s, tmpbuf, &ulen);
uv = utf8_to_uvchr(tmpbuf, 0);
tend = uvchr_to_utf8(tmpbuf, uv);
@@ -3277,7 +3277,7 @@
d = (U8*)SvPVX(TARG);
send = s + len;
while (s < send) {
- toUPPER_utf8(s, tmpbuf, &ulen); /* XXX --jhi */
+ toUPPER_utf8(s, tmpbuf, &ulen);
Copy(tmpbuf, d, ulen, U8);
d += ulen;
s += UTF8SKIP(s);
@@ -3344,7 +3344,7 @@
d = (U8*)SvPVX(TARG);
send = s + len;
while (s < send) {
- toLOWER_utf8(s, tmpbuf, &ulen); /* XXX --jhi */
+ toLOWER_utf8(s, tmpbuf, &ulen);
Copy(tmpbuf, d, ulen, U8);
d += ulen;
s += UTF8SKIP(s);
==== //depot/perl/t/op/lc.t#3 (text) ====
Index: perl/t/op/lc.t
--- perl/t/op/lc.t.~1~ Tue Oct 23 06:30:05 2001
+++ perl/t/op/lc.t Tue Oct 23 06:30:05 2001
@@ -91,3 +91,18 @@
ok("\L\x{DF}AB\x{149}CD" eq "\x{DF}ab\x{149}cd",
"multicharacter lowercase");
+# titlecase is used for \u / ucfirst.
+
+# \x{587} is ARMENIAN SMALL LIGATURE ECH YIWN and its titlecase is
+# \x{535}\x{582} ARMENIAN CAPITAL LETTER ECH + ARMENIAN SMALL LETTER YIWN
+# while its lowercase is
+# \x{587} itself
+# and its uppercase is
+# \x{535}\x{552} ARMENIAN CAPITAL LETTER ECH + ARMENIAN CAPITAL LETTER YIWN
+
+$a = "\x{587}";
+
+ok("\L\x{587}" eq "\x{587}", "ligature lowercase");
+ok("\u\x{587}" eq "\x{535}\x{582}", "ligature titlecase");
+ok("\U\x{587}" eq "\x{535}\x{552}", "ligature uppercase");
+
End of Patch.