Change 20956 by [EMAIL PROTECTED] on 2003/08/30 18:38:05

        This is probably a wrong fix for
        [perl #23645] tell with perlio on appended files
        but maybe this gets NI-S agitated enough to present the correct fix :-)

Affected files ...

... //depot/perl/perlio.c#238 edit
... //depot/perl/t/io/tell.t#20 edit

Differences ...

==== //depot/perl/perlio.c#238 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#237~20954~    Sat Aug 30 10:14:19 2003
+++ perl/perlio.c       Sat Aug 30 11:38:05 2003
@@ -2375,6 +2375,28 @@
     return code;
 }
 
+IV
+PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
+{
+    int fd = PerlIOSelf(f, PerlIOUnix)->fd;
+    Off_t new;
+    if (PerlIOBase(f)->flags & PERLIO_F_NOTREG) {
+#ifdef  ESPIPE
+       SETERRNO(ESPIPE, LIB_INVARG);
+#else
+       SETERRNO(EINVAL, LIB_INVARG);
+#endif
+       return -1;
+    }
+    new  = PerlLIO_lseek(fd, offset, whence);
+    if (new == (Off_t) - 1)
+     {
+      return -1;
+     }
+    PerlIOBase(f)->flags &= ~PERLIO_F_EOF;
+    return  0;
+}
+
 PerlIO *
 PerlIOUnix_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers,
                IV n, const char *mode, int fd, int imode,
@@ -2409,6 +2431,8 @@
        }
         PerlIOUnix_setfd(aTHX_ f, fd, imode);
        PerlIOBase(f)->flags |= PERLIO_F_OPEN;
+       if (*mode == IoTYPE_APPEND)
+           PerlIOUnix_seek(aTHX_ f, 0, SEEK_END);
        return f;
     }
     else {
@@ -2483,28 +2507,6 @@
        }
        PERL_ASYNC_CHECK();
     }
-}
-
-IV
-PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
-{
-    int fd = PerlIOSelf(f, PerlIOUnix)->fd;
-    Off_t new;
-    if (PerlIOBase(f)->flags & PERLIO_F_NOTREG) {
-#ifdef  ESPIPE
-       SETERRNO(ESPIPE, LIB_INVARG);
-#else
-       SETERRNO(EINVAL, LIB_INVARG);
-#endif
-       return -1;
-    }
-    new  = PerlLIO_lseek(fd, offset, whence);
-    if (new == (Off_t) - 1)
-     {
-      return -1;
-     }
-    PerlIOBase(f)->flags &= ~PERLIO_F_EOF;
-    return  0;
 }
 
 Off_t

==== //depot/perl/t/io/tell.t#20 (xtext) ====
Index: perl/t/io/tell.t
--- perl/t/io/tell.t#19~19585~  Wed May 21 12:28:23 2003
+++ perl/t/io/tell.t    Sat Aug 30 11:38:05 2003
@@ -7,7 +7,7 @@
     @INC = '../lib';
 }
 
-print "1..27\n";
+print "1..28\n";
 
 $TST = 'tst';
 
@@ -143,4 +143,12 @@
 
 close($tst);
 
+open($tst,">$written")  || die "Cannot open $written:$!";
+print $tst "foobar";
+close $tst;
+open($tst,">>$written")  || die "Cannot open $written:$!";
+
+if (tell($tst) == 6)
+{ print "ok 28\n"; } else { print "not ok 28\n"; }
+close $tst;
 
End of Patch.

Reply via email to