summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2014-03-01 21:32:19 +0100
committerNicholas Clark <nick@ccl4.org>2014-03-19 10:57:52 +0100
commit9229bf8d9dfb18c8cb2feba39b2482f9fd83cf11 (patch)
tree2c0b934d3de2400c48a7a10fefdb4ad4962c5278 /doio.c
parent7c491510e1dbbc37aae15850c893746a82211cf5 (diff)
downloadperl-9229bf8d9dfb18c8cb2feba39b2482f9fd83cf11.tar.gz
Perl_do_openn() doesn't need to set num_svs and svp.
These variables are no longer used later in the function, so no need to set them. This permits the declaration of the variable namesv to be moved from the top of the function into the blocks that use it.
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/doio.c b/doio.c
index a02346264f..af8b72e780 100644
--- a/doio.c
+++ b/doio.c
@@ -78,7 +78,6 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw,
bool was_fdopen = FALSE;
char *type = NULL;
char mode[PERL_MODE_MAX]; /* file mode ("r\0", "rb\0", "ab\0" etc.) */
- SV *namesv;
PERL_ARGS_ASSERT_DO_OPENN;
@@ -136,6 +135,7 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw,
;
const int modifyingmode = O_WRONLY|O_RDWR|O_CREAT|appendtrunc;
int ismodifying;
+ SV *namesv;
if (num_svs != 0) {
Perl_croak(aTHX_ "panic: sysopen with multiple args, num_svs=%ld",
@@ -172,10 +172,8 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw,
IoTYPE(io) = PerlIO_intmode2str(rawmode, &mode[ix], &writing);
namesv = newSVpvn_flags(oname, len, SVs_TEMP);
- num_svs = 1;
- svp = &namesv;
type = NULL;
- fp = PerlIO_openn(aTHX_ type, mode, -1, rawmode, rawperm, NULL, num_svs, svp);
+ fp = PerlIO_openn(aTHX_ type, mode, -1, rawmode, rawperm, NULL, 1, &namesv);
}
else {
/* Regular (non-sys) open */
@@ -410,13 +408,14 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw,
}
}
else {
- if (!num_svs) {
- namesv = newSVpvn_flags(type, tend - type, SVs_TEMP);
- num_svs = 1;
- svp = &namesv;
+ if (num_svs) {
+ fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp);
+ }
+ else {
+ SV *namesv = newSVpvn_flags(type, tend - type, SVs_TEMP);
type = NULL;
+ fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,1,&namesv);
}
- fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp);
}
} /* !& */
if (!fp && type && *type && *type != ':' && !isIDFIRST(*type))
@@ -444,13 +443,14 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw,
}
}
else {
- if (!num_svs) {
- namesv = newSVpvn_flags(type, tend - type, SVs_TEMP);
- num_svs = 1;
- svp = &namesv;
+ if (num_svs) {
+ fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp);
+ }
+ else {
+ SV *namesv = newSVpvn_flags(type, tend - type, SVs_TEMP);
type = NULL;
+ fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,1,&namesv);
}
- fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp);
}
if (!fp && type && *type && *type != ':' && !isIDFIRST(*type))
goto unknown_open_mode;
@@ -523,13 +523,14 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw,
IoTYPE(io) = IoTYPE_STD;
}
else {
- if (!num_svs) {
- namesv = newSVpvn_flags(type, tend - type, SVs_TEMP);
- num_svs = 1;
- svp = &namesv;
+ if (num_svs) {
+ fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp);
+ }
+ else {
+ SV *namesv = newSVpvn_flags(type, tend - type, SVs_TEMP);
type = NULL;
+ fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,1,&namesv);
}
- fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp);
}
}
}