Change 13849 by jhi@alpha on 2001/12/22 16:40:24

        Integrate perlio;
        Fix mis-parse of autoloaded usage code by declaring the sub
        Correct checking code which Ilya spotted was tripped by CR at EOF.
               The CR at EOF fix earlier broke CR at end-of-buffer.

Affected files ...

.... //depot/perl/ext/POSIX/POSIX.pm#26 integrate
.... //depot/perl/perlio.c#154 integrate
.... //depot/perl/regexec.c#216 edit
.... //depot/perl/sv.c#501 integrate

Differences ...

==== //depot/perl/ext/POSIX/POSIX.pm#26 (text) ====
Index: perl/ext/POSIX/POSIX.pm
--- perl/ext/POSIX/POSIX.pm.~1~ Sat Dec 22 09:45:06 2001
+++ perl/ext/POSIX/POSIX.pm     Sat Dec 22 09:45:06 2001
@@ -20,6 +20,8 @@
 }
 
 sub croak { require Carp;  goto &Carp::croak }
+# declare usage to assist AutoLoad
+sub usage;
 
 XSLoader::load 'POSIX', $VERSION;
 
@@ -56,17 +58,17 @@
 1;
 __END__
 
-sub usage { 
+sub usage {
     my ($mess) = @_;
     croak "Usage: POSIX::$mess";
 }
 
-sub redef { 
+sub redef {
     my ($mess) = @_;
     croak "Use method $mess instead";
 }
 
-sub unimpl { 
+sub unimpl {
     my ($mess) = @_;
     $mess =~ s/xxx//;
     croak "Unimplemented: POSIX::$mess";
@@ -898,7 +900,7 @@
     chmod mkdir stat umask
     times
     wait waitpid
-    gmtime localtime time 
+    gmtime localtime time
     alarm chdir chown close fork getlogin getppid getpgrp link
        pipe read rmdir sleep unlink write
     utime

==== //depot/perl/perlio.c#154 (text) ====
Index: perl/perlio.c
--- perl/perlio.c.~1~   Sat Dec 22 09:45:06 2001
+++ perl/perlio.c       Sat Dec 22 09:45:06 2001
@@ -3520,11 +3520,13 @@
                    /*
                     * Blast - found CR as last char in buffer
                     */
+            
                    if (b->ptr < nl) {
                        /*
                         * They may not care, defer work as long as
                         * possible
                         */
+                       c->nl = nl;
                        return (nl - b->ptr);
                    }
                    else {
@@ -3545,6 +3547,7 @@
                        /*
                         * CR at EOF - just fall through
                         */
+                       /* Should we clear EOF though ??? */
                    }
                }
            }
@@ -3563,12 +3566,15 @@
     if (!b->buf)
        PerlIO_get_base(f);
     if (!ptr) {
-       if (c->nl)
+       if (c->nl) {
            ptr = c->nl + 1;
+            if (ptr == b->end && *c->nl == 0xd) {
+               /* Defered CR at end of buffer case - we lied about count */
+               ptr--;  
+            }
+        }
        else {
            ptr = b->end;
-           if ((flags & PERLIO_F_CRLF) && ptr > b->buf && ptr[-1] == 0xd)
-               ptr--;
        }
        ptr -= cnt;
     }
@@ -3576,19 +3582,15 @@
        /*
         * Test code - delete when it works ...
         */
-       STDCHAR *chk;
-       if (c->nl)
-           chk = c->nl + 1;
-       else {
-           chk = b->end;
-           if ((flags & PERLIO_F_CRLF) && chk > b->buf && chk[-1] == 0xd)
-               chk--;
-       }
+       STDCHAR *chk = (c->nl) ? (c->nl+1) : b->end;
+        if (ptr+cnt == c->nl && c->nl+1 == b->end && *c->nl == 0xd) {
+         /* Defered CR at end of buffer case - we lied about count */
+         chk--;
+        } 
        chk -= cnt;
 
-       if (ptr != chk) {
-           dTHX;
-           Perl_croak(aTHX_ "ptr wrong %p != %p fl=%08" UVxf
+       if (ptr != chk ) {
+           Perl_warn(aTHX_ "ptr wrong %p != %p fl=%08" UVxf
                       " nl=%p e=%p for %d", ptr, chk, flags, c->nl,
                       b->end, cnt);
        }

==== //depot/perl/regexec.c#216 (text) ====
==== //depot/perl/sv.c#501 (text) ====
Index: perl/sv.c
--- perl/sv.c.~1~       Sat Dec 22 09:45:06 2001
+++ perl/sv.c   Sat Dec 22 09:45:06 2001
@@ -5666,7 +5666,7 @@
     DEBUG_P(PerlIO_printf(Perl_debug_log,
        "Screamer: entering, ptr=%"UVuf", cnt=%ld\n",PTR2UV(ptr),(long)cnt));
     DEBUG_P(PerlIO_printf(Perl_debug_log,
-       "Screamer: entering: FILE * thinks ptr=%"UVuf", cnt=%ld, base=%"UVuf"\n",
+       "Screamer: entering: PerlIO * thinks ptr=%"UVuf", cnt=%ld, base=%"UVuf"\n",
               PTR2UV(PerlIO_get_ptr(fp)), (long)PerlIO_get_cnt(fp),
               PTR2UV(PerlIO_has_base(fp) ? PerlIO_get_base(fp) : 0)));
     for (;;) {
@@ -5701,18 +5701,22 @@
                              "Screamer: going to getc, ptr=%"UVuf", cnt=%ld\n",
                              PTR2UV(ptr),(long)cnt));
        PerlIO_set_ptrcnt(fp, (STDCHAR*)ptr, cnt); /* deregisterize cnt and ptr */
+#if 0
        DEBUG_P(PerlIO_printf(Perl_debug_log,
            "Screamer: pre: FILE * thinks ptr=%"UVuf", cnt=%ld, base=%"UVuf"\n",
            PTR2UV(PerlIO_get_ptr(fp)), (long)PerlIO_get_cnt(fp),
            PTR2UV(PerlIO_has_base (fp) ? PerlIO_get_base(fp) : 0)));
+#endif
        /* This used to call 'filbuf' in stdio form, but as that behaves like
           getc when cnt <= 0 we use PerlIO_getc here to avoid introducing
           another abstraction.  */
        i   = PerlIO_getc(fp);          /* get more characters */
+#if 0
        DEBUG_P(PerlIO_printf(Perl_debug_log,
            "Screamer: post: FILE * thinks ptr=%"UVuf", cnt=%ld, base=%"UVuf"\n",
            PTR2UV(PerlIO_get_ptr(fp)), (long)PerlIO_get_cnt(fp),
            PTR2UV(PerlIO_has_base (fp) ? PerlIO_get_base(fp) : 0)));
+#endif
        cnt = PerlIO_get_cnt(fp);
        ptr = (STDCHAR*)PerlIO_get_ptr(fp);     /* reregisterize cnt and ptr */
        DEBUG_P(PerlIO_printf(Perl_debug_log,
End of Patch.

Reply via email to