case KEY_push:
case KEY_setpgrp: case KEY_shift:
case KEY_splice:
- case KEY_stat: case KEY_substr:
+ case KEY_stat:
case KEY_sysopen:
case KEY_system:
case KEY_tell: case KEY_tie: case KEY_tied:
new ATTRSUB. */
(void)core_prototype((SV *)cv, name, code, &opnum);
if (ampable) {
- if (opnum == OP_VEC || opnum == OP_LOCK) CvLVALUE_on(cv);
+ if (opnum == OP_VEC || opnum == OP_LOCK
+ || opnum == OP_SUBSTR)
+ CvLVALUE_on(cv);
newATTRSUB(oldsavestack_ix,
newSVOP(
OP_CONST, 0,
argop->op_private |= OPpCOREARGS_DEREF2;
if (scalar_mod_type(NULL, opnum))
argop->op_private |= OPpCOREARGS_SCALARMOD;
- goto onearg;
+ if (opnum == OP_SUBSTR) {
+ o->op_private |= OPpMAYBE_LVSUB;
+ return o;
+ }
+ else goto onearg;
}
}
}
SV *repl_sv = NULL;
const char *repl = NULL;
STRLEN repl_len;
- const int num_args = PL_op->op_private & 7;
+ int num_args = PL_op->op_private & 7;
bool repl_need_utf8_upgrade = FALSE;
bool repl_is_utf8 = FALSE;
if (num_args > 2) {
if (num_args > 3) {
- repl_sv = POPs;
+ if((repl_sv = POPs)) {
repl = SvPV_const(repl_sv, repl_len);
repl_is_utf8 = DO_UTF8(repl_sv) && SvCUR(repl_sv);
+ }
+ else num_args--;
+ }
+ if ((len_sv = POPs)) {
+ len_iv = SvIV(len_sv);
+ len_is_uv = SvIOK_UV(len_sv);
}
- len_sv = POPs;
- len_iv = SvIV(len_sv);
- len_is_uv = SvIOK_UV(len_sv);
+ else num_args--;
}
pos_sv = POPs;
pos1_iv = SvIV(pos_sv);
&CORE::srand;
pass '&srand with no args does not crash';
+test_proto 'substr';
+$tests += 5;
+$_ = "abc";
+is &mysubstr($_, 1, 1, "d"), 'b', '4-arg &substr';
+is $_, 'adc', 'what 4-arg &substr does';
+is &mysubstr("abc", 1, 1), 'b', '3-arg &substr';
+is &mysubstr("abc", 1), 'bc', '2-arg &substr';
+&mysubstr($_, 1) = 'long';
+is $_, 'along', 'lvalue &substr';
+
test_proto 'symlink';
test_proto 'syscall';
test_proto 'sysread';