This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add note about map in scalar context
[perl5.git] / doio.c
diff --git a/doio.c b/doio.c
index 886add2..695a209 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1,6 +1,6 @@
 /*    doio.c
  *
- *    Copyright (c) 1991-1997, Larry Wall
+ *    Copyright (c) 1991-1999, 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.
 #include "perl.h"
 
 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
+#ifndef HAS_SEM
 #include <sys/ipc.h>
+#endif
 #ifdef HAS_MSG
 #include <sys/msg.h>
 #endif
-#ifdef HAS_SEM
-#include <sys/sem.h>
-#endif
 #ifdef HAS_SHM
 #include <sys/shm.h>
 # ifndef HAS_SHMAT_PROTOTYPE
@@ -125,22 +124,42 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
     }
 
     if (as_raw) {
-       result = rawmode & 3;
-       IoTYPE(io) = "<>++"[result];
+#if defined(O_LARGEFILE)
+       rawmode |= O_LARGEFILE;
+#endif
+
+#ifndef O_ACCMODE
+#define O_ACCMODE 3            /* Assume traditional implementation */
+#endif
+
+       switch (result = rawmode & O_ACCMODE) {
+       case O_RDONLY:
+            IoTYPE(io) = '<';
+            break;
+       case O_WRONLY:
+            IoTYPE(io) = '>';
+            break;
+       case O_RDWR:
+       default:
+            IoTYPE(io) = '+';
+            break;
+       }
+
        writing = (result > 0);
        fd = PerlLIO_open3(name, rawmode, rawperm);
+
        if (fd == -1)
            fp = NULL;
        else {
            char *fpmode;
-           if (result == 0)
+           if (result == O_RDONLY)
                fpmode = "r";
 #ifdef O_APPEND
            else if (rawmode & O_APPEND)
-               fpmode = (result == 1) ? "a" : "a+";
+               fpmode = (result == O_WRONLY) ? "a" : "a+";
 #endif
            else
-               fpmode = (result == 1) ? "w" : "r+";
+               fpmode = (result == O_WRONLY) ? "w" : "r+";
            fp = PerlIO_fdopen(fd, fpmode);
            if (!fp)
                PerlLIO_close(fd);
@@ -168,13 +187,21 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
        if (*name == '|') {
            /*SUPPRESS 530*/
            for (name++; isSPACE(*name); name++) ;
+           if (*name == '\0') { /* command is missing 19990114 */
+               dTHR;
+               if (ckWARN(WARN_PIPE))
+                   warner(WARN_PIPE, "Missing command in piped open");
+               errno = EPIPE;
+               goto say_false;
+           }
            if (strNE(name,"-"))
                TAINT_ENV();
            TAINT_PROPER("piped open");
            if (name[strlen(name)-1] == '|') {
+               dTHR;
                name[strlen(name)-1] = '\0' ;
-               if (PL_dowarn)
-                   warn("Can't do bidirectional pipe");
+               if (ckWARN(WARN_PIPE))
+                   warner(WARN_PIPE, "Can't do bidirectional pipe");
            }
            fp = PerlProc_popen(name,"w");
            writing = 1;
@@ -264,6 +291,13 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
                name[--len] = '\0';
            /*SUPPRESS 530*/
            for (; isSPACE(*name); name++) ;
+           if (*name == '\0') { /* command is missing 19990114 */
+               dTHR;
+               if (ckWARN(WARN_PIPE))
+                   warner(WARN_PIPE, "Missing command in piped open");
+               errno = EPIPE;
+               goto say_false;
+           }
            if (strNE(name,"-"))
                TAINT_ENV();
            TAINT_PROPER("piped open");
@@ -283,8 +317,9 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
        }
     }
     if (!fp) {
-       if (PL_dowarn && IoTYPE(io) == '<' && strchr(name, '\n'))
-           warn(warn_nl, "open");
+       dTHR;
+       if (ckWARN(WARN_NEWLINE) && IoTYPE(io) == '<' && strchr(name, '\n'))
+           warner(WARN_NEWLINE, PL_warn_nl, "open");
        goto say_false;
     }
     if (IoTYPE(io) &&
@@ -301,7 +336,7 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
 #ifdef S_IFMT
            !(PL_statbuf.st_mode & S_IFMT)
 #else
-           !statbuf.st_mode
+           !PL_statbuf.st_mode
 #endif
        ) {
            char tmpbuf[256];
@@ -344,8 +379,12 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
        PerlIO_clearerr(fp);
     }
 #if defined(HAS_FCNTL) && defined(F_SETFD)
