summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-03-09 21:49:20 +0000
committerNicholas Clark <nick@ccl4.org>2006-03-09 21:49:20 +0000
commit5ef5d7584e52b8ae47b9fe227608cf8da8828e4d (patch)
tree3f146bf3e25b0f0fc114b3959a5f5d17b7722b18 /perl.c
parent89122651e52a79401bfe24208c007cc022c04e0e (diff)
downloadperl-5ef5d7584e52b8ae47b9fe227608cf8da8828e4d.tar.gz
Avoid scribbling on the passed in command line string for -i in
moreswitches. p4raw-id: //depot/perl@27451
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/perl.c b/perl.c
index 3cdca43baa..c152a39689 100644
--- a/perl.c
+++ b/perl.c
@@ -3104,13 +3104,17 @@ Perl_moreswitches(pTHX_ char *s)
return s+1;
}
#endif /* __CYGWIN__ */
- PL_inplace = savepv(s+1);
- for (s = PL_inplace; *s && !isSPACE(*s); s++)
- ;
+ {
+ const char *start = ++s;
+ while (*s && !isSPACE(*s))
+ ++s;
+
+ PL_inplace = savepvn(start, s - start);
+ }
if (*s) {
- *s++ = '\0';
+ ++s;
if (*s == '-') /* Additional switches on #! line. */
- s++;
+ s++;
}
return s;
case 'I': /* -I handled both here and in parse_body() */