Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline() not quite as equal as <> #4116

Closed
p5pRT opened this issue Jun 21, 2001 · 11 comments
Closed

readline() not quite as equal as <> #4116

p5pRT opened this issue Jun 21, 2001 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 21, 2001

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

Searchable as RT7154$

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2001

From @jhi

$ perl -we 'open(X, "/etc/motd");<X>'

$ perl -Mstrict -e 'open(X, "/etc/motd");<X>'

$ perl -we 'open(X, "/etc/motd");readline(X)'
Name "main​::X" used only once​: possible typo at -e line 1.

$ perl -Mstrict -e 'open(X, "/etc/motd");readline(X)'
Bareword "X" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

$ perl -v

This is perl, v5.6.1 built for alpha-dec_osf
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http​://www.perl.com/, the Perl Home Page.

Ditto for bleadperl.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.1:

Configured by jhi at Thu Feb  1 06:47:41 EET 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=dec_osf, osvers=4.0, archname=alpha-dec_osf
    uname='osf1 kosh.hut.fi v4.0 1229 alpha '
    config_args='-des -Dprefix=/u/vieraat/vieraat/jhi/Perl'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-std -fprm d -ieee -D_INTRINSICS -DLANGUAGE_C',
    optimize='-O4',
    cppflags='-std -ieee -D_INTRINSICS -DLANGUAGE_C'
    ccversion='V5.9-010', 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 =''
    libpth=/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /var/shlib
    libs=-lgdbm -ldbm -ldb -lm -liconv -lutil
    perllibs=-lm -liconv -lutil
    libc=/usr/shlib/libc.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-rpath,/u/vieraat/vieraat/jhi/Perl/lib/perl5/5.6.1/alpha-dec_osf/CORE'
    cccdlflags=' ', lddlflags='-shared -expect_unresolved "*" -O4 -msym -std -s'

Locally applied patches:
    v5.6.1-TRIAL2


@INC for perl v5.6.1:
    /u/vieraat/vieraat/jhi/Perl/lib
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/5.6.1/alpha-dec_osf
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/5.6.1
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.6.1/alpha-dec_osf
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.6.1
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.6.0/alpha-dec_osf
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.6.0
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.00558/alpha-dec_osf
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.00558
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.00556/alpha-dec_osf
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.00556
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.005/alpha-dec_osf
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl/5.005
    /u/vieraat/vieraat/jhi/Perl/lib/perl5/site_perl
    .


Environment for perl v5.6.1:
    HOME=/u/vieraat/vieraat/jhi
    LANG=C
    LANGUAGE (unset)
    LC_ALL=fi_FI.ISO8859-1
    LC_CTYPE=fi_FI.ISO8859-1
    LD_LIBRARY_PATH=/u/vieraat/vieraat/jhi/pp4/perl
    LOGDIR (unset)
    PATH=/u/vieraat/vieraat/jhi/Perl/bin:/u/vieraat/vieraat/jhi/.s:/u/vieraat/vieraat/jhi/.b/OSF1:/c/bin:/p/bin:/p/adm/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/ccs/bin:/usr/lib:/etc:/lib:/p/X6/bin:/p/X5/bin:/usr/bin/X11:/usr/lbin:/usr/sbin/acct:/usr/tcb/bin:/tcb/bin:/usr/field:/u/vieraat/vieraat/jhi
    PERLLIB=/u/vieraat/vieraat/jhi/Perl/lib
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2001

From [Unknown Contact. See original ticket]

perlfunc only documents the use of C<readline *FH>, but I agree that
C<readline FH> is reasonable (and does in fact work in perl-current).
The appended patch gets rid of the warnings, but it causes test #10 in
op/flip.t to fail. I'm not sure what that test is trying to accomplish.

(Also appended is an entirely unrelated typo fix.)

- ams

