diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-12-10 21:30:10 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-12-10 21:30:10 +0000 |
commit | 3a2263fe90d1c0e6c8f9368f10e6672379a975a2 (patch) | |
tree | f4ecc8075c4fe608fca0d50cea8273adb3179ea8 /pp.c | |
parent | 05b465836ef698192f94eef4a60cd63313013848 (diff) | |
download | perl-3a2263fe90d1c0e6c8f9368f10e6672379a975a2.tar.gz |
Integrate from the maint-5.8/ branch :
changes 18219, 18236, 18242-3, 18247-8,
18253-5, 18257, 18273-6
p4raw-id: //depot/perl@18280
p4raw-branched: from //depot/maint-5.8/perl@18279 'branch in'
t/op/lc_user.t
p4raw-integrated: from //depot/maint-5.8/perl@18279 'copy in'
lib/File/Copy.pm (@17645..) lib/utf8_heavy.pl pod/perlsec.pod
(@18080..) hints/irix_6.sh (@18173..) t/uni/tr_utf8.t
(@18197..) pod/perlunicode.pod (@18242..) t/op/pat.t (@18248..)
t/op/split.t (@18274..) 'edit in' pod/perlguts.pod (@18242..)
'merge in' pp.c (@18126..) MANIFEST (@18234..)
p4raw-integrated: from //depot/maint-5.8/perl@18254 'merge in'
pod/perldiag.pod (@18234..)
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -3324,7 +3324,9 @@ PP(pp_ucfirst) STRLEN slen; SvGETMAGIC(sv); - if (DO_UTF8(sv) && (s = (U8*)SvPV_nomg(sv, slen)) && slen && UTF8_IS_START(*s)) { + if (DO_UTF8(sv) && + (s = (U8*)SvPV_nomg(sv, slen)) && slen && + UTF8_IS_START(*s)) { U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; STRLEN ulen; STRLEN tculen; @@ -3335,8 +3337,16 @@ PP(pp_ucfirst) if (!SvPADTMP(sv) || SvREADONLY(sv)) { dTARGET; + /* slen is the byte length of the whole SV. + * ulen is the byte length of the original Unicode character + * stored as UTF-8 at s. + * tculen is the byte length of the freshly titlecased + * Unicode character stored as UTF-8 at tmpbuf. + * We first set the result to be the titlecased character, + * and then append the rest of the SV data. */ sv_setpvn(TARG, (char*)tmpbuf, tculen); - sv_catpvn(TARG, (char*)(s + ulen), slen - ulen); + if (slen > ulen) + sv_catpvn(TARG, (char*)(s + ulen), slen - ulen); SvUTF8_on(TARG); SETs(TARG); } @@ -3376,7 +3386,9 @@ PP(pp_lcfirst) STRLEN slen; SvGETMAGIC(sv); - if (DO_UTF8(sv) && (s = (U8*)SvPV_nomg(sv, slen)) && slen && UTF8_IS_START(*s)) { + if (DO_UTF8(sv) && + (s = (U8*)SvPV_nomg(sv, slen)) && slen && + UTF8_IS_START(*s)) { STRLEN ulen; U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; U8 *tend; @@ -3389,7 +3401,8 @@ PP(pp_lcfirst) if (!SvPADTMP(sv) || (STRLEN)(tend - tmpbuf) != ulen || SvREADONLY(sv)) { dTARGET; sv_setpvn(TARG, (char*)tmpbuf, tend - tmpbuf); - sv_catpvn(TARG, (char*)(s + ulen), slen - ulen); + if (slen > ulen) + sv_catpvn(TARG, (char*)(s + ulen), slen - ulen); SvUTF8_on(TARG); SETs(TARG); } |