diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-10 19:06:02 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-10 19:06:02 +0000 |
commit | f2095865e3489f4ebbf137f6e644e545a84288ae (patch) | |
tree | 8454567322fdea9a7917c5e5c28e9df4a45e0113 /perl.c | |
parent | 94dd854965f7320316afa0b2c765c34c7d877888 (diff) | |
download | perl-f2095865e3489f4ebbf137f6e644e545a84288ae.tar.gz |
Noted by Nat: -0 didn't work that well with Unicode.
p4raw-id: //depot/perl@19185
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 49 |
1 files changed, 36 insertions, 13 deletions
@@ -2171,19 +2171,42 @@ Perl_moreswitches(pTHX_ char *s) switch (*s) { case '0': { - I32 flags = 0; - numlen = 4; - rschar = (U32)grok_oct(s, &numlen, &flags, NULL); - SvREFCNT_dec(PL_rs); - if (rschar & ~((U8)~0)) - PL_rs = &PL_sv_undef; - else if (!rschar && numlen >= 2) - PL_rs = newSVpvn("", 0); - else { - char ch = (char)rschar; - PL_rs = newSVpvn(&ch, 1); - } - return s + numlen; + I32 flags = 0; + + SvREFCNT_dec(PL_rs); + if (s[1] == 'x' && s[2]) { + char *e; + U8 *tmps; + + for (s += 2, e = s; *e; e++); + numlen = e - s; + flags = PERL_SCAN_SILENT_ILLDIGIT; + rschar = (U32)grok_hex(s, &numlen, &flags, NULL); + if (s + numlen < e) { + rschar = 0; /* Grandfather -0xFOO as -0 -xFOO. */ + numlen = 0; + s--; + } + PL_rs = newSVpvn("", 0); + SvGROW(PL_rs, UNISKIP(rschar) + 1); + tmps = (U8*)SvPVX(PL_rs); + uvchr_to_utf8(tmps, rschar); + SvCUR_set(PL_rs, UNISKIP(rschar)); + SvUTF8_on(PL_rs); + } + else { + numlen = 4; + rschar = (U32)grok_oct(s, &numlen, &flags, NULL); + if (rschar & ~((U8)~0)) + PL_rs = &PL_sv_undef; + else if (!rschar && numlen >= 2) + PL_rs = newSVpvn("", 0); + else { + char ch = (char)rschar; + PL_rs = newSVpvn(&ch, 1); + } + } + return s + numlen; } case 'C': s++; |