Inline Patch
--- perl/opcode.pl~	Sat Jun 23 04:22:46 2001
+++ perl/opcode.pl	Sat Jun 23 04:59:32 2001
@@ -444,7 +444,7 @@
 backtick	quoted execution (``, qx)	ck_open		t%	
 # glob defaults its first arg to $_
 glob		glob			ck_glob		t@	S?
-readline	<HANDLE>		ck_null		t%	
+readline	<HANDLE>		ck_fun		t%	F
 rcatline	append I/O operator	ck_null		t%	
 
 # Bindable operators.

--- perl/toke.c~	Fri Jun 22 23:57:53 2001
+++ perl/toke.c	Sat Jun 23 04:23:15 2001
@@ -43,7 +43,7 @@
 #define UTF ((PL_linestr && DO_UTF8(PL_linestr)) || (PL_hints & HINT_UTF8))
 #endif
 
-/* In variables name $^X, these are the legal values for X.
+/* In variables named $^X, these are the legal values for X.
  * 1999-02-27 mjd-perl-patch@plover.com */
 #define isCONTROLVAR(x) (isUPPER(x) || strchr("[\\]^_?", (x)))

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2001

From @gsar

See​:

  http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-10/msg00795.html

+++ perl/opcode.pl Sat Jun 23 04​:59​:32 2001
@​@​ -444,7 +444,7 @​@​
backtick quoted execution (``, qx) ck_open t%
# glob defaults its first arg to $_
glob glob ck_glob t@​ S?
-readline <HANDLE> ck_null t%
+readline <HANDLE> ck_fun t% F

I'm not entirely sure that this change will be a no-op wrt functionality.
Please check that it preserves the shape and contents of the optree
generated. The flip.t failure worries me.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2001

From @jhi

I'm actually rather confused by this whole thing...

(1) if one takes a look a the the original flip failure (by japhy, IIRC),
  he was testing for

  readline(FOO);$.=1;print "ok\n" if 1..10;

  versus

  <FOO>;$.=1;print "ok\n" if 1..10;

  The readline() version dumped core, the diamond version didn't.
  Simon fixed the core dump.

(2) Now, however, *somehow* an exactly opposite (in Boolean sense) version
  of the test ended up in op/flip.t​:

  readline(FOO);$.=1;print "ok\n" unless 1..10;

  Notice the unless instead of an if. Why so, I don't know, but I
  very much suspect my idiocy and quickly "fixing" tests without
  thinking, just to get them to "ok". So that's the version of the
  logic we have been testing since Simon's patch.

(3) Now with Abhijit's patch the more sensible (right?) version of the
  logic has been restored. I think.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2001

From @gsar

Hugo, you mean.

(2) Now, however, *somehow* an exactly opposite (in Boolean sense) version
of the test ended up in op/flip.t​:

readline(FOO);$.=1;print "ok\n" unless 1..10;

Well, Hugo's original patch has the "unless" in it. See the archive
link.

(3) Now with Abhijit's patch the more sensible (right?) version of the
logic has been restored. I think.

I'm not so sure.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2001

From [Unknown Contact. See original ticket]

It appears not, because C<readline;> will now die with "Not enough
arguments..." instead of merely warning. Is such a change acceptable,
given that readline without arguments did nothing useful earlier?

Please check that it preserves the shape and contents of the optree
generated.

The shape is preserved in all cases, as is the functionality, but now
C<readline FH> causes FH to be interpreted as a PV rather than a GV.
Does that matter? (And have I misunderstood the meaning of the "F"
specifier in opcode.pl?)

The flip.t failure worries me.

The overload.t failure worries me more, although I'm not sure what to
make of the if/unless thing in the flip.t test either.

The appended patches revert to the original behaviour, with the sole
exception that -Mstrict doesn't complain about C<readline FH>. Jarkko,
you may want to apply these until I have had a chance to investigate
further.

- ams

