summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorColin Kuskie <ckuskie@cadence.com>1998-07-07 02:44:33 -0700
committerGurusamy Sarathy <gsar@cpan.org>1998-07-08 03:58:19 +0000
commit2d259d9294e79c03b1a69d3eaac3d6e5647468d7 (patch)
tree6d9fee2ffac45928e6e7211e6e579e238a84d8e1 /doio.c
parentd426b052dee31c20224ef2893d5c969ad5a2c617 (diff)
downloadperl-2d259d9294e79c03b1a69d3eaac3d6e5647468d7.tar.gz
added patch for -i'foo*bar', made code somewhat simpler, tweaked doc
Message-ID: <Pine.GSO.3.96.980707093457.28681A-100000@pdxue150.cadence.com> Subject: Corrected -i prefix patch p4raw-id: //depot/perl@1368
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/doio.c b/doio.c
index ff8384c331..f74f0ea5f5 100644
--- a/doio.c
+++ b/doio.c
@@ -421,11 +421,19 @@ nextargv(register GV *gv)
continue;
}
if (*inplace) {
-#ifdef SUFFIX
- add_suffix(sv,inplace);
-#else
- sv_catpv(sv,inplace);
-#endif
+ char *star = strchr(inplace, '*');
+ if (star) {
+ char *begin = inplace;
+ sv_setpvn(sv, "", 0);
+ do {
+ sv_catpvn(sv, begin, star - begin);
+ sv_catpvn(sv, oldname, oldlen);
+ begin = ++star;
+ } while ((star = strchr(begin, '*')));
+ }
+ else {
+ sv_catpv(sv,inplace);
+ }
#ifndef FLEXFILENAMES
if (PerlLIO_stat(SvPVX(sv),&statbuf) >= 0
&& statbuf.st_dev == filedev