X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=doio.c;h=7ed4e975a511fe38a838aad8ff7877e28069f345;hb=33b5f13c2468a991d2b495f02a62b59163be82af;hp=380e3c7150645d1a13cef2f917c4499df2a7ca78;hpb=561b68a973f8a5d10c61d6a02c02f3002a0a63ba;p=p5sagit%2Fp5-mst-13.2.git diff --git a/doio.c b/doio.c index 380e3c7..7ed4e97 100644 --- a/doio.c +++ b/doio.c @@ -65,8 +65,8 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, { dVAR; register IO * const io = GvIOn(gv); - PerlIO *saveifp = Nullfp; - PerlIO *saveofp = Nullfp; + PerlIO *saveifp = NULL; + PerlIO *saveofp = NULL; int savefd = -1; char savetype = IoTYPE_CLOSED; int writing = 0; @@ -125,7 +125,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, "Warning: unable to close filehandle %s properly.\n", GvENAME(gv)); } - IoOFP(io) = IoIFP(io) = Nullfp; + IoOFP(io) = IoIFP(io) = NULL; } if (as_raw) { @@ -179,7 +179,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, namesv = sv_2mortal(newSVpv(oname,0)); num_svs = 1; svp = &namesv; - type = Nullch; + type = NULL; fp = PerlIO_openn(aTHX_ type, mode, -1, rawmode, rawperm, NULL, num_svs, svp); } else { @@ -336,7 +336,8 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, } else { GV *thatgv; - thatgv = gv_fetchpv(type,0,SVt_PVIO); + thatgv = gv_fetchpvn_flags(type, tend - type, + 0, SVt_PVIO); thatio = GvIO(thatgv); } if (!thatio) { @@ -380,7 +381,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, fd = -1; } if (!num_svs) - type = Nullch; + type = NULL; if (that_fp) { fp = PerlIO_fdupopen(aTHX_ that_fp, NULL, dodup); } @@ -411,7 +412,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, namesv = sv_2mortal(newSVpvn(type,tend - type)); num_svs = 1; svp = &namesv; - type = Nullch; + type = NULL; } fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp); } @@ -449,7 +450,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, namesv = sv_2mortal(newSVpvn(type,tend - type)); num_svs = 1; svp = &namesv; - type = Nullch; + type = NULL; } fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp); } @@ -541,7 +542,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, namesv = sv_2mortal(newSVpvn(type,tend - type)); num_svs = 1; svp = &namesv; - type = Nullch; + type = NULL; } fp = PerlIO_openn(aTHX_ type,mode,-1,0,0,NULL,num_svs,svp); } @@ -703,7 +704,7 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, *s = 'w'; if (!(IoOFP(io) = PerlIO_openn(aTHX_ type,s,fd,0,0,NULL,0,svp))) { PerlIO_close(fp); - IoIFP(io) = Nullfp; + IoIFP(io) = NULL; goto say_false; } } @@ -733,13 +734,13 @@ Perl_nextargv(pTHX_ register GV *gv) IO * const io = GvIOp(gv); if (!PL_argvoutgv) - PL_argvoutgv = gv_fetchpv("ARGVOUT",TRUE,SVt_PVIO); + PL_argvoutgv = gv_fetchpvs("ARGVOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); if (io && (IoFLAGS(io) & IOf_ARGV) && (IoFLAGS(io) & IOf_START)) { IoFLAGS(io) &= ~IOf_START; if (PL_inplace) { if (!PL_argvout_stack) PL_argvout_stack = newAV(); - av_push(PL_argvout_stack, SvREFCNT_inc(PL_defoutgv)); + av_push(PL_argvout_stack, SvREFCNT_inc_simple(PL_defoutgv)); } } if (PL_filemode & (S_ISUID|S_ISGID)) { @@ -754,7 +755,7 @@ Perl_nextargv(pTHX_ register GV *gv) PL_lastfd = -1; PL_filemode = 0; if (!GvAV(gv)) - return Nullfp; + return NULL; while (av_len(GvAV(gv)) >= 0) { STRLEN oldlen; sv = av_shift(GvAV(gv)); @@ -762,11 +763,12 @@ Perl_nextargv(pTHX_ register GV *gv) 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,Nullfp)) { + if (do_open(gv,PL_oldname,oldlen,PL_inplace!=0,O_RDONLY,0,NULL)) { if (PL_inplace) { TAINT_PROPER("inplace open"); if (oldlen == 1 && *PL_oldname == '-') { - setdefout(gv_fetchpv("STDOUT",TRUE,SVt_PVIO)); + setdefout(gv_fetchpvs("STDOUT", GV_ADD|GV_NOTQUAL, + SVt_PVIO)); return IoIFP(GvIOp(gv)); } #ifndef FLEXFILENAMES @@ -832,7 +834,7 @@ Perl_nextargv(pTHX_ register GV *gv) (void)PerlLIO_unlink(SvPVX_const(sv)); (void)PerlLIO_rename(PL_oldname,SvPVX_const(sv)); do_open(gv,(char*)SvPVX_const(sv),SvCUR(sv),PL_inplace!=0, - O_RDONLY,0,Nullfp); + O_RDONLY,0,NULL); #endif /* DOSISH */ #else (void)UNLINK(SvPVX_const(sv)); @@ -869,11 +871,11 @@ Perl_nextargv(pTHX_ register GV *gv) SETERRNO(0,0); /* in case sprintf set errno */ #ifdef VMS if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv), - PL_inplace!=0,O_WRONLY|O_CREAT|O_TRUNC,0,Nullfp)) + PL_inplace!=0,O_WRONLY|O_CREAT|O_TRUNC,0,NULL)) #else if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv), PL_inplace!=0,O_WRONLY|O_CREAT|OPEN_EXCL,0666, - Nullfp)) + NULL)) #endif { if (ckWARN_d(WARN_INPLACE)) @@ -931,11 +933,11 @@ Perl_nextargv(pTHX_ register GV *gv) GV *oldout = (GV*)av_pop(PL_argvout_stack); setdefout(oldout); SvREFCNT_dec(oldout); - return Nullfp; + return NULL; } - setdefout(gv_fetchpv("STDOUT",TRUE,SVt_PVIO)); + setdefout(gv_fetchpvs("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO)); } - return Nullfp; + return NULL; } /* explicit renamed to avoid C++ conflict -- kja */ @@ -1002,7 +1004,7 @@ Perl_io_close(pTHX_ IO *io, bool not_implicit) retval = (PerlIO_close(IoIFP(io)) != EOF && !prev_err); } } - IoOFP(io) = IoIFP(io) = Nullfp; + IoOFP(io) = IoIFP(io) = NULL; } else if (not_implicit) { SETERRNO(EBADF,SS_IVCHAN); @@ -1295,7 +1297,7 @@ Perl_my_stat(pTHX) return PL_laststatval; if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) report_evil_fh(gv, io, PL_op->op_type); - PL_statgv = Nullgv; + PL_statgv = NULL; sv_setpvn(PL_statname,"", 0); return (PL_laststatval = -1); } @@ -1318,7 +1320,7 @@ Perl_my_stat(pTHX) } s = SvPV_const(sv, len); - PL_statgv = Nullgv; + PL_statgv = NULL; sv_setpvn(PL_statname, s, len); s = SvPVX_const(PL_statname); /* s now NUL-terminated */ PL_laststype = OP_STAT; @@ -1355,7 +1357,7 @@ Perl_my_lstat(pTHX) Perl_croak(aTHX_ no_prev_lstat); PL_laststype = OP_LSTAT; - PL_statgv = Nullgv; + PL_statgv = NULL; sv = POPs; PUTBACK; if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV && ckWARN(WARN_IO)) { @@ -1423,9 +1425,9 @@ Perl_do_execfree(pTHX) { dVAR; Safefree(PL_Argv); - PL_Argv = Null(char **); + PL_Argv = NULL; Safefree(PL_Cmd); - PL_Cmd = Nullch; + PL_Cmd = NULL; } #ifdef PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION @@ -1972,7 +1974,8 @@ Perl_do_ipcget(pTHX_ I32 optype, SV **mark, SV **sp) const key_t key = (key_t)SvNVx(*++mark); const I32 n = (optype == OP_MSGGET) ? 0 : SvIVx(*++mark); const I32 flags = SvIVx(*++mark); - (void)sp; + + PERL_UNUSED_ARG(sp); SETERRNO(0,0); switch (optype) @@ -2314,89 +2317,14 @@ Perl_start_glob (pTHX_ SV *tmpglob, IO *io) SAVEFREESV(tmpcmd); #ifdef VMS /* expand the wildcards right here, rather than opening a pipe, */ /* since spawning off a process is a real performance hit */ - { -#include -#include -#include -#include - char rslt[NAM$C_MAXRSS+1+sizeof(unsigned short int)] = {'\0','\0'}; - char vmsspec[NAM$C_MAXRSS+1]; - char * const rstr = rslt + sizeof(unsigned short int); - char *begin, *end, *cp; - $DESCRIPTOR(dfltdsc,"SYS$DISK:[]*.*;"); - PerlIO *tmpfp; - STRLEN i; - struct dsc$descriptor_s wilddsc - = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; - struct dsc$descriptor_vs rsdsc - = {sizeof rslt, DSC$K_DTYPE_VT, DSC$K_CLASS_VS, rslt}; - unsigned long int cxt = 0, sts = 0, ok = 1, hasdir = 0, hasver = 0, isunix = 0; - - /* We could find out if there's an explicit dev/dir or version - by peeking into lib$find_file's internal context at - ((struct NAM *)((struct FAB *)cxt)->fab$l_nam)->nam$l_fnb - but that's unsupported, so I don't want to do it now and - have it bite someone in the future. */ - cp = SvPV(tmpglob,i); - for (; i; i--) { - if (cp[i] == ';') hasver = 1; - if (cp[i] == '.') { - if (sts) hasver = 1; - else sts = 1; - } - if (cp[i] == '/') { - hasdir = isunix = 1; - break; - } - if (cp[i] == ']' || cp[i] == '>' || cp[i] == ':') { - hasdir = 1; - break; - } - } - if ((tmpfp = PerlIO_tmpfile()) != NULL) { - Stat_t st; - if (!PerlLIO_stat(SvPVX_const(tmpglob),&st) && S_ISDIR(st.st_mode)) - ok = ((wilddsc.dsc$a_pointer = tovmspath(SvPVX(tmpglob),vmsspec)) != NULL); - else ok = ((wilddsc.dsc$a_pointer = tovmsspec(SvPVX(tmpglob),vmsspec)) != NULL); - if (ok) wilddsc.dsc$w_length = (unsigned short int) strlen(wilddsc.dsc$a_pointer); - for (cp=wilddsc.dsc$a_pointer; ok && cp && *cp; cp++) - if (*cp == '?') *cp = '%'; /* VMS style single-char wildcard */ - while (ok && ((sts = lib$find_file(&wilddsc,&rsdsc,&cxt, - &dfltdsc,NULL,NULL,NULL))&1)) { - /* with varying string, 1st word of buffer contains result length */ - end = rstr + *((unsigned short int*)rslt); - if (!hasver) while (*end != ';' && end > rstr) end--; - *(end++) = '\n'; *end = '\0'; - for (cp = rstr; *cp; cp++) *cp = _tolower(*cp); - if (hasdir) { - if (isunix) trim_unixpath(rstr,SvPVX(tmpglob),1); - begin = rstr; - } - else { - begin = end; - while (*(--begin) != ']' && *begin != '>') ; - ++begin; - } - ok = (PerlIO_puts(tmpfp,begin) != EOF); - } - if (cxt) (void)lib$find_file_end(&cxt); - if (ok && sts != RMS$_NMF && - sts != RMS$_DNF && sts != RMS_FNF) ok = 0; - if (!ok) { - if (!(sts & 1)) { - SETERRNO((sts == RMS$_SYN ? EINVAL : EVMSERR),sts); - } - PerlIO_close(tmpfp); - fp = NULL; - } - else { - PerlIO_rewind(tmpfp); - IoTYPE(io) = IoTYPE_RDONLY; - IoIFP(io) = fp = tmpfp; - IoFLAGS(io) &= ~IOf_UNTAINT; /* maybe redundant */ - } - } - } + +PerlIO * +Perl_vms_start_glob + (pTHX_ SV *tmpglob, + IO *io); + + fp = Perl_vms_start_glob(aTHX_ tmpglob, io); + #else /* !VMS */ #ifdef MACOS_TRADITIONAL sv_setpv(tmpcmd, "glob "); @@ -2436,7 +2364,7 @@ Perl_start_glob (pTHX_ SV *tmpglob, IO *io) #endif /* !DOSISH */ #endif /* MACOS_TRADITIONAL */ (void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd), - FALSE, O_RDONLY, 0, Nullfp); + FALSE, O_RDONLY, 0, NULL); fp = IoIFP(io); #endif /* !VMS */ LEAVE;