Inline Patch
--- current/opcode.pl~	Mon Jun 25 17:54:34 2001
+++ current/opcode.pl	Mon Jun 25 22:10:39 2001
@@ -444,7 +444,7 @@
 backtick	quoted execution (``, qx)	ck_open		t%	
 # glob defaults its first arg to $_
 glob		glob			ck_glob		t@	S?
-readline	<HANDLE>		ck_fun		t%	F
+readline	<HANDLE>		ck_null		t%	F?
 rcatline	append I/O operator	ck_null		t%	
 
 # Bindable operators.

--- current/lib/overload.t~	Mon Jun 25 22:23:18 2001
+++ current/lib/overload.t	Mon Jun 25 17:55:37 2001
@@ -729,7 +729,7 @@
   $iter = iterator->new(5);
   test scalar <${iter}>, '5';	# 176
   $acc = '';
-  $acc .= " $out" while $out = <${iter}>;
+  $acc .= " $out" while $out = <$iter>;
   test $acc, ' 4 3 2 1 0';	# 177
 }
 {

--- current/t/op/flip.t~	Mon Jun 25 21:31:54 2001
+++ current/t/op/flip.t	Mon Jun 25 21:32:00 2001
@@ -32,5 +32,5 @@
     # coredump reported in bug 20001018.008
     readline(UNKNOWN);
     $. = 1;
-    print "ok 10\n" if 1 .. 10;
+    print "ok 10\n" unless 1 .. 10;
 }

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2001

From @jhi

Done.

you may want to apply these until I have had a chance to investigate
further.

@p5pRT
Copy link
Author

p5pRT commented Jun 26, 2001

From @vanstyn

Looking at it now, it looks wrong to me​: I'd expect bool(1..10) to be
true when $. = 1. Clearly I didn't think so at the time - what am I
missing now that I didn't then?

Hugo

@p5pRT
Copy link
Author

p5pRT commented Dec 2, 2004

From @smpeters

[jhi@​cc.hut.fi - Thu Jun 21 03​:08​:05 2001]​:

-----------------------------------------------------------------
[Please enter your report here]

$ perl -we 'open(X, "/etc/motd");<X>'

$ perl -Mstrict -e 'open(X, "/etc/motd");<X>'

$ perl -we 'open(X, "/etc/motd");readline(X)'
Name "main​::X" used only once​: possible typo at -e line 1.

$ perl -Mstrict -e 'open(X, "/etc/motd");readline(X)'
Bareword "X" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

The orignal intent of this ticket was that the <> operator takes just X
(so <X>) while readline must be passed a typeglob (so you get
readline(*X)). Is this something that we would want to change. To me,
changing it would seem to break things. Anyone else have an opinion?

@p5pRT
Copy link
Author

p5pRT commented Dec 2, 2004

From @jhi

Steve Peters via RT wrote​:

[jhi@​cc.hut.fi - Thu Jun 21 03​:08​:05 2001]​:

-----------------------------------------------------------------
[Please enter your report here]

$ perl -we 'open(X, "/etc/motd");<X>'

$ perl -Mstrict -e 'open(X, "/etc/motd");<X>'

$ perl -we 'open(X, "/etc/motd");readline(X)'
Name "main​::X" used only once​: possible typo at -e line 1.

$ perl -Mstrict -e 'open(X, "/etc/motd");readline(X)'
Bareword "X" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

The orignal intent of this ticket was that the <> operator takes just X
(so <X>) while readline must be passed a typeglob (so you get
readline(*X)). Is this something that we would want to change. To me,
changing it would seem to break things. Anyone else have an opinion?

I think this was discussed and played around with back when, and yes,
as far as I can remember, it would have broken things. I think this
ticket can be closed.

P.S. Steve, you seem to be cleaning up the treacherous jungle known as
the perlbug queues quite nicely. Thanks!

--
Jarkko Hietaniemi <jhi@​iki.fi> http​://www.iki.fi/jhi/ "There is this special
biologist word we use for 'stable'. It is 'dead'." -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Dec 2, 2004

@smpeters - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant