X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=mg.c;h=2e528ba53854aa1310b74edd39cb32c5728c4861;hb=e9c1fd70a0c901791f5a7169cb6bf808e7e42d7a;hp=8e0f7cbbdcc6415e4233923d777756e7a50b0494;hpb=685f876f92b24f3af803e9cf12142657dfafec2f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/mg.c b/mg.c index 8e0f7cb..2e528ba 100644 --- a/mg.c +++ b/mg.c @@ -169,7 +169,6 @@ U32 Perl_mg_length(pTHX_ SV *sv) { MAGIC* mg; - char *junk; STRLEN len; for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { @@ -186,7 +185,13 @@ Perl_mg_length(pTHX_ SV *sv) } } - junk = SvPV(sv, len); + if (DO_UTF8(sv)) + { + U8 *s = (U8*)SvPV(sv, len); + len = Perl_utf8_length(aTHX_ s, s + len); + } + else + (void)SvPV(sv, len); return len; } @@ -435,6 +440,13 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) goto getparen; } return 0; + case '\016': /* ^N */ + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { + paren = rx->lastcloseparen; + if (paren) + goto getparen; + } + return 0; case '`': if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if (rx->startp[0] != -1) { @@ -660,6 +672,14 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) } sv_setsv(sv,&PL_sv_undef); break; + case '\016': /* ^N */ + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { + paren = rx->lastcloseparen; + if (paren) + goto getparen; + } + sv_setsv(sv,&PL_sv_undef); + break; case '`': if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if ((s = rx->subbeg) && rx->startp[0] != -1) { @@ -1133,19 +1153,16 @@ int Perl_magic_getnkeys(pTHX_ SV *sv, MAGIC *mg) { HV *hv = (HV*)LvTARG(sv); - HE *entry; I32 i = 0; - + if (hv) { - (void) hv_iterinit(hv); - if (! SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) - i = HvKEYS(hv); - else { - /*SUPPRESS 560*/ - while ((entry = hv_iternext(hv))) { - i++; - } - } + (void) hv_iterinit(hv); + if (! SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) + i = HvKEYS(hv); + else { + while (hv_iternext(hv)) + i++; + } } sv_setiv(sv, (IV)i); @@ -1734,7 +1751,9 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) # ifdef WIN32 SetLastError( SvIV(sv) ); # else -# ifndef OS2 +# ifdef OS2 + os2_setsyserrno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)); +# else /* will anyone ever use this? */ SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv), 4); # endif @@ -2071,12 +2090,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) * the setproctitle() routine to manipulate that. */ { s = SvPV(sv, len); -# if __FreeBSD_version >= 410001 +# if __FreeBSD_version > 410001 /* The leading "-" removes the "perl: " prefix, * but not the "(perl) suffix from the ps(1) * output, because that's what ps(1) shows if the * argv[] is modified. */ - setproctitle("-%s", s, len + 1); + setproctitle("-%s", s); # else /* old FreeBSDs, NetBSD, OpenBSD, anyBSD */ /* This doesn't really work if you assume that * $0 = 'foobar'; will wipe out 'perl' from the $0 @@ -2107,11 +2126,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) break; } /* can grab env area too? */ - if (PL_origenviron && (PL_origenviron[0] == s + 1 -#ifdef OS2 - || (PL_origenviron[0] == s + 9 && (s += 8)) -#endif - )) { + if (PL_origenviron && (PL_origenviron[0] == s + 1)) { my_setenv("NoNe SuCh", Nullch); /* force copy of environment */ for (i = 0; PL_origenviron[i]; i++) @@ -2161,7 +2176,7 @@ Perl_magic_mutexfree(pTHX_ SV *sv, MAGIC *mg) { DEBUG_S(PerlIO_printf(Perl_debug_log, "0x%"UVxf": magic_mutexfree 0x%"UVxf"\n", - PTR2UV(thr), PTR2UV(sv));) + PTR2UV(thr), PTR2UV(sv))); if (MgOWNER(mg)) Perl_croak(aTHX_ "panic: magic_mutexfree"); MUTEX_DESTROY(MgMUTEXP(mg)); @@ -2206,7 +2221,6 @@ Perl_sighandler(int sig) CV *cv = Nullcv; OP *myop = PL_op; U32 flags = 0; - I32 o_save_i = PL_savestack_ix; XPV *tXpv = PL_Xpv; #if defined(WIN32) && defined(PERL_IMPLICIT_CONTEXT) @@ -2230,7 +2244,6 @@ Perl_sighandler(int sig) infinity, so we fix 4 (in fact 5): */ if (flags & 1) { PL_savestack_ix += 5; /* Protect save in progress. */ - o_save_i = PL_savestack_ix; SAVEDESTRUCTOR_X(unwind_handler_stack, (void*)&flags); } if (flags & 4)