This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlsio_binmode() is pretty much a mathom on UNIX platforms, but it is
authorSteve Peters <steve@fisharerojo.org>
Mon, 31 Oct 2005 03:51:08 +0000 (03:51 +0000)
committerSteve Peters <steve@fisharerojo.org>
Mon, 31 Oct 2005 03:51:08 +0000 (03:51 +0000)
used on Cygwin, at least.

p4raw-id: //depot/perl@25911

mathoms.c
perlio.c

index be61f8e..9d063e0 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -492,69 +492,6 @@ Perl_huge(void)
 }
 #endif
 
-#ifndef USE_SFIO
-int
-perlsio_binmode(FILE *fp, int iotype, int mode)
-{
-    /*
-     * This used to be contents of do_binmode in doio.c
-     */
-#ifdef DOSISH
-#  if defined(atarist) || defined(__MINT__)
-    if (!fflush(fp)) {
-        if (mode & O_BINARY)
-            ((FILE *) fp)->_flag |= _IOBIN;
-        else
-            ((FILE *) fp)->_flag &= ~_IOBIN;
-        return 1;
-    }
-    return 0;
-#  else
-    dTHX;
-#ifdef NETWARE
-    if (PerlLIO_setmode(fp, mode) != -1) {
-#else
-    if (PerlLIO_setmode(fileno(fp), mode) != -1) {
-#endif
-#    if defined(WIN32) && defined(__BORLANDC__)
-        /*
-         * The translation mode of the stream is maintained independent 
-of
-         * the translation mode of the fd in the Borland RTL (heavy
-         * digging through their runtime sources reveal).  User has to 
-set
-         * the mode explicitly for the stream (though they don't 
-document
-         * this anywhere). GSAR 97-5-24
-         */
-        fseek(fp, 0L, 0);
-        if (mode & O_BINARY)
-            fp->flags |= _F_BIN;
-        else
-            fp->flags &= ~_F_BIN;
-#    endif
-        return 1;
-    }
-    else
-        return 0;
-#  endif
-#else
-#  if defined(USEMYBINMODE)
-    dTHX;
-    if (my_binmode(fp, iotype, mode) != FALSE)
-        return 1;
-    else
-        return 0;
-#  else
-    PERL_UNUSED_ARG(fp);
-    PERL_UNUSED_ARG(iotype);
-    PERL_UNUSED_ARG(mode);
-    return 1;
-#  endif
-#endif
-}
-#endif /* sfio */
-
 /* compatibility with versions <= 5.003. */
 void
 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
index 9a7c0bc..2505614 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -112,6 +112,69 @@ int mkstemp(char*);
        else                                                    \
                SETERRNO(EBADF, SS_IVCHAN)
 
+#ifndef USE_SFIO
+int
+perlsio_binmode(FILE *fp, int iotype, int mode)
+{
+    /*
+     * This used to be contents of do_binmode in doio.c
+     */
+#ifdef DOSISH
+#  if defined(atarist) || defined(__MINT__)
+    if (!fflush(fp)) {
+        if (mode & O_BINARY)
+            ((FILE *) fp)->_flag |= _IOBIN;
+        else
+            ((FILE *) fp)->_flag &= ~_IOBIN;
+        return 1;
+    }
+    return 0;
+#  else
+    dTHX;
+#ifdef NETWARE
+    if (PerlLIO_setmode(fp, mode) != -1) {
+#else
+    if (PerlLIO_setmode(fileno(fp), mode) != -1) {
+#endif
+#    if defined(WIN32) && defined(__BORLANDC__)
+        /*
+         * The translation mode of the stream is maintained independent 
+of
+         * the translation mode of the fd in the Borland RTL (heavy
+         * digging through their runtime sources reveal).  User has to 
+set
+         * the mode explicitly for the stream (though they don't 
+document
+         * this anywhere). GSAR 97-5-24
+         */
+        fseek(fp, 0L, 0);
+        if (mode & O_BINARY)
+            fp->flags |= _F_BIN;
+        else
+            fp->flags &= ~_F_BIN;
+#    endif
+        return 1;
+    }
+    else
+        return 0;
+#  endif
+#else
+#  if defined(USEMYBINMODE)
+    dTHX;
+    if (my_binmode(fp, iotype, mode) != FALSE)
+        return 1;
+    else
+        return 0;
+#  else
+    PERL_UNUSED_ARG(fp);
+    PERL_UNUSED_ARG(iotype);
+    PERL_UNUSED_ARG(mode);
+    return 1;
+#  endif
+#endif
+}
+#endif /* sfio */
+
 #ifndef O_ACCMODE
 #define O_ACCMODE 3             /* Assume traditional implementation */
 #endif