X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=doio.c;h=a52df3e78437750f694a9a7eca2392a3207f8e6f;hb=ed5c9e5071c7b22c1c8d5ca4426c026435a9f731;hp=0e8713eb0429142fa646bd6278313bef327ab52f;hpb=3595fceffa85af002f95c6d2ac8101f7f95d390a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/doio.c b/doio.c index 0e8713e..a52df3e 100644 --- a/doio.c +++ b/doio.c @@ -1,6 +1,6 @@ /* doio.c * - * Copyright (c) 1991-1994, Larry Wall + * Copyright (c) 1991-1997, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -34,7 +34,11 @@ #endif #ifdef I_UTIME -#include +# ifdef WIN32 +# include +# else +# include +# endif #endif #ifdef I_FCNTL #include @@ -43,6 +47,15 @@ #include #endif +#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX) +#include +#endif + +/* XXX If this causes problems, set i_unistd=undef in the hint file. */ +#ifdef I_UNISTD +# include +#endif + #if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */ # include # include @@ -53,33 +66,37 @@ # endif #endif +/* Put this after #includes because defines _XOPEN_*. */ +#ifndef Sock_size_t +# if _XOPEN_VERSION >= 5 || defined(_XOPEN_SOURCE_EXTENDED) +# define Sock_size_t Size_t +# else +# define Sock_size_t int +# endif +#endif + bool -do_open(gv,name,len,supplied_fp) +do_open(gv,name,len,as_raw,rawmode,rawperm,supplied_fp) GV *gv; register char *name; I32 len; -FILE *supplied_fp; +int as_raw; +int rawmode, rawperm; +PerlIO *supplied_fp; { - FILE *fp; register IO *io = GvIOn(gv); - char *myname = savepv(name); - int result; - int fd; - int writing = 0; - int dodup; - char mode[3]; /* stdio file mode ("r\0" or "r+\0") */ - FILE *saveifp = Nullfp; - FILE *saveofp = Nullfp; + PerlIO *saveifp = Nullfp; + PerlIO *saveofp = Nullfp; char savetype = ' '; + int writing = 0; + PerlIO *fp; + int fd; + int result; - SAVEFREEPV(myname); - mode[0] = mode[1] = mode[2] = '\0'; - name = myname; forkprocess = 1; /* assume true if no fork */ - while (len && isSPACE(name[len-1])) - name[--len] = '\0'; + if (IoIFP(io)) { - fd = fileno(IoIFP(io)); + fd = PerlIO_fileno(IoIFP(io)); if (IoTYPE(io) == '-') result = 0; else if (fd <= maxsysfd) { @@ -92,116 +109,148 @@ FILE *supplied_fp; result = my_pclose(IoIFP(io)); else if (IoIFP(io) != IoOFP(io)) { if (IoOFP(io)) { - result = fclose(IoOFP(io)); - fclose(IoIFP(io)); /* clear stdio, fd already closed */ + result = PerlIO_close(IoOFP(io)); + PerlIO_close(IoIFP(io)); /* clear stdio, fd already closed */ } else - result = fclose(IoIFP(io)); + result = PerlIO_close(IoIFP(io)); } else - result = fclose(IoIFP(io)); + result = PerlIO_close(IoIFP(io)); if (result == EOF && fd > maxsysfd) - fprintf(stderr,"Warning: unable to close filehandle %s properly.\n", + PerlIO_printf(PerlIO_stderr(), "Warning: unable to close filehandle %s properly.\n", GvENAME(gv)); IoOFP(io) = IoIFP(io) = Nullfp; } - if (*name == '+' && len > 1 && name[len-1] != '|') { /* scary */ - mode[1] = *name++; - mode[2] = '\0'; - --len; - writing = 1; - } - else { - mode[1] = '\0'; - } - IoTYPE(io) = *name; - if (*name == '|') { - /*SUPPRESS 530*/ - for (name++; isSPACE(*name); name++) ; - if (strNE(name,"-")) - TAINT_ENV(); - TAINT_PROPER("piped open"); - if (dowarn && name[strlen(name)-1] == '|') - warn("Can't do bidirectional pipe"); - fp = my_popen(name,"w"); - writing = 1; + + if (as_raw) { + result = rawmode & 3; + IoTYPE(io) = "<>++"[result]; + writing = (result > 0); + fd = open(name, rawmode, rawperm); + if (fd == -1) + fp = NULL; + else { + char *fpmode; + if (result == 0) + fpmode = "r"; +#ifdef O_APPEND + else if (rawmode & O_APPEND) + fpmode = (result == 1) ? "a" : "a+"; +#endif + else + fpmode = (result == 1) ? "w" : "r+"; + fp = PerlIO_fdopen(fd, fpmode); + if (!fp) + close(fd); + } } - else if (*name == '>') { - TAINT_PROPER("open"); - name++; - if (*name == '>') { - mode[0] = IoTYPE(io) = 'a'; - name++; + else { + char *myname; + char mode[3]; /* stdio file mode ("r\0" or "r+\0") */ + int dodup; + + myname = savepvn(name, len); + SAVEFREEPV(myname); + name = myname; + while (len && isSPACE(name[len-1])) + name[--len] = '\0'; + + mode[0] = mode[1] = mode[2] = '\0'; + IoTYPE(io) = *name; + if (*name == '+' && len > 1 && name[len-1] != '|') { /* scary */ + mode[1] = *name++; + --len; + writing = 1; } - else - mode[0] = 'w'; - writing = 1; - if (*name == '&') { - duplicity: - dodup = 1; + + if (*name == '|') { + /*SUPPRESS 530*/ + for (name++; isSPACE(*name); name++) ; + if (strNE(name,"-")) + TAINT_ENV(); + TAINT_PROPER("piped open"); + if (dowarn && name[strlen(name)-1] == '|') + warn("Can't do bidirectional pipe"); + fp = my_popen(name,"w"); + writing = 1; + } + else if (*name == '>') { + TAINT_PROPER("open"); name++; - if (*name == '=') { - dodup = 0; + if (*name == '>') { + mode[0] = IoTYPE(io) = 'a'; name++; } - if (!*name && supplied_fp) - fp = supplied_fp; - else { - while (isSPACE(*name)) + else + mode[0] = 'w'; + writing = 1; + + if (*name == '&') { + duplicity: + dodup = 1; + name++; + if (*name == '=') { + dodup = 0; name++; - if (isDIGIT(*name)) - fd = atoi(name); + } + if (!*name && supplied_fp) + fp = supplied_fp; else { - IO* thatio; - gv = gv_fetchpv(name,FALSE,SVt_PVIO); - thatio = GvIO(gv); - if (!thatio) { + /*SUPPRESS 530*/ + for (; isSPACE(*name); name++) ; + if (isDIGIT(*name)) + fd = atoi(name); + else { + IO* thatio; + gv = gv_fetchpv(name,FALSE,SVt_PVIO); + thatio = GvIO(gv); + if (!thatio) { #ifdef EINVAL - SETERRNO(EINVAL,SS$_IVCHAN); + SETERRNO(EINVAL,SS$_IVCHAN); #endif - goto say_false; - } - if (IoIFP(thatio)) { - fd = fileno(IoIFP(thatio)); - if (IoTYPE(thatio) == 's') - IoTYPE(io) = 's'; + goto say_false; + } + if (IoIFP(thatio)) { + fd = PerlIO_fileno(IoIFP(thatio)); + if (IoTYPE(thatio) == 's') + IoTYPE(io) = 's'; + } + else + fd = -1; } - else - fd = -1; - } - if (dodup) - fd = dup(fd); - if (!(fp = fdopen(fd,mode))) if (dodup) - close(fd); - } - } - else { - while (isSPACE(*name)) - name++; - if (strEQ(name,"-")) { - fp = stdout; - IoTYPE(io) = '-'; + fd = dup(fd); + if (!(fp = PerlIO_fdopen(fd,mode))) { + if (dodup) + close(fd); + } + } } - else { - fp = fopen(name,mode); + else { + /*SUPPRESS 530*/ + for (; isSPACE(*name); name++) ; + if (strEQ(name,"-")) { + fp = PerlIO_stdout(); + IoTYPE(io) = '-'; + } + else { + fp = PerlIO_open(name,mode); + } } } - } - else { - if (*name == '<') { + else if (*name == '<') { + /*SUPPRESS 530*/ + for (name++; isSPACE(*name); name++) ; mode[0] = 'r'; - name++; - while (isSPACE(*name)) - name++; if (*name == '&') goto duplicity; if (strEQ(name,"-")) { - fp = stdin; + fp = PerlIO_stdin(); IoTYPE(io) = '-'; } else - fp = fopen(name,mode); + fp = PerlIO_open(name,mode); } else if (name[len-1] == '|') { name[--len] = '\0'; @@ -220,11 +269,11 @@ FILE *supplied_fp; /*SUPPRESS 530*/ for (; isSPACE(*name); name++) ; if (strEQ(name,"-")) { - fp = stdin; + fp = PerlIO_stdin(); IoTYPE(io) = '-'; } else - fp = fopen(name,"r"); + fp = PerlIO_open(name,"r"); } } if (!fp) { @@ -234,8 +283,8 @@ FILE *supplied_fp; } if (IoTYPE(io) && IoTYPE(io) != '|' && IoTYPE(io) != '-') { - if (Fstat(fileno(fp),&statbuf) < 0) { - (void)fclose(fp); + if (Fstat(PerlIO_fileno(fp),&statbuf) < 0) { + (void)PerlIO_close(fp); goto say_false; } if (S_ISSOCK(statbuf.st_mode)) @@ -248,52 +297,53 @@ FILE *supplied_fp; !statbuf.st_mode #endif ) { - int buflen = sizeof tokenbuf; - if (getsockname(fileno(fp), (struct sockaddr *)tokenbuf, &buflen) >= 0 - || errno != ENOTSOCK) + Sock_size_t buflen = sizeof tokenbuf; + if (getsockname(PerlIO_fileno(fp), (struct sockaddr *)tokenbuf, + &buflen) >= 0 + || errno != ENOTSOCK) IoTYPE(io) = 's'; /* some OS's return 0 on fstat()ed socket */ /* but some return 0 for streams too, sigh */ } #endif } if (saveifp) { /* must use old fp? */ - fd = fileno(saveifp); + fd = PerlIO_fileno(saveifp); if (saveofp) { - fflush(saveofp); /* emulate fclose() */ + PerlIO_flush(saveofp); /* emulate PerlIO_close() */ if (saveofp != saveifp) { /* was a socket? */ - fclose(saveofp); + PerlIO_close(saveofp); if (fd > 2) Safefree(saveofp); } } - if (fd != fileno(fp)) { + if (fd != PerlIO_fileno(fp)) { int pid; SV *sv; - dup2(fileno(fp), fd); - sv = *av_fetch(fdpid,fileno(fp),TRUE); + dup2(PerlIO_fileno(fp), fd); + sv = *av_fetch(fdpid,PerlIO_fileno(fp),TRUE); (void)SvUPGRADE(sv, SVt_IV); pid = SvIVX(sv); SvIVX(sv) = 0; sv = *av_fetch(fdpid,fd,TRUE); (void)SvUPGRADE(sv, SVt_IV); SvIVX(sv) = pid; - fclose(fp); + PerlIO_close(fp); } fp = saveifp; - clearerr(fp); + PerlIO_clearerr(fp); } #if defined(HAS_FCNTL) && defined(F_SETFD) - fd = fileno(fp); + fd = PerlIO_fileno(fp); fcntl(fd,F_SETFD,fd > maxsysfd); #endif IoIFP(io) = fp; if (writing) { if (IoTYPE(io) == 's' || (IoTYPE(io) == '>' && S_ISCHR(statbuf.st_mode)) ) { - if (!(IoOFP(io) = fdopen(fileno(fp),"w"))) { - fclose(fp); + if (!(IoOFP(io) = PerlIO_fdopen(PerlIO_fileno(fp),"w"))) { + PerlIO_close(fp); IoIFP(io) = Nullfp; goto say_false; } @@ -310,7 +360,7 @@ say_false: return FALSE; } -FILE * +PerlIO * nextargv(gv) register GV *gv; { @@ -325,7 +375,7 @@ register GV *gv; if (!argvoutgv) argvoutgv = gv_fetchpv("ARGVOUT",TRUE,SVt_PVIO); if (filemode & (S_ISUID|S_ISGID)) { - fflush(IoIFP(GvIOn(argvoutgv))); /* chmod must follow last write */ + PerlIO_flush(IoIFP(GvIOn(argvoutgv))); /* chmod must follow last write */ #ifdef HAS_FCHMOD (void)fchmod(lastfd,filemode); #else @@ -340,7 +390,7 @@ register GV *gv; sv_setsv(GvSV(gv),sv); SvSETMAGIC(GvSV(gv)); oldname = SvPVx(GvSV(gv), len); - if (do_open(gv,oldname,len,Nullfp)) { + if (do_open(gv,oldname,len,FALSE,0,0,Nullfp)) { if (inplace) { TAINT_PROPER("inplace open"); if (strEQ(oldname,"-")) { @@ -388,8 +438,8 @@ register GV *gv; do_close(gv,FALSE); (void)unlink(SvPVX(sv)); (void)rename(oldname,SvPVX(sv)); - do_open(gv,SvPVX(sv),SvCUR(GvSV(gv)),Nullfp); -#endif /* MSDOS */ + do_open(gv,SvPVX(sv),SvCUR(sv),FALSE,0,0,Nullfp); +#endif /* DOSISH */ #else (void)UNLINK(SvPVX(sv)); if (link(oldname,SvPVX(sv)) < 0) { @@ -402,13 +452,15 @@ register GV *gv; #endif } else { -#ifndef DOSISH +#if !defined(DOSISH) && !defined(AMIGAOS) +# ifndef VMS /* Don't delete; use automatic file versioning */ if (UNLINK(oldname) < 0) { warn("Can't rename %s to %s: %s, skipping file", oldname, SvPVX(sv), Strerror(errno) ); do_close(gv,FALSE); continue; } +# endif #else croak("Can't do inplace edit without backup"); #endif @@ -417,14 +469,14 @@ register GV *gv; sv_setpvn(sv,">",1); sv_catpv(sv,oldname); SETERRNO(0,0); /* in case sprintf set errno */ - if (!do_open(argvoutgv,SvPVX(sv),SvCUR(sv),Nullfp)) { + if (!do_open(argvoutgv,SvPVX(sv),SvCUR(sv),FALSE,0,0,Nullfp)) { warn("Can't do inplace edit on %s: %s", oldname, Strerror(errno) ); do_close(gv,FALSE); continue; } setdefout(argvoutgv); - lastfd = fileno(IoIFP(GvIOp(argvoutgv))); + lastfd = PerlIO_fileno(IoIFP(GvIOp(argvoutgv))); (void)Fstat(lastfd,&statbuf); #ifdef HAS_FCHMOD (void)fchmod(lastfd,filemode); @@ -444,7 +496,7 @@ register GV *gv; return IoIFP(GvIOp(gv)); } else - fprintf(stderr,"Can't open %s: %s\n",SvPV(sv, na), Strerror(errno)); + PerlIO_printf(PerlIO_stderr(), "Can't open %s: %s\n",SvPV(sv, na), Strerror(errno)); } if (inplace) { (void)do_close(argvoutgv,FALSE); @@ -479,15 +531,15 @@ GV *wgv; if (pipe(fd) < 0) goto badexit; - IoIFP(rstio) = fdopen(fd[0], "r"); - IoOFP(wstio) = fdopen(fd[1], "w"); + IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"); + IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"); IoIFP(wstio) = IoOFP(wstio); IoTYPE(rstio) = '<'; IoTYPE(wstio) = '>'; if (!IoIFP(rstio) || !IoOFP(wstio)) { - if (IoIFP(rstio)) fclose(IoIFP(rstio)); + if (IoIFP(rstio)) PerlIO_close(IoIFP(rstio)); else close(fd[0]); - if (IoOFP(wstio)) fclose(IoOFP(wstio)); + if (IoOFP(wstio)) PerlIO_close(IoOFP(wstio)); else close(fd[1]); goto badexit; } @@ -501,18 +553,18 @@ badexit: } #endif +/* explicit renamed to avoid C++ conflict -- kja */ bool #ifndef CAN_PROTOTYPE -do_close(gv,explicit) +do_close(gv,not_implicit) GV *gv; -bool explicit; +bool not_implicit; #else -do_close(GV *gv, bool explicit) +do_close(GV *gv, bool not_implicit) #endif /* CAN_PROTOTYPE */ { - bool retval = FALSE; - register IO *io; - int status; + bool retval; + IO *io; if (!gv) gv = argvgv; @@ -522,34 +574,46 @@ do_close(GV *gv, bool explicit) } io = GvIO(gv); if (!io) { /* never opened */ - if (dowarn && explicit) + if (dowarn && not_implicit) warn("Close on unopened file <%s>",GvENAME(gv)); return FALSE; } + retval = io_close(io); + if (not_implicit) { + IoLINES(io) = 0; + IoPAGE(io) = 0; + IoLINES_LEFT(io) = IoPAGE_LEN(io); + } + IoTYPE(io) = ' '; + return retval; +} + +bool +io_close(io) +IO* io; +{ + bool retval = FALSE; + int status; + if (IoIFP(io)) { if (IoTYPE(io) == '|') { status = my_pclose(IoIFP(io)); - retval = (status == 0); - statusvalue = FIXSTATUS(status); + STATUS_NATIVE_SET(status); + retval = (STATUS_POSIX == 0); } else if (IoTYPE(io) == '-') retval = TRUE; else { if (IoOFP(io) && IoOFP(io) != IoIFP(io)) { /* a socket */ - retval = (fclose(IoOFP(io)) != EOF); - fclose(IoIFP(io)); /* clear stdio, fd already closed */ + retval = (PerlIO_close(IoOFP(io)) != EOF); + PerlIO_close(IoIFP(io)); /* clear stdio, fd already closed */ } else - retval = (fclose(IoIFP(io)) != EOF); + retval = (PerlIO_close(IoIFP(io)) != EOF); } IoOFP(io) = IoIFP(io) = Nullfp; } - if (explicit) { - IoLINES(io) = 0; - IoPAGE(io) = 0; - IoLINES_LEFT(io) = IoPAGE_LEN(io); - } - IoTYPE(io) = ' '; + return retval; } @@ -567,20 +631,20 @@ GV *gv; while (IoIFP(io)) { -#ifdef USE_STDIO_PTR /* (the code works without this) */ - if (FILE_cnt(IoIFP(io)) > 0) /* cheat a little, since */ - return FALSE; /* this is the most usual case */ -#endif + if (PerlIO_has_cntptr(IoIFP(io))) { /* (the code works without this) */ + if (PerlIO_get_cnt(IoIFP(io)) > 0) /* cheat a little, since */ + return FALSE; /* this is the most usual case */ + } - ch = getc(IoIFP(io)); + ch = PerlIO_getc(IoIFP(io)); if (ch != EOF) { - (void)ungetc(ch, IoIFP(io)); + (void)PerlIO_ungetc(IoIFP(io),ch); return FALSE; } -#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE) - if (FILE_cnt(IoIFP(io)) < -1) - FILE_cnt(IoIFP(io)) = -1; -#endif + if (PerlIO_has_cntptr(IoIFP(io)) && PerlIO_canset_cnt(IoIFP(io))) { + if (PerlIO_get_cnt(IoIFP(io)) < -1) + PerlIO_set_cnt(IoIFP(io),-1); + } if (op->op_flags & OPf_SPECIAL) { /* not necessarily a real EOF yet? */ if (!nextargv(argvgv)) /* get another fp handy */ return TRUE; @@ -605,11 +669,11 @@ GV *gv; goto phooey; #ifdef ULTRIX_STDIO_BOTCH - if (feof(IoIFP(io))) - (void)fseek (IoIFP(io), 0L, 2); /* ultrix 1.2 workaround */ + if (PerlIO_eof(IoIFP(io))) + (void)PerlIO_seek (IoIFP(io), 0L, 2); /* ultrix 1.2 workaround */ #endif - return ftell(IoIFP(io)); + return PerlIO_tell(IoIFP(io)); phooey: if (dowarn) @@ -634,11 +698,11 @@ int whence; goto nuts; #ifdef ULTRIX_STDIO_BOTCH - if (feof(IoIFP(io))) - (void)fseek (IoIFP(io), 0L, 2); /* ultrix 1.2 workaround */ + if (PerlIO_eof(IoIFP(io))) + (void)PerlIO_seek (IoIFP(io), 0L, 2); /* ultrix 1.2 workaround */ #endif - return fseek(IoIFP(io), pos, whence) >= 0; + return PerlIO_seek(IoIFP(io), pos, whence) >= 0; nuts: if (dowarn) @@ -651,7 +715,7 @@ nuts: /* code courtesy of William Kucharski */ #define HAS_CHSIZE -I32 chsize(fd, length) +I32 my_chsize(fd, length) I32 fd; /* file descriptor */ Off_t length; /* length to set file to */ { @@ -699,60 +763,10 @@ Off_t length; /* length to set file to */ } #endif /* F_FREESP */ -I32 -looks_like_number(sv) -SV *sv; -{ - register char *s; - register char *send; - - if (!SvPOK(sv)) { - STRLEN len; - if (!SvPOKp(sv)) - return TRUE; - s = SvPV(sv, len); - send = s + len; - } - else { - s = SvPVX(sv); - send = s + SvCUR(sv); - } - while (isSPACE(*s)) - s++; - if (s >= send) - return FALSE; - if (*s == '+' || *s == '-') - s++; - while (isDIGIT(*s)) - s++; - if (s == send) - return TRUE; - if (*s == '.') - s++; - else if (s == SvPVX(sv)) - return FALSE; - while (isDIGIT(*s)) - s++; - if (s == send) - return TRUE; - if (*s == 'e' || *s == 'E') { - s++; - if (*s == '+' || *s == '-') - s++; - while (isDIGIT(*s)) - s++; - } - while (isSPACE(*s)) - s++; - if (s >= send) - return TRUE; - return FALSE; -} - bool do_print(sv,fp) register SV *sv; -FILE *fp; +PerlIO *fp; { register char *tmps; STRLEN len; @@ -764,13 +778,13 @@ FILE *fp; if (SvGMAGICAL(sv)) mg_get(sv); if (SvIOK(sv) && SvIVX(sv) != 0) { - fprintf(fp, ofmt, (double)SvIVX(sv)); - return !ferror(fp); + PerlIO_printf(fp, ofmt, (double)SvIVX(sv)); + return !PerlIO_error(fp); } if ( (SvNOK(sv) && SvNVX(sv) != 0.0) || (looks_like_number(sv) && sv_2nv(sv) != 0.0) ) { - fprintf(fp, ofmt, SvNVX(sv)); - return !ferror(fp); + PerlIO_printf(fp, ofmt, SvNVX(sv)); + return !PerlIO_error(fp); } } switch (SvTYPE(sv)) { @@ -782,17 +796,17 @@ FILE *fp; if (SvIOK(sv)) { if (SvGMAGICAL(sv)) mg_get(sv); - fprintf(fp, "%ld", (long)SvIVX(sv)); - return !ferror(fp); + PerlIO_printf(fp, "%ld", (long)SvIVX(sv)); + return !PerlIO_error(fp); } /* FALL THROUGH */ default: tmps = SvPV(sv, len); break; } - if (len && (fwrite1(tmps,1,len,fp) == 0 || ferror(fp))) + if (len && (PerlIO_write(fp,tmps,len) == 0 || PerlIO_error(fp))) return FALSE; - return TRUE; + return !PerlIO_error(fp); } I32 @@ -812,7 +826,7 @@ dARGS statgv = tmpgv; sv_setpv(statname,""); laststype = OP_STAT; - return (laststatval = Fstat(fileno(IoIFP(io)), &statcache)); + return (laststatval = Fstat(PerlIO_fileno(IoIFP(io)), &statcache)); } else { if (tmpgv == defgv) @@ -923,6 +937,8 @@ do_execfree() } } +#ifndef OS2 + bool do_exec(cmd) char *cmd; @@ -982,7 +998,7 @@ char *cmd; break; } doshell: - execl("/bin/sh","sh","-c",cmd,(char*)0); + execl(sh_path, "sh", "-c", cmd, (char*)0); return FALSE; } } @@ -1012,6 +1028,8 @@ char *cmd; return FALSE; } +#endif /* OS2 */ + I32 apply(type,mark,sp) I32 type; @@ -1026,9 +1044,10 @@ register SV **sp; if (tainting) { while (++mark <= sp) { - MAGIC *mg; - if (SvMAGICAL(*mark) && (mg = mg_find(*mark, 't')) && mg->mg_len & 1) - tainted = TRUE; + if (SvTAINTED(*mark)) { + TAINT; + break; + } } mark = oldmark; } @@ -1061,6 +1080,8 @@ register SV **sp; #ifdef HAS_KILL case OP_KILL: TAINT_PROPER("kill"); + if (mark == sp) + break; s = SvPVx(*++mark, na); tot = sp - mark; if (isUPPER(*s)) { @@ -1158,8 +1179,13 @@ register SV **sp; #endif Zero(&utbuf, sizeof utbuf, char); +#ifdef BIG_TIME + utbuf.actime = (Time_t)SvNVx(*++mark); /* time accessed */ + utbuf.modtime = (Time_t)SvNVx(*++mark); /* time modified */ +#else utbuf.actime = SvIVx(*++mark); /* time accessed */ utbuf.modtime = SvIVx(*++mark); /* time modified */ +#endif tot = sp - mark; while (++mark <= sp) { if (utime(SvPVx(*mark, na),&utbuf)) @@ -1206,7 +1232,7 @@ register struct stat *statbufp; */ return (bit & statbufp->st_mode) ? TRUE : FALSE; -#else /* ! MSDOS */ +#else /* ! DOSISH */ if ((effective ? euid : uid) == 0) { /* root is special */ if (bit == S_IXUSR) { if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode)) @@ -1227,7 +1253,7 @@ register struct stat *statbufp; else if (statbufp->st_mode & bit >> 6) return TRUE; /* ok as "other" */ return FALSE; -#endif /* ! MSDOS */ +#endif /* ! DOSISH */ } #endif /* ! VMS */ @@ -1286,7 +1312,7 @@ SV **sp; #endif #if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM) default: - croak("%s not implemented", op_name[optype]); + croak("%s not implemented", op_desc[optype]); #endif } return -1; /* should never happen */ @@ -1342,7 +1368,7 @@ SV **sp; #endif #if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM) default: - croak("%s not implemented", op_name[optype]); + croak("%s not implemented", op_desc[optype]); #endif } @@ -1358,13 +1384,13 @@ SV **sp; { a = SvPV(astr, len); if (len != infosize) - croak("Bad arg length for %s, is %d, should be %d", - op_name[optype], len, infosize); + croak("Bad arg length for %s, is %lu, should be %ld", + op_desc[optype], (unsigned long)len, (long)infosize); } } else { - I32 i = SvIV(astr); + IV i = SvIV(astr); a = (char *)i; /* ouch */ } SETERRNO(0,0);