This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Note the autodie upgrade in perldelta
[perl5.git] / doio.c
diff --git a/doio.c b/doio.c
index 9877eba..cecc574 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -929,8 +929,7 @@ Perl_do_close(pTHX_ GV *gv, bool not_implicit)
     io = GvIO(gv);
     if (!io) {         /* never opened */
        if (not_implicit) {
-           if (ckWARN(WARN_UNOPENED)) /* no check for closed here */
-               report_evil_fh(gv);
+           report_evil_fh(gv);
            SETERRNO(EBADF,SS_IVCHAN);
        }
        return FALSE;
@@ -1035,20 +1034,19 @@ Off_t
 Perl_do_tell(pTHX_ GV *gv)
 {
     dVAR;
-    register IO *io = NULL;
+    IO *const io = GvIO(gv);
     register PerlIO *fp;
 
     PERL_ARGS_ASSERT_DO_TELL;
 
-    if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) {
+    if (io && (fp = IoIFP(io))) {
 #ifdef ULTRIX_STDIO_BOTCH
        if (PerlIO_eof(fp))
            (void)PerlIO_seek(fp, 0L, 2);       /* ultrix 1.2 workaround */
 #endif
        return PerlIO_tell(fp);
     }
-    if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
-       report_evil_fh(gv);
+    report_evil_fh(gv);
     SETERRNO(EBADF,RMS_IFI);
     return (Off_t)-1;
 }
@@ -1057,18 +1055,17 @@ bool
 Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence)
 {
     dVAR;
-    register IO *io = NULL;
+    IO *const io = GvIO(gv);
     register PerlIO *fp;
 
-    if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) {
+    if (io && (fp = IoIFP(io))) {
 #ifdef ULTRIX_STDIO_BOTCH
        if (PerlIO_eof(fp))
            (void)PerlIO_seek(fp, 0L, 2);       /* ultrix 1.2 workaround */
 #endif
        return PerlIO_seek(fp, pos, whence) >= 0;
     }
-    if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
-       report_evil_fh(gv);
+    report_evil_fh(gv);
     SETERRNO(EBADF,RMS_IFI);
     return FALSE;
 }
@@ -1077,15 +1074,14 @@ Off_t
 Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence)
 {
     dVAR;
-    register IO *io = NULL;
+    IO *const io = GvIO(gv);
     register PerlIO *fp;
 
     PERL_ARGS_ASSERT_DO_SYSSEEK;
 
-    if (gv && (io = GvIO(gv)) && (fp = IoIFP(io)))
+    if (io && (fp = IoIFP(io)))
        return PerlLIO_lseek(PerlIO_fileno(fp), pos, whence);
-    if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
-       report_evil_fh(gv);
+    report_evil_fh(gv);
     SETERRNO(EBADF,RMS_IFI);
     return (Off_t)-1;
 }
@@ -1228,6 +1224,9 @@ Perl_do_print(pTHX_ register SV *sv, PerlIO *fp)
                tmpbuf = bytes_to_utf8((const U8*) tmps, &len);
                tmps = (char *) tmpbuf;
            }
+           else if (ckWARN_d(WARN_UTF8)) {
+               (void) check_utf8_print((const U8*) tmps, len);
+           }
        }
        else if (DO_UTF8(sv)) {
            STRLEN tmplen = len;
@@ -1244,6 +1243,9 @@ Perl_do_print(pTHX_ register SV *sv, PerlIO *fp)
                                 "Wide character in %s",
                                   PL_op ? OP_DESC(PL_op) : "print"
                                );
+                   /* Could also check that isn't one of the things to avoid
+                    * in utf8 by using check_utf8_print(), but not doing so,
+                    * since the stream isn't a UTF8 stream */
            }
        }
        /* To detect whether the process is about to overstep its
@@ -1284,13 +1286,11 @@ Perl_my_stat_flags(pTHX_ const U32 flags)
             } else if (IoDIRP(io)) {
                 return (PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache));
             } else {
-                if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
-                    report_evil_fh(gv);
+               report_evil_fh(gv);
                 return (PL_laststatval = -1);
             }
        } else {
-            if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
-                report_evil_fh(gv);
+           report_evil_fh(gv);
             return (PL_laststatval = -1);
         }
     }
@@ -1905,7 +1905,7 @@ Perl_cando(pTHX_ Mode_t mode, bool effective, register const Stat_t *statbufp)
     /* [Comments and code from Len Reed]
      * MS-DOS "user" is similar to UNIX's "superuser," but can't write
      * to write-protected files.  The execute permission bit is set
-     * by the Miscrosoft C library stat() function for the following:
+     * by the Microsoft C library stat() function for the following:
      *         .exe files
      *         .com files
      *         .bat files