This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Updated: Perl 5.8.0-3 breaks binmode()


 I have found a change (patch) that will make stdio work the same as perlio.
Both are broken for text mounts in that they force binary mode.  The is a
bug/feature in fgetc/fopen in the way perl uses them that prevents text mode
from working on read, but works on write.

Here are the diff files:

diff -ur perl-5.8.0~/perlio.c perl-5.8.0/perlio.c
--- perl-5.8.0~/perlio.c 2002-07-11 12:39:36.000000000 -0400
+++ perl-5.8.0/perlio.c 2003-06-17 16:06:39.000000000 -0400
@@ -2484,7 +2484,7 @@
     while (*mode) {
  *tmode++ = *mode++;
     }
-#ifdef PERLIO_USING_CRLF
+#if defined(PERLIO_USING_CRLF) || defined(__CYGWIN__)
     *tmode++ = 'b';
 #endif
     *tmode = '\0';
@@ -2585,15 +2585,15 @@
   fd = PerlLIO_open3(path, imode, perm);
      }
      else {
-  FILE *stdio = PerlSIO_fopen(path, mode);
+  FILE *stdio = PerlSIO_fopen(path,
+                               (mode = PerlIOStdio_mode(mode, tmode)));
   if (stdio) {
       PerlIOStdio *s;
       if (!f) {
    f = PerlIO_allocate(aTHX);
       }
       if ((f = PerlIO_push(aTHX_ f, self,
-        (mode = PerlIOStdio_mode(mode, tmode)),
-        PerlIOArg))) {
+      mode, PerlIOArg))) {
    s = PerlIOSelf(f, PerlIOStdio);
    s->stdio = stdio;
    PerlIOUnix_refcnt_inc(fileno(s->stdio));

Which causes stdio to open ALL files/pipes/etc in binary mode.  (Which is
the same thing that perlio/unix does...)

   -Don Slutz


Don Slutz wrote:

> Nope, I no longer have the perl 5.6.0 patch I was working on (lost the
> disk it was on) and found that binmode() would get around the issue and
> so got put on the back burner...
>
> I will take a quick look at the latest source via setup and see if I can
> figure out the 5.8 version...
>
> I have attached the test files.
>
>    -Don
>
> -----Original Message-----
> From: Gerrit P. Haase [mailto:gp@familiehaase.de]
> Sent: Monday, June 09, 2003 6:12 PM
> To: Don Slutz
> Cc: cygwin@cygwin.com
> Subject: Re: Updated: Perl 5.8.0-3 breaks binmode()
>
> Hallo Don,
>
> > This update breaks the usage of binmode(FH).  I am sure that:
>
> >> News:  Changes: - Moved Cygwin to the non DOSish platforms.
>
> > is the main reason.   Last time I was in the perl sources, I saw that
> > perl only expected two types of file opens; text or binary.  However
> > cygwin supports 3: default, text, and binary.
>
> > I would expect that declaring cygwin to be like VOS (text open is
> > different then binary open; but do not change end of line handling)
> > would be the fix.
>
> Where and what to apply?  Do you have a patch handy for me to test
> with?
>
> > I have also found that | some times does things to end of lines also.
>
> > Here is output of some tests that I ran to validate this issue (tests
> > are available via direct e-mail):
>
> Yes, please send me your tests.
>
> Gerrit
> --
> =^..^=
>
>   ------------------------------------------------------------------------
>
>    Part 1.2    Type: application/ms-tnef
>            Encoding: base64


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]