Change 13621 by jhi@alpha on 2001/12/11 14:33:14

        Try to handle platforms that have O_TEXT != O_BINARY but
        which are not DOSish, BeOS being one of such platforms.
        Ideally this should be a Configure test, not a hardwired
        cpp symbol test... 

Affected files ...

.... //depot/perl/doio.c#181 edit
.... //depot/perl/perl.h#419 edit
.... //depot/perl/perlio.c#147 edit
.... //depot/perl/perliol.h#23 edit

Differences ...

==== //depot/perl/doio.c#181 (text) ====
Index: perl/doio.c
--- perl/doio.c.~1~     Tue Dec 11 07:45:06 2001
+++ perl/doio.c Tue Dec 11 07:45:06 2001
@@ -1107,7 +1107,11 @@
  /* The old body of this is now in non-LAYER part of perlio.c
   * This is a stub for any XS code which might have been calling it.
   */
- char *name = (O_BINARY != O_TEXT && !(mode & O_BINARY)) ? ":crlf" : ":raw";
+ char *name = ":raw";
+#ifdef PERLIO_CRLF
+ if (!(mode & O_BINARY)))
+     name = ":crlf";
+#endif
  return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
 }
 

==== //depot/perl/perl.h#419 (text) ====
Index: perl/perl.h
--- perl/perl.h.~1~     Tue Dec 11 07:45:06 2001
+++ perl/perl.h Tue Dec 11 07:45:06 2001
@@ -3925,6 +3925,18 @@
 #  define O_TEXT 0
 #endif
 
+#if O_TEXT != O_BINARY
+    /* If you have different O_TEXT and O_BINARY and you are a CLRF shop,
+     * that is, you are somehow DOSish. */
+#   if !defined(__BEOS__)
+#      define PERLIO_CLRF 1
+#   else
+    /* If you have O_TEXT different from your O_BINARY but you still are
+     * not a CRLF shop. */
+#       undef PERLIO_CLRF
+#   endif
+#endif
+
 #ifdef IAMSUID
 
 #ifdef I_SYS_STATVFS

==== //depot/perl/perlio.c#147 (text) ====
Index: perl/perlio.c
--- perl/perlio.c.~1~   Tue Dec 11 07:45:06 2001
+++ perl/perlio.c       Tue Dec 11 07:45:06 2001
@@ -859,14 +859,12 @@
 PerlIO_default_buffer(pTHX_ PerlIO_list_t *av)
 {
     PerlIO_funcs *tab = &PerlIO_perlio;
-    if (O_BINARY != O_TEXT) {
-       tab = &PerlIO_crlf;
-    }
-    else {
-       if (PerlIO_stdio.Set_ptrcnt) {
-           tab = &PerlIO_stdio;
-       }
-    }
+#ifdef PERLIO_CRLF
+    tab = &PerlIO_crlf;
+#endif
+    if (PerlIO_stdio.Set_ptrcnt)
+        tab = &PerlIO_stdio;
+#else
     PerlIO_debug("Pushing %s\n", tab->name);
     PerlIO_list_push(aTHX_ av, PerlIO_find_layer(aTHX_ tab->name, 0, 0),
                     &PL_sv_undef);
@@ -1078,7 +1076,8 @@
     /* Can't flush if switching encodings. */
     if (!(names && memEQ(names, ":encoding(", 10))) {
         PerlIO_flush(f);
-       if (!names && (O_TEXT != O_BINARY && (mode & O_BINARY))) {
+#ifdef PERLIO_CRLF
+       if (!names && (mode & O_BINARY)) {
            PerlIO *top = f;
            while (*top) {
                if (PerlIOBase(top)->tab == &PerlIO_crlf) {
@@ -1089,6 +1088,7 @@
                PerlIO_flush(top);
            }
        }
+#endif
     }
     return PerlIO_apply_layers(aTHX_ f, NULL, names) == 0 ? TRUE : FALSE;
 }
@@ -1781,7 +1781,7 @@
            *s++ = '+';
        }
     }
-#if O_TEXT != O_BINARY
+#ifdef PERLIO_CRLF
     if (!(flags & PERLIO_F_CRLF))
        *s++ = 'b';
 #endif
@@ -2367,9 +2367,9 @@
     while (*mode) {
        *tmode++ = *mode++;
     }
-    if (O_BINARY != O_TEXT) {
-       *tmode++ = 'b';
-    }
+#ifdef PERLIO_CRLF
+    *tmode++ = 'b';
+#endif
     *tmode = '\0';
     return ret;
 }
@@ -2906,7 +2906,7 @@
                return NULL;
            } else {
                fd = PerlIO_fileno(f);
-#if (O_BINARY != O_TEXT) && !defined(__BEOS__)
+#ifdef PERLIO_CRLF
                /*
                 * do something about failing setmode()? --jhi
                 */

==== //depot/perl/perliol.h#23 (text) ====
Index: perl/perliol.h
--- perl/perliol.h.~1~  Tue Dec 11 07:45:06 2001
+++ perl/perliol.h      Tue Dec 11 07:45:06 2001
@@ -111,7 +111,7 @@
 extern SV *PerlIO_arg_fetch(PerlIO_list_t *av, IV n);
 #define PerlIOArg PerlIO_arg_fetch(layers,n)
 
-#if O_BINARY != O_TEXT
+#ifdef PERLIO_CRLF
 #define PERLIO_STDTEXT "t"
 #else
 #define PERLIO_STDTEXT ""
End of Patch.

Reply via email to