summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-01-05 12:48:10 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-01-05 12:48:10 +0000
commitfaecd977681fb50ecb4b9174f76ac49d0d9e21c7 (patch)
treee703dff9d6db5314a74b22a49f448c449346fdd5 /doio.c
parent439481750538dbb51d2e41a78ef67e76929da233 (diff)
downloadperl-faecd977681fb50ecb4b9174f76ac49d0d9e21c7.tar.gz
severe bugs in change#3786 fixed
p4raw-link: @3786 on //depot/perl: 6170680bfd1817febf6b13f65734e3e2e6e3f9bf p4raw-id: //depot/perl@4757
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/doio.c b/doio.c
index 4571b2c711..d2385f0e84 100644
--- a/doio.c
+++ b/doio.c
@@ -183,28 +183,29 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
}
}
else {
- char *myname;
- char *type = name;
- char *otype = name;
+ char *type;
+ char *oname = name;
STRLEN tlen;
- STRLEN otlen = len;
+ STRLEN olen = len;
char mode[3]; /* stdio file mode ("r\0" or "r+\0") */
int dodup;
+ type = savepvn(name, len);
+ tlen = len;
+ SAVEFREEPV(type);
if (num_svs) {
- type = name;
- name = SvPV(svs, tlen) ;
- len = (I32)tlen;
+ STRLEN l;
+ name = SvPV(svs, l) ;
+ len = (I32)l;
+ name = savepvn(name, len);
+ SAVEFREEPV(name);
}
-
- tlen = otlen;
- myname = savepvn(name, len);
- SAVEFREEPV(myname);
- name = myname;
- if (!num_svs)
+ else {
while (tlen && isSPACE(type[tlen-1]))
type[--tlen] = '\0';
-
+ name = type;
+ len = tlen;
+ }
mode[0] = mode[1] = mode[2] = '\0';
IoTYPE(io) = *type;
if (*type == '+' && tlen > 1 && type[tlen-1] != '|') { /* scary */
@@ -216,12 +217,14 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
if (*type == '|') {
if (num_svs && (tlen != 2 || type[1] != '-')) {
unknown_desr:
- Perl_croak(aTHX_ "Unknown open() mode '%.*s'", otlen, otype);
+ Perl_croak(aTHX_ "Unknown open() mode '%.*s'", olen, oname);
}
/*SUPPRESS 530*/
- for (type++; isSPACE(*type); type++) ;
- if (!num_svs)
+ for (type++, tlen--; isSPACE(*type); type++, tlen--) ;
+ if (!num_svs) {
name = type;
+ len = tlen;
+ }
if (*name == '\0') { /* command is missing 19990114 */
dTHR;
if (ckWARN(WARN_PIPE))
@@ -232,9 +235,9 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
if (strNE(name,"-") || num_svs)
TAINT_ENV();
TAINT_PROPER("piped open");
- if (name[strlen(name)-1] == '|') {
+ if (name[len-1] == '|') {
dTHR;
- name[strlen(name)-1] = '\0' ;
+ name[--len] = '\0' ;
if (ckWARN(WARN_PIPE))
Perl_warner(aTHX_ WARN_PIPE, "Can't open bidirectional pipe");
}
@@ -308,7 +311,7 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
if (!(fp = PerlIO_fdopen(fd,mode))) {
if (dodup)
PerlLIO_close(fd);
- }
+ }
}
}
else {