X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=mg.c;h=9dc70300dcd790fc9eb68260962420b6f73a3a34;hb=a3dfe201291c96fc01babd3d4782d52ba945f2a3;hp=d2305311cb03f3f0dd4fa72ab63a01a1ac0a4dc8;hpb=d9aad7f7caf6c1d42b8e71a2a04bfca6447d2827;p=p5sagit%2Fp5-mst-13.2.git diff --git a/mg.c b/mg.c index d230531..9dc7030 100644 --- a/mg.c +++ b/mg.c @@ -1,6 +1,6 @@ /* mg.c * - * Copyright (c) 1991-1999, Larry Wall + * Copyright (c) 1991-2000, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -60,6 +60,14 @@ S_save_magic(pTHX_ I32 mgs_ix, SV *sv) SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; } +/* +=for apidoc mg_magical + +Turns on the magical status of an SV. See C. + +=cut +*/ + void Perl_mg_magical(pTHX_ SV *sv) { @@ -77,6 +85,14 @@ Perl_mg_magical(pTHX_ SV *sv) } } +/* +=for apidoc mg_get + +Do magic after a value is retrieved from the SV. See C. + +=cut +*/ + int Perl_mg_get(pTHX_ SV *sv) { @@ -112,6 +128,14 @@ Perl_mg_get(pTHX_ SV *sv) return 0; } +/* +=for apidoc mg_set + +Do magic after a value is assigned to the SV. See C. + +=cut +*/ + int Perl_mg_set(pTHX_ SV *sv) { @@ -138,6 +162,14 @@ Perl_mg_set(pTHX_ SV *sv) return 0; } +/* +=for apidoc mg_length + +Report on the SV's length. See C. + +=cut +*/ + U32 Perl_mg_length(pTHX_ SV *sv) { @@ -196,6 +228,14 @@ Perl_mg_size(pTHX_ SV *sv) return 0; } +/* +=for apidoc mg_clear + +Clear something magical that the SV represents. See C. + +=cut +*/ + int Perl_mg_clear(pTHX_ SV *sv) { @@ -217,6 +257,14 @@ Perl_mg_clear(pTHX_ SV *sv) return 0; } +/* +=for apidoc mg_find + +Finds the magic pointer for type matching the SV. See C. + +=cut +*/ + MAGIC* Perl_mg_find(pTHX_ SV *sv, int type) { @@ -228,6 +276,14 @@ Perl_mg_find(pTHX_ SV *sv, int type) return 0; } +/* +=for apidoc mg_copy + +Copies the magic from one SV to another. See C. + +=cut +*/ + int Perl_mg_copy(pTHX_ SV *sv, SV *nsv, const char *key, I32 klen) { @@ -244,6 +300,14 @@ Perl_mg_copy(pTHX_ SV *sv, SV *nsv, const char *key, I32 klen) return count; } +/* +=for apidoc mg_free + +Free any magic storage used by the SV. See C. + +=cut +*/ + int Perl_mg_free(pTHX_ SV *sv) { @@ -406,6 +470,9 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) case '\004': /* ^D */ sv_setiv(sv, (IV)(PL_debug & 32767)); +#if defined(YYDEBUG) && defined(DEBUGGING) + PL_yydebug = (PL_debug & 1); +#endif break; case '\005': /* ^E */ #ifdef MACOS_TRADITIONAL @@ -500,10 +567,13 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) sv_setiv(sv, (IV)PL_basetime); #endif break; - case '\027': /* ^W & $^Warnings*/ + case '\025': /* ^U */ + sv_setiv(sv, (IV)PL_bigchar); + break; + case '\027': /* ^W & $^WARNING_BITS */ if (*(mg->mg_ptr+1) == '\0') sv_setiv(sv, (IV)((PL_dowarn & G_WARN_ON) ? TRUE : FALSE)); - else if (strEQ(mg->mg_ptr, "\027arnings")) { + else if (strEQ(mg->mg_ptr, "\027ARNING_BITS")) { if (PL_compiling.cop_warnings == WARN_NONE || PL_compiling.cop_warnings == WARN_STD) { @@ -542,6 +612,10 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) PL_tainted = FALSE; } sv_setpvn(sv, s, i); + if ((PL_curpm->op_pmdynflags & PMdf_UTF8) && !IN_BYTE) + SvUTF8_on(sv); + else + SvUTF8_off(sv); if (PL_tainting) PL_tainted = (was_tainted || RX_MATCH_TAINTED(rx)); break; @@ -842,10 +916,10 @@ Perl_magic_clear_all_env(pTHX_ SV *sv, MAGIC *mg) } FreeEnvironmentStrings(envv); # else -# ifdef CYGWIN +# ifdef __CYGWIN__ I32 i; for (i = 0; environ[i]; i++) - Safefree(environ[i]); + safesysfree(environ[i]); # else # ifndef PERL_USE_SAFE_PUTENV I32 i; @@ -856,7 +930,7 @@ Perl_magic_clear_all_env(pTHX_ SV *sv, MAGIC *mg) for (i = 0; environ[i]; i++) safesysfree(environ[i]); # endif /* PERL_USE_SAFE_PUTENV */ -# endif /* CYGWIN */ +# endif /* __CYGWIN__ */ environ[0] = Nullch; @@ -1219,7 +1293,7 @@ Perl_magic_getpos(pTHX_ SV *sv, MAGIC *mg) if (mg && mg->mg_len >= 0) { dTHR; I32 i = mg->mg_len; - if (IN_UTF8) + if (DO_UTF8(lsv)) sv_pos_b2u(lsv, &i); sv_setiv(sv, i + PL_curcop->cop_arybase); return 0; @@ -1235,7 +1309,7 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) SV* lsv = LvTARG(sv); SSize_t pos; STRLEN len; - STRLEN ulen; + STRLEN ulen = 0; dTHR; mg = 0; @@ -1256,12 +1330,10 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) pos = SvIV(sv) - PL_curcop->cop_arybase; - if (IN_UTF8) { + if (DO_UTF8(lsv)) { ulen = sv_len_utf8(lsv); if (ulen) len = ulen; - else - ulen = 0; } if (pos < 0) { @@ -1638,7 +1710,10 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) PL_basetime = (Time_t)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)); #endif break; - case '\027': /* ^W & $^Warnings */ + case '\025': /* ^U */ + PL_bigchar = SvTRUE(sv); + break; + case '\027': /* ^W & $^WARNING_BITS */ if (*(mg->mg_ptr+1) == '\0') { if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { i = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv); @@ -1646,7 +1721,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) | (i ? G_WARN_ON : G_WARN_OFF) ; } } - else if (strEQ(mg->mg_ptr, "\027arnings")) { + else if (strEQ(mg->mg_ptr, "\027ARNING_BITS")) { if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { if (memEQ(SvPVX(sv), WARN_ALLstring, WARNsize)) { PL_compiling.cop_warnings = WARN_ALL;