-    fd = PerlIO_fileno(fp);
-    fcntl(fd,F_SETFD,fd > PL_maxsysfd);
+    {
+       int save_errno = errno;
+       fd = PerlIO_fileno(fp);
+       fcntl(fd,F_SETFD,fd > PL_maxsysfd); /* can change errno */
+       errno = save_errno;
+    }
 #endif
     IoIFP(io) = fp;
     if (writing) {
@@ -388,7 +427,7 @@ nextargv(register GV *gv)
 #ifdef HAS_FCHMOD
        (void)fchmod(PL_lastfd,PL_filemode);
 #else
-       (void)PerlLIO_chmod(oldname,filemode);
+       (void)PerlLIO_chmod(PL_oldname,PL_filemode);
 #endif
     }
     PL_filemode = 0;
@@ -400,7 +439,7 @@ nextargv(register GV *gv)
        sv_setsv(GvSV(gv),sv);
        SvSETMAGIC(GvSV(gv));
        PL_oldname = SvPVx(GvSV(gv), oldlen);
-       if (do_open(gv,PL_oldname,oldlen,PL_inplace!=0,0,0,Nullfp)) {
+       if (do_open(gv,PL_oldname,oldlen,PL_inplace!=0,O_RDONLY,0,Nullfp)) {
            if (PL_inplace) {
                TAINT_PROPER("inplace open");
                if (oldlen == 1 && *PL_oldname == '-') {
@@ -408,8 +447,8 @@ nextargv(register GV *gv)
                    return IoIFP(GvIOp(gv));
                }
 #ifndef FLEXFILENAMES
-               filedev = statbuf.st_dev;
-               fileino = statbuf.st_ino;
+               filedev = PL_statbuf.st_dev;
+               fileino = PL_statbuf.st_ino;
 #endif
                PL_filemode = PL_statbuf.st_mode;
                fileuid = PL_statbuf.st_uid;
@@ -437,14 +476,14 @@ nextargv(register GV *gv)
                        sv_catpv(sv,PL_inplace);
                    }
 #ifndef FLEXFILENAMES
-                   if (PerlLIO_stat(SvPVX(sv),&statbuf) >= 0
-                     && statbuf.st_dev == filedev
-                     && statbuf.st_ino == fileino
+                   if (PerlLIO_stat(SvPVX(sv),&PL_statbuf) >= 0
+                     && PL_statbuf.st_dev == filedev
+                     && PL_statbuf.st_ino == fileino
 #ifdef DJGPP
                       || (_djstat_fail_bits & _STFAIL_TRUENAME)!=0
 #endif
                       ) {
-                       warn("Can't do inplace edit: %s would not be uniq",
+                       warn("Can't do inplace edit: %s would not be unique",
                          SvPVX(sv) );
                        do_close(gv,FALSE);
                        continue;
@@ -461,18 +500,18 @@ nextargv(register GV *gv)
 #else
                    do_close(gv,FALSE);
                    (void)PerlLIO_unlink(SvPVX(sv));
-                   (void)PerlLIO_rename(oldname,SvPVX(sv));
-                   do_open(gv,SvPVX(sv),SvCUR(sv),inplace!=0,0,0,Nullfp);
+                   (void)PerlLIO_rename(PL_oldname,SvPVX(sv));
+                   do_open(gv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,O_RDONLY,0,Nullfp);
 #endif /* DOSISH */
 #else
                    (void)UNLINK(SvPVX(sv));
-                   if (link(oldname,SvPVX(sv)) < 0) {
+                   if (link(PL_oldname,SvPVX(sv)) < 0) {
                        warn("Can't rename %s to %s: %s, skipping file",
-                         oldname, SvPVX(sv), Strerror(errno) );
+                         PL_oldname, SvPVX(sv), Strerror(errno) );
                        do_close(gv,FALSE);
                        continue;
                    }
-                   (void)UNLINK(oldname);
+                   (void)UNLINK(PL_oldname);
 #endif
                }
                else {
@@ -493,8 +532,13 @@ nextargv(register GV *gv)
                sv_setpvn(sv,">",!PL_inplace);
                sv_catpvn(sv,PL_oldname,oldlen);
                SETERRNO(0,0);          /* in case sprintf set errno */
+#ifdef VMS
+               if (!do_open(PL_argvoutgv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,
+                 O_WRONLY|O_CREAT|O_TRUNC,0,Nullfp)) { 
+#else
                if (!do_open(PL_argvoutgv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,
                             O_WRONLY|O_CREAT|OPEN_EXCL,0666,Nullfp)) {
+#endif
                    warn("Can't do inplace edit on %s: %s",
                      PL_oldname, Strerror(errno) );
                    do_close(gv,FALSE);
@@ -508,7 +552,7 @@ nextargv(register GV *gv)
 #else
 #  if !(defined(WIN32) && defined(__BORLANDC__))
                /* Borland runtime creates a readonly file! */
-               (void)PerlLIO_chmod(oldname,filemode);
+               (void)PerlLIO_chmod(PL_oldname,PL_filemode);
 #  endif
 #endif
                if (fileuid != PL_statbuf.st_uid || filegid != PL_statbuf.st_gid) {
@@ -516,7 +560,7 @@ nextargv(register GV *gv)
                    (void)fchown(PL_lastfd,fileuid,filegid);
 #else
 #ifdef HAS_CHOWN
-                   (void)PerlLIO_chown(oldname,fileuid,filegid);
+                   (void)PerlLIO_chown(PL_oldname,fileuid,filegid);
 #endif
 #endif
                }
@@ -525,7 +569,7 @@ nextargv(register GV *gv)
        }
        else
            PerlIO_printf(PerlIO_stderr(), "Can't open %s: %s\n",
-             SvPV(sv, PL_na), Strerror(errno));
+             SvPV(sv, oldlen), Strerror(errno));
     }
     if (PL_inplace) {
        (void)do_close(PL_argvoutgv,FALSE);
@@ -596,8 +640,10 @@ do_close(GV *gv, bool not_implicit)
     io = GvIO(gv);
     if (!io) {         /* never opened */
        if (not_implicit) {
-           if (PL_dowarn)
-               warn("Close on unopened file <%s>",GvENAME(gv));
+           dTHR;
+           if (ckWARN(WARN_UNOPENED))
+               warner(WARN_UNOPENED, 
+                      "Close on unopened file <%s>",GvENAME(gv));
            SETERRNO(EBADF,SS$_IVCHAN);
        }
        return FALSE;
@@ -671,7 +717,7 @@ do_eof(GV *gv)
            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 (PL_op->op_flags & OPf_SPECIAL) { /* not necessarily a real EOF yet? */
            if (!nextargv(PL_argvgv))   /* get another fp handy */
                return TRUE;
        }
@@ -681,7 +727,7 @@ do_eof(GV *gv)
     return TRUE;
 }
 
-long
+Off_t
 do_tell(GV *gv)
 {
     register IO *io;
@@ -694,14 +740,17 @@ do_tell(GV *gv)
 #endif
        return PerlIO_tell(fp);
     }
-    if (PL_dowarn)
-       warn("tell() on unopened file");
+    {
+       dTHR;
+       if (ckWARN(WARN_UNOPENED))
+           warner(WARN_UNOPENED, "tell() on unopened file");
+    }
     SETERRNO(EBADF,RMS$_IFI);
-    return -1L;
+    return (Off_t)-1;
 }
 
 bool
-do_seek(GV *gv, long int pos, int whence)
+do_seek(GV *gv, Off_t pos, int whence)
 {
     register IO *io;
     register PerlIO *fp;
@@ -713,22 +762,28 @@ do_seek(GV *gv, long int pos, int whence)
 #endif
        return PerlIO_seek(fp, pos, whence) >= 0;
     }
-    if (PL_dowarn)
-       warn("seek() on unopened file");
+    {
+       dTHR;
+       if (ckWARN(WARN_UNOPENED))
+           warner(WARN_UNOPENED, "seek() on unopened file");
+    }
     SETERRNO(EBADF,RMS$_IFI);
     return FALSE;
 }
 
-long
-do_sysseek(GV *gv, long int pos, int whence)
+Off_t
+do_sysseek(GV *gv, Off_t pos, int whence)
 {
     register IO *io;
     register PerlIO *fp;
 
     if (gv && (io = GvIO(gv)) && (fp = IoIFP(io)))
        return PerlLIO_lseek(PerlIO_fileno(fp), pos, whence);
-    if (PL_dowarn)
-       warn("sysseek() on unopened file");
+    {
+       dTHR;
+       if (ckWARN(WARN_UNOPENED))
+           warner(WARN_UNOPENED, "sysseek() on unopened file");
+    }
     SETERRNO(EBADF,RMS$_IFI);
     return -1L;
 }
@@ -739,7 +794,7 @@ do_binmode(PerlIO *fp, int iotype, int flag)
     if (flag != TRUE)
        croak("panic: unsetting binmode"); /* Not implemented yet */
 #ifdef DOSISH
-#ifdef atarist
+#if defined(atarist) || defined(__MINT__)
     if (!PerlIO_flush(fp) && (fp->_flag |= _IOBIN))
        return 1;
     else
@@ -848,8 +903,11 @@ do_print(register SV *sv, PerlIO *fp)
     }
     switch (SvTYPE(sv)) {
     case SVt_NULL:
-       if (PL_dowarn)
-           warn(warn_uninit);
+       {
+           dTHR;
+           if (ckWARN(WARN_UNINITIALIZED))
+               warner(WARN_UNINITIALIZED, PL_warn_uninit);
+       }
        return TRUE;
     case SVt_IV:
        if (SvIOK(sv)) {
@@ -875,7 +933,7 @@ my_stat(ARGSproto)
     IO *io;
     GV* tmpgv;
 
-    if (op->op_flags & OPf_REF) {
+    if (PL_op->op_flags & OPf_REF) {
        EXTEND(SP,1);
        tmpgv = cGVOP->op_gv;
       do_fstat:
@@ -889,8 +947,8 @@ my_stat(ARGSproto)
        else {
            if (tmpgv == PL_defgv)
                return PL_laststatval;
-           if (PL_dowarn)
-               warn("Stat on unopened file <%s>",
+           if (ckWARN(WARN_UNOPENED))
+               warner(WARN_UNOPENED, "Stat on unopened file <%s>",
                  GvENAME(tmpgv));
            PL_statgv = Nullgv;
            sv_setpv(PL_statname,"");
@@ -900,6 +958,7 @@ my_stat(ARGSproto)
     else {
        SV* sv = POPs;
        char *s;
+       STRLEN n_a;
        PUTBACK;
        if (SvTYPE(sv) == SVt_PVGV) {
            tmpgv = (GV*)sv;
@@ -910,13 +969,13 @@ my_stat(ARGSproto)
            goto do_fstat;
        }
 
-       s = SvPV(sv, PL_na);
+       s = SvPV(sv, n_a);
        PL_statgv = Nullgv;
        sv_setpv(PL_statname, s);
        PL_laststype = OP_STAT;
        PL_laststatval = PerlLIO_stat(s, &PL_statcache);
-       if (PL_laststatval < 0 && PL_dowarn && strchr(s, '\n'))
-           warn(warn_nl, "stat");
+       if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n'))
+           warner(WARN_NEWLINE, PL_warn_nl, "stat");
        return PL_laststatval;
     }
 }
@@ -926,7 +985,8 @@ my_lstat(ARGSproto)
 {
     djSP;
     SV *sv;
-    if (op->op_flags & OPf_REF) {
+    STRLEN n_a;
+    if (PL_op->op_flags & OPf_REF) {
        EXTEND(SP,1);
        if (cGVOP->op_gv == PL_defgv) {
            if (PL_laststype != OP_LSTAT)
@@ -940,14 +1000,14 @@ my_lstat(ARGSproto)
     PL_statgv = Nullgv;
     sv = POPs;
     PUTBACK;
-    sv_setpv(PL_statname,SvPV(sv, PL_na));
+    sv_setpv(PL_statname,SvPV(sv, n_a));
 #ifdef HAS_LSTAT
-    PL_laststatval = PerlLIO_lstat(SvPV(sv, PL_na),&PL_statcache);
+    PL_laststatval = PerlLIO_lstat(SvPV(sv, n_a),&PL_statcache);
 #else
-    laststatval = PerlLIO_stat(SvPV(sv, na),&statcache);
+    PL_laststatval = PerlLIO_stat(SvPV(sv, n_a),&PL_statcache);
 #endif
-    if (PL_laststatval < 0 && PL_dowarn && strchr(SvPV(sv, PL_na), '\n'))
-       warn(warn_nl, "lstat");
+    if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, n_a), '\n'))
+       warner(WARN_NEWLINE, PL_warn_nl, "lstat");
     return PL_laststatval;
 }
 
@@ -956,6 +1016,7 @@ do_aexec(SV *really, register SV **mark, register SV **sp)
 {
     register char **a;
     char *tmps;
+    STRLEN n_a;
 
     if (sp > mark) {
        dTHR;
@@ -963,19 +1024,20 @@ do_aexec(SV *really, register SV **mark, register SV **sp)
        a = PL_Argv;
        while (++mark <= sp) {
            if (*mark)
-               *a++ = SvPVx(*mark, PL_na);
+               *a++ = SvPVx(*mark, n_a);
            else
                *a++ = "";
        }
        *a = Nullch;
        if (*PL_Argv[0] != '/') /* will execvp use PATH? */
            TAINT_ENV();                /* testing IFS here is overkill, probably */
-       if (really && *(tmps = SvPV(really, PL_na)))
+       if (really && *(tmps = SvPV(really, n_a)))
            PerlProc_execvp(tmps,PL_Argv);
        else
            PerlProc_execvp(PL_Argv[0],PL_Argv);
-       if (PL_dowarn)
-           warn("Can't exec \"%s\": %s", PL_Argv[0], Strerror(errno));
+       if (ckWARN(WARN_EXEC))
+           warner(WARN_EXEC, "Can't exec \"%s\": %s", 
+               PL_Argv[0], Strerror(errno));
     }
     do_execfree();
     return FALSE;
@@ -1077,8 +1139,12 @@ do_exec(char *cmd)
            do_execfree();
            goto doshell;
        }
-       if (PL_dowarn)
-           warn("Can't exec \"%s\": %s", PL_Argv[0], Strerror(errno));
+       {
+           dTHR;
+           if (ckWARN(WARN_EXEC))
+               warner(WARN_EXEC, "Can't exec \"%s\": %s", 
+                   PL_Argv[0], Strerror(errno));
+       }
     }
     do_execfree();
     return FALSE;
@@ -1096,10 +1162,11 @@ apply(I32 type, register SV **mark, register SV **sp)
     char *what;
     char *s;
     SV **oldmark = mark;
+    STRLEN n_a;
 
 #define APPLY_TAINT_PROPER() \
     STMT_START {                                                       \
-       if (PL_tainting && PL_tainted) { goto taint_proper_label; }     \
+       if (PL_tainted) { TAINT_PROPER(what); }                         \
     } STMT_END
 
     /* This is a first heuristic; it doesn't catch tainting magic. */
@@ -1121,7 +1188,7 @@ apply(I32 type, register SV **mark, register SV **sp)
            APPLY_TAINT_PROPER();
            tot = sp - mark;
            while (++mark <= sp) {
-               char *name = SvPVx(*mark, PL_na);
+               char *name = SvPVx(*mark, n_a);
                APPLY_TAINT_PROPER();
                if (PerlLIO_chmod(name, val))
                    tot--;
@@ -1138,7 +1205,7 @@ apply(I32 type, register SV **mark, register SV **sp)
            APPLY_TAINT_PROPER();
            tot = sp - mark;
            while (++mark <= sp) {
-               char *name = SvPVx(*mark, PL_na);
+               char *name = SvPVx(*mark, n_a);
                APPLY_TAINT_PROPER();
                if (PerlLIO_chown(name, val, val2))
                    tot--;
@@ -1158,7 +1225,7 @@ nothing in the core.
        APPLY_TAINT_PROPER();
        if (mark == sp)
            break;
-       s = SvPVx(*++mark, PL_na);
+       s = SvPVx(*++mark, n_a);
        if (isUPPER(*s)) {
            if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
                s += 3;
@@ -1228,7 +1295,7 @@ nothing in the core.
        APPLY_TAINT_PROPER();
        tot = sp - mark;
        while (++mark <= sp) {
-           s = SvPVx(*mark, PL_na);
+           s = SvPVx(*mark, n_a);
            APPLY_TAINT_PROPER();
            if (PL_euid || PL_unsafe) {
                if (UNLINK(s))
@@ -1238,7 +1305,7 @@ nothing in the core.
 #ifdef HAS_LSTAT
                if (PerlLIO_lstat(s,&PL_statbuf) < 0 || S_ISDIR(PL_statbuf.st_mode))
 #else
-               if (PerlLIO_stat(s,&statbuf) < 0 || S_ISDIR(statbuf.st_mode))
+               if (PerlLIO_stat(s,&PL_statbuf) < 0 || S_ISDIR(PL_statbuf.st_mode))
 #endif
                    tot--;
                else {
@@ -1257,23 +1324,23 @@ nothing in the core.
            struct utimbuf utbuf;
 #else
            struct {
-               long    actime;
-               long    modtime;
+               Time_t  actime;
+               Time_t  modtime;
            } utbuf;
 #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 */
+           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 */
+           utbuf.actime = (Time_t)SvIVx(*++mark);      /* time accessed */
+           utbuf.modtime = (Time_t)SvIVx(*++mark);     /* time modified */
 #endif
            APPLY_TAINT_PROPER();
            tot = sp - mark;
            while (++mark <= sp) {
-               char *name = SvPVx(*mark, PL_na);
+               char *name = SvPVx(*mark, n_a);
                APPLY_TAINT_PROPER();
                if (PerlLIO_utime(name, &utbuf))
                    tot--;
@@ -1286,10 +1353,6 @@ nothing in the core.
     }
     return tot;
 
-  taint_proper_label:
-    TAINT_PROPER(what);
-    return 0;  /* this should never happen */
-
 #undef APPLY_TAINT_PROPER
 }
 
@@ -1398,7 +1461,7 @@ do_ipcget(I32 optype, SV **mark, SV **sp)
 #endif
 #if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
     default:
-       croak("%s not implemented", op_desc[optype]);
+       croak("%s not implemented", PL_op_desc[optype]);
 #endif
     }
     return -1;                 /* should never happen */
@@ -1455,7 +1518,7 @@ do_ipcctl(I32 optype, SV **mark, SV **sp)
 #endif
 #if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
     default:
-       croak("%s not implemented", op_desc[optype]);
+       croak("%s not implemented", PL_op_desc[optype]);
 #endif
     }
 
@@ -1472,7 +1535,9 @@ do_ipcctl(I32 optype, SV **mark, SV **sp)
            a = SvPV(astr, len);
            if (len != infosize)
                croak("Bad arg length for %s, is %lu, should be %ld",
-                       op_desc[optype], (unsigned long)len, (long)infosize);
+                     PL_op_desc[optype],
+                     (unsigned long)len,
+                     (long)infosize);
        }
     }
     else