Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.88k stars 531 forks source link

Not OK: perl v5.7.1 +DEVEL10721 +devel-10722 on alpha-dec_osf-per lio 4.0f (UNINSTALLED) #4100

Closed p5pRT closed 20 years ago

p5pRT commented 23 years ago

Migrated from rt.perl.org#7135 (status was 'resolved')

Searchable as RT7135$

p5pRT commented 23 years ago

From spider@Orb.Nashua.NH.US

PERLIO=unix breaks some tests. One of them I had to fix this snapshot just to get it to run again. Specifically\, the last pack test for warnings.t fails\, but warnings.t wasn't patched to reflect moving its test data on it. Otherwise\, the phantom test 28 of POSIX.t\, t/io/tell.t test 10\, and ext/IO/lib/IO/t/io_tell.t test 10 fail. The two 'tell' tests fail because of a bug in perlio itself. The others are bad expectations on the part of the tests for the unixio case.

Finally\, while I'm here\, fix the bad assumption in t/lib/1_compile.t that somehow thinks lib/attributes.pm doesn't get tested. (What d'you think t/op/attrs.t tests? Hint--it says right at the top.)

Patched files​: ./ext/POSIX/POSIX.t ./lib/warnings.t ./t/lib/1_compile.t ./t/lib/warnings/pp ./perlio.c

(Of course\, t/lib/warnings/pp should be split\, with the pp_pack data showing in a new file\, but this at leasts gets them reporting properly and working under PERLIO=unix.)

Inline Patch ```diff --- ./ext/POSIX/POSIX.t.DIST Mon Jun 18 01:21:16 2001 +++ ./ext/POSIX/POSIX.t Tue Jun 19 14:54:00 2001 @@ -135,5 +135,8 @@ $| = 0; # The following line assumes buffered output, which may be not true with EMX: -print '@#!*$@(!@#$' unless ($^O eq 'os2' || $^O eq 'uwin' || $^O eq 'os390'); +print '@#!*$@(!@#$' unless ($^O eq 'os2' || $^O eq 'uwin' || $^O eq 'os390' || + (defined $ENV{PERLIO} && + $ENV{PERLIO} eq 'unix' && + $Config::Config{useperlio})); _exit(0); --- ./lib/warnings.t.DIST Mon Jun 18 08:52:00 2001 +++ ./lib/warnings.t Tue Jun 19 14:47:30 2001 @@ -21,9 +21,9 @@ my @w_files = () ; if (@ARGV) - { print "ARGV = [@ARGV]\n" ; @w_files = map { s#^#./pragma/warn/#; $_ } @ARGV } + { print "ARGV = [@ARGV]\n" ; @w_files = map { s#^#./lib/warnings/#; $_ } @ARGV } else - { @w_files = sort glob("pragma/warn/*") } + { @w_files = sort glob("lib/warnings/*") } my $files = 0; foreach my $file (@w_files) { --- ./t/lib/1_compile.t.DIST Sat Jun 16 18:49:41 2001 +++ ./t/lib/1_compile.t Tue Jun 19 14:52:55 2001 @@ -251,6 +251,7 @@ User::grent User::pwent XS::Typemap +attributes attrs autouse base --- ./t/lib/warnings/pp.orig Mon Jun 18 10:32:19 2001 +++ ./t/lib/warnings/pp Tue Jun 19 15:20:55 2001 @@ -63,7 +63,7 @@ EXPECT Odd number of elements in hash assignment at - line 3. ######## -# pp.c +# pp_pack.c use warnings 'pack' ; use warnings 'unpack' ; my @a = unpack ("A,A", "22") ; @@ -85,7 +85,7 @@ EXPECT Use of uninitialized value in scalar dereference at - line 4. ######## -# pp.c +# pp_pack.c use warnings 'pack' ; sub foo { my $a = "a"; return $a . $a++ . $a++ } my $a = pack("p", &foo) ; @@ -108,16 +108,16 @@ reverse ; EXPECT ######## -# pp.c +# pp_pack.c use warnings 'pack' ; -print unpack("C", pack("C", -1)), "\n"; -print unpack("C", pack("C", 0)), "\n"; -print unpack("C", pack("C", 255)), "\n"; -print unpack("C", pack("C", 256)), "\n"; -print unpack("c", pack("c", -129)), "\n"; -print unpack("c", pack("c", -128)), "\n"; -print unpack("c", pack("c", 127)), "\n"; -print unpack("c", pack("c", 128)), "\n"; +print unpack("C", pack("C", -1)), "\n", + unpack("C", pack("C", 0)), "\n", + unpack("C", pack("C", 255)), "\n", + unpack("C", pack("C", 256)), "\n", + unpack("c", pack("c", -129)), "\n", + unpack("c", pack("c", -128)), "\n", + unpack("c", pack("c", 127)), "\n", + unpack("c", pack("c", 128)), "\n"; no warnings 'pack' ; print unpack("C", pack("C", -1)), "\n"; print unpack("C", pack("C", 0)), "\n"; @@ -129,9 +129,9 @@ print unpack("c", pack("c", 128)), "\n"; EXPECT Character in "C" format wrapped at - line 3. -Character in "C" format wrapped at - line 6. -Character in "c" format wrapped at - line 7. -Character in "c" format wrapped at - line 10. +Character in "C" format wrapped at - line 3. +Character in "c" format wrapped at - line 3. +Character in "c" format wrapped at - line 3. 255 0 255 --- ./perlio.c.DIST Sat Jun 16 16:49:29 2001 +++ ./perlio.c Tue Jun 19 14:53:00 2001 @@ -2800,17 +2800,24 @@ PerlIOBuf_unread(PerlIO *f, const void * if (PerlIOBase(f)->flags & PERLIO_F_RDBUF) { avail = (b->ptr - b->buf); + if (avail > (SSize_t) count) + avail = count; } else { avail = b->bufsiz; + /* Adjust this here to keep a subsequent tell() correct. + * (b->ptr - b->buf) *MUST* be an accurate reflection of the amount + * unread in this buffer. (See previous part of the if for an example, + * or try PERLIO=unix on t/io/tell.t.) + */ + if (avail > (SSize_t) count) + avail = count; b->end = b->buf + avail; b->ptr = b->end; PerlIOBase(f)->flags |= PERLIO_F_RDBUF; - b->posn -= b->bufsiz; + b->posn -= avail; } - if (avail > (SSize_t) count) - avail = count; if (avail > 0) { b->ptr -= avail; ```
Perl Info ``` Flags: category=install severity=none Site configuration information for perl v5.7.1: Configured by spider at Tue Jun 19 14:12:40 EDT 2001. Summary of my perl5 (revision 5.0 version 7 subversion 17) configuration: Platform: osname=dec_osf, osvers=4.0f, archname=alpha-dec_osf-perlio uname='osf1 orb.nashua.nh.us v4.0 1229 alpha ' config_args='-dsEO -Dusedevel -Uversiononly -Darchlib=/local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio -Darchname=alpha-dec_osf-perlio -Dbin=/local/bin/pexp -Dbinexp=/local/bin/pexp -Dcc=cc -Dccflags=-std -I/usr/local/include -DDEBUGGING -DDEBUGGING_OPS -D_INTRINSICS -D_INLINE_INTRINSICS -Drand=__random -Dsrand=__srandom -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC -DEMBEDMYMALLOC= -fprm d -ieee -Ud_bincompat3 -Ud_bincompat5005 -Dd_dosuid=define -Dinc_version_list= -Uinc_version_list_init= -Dinstallbin=/local/OSF1/alpha/bin/pexp -Uinstallstyle= -Dlddlflags=-shared -msym -expect_unresolved "*" -g -std -Dldflags=-std -msym -g -Dlibswanted=sfio gdbm m iconv -Ulibsfiles= -Ulibsfound= -Dman1dir=/local/man/man1 -Dman1ext=1 -Dman3dir=/local/man/man3 -Dman3ext=3pl -Doptimize=-g -Dpager=/local/bin/less -Dprefix=/local/opt/perl -Dscriptdir=/local/share/pexp -Dsitebin=/local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio/bin -Dsitevers=5.7.1 -Usitebinexp= -Uinstallsitebin= -Dsitelib=/local/opt/per! l/lib/site_perl/5.7.1 -Dsitearch=/local/opt/perl/lib/site_perl/5.7.1/alpha-dec_osf-perlio -Duseshrplib -Ud_safemcpy= -Ud_sfio= -Ui_dbm -Uinstallarchlib= -Uinstallprivlib= -Uinstallscript= -Uinstallsitearch= -Uinstallsitelib= -Uinstallusrbinperl -Ulibs= -Uperlpath= -Uprivlib= -Urandbits= -Uusethreads -Dlibperl=libperlshr.so -Dusemymalloc=y -Duseperlio -e' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef Compiler: cc='cc', ccflags ='-std -I/usr/local/include -DDEBUGGING -DDEBUGGING_OPS -D_INTRINSICS -D_INLINE_INTRINSICS -Drand=__random -Dsrand=__srandom -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC -DEMBEDMYMALLOC= -fprm d -ieee', optimize='-g', cppflags='-std -I/usr/local/include -DDEBUGGING -DDEBUGGING_OPS -D_INTRINSICS -D_INLINE_INTRINSICS -Drand=__random -Dsrand=__srandom -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC -DEMBEDMYMALLOC= -ieee' ccversion='V6.3-129', gccversion='', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='ld', ldflags ='-std -msym -g -L/usr/local/lib' libpth=/usr/local/lib /usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /var/shlib libs=-lm -liconv perllibs=-lm -liconv libc=/usr/shlib/libc.so, so=so, useshrplib=true, libperl=libperlshr.so Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-rpath,/local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio/CORE' cccdlflags=' ', lddlflags='-shared -msym -expect_unresolved "*" -g -std -L/usr/local/lib' Locally applied patches: DEVEL10721 devel-10722 @INC for perl v5.7.1: lib /local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio /local/opt/perl/lib/5.7.1 /local/opt/perl/lib/site_perl/5.7.1/alpha-dec_osf-perlio /local/opt/perl/lib/site_perl/5.7.1 /local/opt/perl/lib/site_perl . Environment for perl v5.7.1: HOME=/users/spider LANG=en_US.ISO8859-1 LANGUAGE (unset) LD_LIBRARY_PATH=/local/src/perl/bleadperl LOGDIR (unset) PATH=/users/spider/bin/OSF1/alpha:/users/spider/bin:/local/OSF1/alpha/bin:/local/share:/local/OSF1/alpha/sbin:/local/etc:/usr/local:/tcb/bin:/usr/ccs/bin:/usr/bin:/usr/lbin:/usr/dt/bin:/usr/bin/X11:/usr/bin/mme:/usr/sbin:/sbin:/usr/field:/usr/opt/SWN200/bin:/local/OSF1/alpha/bin/mnt:/local/share/mnt:. PERL_BADLANG (unset) SHELL=/usr/bin/ksh ```
p5pRT commented 23 years ago

From @jhi

Thanks\, applied.

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

It always has\, it makes the "stream" completely unbuffered and that isn't really very perlish.

Making all the tests work with PERLIO=unix is not very interesting. Indeed the "unix" layer is there for obscure cases where you want direct control over what gets written - so "fixing" unix layer to make tests pass is counter productive. That said you may have found a bug in the "unread" case which is used to "fake" a buffer out of nothingness - but I am not sure your fix is correct see discussion below.

PERLIO=stdio and PERLIO=perlio is sufficient.

Patched files​: ./perlio.c

--- ./perlio.c.DIST Sat Jun 16 16​:49​:29 2001 +++ ./perlio.c Tue Jun 19 14​:53​:00 2001 @​@​ -2800\,17 +2800\,24 @​@​ PerlIOBuf_unread(PerlIO *f\, const void * if (PerlIOBase(f)->flags & PERLIO_F_RDBUF) { avail = (b->ptr - b->buf); + if (avail > (SSize_t) count) + avail = count; } else { avail = b->bufsiz; + /* Adjust this here to keep a subsequent tell() correct. + * (b->ptr - b->buf) *MUST* be an accurate reflection of the amount + * unread in this buffer.

Sorry but no\, (b->end - b->ptr) is the amount unread. (b->ptr - b->buf) is the amount that HAS BEEN read. unread() _reduces_ the amount that has been read.

In addition b->posn is the file location of b->buf[0]\, so "tell" takes b->posn (where buffer is)\, and adds the amount that HAS BEEN read to get logical position.

The idea of unread code was in the simple case where we are doing ungetc() type things to move ->ptr back towards the start of the buffer and copy the unread stuff into space so created.

If the buffer was empty then it makes sense to put the data at the _end_ of the buffer in case another unread comes along.

There may well be a bug\, but I am not convinced the patch is correct with the spirit of what I intended.

The ungetc() case it unchanged by your patch as you just moved avail/count compare into its block.

The intent of the "buffer idle" case was to set up the state so that whole buffer was "available"\, and then fall through to chip just "count" bytes off the end. I thought it worked - what may be an issue I guess is if b->posn goes -ve and Off_t is unsigned. But if that is the problem then clamping b->posn @​ 0 is the right fix\, not anything related to count.

  \(See previous part of the if for an example\,

+ * or try PERLIO=unix on t/io/tell.t.) + */ + if (avail > (SSize_t) count) + avail = count; b->end = b->buf + avail; b->ptr = b->end; PerlIOBase(f)->flags |= PERLIO_F_RDBUF; - b->posn -= b->bufsiz; + b->posn -= avail; } - if (avail > (SSize_t) count) - avail = count; if (avail > 0) { b->ptr -= avail;

[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags​: category=install severity=none --- Site configuration information for perl v5.7.1​:

Configured by spider at Tue Jun 19 14​:12​:40 EDT 2001.

Summary of my perl5 (revision 5.0 version 7 subversion 17) configuration​: Platform​: osname=dec_osf\, osvers=4.0f\, archname=alpha-dec_osf-perlio uname='osf1 orb.nashua.nh.us v4.0 1229 alpha ' config_args='-dsEO -Dusedevel -Uversiononly -Darchlib=/local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio -Darchname=alpha-dec_osf-perlio -Dbin=/local/bin/pexp -Dbinexp=/local/bin/pexp -Dcc=cc -Dccflags=-std -I/usr/local/include -DDEBUGGING -DDEBUGGING_OPS -D_INTRINSICS -D_INLINE_INTRINSICS -Drand=__random -Dsrand=__srandom -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC -DEMBEDMYMALLOC= -fprm d -ieee -Ud_bincompat3 -Ud_bincompat5005 -Dd_dosuid=define -Dinc_version_list= -Uinc_version_list_init= -Dinstallbin=/local/OSF1/alpha/bin/pexp -Uinstallstyle= -Dlddlflags=-shared -msym -expect_unresolved "*" -g -std -Dldflags=-std -msym -g -Dlibswanted=sfio gdbm m iconv -Ulibsfiles= -Ulibsfound= -Dman1dir=/local/man/man1 -Dman1ext=1 -Dman3dir=/local/man/man3 -Dman3ext=3pl -Doptimize=-g -Dpager=/local/bin/less -Dprefix=/local/opt/perl -Dscriptdir=/local/share/pexp -Dsitebin=/local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio/bin -Dsitevers=5.7.1 -Usitebinexp= -Uinstallsitebin= -Dsitelib=/local/opt/per! l/lib/site_perl/5.7.1 -Dsitearch=/local/opt/perl/lib/site_perl/5.7.1/alpha-dec_osf-perlio -Duseshrplib -Ud_safemcpy= -Ud_sfio= -Ui_dbm -Uinstallarchlib= -Uinstallprivlib= -Uinstallscript= -Uinstallsitearch= -Uinstallsitelib= -Uinstallusrbinperl -Ulibs= -Uperlpath= -Uprivlib= -Urandbits= -Uusethreads -Dlibperl=libperlshr.so -Dusemymalloc=y -Duseperlio -e' hint=recommended\, useposix=true\, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef Compiler​: cc='cc'\, ccflags ='-std -I/usr/local/include -DDEBUGGING -DDEBUGGING_OPS -D_INTRINSICS -D_INLINE_INTRINSICS -Drand=__random -Dsrand=__srandom -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC -DEMBEDMYMALLOC= -fprm d -ieee'\, optimize='-g'\, cppflags='-std -I/usr/local/include -DDEBUGGING -DDEBUGGING_OPS -D_INTRINSICS -D_INLINE_INTRINSICS -Drand=__random -Dsrand=__srandom -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC -DEMBEDMYMALLOC= -ieee' ccversion='V6.3-129'\, gccversion=''\, gccosandvers='' intsize=4\, longsize=8\, ptrsize=8\, doublesize=8\, byteorder=12345678 d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=8 ivtype='long'\, ivsize=8\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8 alignbytes=8\, usemymalloc=y\, prototype=define Linker and Libraries​: ld='ld'\, ldflags ='-std -msym -g -L/usr/local/lib' libpth=/usr/local/lib /usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /var/shlib libs=-lm -liconv perllibs=-lm -liconv libc=/usr/shlib/libc.so\, so=so\, useshrplib=true\, libperl=libperlshr.so Dynamic Linking​: dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags=' -Wl\,-rpath\,/local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio/CORE' cccdlflags=' '\, lddlflags='-shared -msym -expect_unresolved "*" -g -std -L/usr/local/lib'

Locally applied patches​: DEVEL10721 devel-10722

--- @​INC for perl v5.7.1​: lib /local/opt/perl/lib/5.7.1/alpha-dec_osf-perlio /local/opt/perl/lib/5.7.1 /local/opt/perl/lib/site_perl/5.7.1/alpha-dec_osf-perlio /local/opt/perl/lib/site_perl/5.7.1 /local/opt/perl/lib/site_perl .

--- Environment for perl v5.7.1​: HOME=/users/spider LANG=en_US.ISO8859-1 LANGUAGE (unset) LD_LIBRARY_PATH=/local/src/perl/bleadperl LOGDIR (unset) PATH=/users/spider/bin/OSF1/alpha​:/users/spider/bin​:/local/OSF1/alpha/bin​:/local/share​:/local/OSF1/alpha/sbin​:/local/etc​:/usr/local​:/tcb/bin​:/usr/ccs/bin​:/usr/bin​:/usr/lbin​:/usr/dt/bin​:/usr/bin/X11​:/usr/bin/mme​:/usr/sbin​:/sbin​:/usr/field​:/usr/opt/SWN200/bin​:/local/OSF1/alpha/bin/mnt​:/local/share/mnt​:. PERL_BADLANG (unset) SHELL=/usr/bin/ksh

p5pRT commented 23 years ago

From @jhi

Bummer. I already applied the patch. But see below.

Patched files​: ./perlio.c

--- ./perlio.c.DIST Sat Jun 16 16​:49​:29 2001 +++ ./perlio.c Tue Jun 19 14​:53​:00 2001 @​@​ -2800\,17 +2800\,24 @​@​ PerlIOBuf_unread(PerlIO *f\, const void * if (PerlIOBase(f)->flags & PERLIO_F_RDBUF) { avail = (b->ptr - b->buf); + if (avail > (SSize_t) count) + avail = count; } else { avail = b->bufsiz; + /* Adjust this here to keep a subsequent tell() correct. + * (b->ptr - b->buf) *MUST* be an accurate reflection of the amount + * unread in this buffer.

All this wealth of information should find its way to the accompanying code as comments\, right\, so in future people wouldn't make wrong fixes\, right? :-)

Sorry but no\, (b->end - b->ptr) is the amount unread. (b->ptr - b->buf) is the amount that HAS BEEN read. unread() _reduces_ the amount that has been read.

In addition b->posn is the file location of b->buf[0]\, so "tell" takes b->posn (where buffer is)\, and adds the amount that HAS BEEN read to get logical position.

The idea of unread code was in the simple case where we are doing ungetc() type things to move ->ptr back towards the start of the buffer and copy the unread stuff into space so created.

If the buffer was empty then it makes sense to put the data at the _end_ of the buffer in case another unread comes along.

There may well be a bug\, but I am not convinced the patch is correct with the spirit of what I intended.

The ungetc() case it unchanged by your patch as you just moved avail/count compare into its block.

The intent of the "buffer idle" case was to set up the state so that whole buffer was "available"\, and then fall through to chip just "count" bytes off the end. I thought it worked - what may be an issue I guess is if b->posn goes -ve and Off_t is unsigned. But if that is the problem then clamping b->posn @​ 0 is the right fix\, not anything related to count.

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

As far as I can see the rest of Spider's patch is fine\, and his change to perlio.c does not break it as such\, just de-optimizes a common case to fix an un-interesting one\, (and introduces a misleading comment).

I would rather understand the root cause of the "bug".

All this wealth of information should find its way to the accompanying code as comments\, right\, so in future people wouldn't make wrong fixes\, right? :-)

Point taken\, my assumption was that the two key "methods"

SSize_t PerlIOBuf_get_cnt(PerlIO *f) { PerlIOBuf *b = PerlIOSelf(f\,PerlIOBuf); if (!b->buf)   PerlIO_get_base(f); if (PerlIOBase(f)->flags & PERLIO_F_RDBUF)   return (b->end - b->ptr); }

and

Off_t PerlIOBuf_tell(PerlIO *f) { PerlIOBuf *b = PerlIOSelf(f\,PerlIOBuf); Off_t posn = b->posn; if (b->buf)   posn += (b->ptr - b->buf); return posn; }

Were readable enough to be self documenting.

Sorry but no\, (b->end - b->ptr) is the amount unread. (b->ptr - b->buf) is the amount that HAS BEEN read. unread() _reduces_ the amount that has been read.

In addition b->posn is the file location of b->buf[0]\, so "tell" takes b->posn (where buffer is)\, and adds the amount that HAS BEEN read to get logical position.

The idea of unread code was in the simple case where we are doing ungetc() type things to move ->ptr back towards the start of the buffer and copy the unread stuff into space so created.

If the buffer was empty then it makes sense to put the data at the _end_ of the buffer in case another unread comes along.

There may well be a bug\, but I am not convinced the patch is correct with the spirit of what I intended.

The ungetc() case it unchanged by your patch as you just moved avail/count compare into its block.

The intent of the "buffer idle" case was to set up the state so that whole buffer was "available"\, and then fall through to chip just "count" bytes off the end. I thought it worked - what may be an issue I guess is if b->posn goes -ve and Off_t is unsigned. But if that is the problem then clamping b->posn @​ 0 is the right fix\, not anything related to count.

p5pRT commented 23 years ago

From @jhi

I believe no progammer has been born yet who wouldn't honestly believe that his or hers code wouldn't be self-documenting.

p5pRT commented 23 years ago

From @jhi

I also believe no programmer thinks they would ever make typos or that they would ever talk in triple negatives.

p5pRT commented 23 years ago

From @nwc10

Really unhelpful statement I realise\, but IIRC I was aware of 2 bugs\, but not the fixes. 1 might be a not-a-bug-now\, in that I think that something wasn't checking the return of the tell() on the layer below\, and so assuming that -1 was a valid offset like any other number (probably the default buffer layer when stacked atop something unseekable)

The other might also be not-a-bug-now\, but really was\, in that if you are layer unix\, you stack an unread on top of unix\, and then stack a buffer layer on top of that\, the first thing the buffer layer does is flush the layer below (with the intent of syncing things) that has the unfortunate side effect of discarding the unread. There wasn't an obvious solution to this one.

Nicholas Clark

p5pRT commented 23 years ago

From @abigail

Nah\, I don't show off JAPHs that are still self-documenting. ;-)

Abigail

p5pRT commented 23 years ago

From @jhi

Self-encrypting\, maybe.

Abigail

p5pRT commented 23 years ago

From @abigail

Self-correcting [1]​:

  #!/opt/perl/bin/perl -- # Remove trailing newline!   BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;
  truncate$0\,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ

The above program doesn't compile\, however\, running it not only fixes the syntax errors; it prints "Just another Perl Hacker" while doing so too.

It's WORO (write once\, run once)\, after running it once\, we end up with a file that compiles\, but produces no output.

[1] Self-correcting is a much more useful feature than self-documenting.

Abigail

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

==== //depot/perlio/perlio.c#103 - /home/perl5/perlio/perlio.c ==== @​@​ -1776\,11 +1776\,12 @​@​ PerlIOBase_unread(PerlIO *f\, const void *vbuf\, Size_t count) {   dTHX; + /* Save the position as current head considers it */   Off_t old = PerlIO_tell(f);   SSize_t done;   PerlIO_push(aTHX_ f\,&PerlIO_pending\,"r"\,Nullsv); + PerlIOSelf(f\,PerlIOBuf)->posn = old;   done = PerlIOBuf_unread(f\,vbuf\,count); - PerlIOSelf(f\,PerlIOBuf)->posn = old - done;   return done; }

@​@​ -2799\,29 +2800\,31 @​@​   {   if (PerlIOBase(f)->flags & PERLIO_F_RDBUF)   { + /* Buffer is already a read buffer\, we can overwrite any chars + which have been read back to buffer start + */   avail = (b->ptr - b->buf); - if (avail > (SSize_t) count) - avail = count;   }   else   { - avail = b->bufsiz; - /* Adjust this here to keep a subsequent tell() correct. - * (b->ptr - b->buf) *MUST* be an accurate reflection of the amount - * unread in this buffer. (See previous part of the if for an example\, - * or try PERLIO=unix on t/io/tell.t.) - */ - if (avail > (SSize_t) count) - avail = count; + /* Buffer is idle\, set it up so whole buffer is available for unread */ + avail = b->bufsiz;   b->end = b->buf + avail;   b->ptr = b->end;   PerlIOBase(f)->flags |= PERLIO_F_RDBUF; - b->posn -= avail; + /* Buffer extends _back_ from where we are now */ + b->posn -= b->bufsiz; + } + if (avail > (SSize_t) count) + { + /* If we have space for more than count\, just move count */ + avail = count;   }   if (avail > 0)   {   b->ptr -= avail;   buf -= avail; + /* In simple stdio-like ungetc() case chars will be already there */   if (buf != b->ptr)   {   Copy(buf\,b->ptr\,avail\,STDCHAR); @​@​ -2906\,9 +2909\,13 @​@​ PerlIOBuf_tell(PerlIO *f) {   PerlIOBuf *b = PerlIOSelf(f\,PerlIOBuf); + /* b->posn is file position where b->buf was read\, or will be written */   Off_t posn = b->posn;   if (b->buf) - posn += (b->ptr - b->buf); + { + /* If buffer is valid adjust position by amount in buffer */ + posn += (b->ptr - b->buf); + }   return posn; }