{
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;
bool was_fdopen = FALSE;
bool in_raw = 0, in_crlf = 0, out_raw = 0, out_crlf = 0;
char *type = NULL;
- char mode[PERL_MODE_MAX]; /* stdio file mode ("r\0", "rb\0", "r+b\0" etc.) */
+ char mode[PERL_MODE_MAX]; /* file mode ("r\0", "rb\0", "ab\0" etc.) */
SV *namesv;
Zero(mode,sizeof(mode),char);
"Warning: unable to close filehandle %s properly.\n",
GvENAME(gv));
}
- IoOFP(io) = IoIFP(io) = Nullfp;
+ IoOFP(io) = IoIFP(io) = NULL;
}
if (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 {
STRLEN olen = len;
char *tend;
int dodup = 0;
- PerlIO *that_fp = NULL;
type = savepvn(oname, len);
tend = type+len;
SAVEFREEPV(type);
/* Lose leading and trailing white space */
- for (; isSPACE(*type); type++) ;
+ while (isSPACE(*type))
+ type++;
while (tend > type && isSPACE(tend[-1]))
*--tend = '\0';
}
type++;
}
- for (type++; isSPACE(*type); type++) ;
+ do {
+ type++;
+ } while (isSPACE(*type));
if (!num_svs) {
name = type;
len = tend-type;
errno = EPIPE;
goto say_false;
}
- if ((*name == '-' && name[1] == '\0') || num_svs)
+ if (!(*name == '-' && name[1] == '\0') || num_svs)
TAINT_ENV();
TAINT_PROPER("piped open");
if (!num_svs && name[len-1] == '|') {
writing = 1;
#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (out_raw)
strcat(mode, "b");
#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (out_raw)
strcat(mode, "b");
fp = supplied_fp;
}
else {
+ PerlIO *that_fp = NULL;
if (num_svs > 1) {
Perl_croak(aTHX_ "More than one argument to '%c&' open",IoTYPE(io));
}
- for (; isSPACE(*type); type++) ;
+ while (isSPACE(*type))
+ type++;
if (num_svs && (SvIOK(*svp) || (SvPOK(*svp) && looks_like_number(*svp)))) {
fd = SvUV(*svp);
num_svs = 0;
thatio = sv_2io(*svp);
}
else {
- GV *thatgv;
- thatgv = gv_fetchpvn_flags(type, tend - type,
+ GV * const thatgv = gv_fetchpvn_flags(type, tend - type,
0, SVt_PVIO);
thatio = GvIO(thatgv);
}
fd = -1;
}
if (!num_svs)
- type = Nullch;
+ type = NULL;
if (that_fp) {
fp = PerlIO_fdupopen(aTHX_ that_fp, NULL, dodup);
}
}
} /* & */
else {
- for (; isSPACE(*type); type++) ;
+ while (isSPACE(*type))
+ type++;
if (*type == IoTYPE_STD && (!type[1] || isSPACE(type[1]) || type[1] == ':')) {
type++;
fp = PerlIO_stdout();
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);
}
goto unknown_open_mode;
} /* IoTYPE_WRONLY */
else if (*type == IoTYPE_RDONLY) {
- for (type++; isSPACE(*type); type++) ;
+ do {
+ type++;
+ } while (isSPACE(*type));
mode[0] = 'r';
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
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);
}
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
}
IoTYPE(io) = IoTYPE_PIPE;
if (num_svs) {
- for (; isSPACE(*type); type++) ;
+ while (isSPACE(*type))
+ type++;
if (*type) {
if (PerlIO_apply_layers(aTHX_ fp, mode, type) != 0) {
goto say_false;
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
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);
}
*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;
}
}
if (PL_inplace) {
if (!PL_argvout_stack)
PL_argvout_stack = newAV();
- av_push(PL_argvout_stack, SvREFCNT_inc(PL_defoutgv));
+ assert(PL_defoutgv);
+ av_push(PL_argvout_stack, SvREFCNT_inc_simple_NN(PL_defoutgv));
}
}
if (PL_filemode & (S_ISUID|S_ISGID)) {
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));
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 == '-') {
if (ckWARN_d(WARN_INPLACE))
Perl_warner(aTHX_ packWARN(WARN_INPLACE),
"Can't rename %s to %"SVf": %s, skipping file",
- PL_oldname, sv, Strerror(errno) );
+ PL_oldname, (void*)sv, Strerror(errno));
do_close(gv,FALSE);
continue;
}
(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));
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))
if (io && (IoFLAGS(io) & IOf_ARGV)
&& PL_argvout_stack && AvFILLp(PL_argvout_stack) >= 0)
{
- GV *oldout = (GV*)av_pop(PL_argvout_stack);
+ GV * const oldout = (GV*)av_pop(PL_argvout_stack);
setdefout(oldout);
SvREFCNT_dec(oldout);
- return Nullfp;
+ return NULL;
}
setdefout(gv_fetchpvs("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO));
}
- return Nullfp;
+ return NULL;
}
/* explicit renamed to avoid C++ conflict -- kja */
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);
/* code courtesy of William Kucharski */
#define HAS_CHSIZE
- struct flock fl;
Stat_t filebuf;
if (PerlLIO_fstat(fd, &filebuf) < 0)
}
else {
/* truncate length */
-
+ struct flock fl;
fl.l_whence = 0;
fl.l_len = 0;
fl.l_start = length;
dVAR;
register const char *tmps;
STRLEN len;
+ U8 *tmpbuf = NULL;
+ bool happy = TRUE;
/* assuming fp is checked earlier */
if (!sv)
return TRUE;
case SVt_IV:
if (SvIOK(sv)) {
- SvGETMAGIC(sv);
+ assert(!SvGMAGICAL(sv));
if (SvIsUV(sv))
PerlIO_printf(fp, "%"UVuf, (UV)SvUVX(sv));
else
}
/* FALL THROUGH */
default:
+ /* Do this first to trigger any overloading. */
+ tmps = SvPV_const(sv, len);
if (PerlIO_isutf8(fp)) {
- if (!SvUTF8(sv))
- sv_utf8_upgrade_flags(sv = sv_mortalcopy(sv),
- SV_GMAGIC|SV_UTF8_NO_ENCODING);
+ if (!SvUTF8(sv)) {
+ /* We don't modify the original scalar. */
+ tmpbuf = bytes_to_utf8((const U8*) tmps, &len);
+ tmps = (char *) tmpbuf;
+ }
}
else if (DO_UTF8(sv)) {
- if (!sv_utf8_downgrade((sv = sv_mortalcopy(sv)), TRUE)
- && ckWARN_d(WARN_UTF8))
- {
- Perl_warner(aTHX_ packWARN(WARN_UTF8), "Wide character in print");
+ STRLEN tmplen = len;
+ bool utf8 = TRUE;
+ U8 * const result = bytes_from_utf8((const U8*) tmps, &tmplen, &utf8);
+ if (!utf8) {
+ tmpbuf = result;
+ tmps = (char *) tmpbuf;
+ len = tmplen;
+ }
+ else {
+ assert((char *)result == tmps);
+ if (ckWARN_d(WARN_UTF8)) {
+ Perl_warner(aTHX_ packWARN(WARN_UTF8),
+ "Wide character in print");
+ }
}
}
- tmps = SvPV_const(sv, len);
break;
}
/* To detect whether the process is about to overstep its
* at which we would get EPERM. Note that when using buffered
* io the write failure can be delayed until the flush/close. --jhi */
if (len && (PerlIO_write(fp,tmps,len) == 0))
- return FALSE;
- return !PerlIO_error(fp);
+ happy = FALSE;
+ Safefree(tmpbuf);
+ return happy ? !PerlIO_error(fp) : FALSE;
}
I32
EXTEND(SP,1);
gv = cGVOP_gv;
do_fstat:
+ if (gv == PL_defgv)
+ return PL_laststatval;
io = GvIO(gv);
- if (io && IoIFP(io)) {
- PL_statgv = gv;
- sv_setpvn(PL_statname,"", 0);
- PL_laststype = OP_STAT;
- return (PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache));
- }
- else {
- if (gv == PL_defgv)
- return PL_laststatval;
- if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
- report_evil_fh(gv, io, PL_op->op_type);
- PL_statgv = Nullgv;
- sv_setpvn(PL_statname,"", 0);
- return (PL_laststatval = -1);
- }
+ PL_laststype = OP_STAT;
+ PL_statgv = gv;
+ sv_setpvn(PL_statname, "", 0);
+ if(io) {
+ if (IoIFP(io)) {
+ return (PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache));
+ } else if (IoDIRP(io)) {
+#ifdef HAS_DIRFD
+ return (PL_laststatval = PerlLIO_fstat(dirfd(IoDIRP(io)), &PL_statcache));
+#else
+ Perl_die(aTHX_ PL_no_func, "dirfd");
+#endif
+ } else {
+ if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
+ report_evil_fh(gv, io, PL_op->op_type);
+ return (PL_laststatval = -1);
+ }
+ } else {
+ if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
+ report_evil_fh(gv, io, PL_op->op_type);
+ return (PL_laststatval = -1);
+ }
}
else if (PL_op->op_private & OPpFT_STACKED) {
return PL_laststatval;
}
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;
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)) {
return PL_laststatval;
}
+static void
+S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
+{
+ const int e = errno;
+ if (ckWARN(WARN_EXEC))
+ Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
+ cmd, Strerror(e));
+ if (do_report) {
+ PerlLIO_write(fd, (void*)&e, sizeof(int));
+ PerlLIO_close(fd);
+ }
+}
+
bool
Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,
int fd, int do_report)
else
PerlProc_execvp(PL_Argv[0],EXEC_ARGV_CAST(PL_Argv));
PERL_FPU_POST_EXEC
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
- (really ? tmps : PL_Argv[0]), Strerror(errno));
- if (do_report) {
- const int e = errno;
-
- PerlLIO_write(fd, (void*)&e, sizeof(int));
- PerlLIO_close(fd);
- }
+ S_exec_failed(aTHX_ (really ? tmps : PL_Argv[0]), fd, do_report);
}
do_execfree();
#endif
{
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
if (*s == 'f') {
s++;
#ifdef HAS_STRLCPY
- strlcat(flags, "f", PERL_FLAGS_MAX);
+ strlcat(flags, "f", PERL_FLAGS_MAX - 2);
#else
strcat(flags,"f");
#endif
if (s[-1] == '\'') {
*--s = '\0';
PERL_FPU_PRE_EXEC
- PerlProc_execl(PL_cshname,"csh", flags, ncmd, (char*)0);
+ PerlProc_execl(PL_cshname, "csh", flags, ncmd, NULL);
PERL_FPU_POST_EXEC
*s = '\'';
+ S_exec_failed(aTHX_ PL_cshname, fd, do_report);
Safefree(cmd);
return FALSE;
}
if (strnEQ(cmd,"exec",4) && isSPACE(cmd[4]))
goto doshell;
- for (s = cmd; *s && isALNUM(*s); s++) ; /* catch VAR=val gizmo */
+ s = cmd;
+ while (isALNUM(*s))
+ s++; /* catch VAR=val gizmo */
if (*s == '=')
goto doshell;
}
doshell:
PERL_FPU_PRE_EXEC
- PerlProc_execl(PL_sh_path, "sh", "-c", cmd, (char*)0);
+ PerlProc_execl(PL_sh_path, "sh", "-c", cmd, NULL);
PERL_FPU_POST_EXEC
+ S_exec_failed(aTHX_ PL_sh_path, fd, do_report);
Safefree(cmd);
return FALSE;
}
PL_Cmd = savepvn(cmd, s-cmd);
a = PL_Argv;
for (s = PL_Cmd; *s;) {
- while (*s && isSPACE(*s)) s++;
+ while (isSPACE(*s))
+ s++;
if (*s)
*(a++) = s;
- while (*s && !isSPACE(*s)) s++;
+ while (*s && !isSPACE(*s))
+ s++;
if (*s)
*s++ = '\0';
}
do_execfree();
goto doshell;
}
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
- PL_Argv[0], Strerror(errno));
- if (do_report) {
- const int e = errno;
- PerlLIO_write(fd, (const void*)&e, sizeof(int));
- PerlLIO_close(fd);
- }
+ S_exec_failed(aTHX_ PL_Argv[0], fd, do_report);
}
do_execfree();
Safefree(cmd);
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)
char *a;
I32 ret = -1;
const I32 id = SvIVx(*++mark);
+#ifdef Semctl
const I32 n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0;
+#endif
const I32 cmd = SvIVx(*++mark);
SV * const astr = *++mark;
STRLEN infosize = 0;
SETERRNO(0,0);
if (shmctl(id, IPC_STAT, &shmds) == -1)
return -1;
- if (mpos < 0 || msize < 0 || mpos + msize > shmds.shm_segsz) {
+ if (mpos < 0 || msize < 0 || (size_t)mpos + msize > shmds.shm_segsz) {
SETERRNO(EFAULT,SS_ACCVIO); /* can't do as caller requested */
return -1;
}
- shm = (char *)shmat(id, (char*)NULL, (optype == OP_SHMREAD) ? SHM_RDONLY : 0);
+ shm = (char *)shmat(id, NULL, (optype == OP_SHMREAD) ? SHM_RDONLY : 0);
if (shm == (char *)-1) /* I hate System V IPC, I really do */
return -1;
if (optype == OP_SHMREAD) {
if (! SvOK(mstr))
sv_setpvn(mstr, "", 0);
SvPV_force_nolen(mstr);
- mbuf = SvGROW(mstr, msize+1);
+ mbuf = SvGROW(mstr, (STRLEN)msize+1);
Copy(shm + mpos, mbuf, msize, char);
SvCUR_set(mstr, msize);
#endif
}
else {
- I32 n;
STRLEN len;
const char *mbuf = SvPV_const(mstr, len);
- if ((n = len) > msize)
- n = msize;
+ const I32 n = (len > msize) ? msize : len;
Copy(mbuf, shm + mpos, n, char);
if (n < msize)
memzero(shm + mpos + n, msize - n);
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 <descrip.h>
-#include <lib$routines.h>
-#include <nam.h>
-#include <rmsdef.h>
- 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 ");
#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;