diff options
author | Paul Marquess <paul.marquess@btinternet.com> | 1998-07-29 10:28:45 +0100 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-08-09 11:31:53 +0000 |
commit | 599cee73f2261c5e09cde7ceba3f9a896989e117 (patch) | |
tree | ca10c96d845fe755d35da930b1935926856e99b9 /mg.c | |
parent | 33938b7370f825af073cea6d9fadf7e82857ec9c (diff) | |
download | perl-599cee73f2261c5e09cde7ceba3f9a896989e117.tar.gz |
lexical warnings; tweaks to places that didn't apply correctly
Message-Id: <9807290828.AA26286@claudius.bfsec.bt.co.uk>
Subject: lexical warnings patch for 5.005_50
p4raw-id: //depot/perl@1773
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 70 |
1 files changed, 64 insertions, 6 deletions
@@ -346,6 +346,34 @@ magic_len(SV *sv, MAGIC *mg) return 0; } +#if 0 +static char * +printW(sv) +SV * sv ; +{ +#if 1 + return "" ; + +#else + int i ; + static char buffer[50] ; + char buf1[20] ; + char * p ; + + + sprintf(buffer, "Buffer %d, Length = %d - ", sv, SvCUR(sv)) ; + p = SvPVX(sv) ; + for (i = 0; i < SvCUR(sv) ; ++ i) { + sprintf (buf1, " %x [%x]", (p+i), *(p+i)) ; + strcat(buffer, buf1) ; + } + + return buffer ; + +#endif +} +#endif + int magic_get(SV *sv, MAGIC *mg) { @@ -360,6 +388,18 @@ magic_get(SV *sv, MAGIC *mg) case '\001': /* ^A */ sv_setsv(sv, PL_bodytarget); break; + case '\002': /* ^B */ + /* printf("magic_get $^B: ") ; */ + if (curcop->cop_warnings == WARN_NONE) + /* printf("WARN_NONE\n"), */ + sv_setpvn(sv, WARN_NONEstring, WARNsize) ; + else if (curcop->cop_warnings == WARN_ALL) + /* printf("WARN_ALL\n"), */ + sv_setpvn(sv, WARN_ALLstring, WARNsize) ; + else + /* printf("some %s\n", printW(curcop->cop_warnings)), */ + sv_setsv(sv, curcop->cop_warnings); + break; case '\004': /* ^D */ sv_setiv(sv, (IV)(PL_debug & 32767)); break; @@ -453,7 +493,7 @@ magic_get(SV *sv, MAGIC *mg) #endif break; case '\027': /* ^W */ - sv_setiv(sv, (IV)PL_dowarn); + sv_setiv(sv, (IV)((PL_dowarn & G_WARN_ON) == G_WARN_ON)); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '&': @@ -847,8 +887,8 @@ magic_setsig(SV *sv, MAGIC *mg) else { i = whichsig(s); /* ...no, a brick */ if (!i) { - if (PL_dowarn || strEQ(s,"ALARM")) - warn("No such signal: SIG%s", s); + if (ckWARN(WARN_SIGNAL) || strEQ(s,"ALARM")) + warner(WARN_SIGNAL, "No such signal: SIG%s", s); return 0; } SvREFCNT_dec(psig_name[i]); @@ -1519,6 +1559,21 @@ magic_set(SV *sv, MAGIC *mg) case '\001': /* ^A */ sv_setsv(PL_bodytarget, sv); break; + case '\002': /* ^B */ + if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { + if (memEQ(SvPVX(sv), WARN_ALLstring, WARNsize)) + compiling.cop_warnings = WARN_ALL; + else if (memEQ(SvPVX(sv), WARN_NONEstring, WARNsize)) + compiling.cop_warnings = WARN_NONE; + else { + if (compiling.cop_warnings != WARN_NONE && + compiling.cop_warnings != WARN_ALL) + sv_setsv(compiling.cop_warnings, sv); + else + compiling.cop_warnings = newSVsv(sv) ; + } + } + break; case '\004': /* ^D */ PL_debug = (SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) | 0x80000000; DEBUG_x(dump_all()); @@ -1568,7 +1623,10 @@ magic_set(SV *sv, MAGIC *mg) #endif break; case '\027': /* ^W */ - PL_dowarn = (bool)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)); + if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { + i = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv); + PL_dowarn = (i ? G_WARN_ON : G_WARN_OFF) ; + } break; case '.': if (PL_localizing) { @@ -1958,8 +2016,8 @@ sighandler(int sig) cv = sv_2cv(psig_ptr[sig],&st,&gv,TRUE); if (!cv || !CvROOT(cv)) { - if (PL_dowarn) - warn("SIG%s handler \"%s\" not defined.\n", + if (ckWARN(WARN_SIGNAL)) + warner(WARN_SIGNAL, "SIG%s handler \"%s\" not defined.\n", sig_name[sig], (gv ? GvENAME(gv) : ((cv && CvGV(cv)) ? GvENAME(CvGV(cv)) |