summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-05-14 23:11:05 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-05-14 23:11:05 +0000
commit7b8d334a971230040a212bc5038097b3f600a094 (patch)
treee0fd6231e06e9b8f7e54aae4cec4ead51585219a /pp.c
parent6ee623d521a149edc6574c512fa951a192cd086a (diff)
downloadperl-7b8d334a971230040a212bc5038097b3f600a094.tar.gz
[win32] merge change#897 from maintbranch
p4raw-link: @897 on //depot/maint-5.004/perl: f06f9b6fc5a686f0169ee2a91b32d5e7125a44ae p4raw-id: //depot/win32/perl@974
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/pp.c b/pp.c
index fafc6066f6..0ebb98b7b6 100644
--- a/pp.c
+++ b/pp.c
@@ -507,8 +507,14 @@ PP(pp_bless)
if (MAXARG == 1)
stash = curcop->cop_stash;
- else
- stash = gv_stashsv(POPs, TRUE);
+ else {
+ SV *ssv = POPs;
+ STRLEN len;
+ char *ptr = SvPV(ssv,len);
+ if (dowarn && len == 0)
+ warn("Explicit blessing to '' (assuming package main)");
+ stash = gv_stashpvn(ptr, len, TRUE);
+ }
(void)sv_bless(TOPs, stash);
RETURN;
@@ -1783,6 +1789,7 @@ PP(pp_substr)
djSP; dTARGET;
SV *sv;
I32 len;
+ I32 len_ok = 0;
STRLEN curlen;
I32 pos;
I32 rem;
@@ -1790,10 +1797,25 @@ PP(pp_substr)
I32 lvalue = op->op_flags & OPf_MOD;
char *tmps;
I32 arybase = curcop->cop_arybase;
+ char *repl = 0;
+ STRLEN repl_len;
SvTAINTED_off(TARG); /* decontaminate */
- if (MAXARG > 2)
+ if (MAXARG > 3) {
+ /* pop off replacement string */
+ sv = POPs;
+ repl = SvPV(sv, repl_len);
+ /* pop off length */
+ sv = POPs;
+ if (SvOK(sv)) {
+ len = SvIV(sv);
+ len_ok++;
+ }
+ } else if (MAXARG == 3) {
len = POPi;
+ len_ok++;
+ }
+
pos = POPi;
sv = POPs;
PUTBACK;
@@ -1802,7 +1824,7 @@ PP(pp_substr)
pos -= arybase;
rem = curlen-pos;
fail = rem;
- if (MAXARG > 2) {
+ if (len_ok) {
if (len < 0) {
rem += len;
if (rem < 0)
@@ -1814,7 +1836,7 @@ PP(pp_substr)
}
else {
pos += curlen;
- if (MAXARG < 3)
+ if (!len_ok)
rem = curlen;
else if (len >= 0) {
rem = pos+len;
@@ -1832,7 +1854,7 @@ PP(pp_substr)
rem -= pos;
}
if (fail < 0) {
- if (dowarn || lvalue)
+ if (dowarn || lvalue || repl)
warn("substr outside of string");
RETPUSHUNDEF;
}
@@ -1862,6 +1884,8 @@ PP(pp_substr)
LvTARGOFF(TARG) = pos;
LvTARGLEN(TARG) = rem;
}
+ else if (repl)
+ sv_insert(sv, pos, rem, repl, repl_len);
}
SPAGAIN;
PUSHs(TARG); /* avoid SvSETMAGIC here */