summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2014-03-02 09:50:38 +0100
committerNicholas Clark <nick@ccl4.org>2014-03-19 10:57:53 +0100
commitd5eb9a4687ba974ffd0d02aab53326c5aba6a9e0 (patch)
treeac42edbd4daada8d4b122daa07c4700ad8169abd
parent4b451737e0f77cc9e91b1336d04f21659d96b732 (diff)
downloadperl-d5eb9a4687ba974ffd0d02aab53326c5aba6a9e0.tar.gz
Change core uses of Perl_do_openn() to Perl_do_open6() or Perl_do_open_raw().
Calls to Perl_do_openn() all have at least 2 unused arguments which clutter the code and hinder easy understanding. Perl_do_open6() and Perl_do_open_raw() each only do one job, so don't have the dead arguments.
-rw-r--r--doio.c21
-rw-r--r--os2/os2.c2
-rw-r--r--pp_hot.c2
-rw-r--r--pp_sys.c7
4 files changed, 17 insertions, 15 deletions
diff --git a/doio.c b/doio.c
index 2a58da339a..1629227853 100644
--- a/doio.c
+++ b/doio.c
@@ -827,13 +827,16 @@ Perl_nextargv(pTHX_ GV *gv)
return NULL;
while (av_tindex(GvAV(gv)) >= 0) {
STRLEN oldlen;
+ bool success;
sv = av_shift(GvAV(gv));
SAVEFREESV(sv);
SvTAINTED_off(GvSVn(gv)); /* previous tainting irrelevant */
sv_setsv(GvSVn(gv),sv);
SvSETMAGIC(GvSV(gv));
PL_oldname = SvPVx(GvSV(gv), oldlen);
- if (do_open(gv,PL_oldname,oldlen,PL_inplace!=0,O_RDONLY,0,NULL)) {
+ success = PL_inplace ? do_open_raw(gv, PL_oldname, oldlen, O_RDONLY, 0)
+ : do_open6(gv, PL_oldname, oldlen, NULL, NULL, 0);
+ if (success) {
if (PL_inplace) {
TAINT_PROPER("inplace open");
if (oldlen == 1 && *PL_oldname == '-') {
@@ -900,7 +903,7 @@ Perl_nextargv(pTHX_ GV *gv)
do_close(gv,FALSE);
(void)PerlLIO_unlink(SvPVX_const(sv));
(void)PerlLIO_rename(PL_oldname,SvPVX_const(sv));
- do_open(gv,(char*)SvPVX_const(sv),SvCUR(sv),TRUE,O_RDONLY,0,NULL);
+ do_open_raw(gv, SvPVX_const(sv), SvCUR(sv), O_RDONLY, 0);
#endif /* DOSISH */
#else
(void)UNLINK(SvPVX_const(sv));
@@ -932,14 +935,14 @@ Perl_nextargv(pTHX_ GV *gv)
sv_setpvn(sv,PL_oldname,oldlen);
SETERRNO(0,0); /* in case sprintf set errno */
- if (!Perl_do_openn(aTHX_ PL_argvoutgv, (char*)SvPVX_const(sv),
- SvCUR(sv), TRUE,
+ if (!Perl_do_open_raw(aTHX_ PL_argvoutgv, SvPVX_const(sv),
+ SvCUR(sv),
#ifdef VMS
- O_WRONLY|O_CREAT|O_TRUNC,0,
+ O_WRONLY|O_CREAT|O_TRUNC, 0
#else
- O_WRONLY|O_CREAT|OPEN_EXCL,0600,
+ O_WRONLY|O_CREAT|OPEN_EXCL, 0600
#endif
- NULL, NULL, 0)) {
+ )) {
Perl_ck_warner_d(aTHX_ packWARN(WARN_INPLACE), "Can't do inplace edit on %s: %s",
PL_oldname, Strerror(errno) );
do_close(gv,FALSE);
@@ -2515,8 +2518,8 @@ Perl_vms_start_glob
if (home && *home) SvSETMAGIC(*home);
if (path && *path) SvSETMAGIC(*path);
}
- (void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd),
- FALSE, O_RDONLY, 0, NULL);
+ (void)do_open6(PL_last_in_gv, SvPVX_const(tmpcmd), SvCUR(tmpcmd),
+ NULL, NULL, 0);
fp = IoIFP(io);
#endif /* !VMS */
LEAVE;
diff --git a/os2/os2.c b/os2/os2.c
index d4e9c90aa7..4ae39e7f2d 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -4257,7 +4257,7 @@ XS(XS_OS2_pipe)
ST(0) = sv_newmortal();
{
GV *gv = newGVgen("OS2::pipe");
- if ( do_open(gv, perltype, strlen(perltype), FALSE, 0, 0, perlio) )
+ if ( do_open6(gv, perltype, strlen(perltype), perlio, NULL, 0) )
sv_setsv(ST(0), sv_bless(newRV((SV*)gv), gv_stashpv("IO::Handle",1)));
else
ST(0) = &PL_sv_undef;
diff --git a/pp_hot.c b/pp_hot.c
index 3a19f527fe..c3637cd381 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1562,7 +1562,7 @@ Perl_do_readline(pTHX)
IoLINES(io) = 0;
if (av_tindex(GvAVn(PL_last_in_gv)) < 0) {
IoFLAGS(io) &= ~IOf_START;
- do_open(PL_last_in_gv,"-",1,FALSE,O_RDONLY,0,NULL);
+ do_open6(PL_last_in_gv, "-", 1, NULL, NULL, 0);
SvTAINTED_off(GvSVn(PL_last_in_gv)); /* previous tainting irrelevant */
sv_setpvs(GvSVn(PL_last_in_gv), "-");
SvSETMAGIC(GvSV(PL_last_in_gv));
diff --git a/pp_sys.c b/pp_sys.c
index 01e397a0c1..9f971773f4 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -638,7 +638,7 @@ PP(pp_open)
}
tmps = SvPV_const(sv, len);
- ok = do_openn(gv, tmps, len, FALSE, O_RDONLY, 0, NULL, MARK+1, (SP-MARK));
+ ok = do_open6(gv, tmps, len, NULL, MARK+1, (SP-MARK));
SP = ORIGMARK;
if (ok)
PUSHi( (I32)PL_forkprocess );
@@ -1598,8 +1598,7 @@ PP(pp_sysopen)
/* Need TIEHANDLE method ? */
const char * const tmps = SvPV_const(sv, len);
- /* FIXME? do_open should do const */
- if (do_open(gv, tmps, len, TRUE, mode, perm, NULL)) {
+ if (do_open_raw(gv, tmps, len, mode, perm)) {
IoLINES(GvIOp(gv)) = 0;
PUSHs(&PL_sv_yes);
}
@@ -2088,7 +2087,7 @@ PP(pp_eof)
if ((IoFLAGS(io) & IOf_START) && av_tindex(GvAVn(gv)) < 0) {
IoLINES(io) = 0;
IoFLAGS(io) &= ~IOf_START;
- do_open(gv, "-", 1, FALSE, O_RDONLY, 0, NULL);
+ do_open6(gv, "-", 1, NULL, NULL, 0);
if (GvSV(gv))
sv_setpvs(GvSV(gv), "-");
else