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

y/// at end of file #8031

Closed
p5pRT opened this issue Jul 21, 2005 · 6 comments
Closed

y/// at end of file #8031

p5pRT opened this issue Jul 21, 2005 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 21, 2005

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

Searchable as RT36622$

@p5pRT
Copy link
Author

p5pRT commented Jul 21, 2005

From pfusik@op.pl

This is a bug report for perl from pfusik@​op.pl,
generated with the help of perlbug 1.34 running under perl v5.8.0.


Among perl golf players, it is widely known that perl doesn't like
y/// at the very end of a file. So, we put an extra space or newline
just to make perl happy. Fortunately trailing whitespace doesn't
count to the score. :-)

If you forget to add something after y///, the error messages are very
misleading. For example, this program​:

#!/usr/bin/perl -0
INIT{$A{$a}=1while$a=pop}1while"@​A{/[a-z]+/ig}"=~/\B/&&y/B-ZA-Gb-za/B-ZA
b-za/

when syntax-checked by perl -c gives the following error message​:
Unrecognized character \x81 at deroter.pl line 2.

(do you see any \x81 here?)

I think this should be finally resolved, because it can even crash perl​:

#!/usr/bin/perl -0
INIT{%A=map{pop,1}@​ARGV}1while"@​A{/\pL+/g}"=~/\B/&&y/B-ZA-Gb-za/A-z/

when syntax-checked gives a page fault.

It's the same on perl 5.8.0 and 5.8.6.
This report is for 5.8.0, because I have only an executable of 5.8.6.



Flags​:
  category=core
  severity=medium


Site configuration information for perl v5.8.0​:

Configured by ActiveState at Mon Mar 31 00​:45​:28 2003.

Summary of my perl5 (revision 5 version 8 subversion 0) configuration​:
  Platform​:
  osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cl', ccflags
='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -D
HAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLI
O -DPERL_MSVCRT_READFIX',
  optimize='-MD -Zi -DNDEBUG -O1',
  cppflags='-DWIN32'
  ccversion='', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='link', ldflags
'-nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"C​:\j\Perl\lib\CORE
" -machine​:x86'
  libpth="D​:\Program Files\Microsoft.NET\FrameworkSDK\Lib\"
"D​:\Program Files\Microsoft.Net\Odbc.Net\" "C​:\j\Perl\lib\CORE"
  libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib msvcrt.lib
  perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
  libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
  gnulibc_version='undef'
  Dynamic Linking​:
  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ',
lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"C​:\
j\Perl\lib\CORE" -machine​:x86'

Locally applied patches​:
  ACTIVEPERL_LOCAL_PATCHES_ENTRY


@​INC for perl v5.8.0​:
  C​:/j/Perl/lib
  C​:/j/Perl/site/lib
  .


Environment for perl v5.8.0​:
  HOME (unset)
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)

PATH=C​:\WINDOWS;C​:\WINDOWS\COMMAND;C​:\U;C​:\JAVA\JDK\BIN;C​:\C\DJGPP\BIN;C
:\J\PERL\BIN;C​:\J\MYSQL\BIN;C​:\U\TEXMF\MAIN\MIKTEX\BIN;C​:\U\GS\GS8.11\BI
N;C​:\C\CYGWIN\BIN;C​:\WINDOWS;C​:\WINDOWS\COMMAND;C​:\U\ANT\BIN
  PERL_BADLANG (unset)
  SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Jul 23, 2005

From @schwern

On Thu, Jul 21, 2005 at 11​:45​:30AM -0700, Piotr Fusik wrote​:

Among perl golf players, it is widely known that perl doesn't like
y/// at the very end of a file. So, we put an extra space or newline
just to make perl happy. Fortunately trailing whitespace doesn't
count to the score. :-)

First let me say how bonkers I went to get either vim or emacs to stop
putting a newline on the end of a file. For those emacs out there
the variable is require-final-newline, set it to nil. Unfortunately all
sorts of modes seem to think they know better and set it to true so even if
you shut it off in your confir you often have to manually set it off.

If you forget to add something after y///, the error messages are very
misleading. For example, this program​:

#!/usr/bin/perl -0
INIT{$A{$a}=1while$a=pop}1while"@​A{/[a-z]+/ig}"=~/\B/&&y/B-ZA-Gb-za/B-ZA
b-za/

when syntax-checked by perl -c gives the following error message​:
Unrecognized character \x81 at deroter.pl line 2.

(do you see any \x81 here?)

Bleadperl appears to have this fixed. A test is attached. Ironically
the fresh_perl test function would always append a newline to the code
being tested. I've whacked that out, it was a hold over from the original
code in t/run/kill_perl.t.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
Ahh email, my old friend. Do you know that revenge is a dish that is best
served cold? And it is very cold on the Internet!

@p5pRT
Copy link
Author

p5pRT commented Jul 23, 2005

From @schwern

tr.patch
--- t/test.pl	2005/07/22 18:43:05	1.1
+++ t/test.pl	2005/07/22 18:43:09
@@ -579,7 +579,7 @@
                   {if (-e _ and -f _)}
     }
 
-    print TEST $prog, "\n";
+    print TEST $prog;
     close TEST or die "Cannot close $tmpfile: $!";
 
     my $results = runperl(%$runperl_args);
--- t/op/tr.t	2005/07/22 18:37:29	1.1
+++ t/op/tr.t	2005/07/22 18:42:16
@@ -6,7 +6,7 @@
     require './test.pl';
 }
 
-plan tests => 99;
+plan tests => 100;
 
 my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1);
 
@@ -383,3 +383,7 @@
 $x = \"foo";
 is( $x =~ tr/A/A/, 2, 'non-modifying tr/// on a scalar ref' );
 is( ref $x, 'SCALAR', "    doesn't stringify its argument" );
+
+# rt.perl.org 36622.  Perl didn't like a y/// at end of file.  No trailing
+# newline allowed.
+fresh_perl_is(q[$_ = "foo"; y/A-Z/a-z/], '');

@p5pRT
Copy link
Author

p5pRT commented Jul 23, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 1, 2005

From @rgs

Michael G Schwern wrote​:

Bleadperl appears to have this fixed. A test is attached. Ironically
the fresh_perl test function would always append a newline to the code
being tested. I've whacked that out, it was a hold over from the original
code in t/run/kill_perl.t.

Thanks, applied as change #25252.

@p5pRT
Copy link
Author

p5pRT commented Aug 1, 2005

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

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

No branches or pull requests

1 participant