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

Term::ReadLine::event_loop doesn't quite match documentation #12002

Closed
p5pRT opened this issue Mar 14, 2012 · 7 comments
Closed

Term::ReadLine::event_loop doesn't quite match documentation #12002

p5pRT opened this issue Mar 14, 2012 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 14, 2012

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

Searchable as RT111758$

@p5pRT
Copy link
Author

p5pRT commented Mar 14, 2012

From @dmcbride

Created by @dmcbride

Rocco pointed out to me that the new event_loop method has a small
typo​:

  $Term​::ReadLine​::toloop = [ @​_ ] if @​_ > 1;

should be​:

  $Term​::ReadLine​::toloop = [ @​_ ] if @​_ > 0;

It was originally intended that toloop would require two parameters
(watcher, registration). Then I realised that the second parameter really
could be optional, but missed fixing this based on the new requirement.
However, the documentation does say it's optional, which is a disagreement
with the implementation. Changing this one character would get the code
and documentation in agreement again.

Perl Info

Flags:
    category=library
    severity=low
    module=Term::ReadLine

Site configuration information for perl 5.15.8:

Configured by nobody at Tue Mar 13 16:50:41 MDT 2012.

Summary of my perl5 (revision 5 version 15 subversion 8) configuration:
  Commit id: e8097ff21716361661e6a00312ab7b5a8a451efe
  Platform:
    osname=linux, osvers=3.2.1-gentoo-r2, archname=x86_64-linux-thread-multi
    uname='linux naboo 3.2.1-gentoo-r2 #1 smp thu jan 26 07:38:45 mst 2012 x86_64 intel(r) core(tm) i7 cpu 930 @ 2.80ghz genuineintel gnulinux '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.5.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.13.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.15.8:
    /home/dmcbride/perl/blead/lib/site_perl/5.15.8/x86_64-linux-thread-multi
    /home/dmcbride/perl/blead/lib/site_perl/5.15.8
    /home/dmcbride/perl/blead/lib/5.15.8/x86_64-linux-thread-multi
    /home/dmcbride/perl/blead/lib/5.15.8
    .


Environment for perl 5.15.8:
    HOME=/home/dmcbride
    LANG=en_US.utf8
    LANGUAGE=
    LC_ALL=en_US.utf8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/dmcbride/bin:/usr/lib/distcc/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/share/cvs/bin:/usr/local/bin:/usr/games/bin:/share/bin:/share/darin/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Mar 14, 2012

From @dmcbride

Patch for the typo.

To answer the question from #p5p by rjbs (for posterity) which was,
roughly, should the @​_>1 in tkRunning be changed as well? The answer is
"no".

The problem is that in tkRunning, we don't shift off the $self object,
and so we are checking that there is a parameter other than $self passed
in, and using it if there is.

In event_loop, we *are* shifting off $self, and thus we only need to
check if there are any parameters *still left*. The alternative would
be to get rid of the shift, and instead capture [ @​_[1..$#_] ], which I
thought to be too ugly, and thus the shift.

@p5pRT
Copy link
Author

p5pRT commented Mar 14, 2012

From @dmcbride

0001-The-event_loop-method-is-shifting-off-self-which-mea.patch
diff --git a/dist/Term-ReadLine/lib/Term/ReadLine.pm b/dist/Term-ReadLine/lib/Term/ReadLine.pm
index f1b1419..3770df0 100644
--- a/dist/Term-ReadLine/lib/Term/ReadLine.pm
+++ b/dist/Term-ReadLine/lib/Term/ReadLine.pm
@@ -454,7 +454,7 @@ sub event_loop {
 
     # store the callback in toloop, again so that other modules will
     # recognise it and call us for the loop.
-    $Term::ReadLine::toloop = [ @_ ] if @_ > 1;
+    $Term::ReadLine::toloop = [ @_ ] if @_ > 0; # 0 because we shifted off $self.
     $Term::ReadLine::toloop;
 }
 

@p5pRT
Copy link
Author

p5pRT commented Mar 14, 2012

@dmcbride - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 15, 2012

From @rjbs

Thanks, applied as 9705c32.

@p5pRT
Copy link
Author

p5pRT commented Mar 15, 2012

From [Unknown Contact. See original ticket]

Thanks, applied as 9705c32.

@p5pRT
Copy link
Author

p5pRT commented Mar 15, 2012

@rjbs - 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