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

Invalid perl code with find2perl #7244

Closed
p5pRT opened this issue Apr 19, 2004 · 4 comments
Closed

Invalid perl code with find2perl #7244

p5pRT opened this issue Apr 19, 2004 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 19, 2004

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

Searchable as RT28963$

@p5pRT
Copy link
Author

p5pRT commented Apr 19, 2004

From @eserte

This is a bug report for perl from slaven@​rezic.de,
generated with the help of perlbug 1.34 running under perl v5.8.0.


Some invocations of find2perl cause wrong perl code to be created, e.h.

  find2perl .

or

  find2perl . -follow -type d -print

No fix here, but an additional test which could go to t/x2p/f2p.t​:

#!./perl -w

BEGIN {
  if ($ENV{'PERL_CORE'}){
  chdir 't';
  unshift @​INC, '../lib';
  }
}

use Test​::More;
use File​::Spec;
use File​::Temp qw(tempfile);

plan tests => 4;

my $f2p = File​::Spec->catfile( File​::Spec->updir(), 'x2p', 'find2perl' );
if ($^O eq 'VMS') {
  # default in the .com extenson if it's not already there
  $f2p = VMS​::Filespec​::rmsexpand($f2p, '.com');
}

TODO​: {
  local $TODO = "Syntax errors";

  check_syntax(".");
  check_syntax(". -follow");
  check_syntax(". -follow -type d");
}

check_syntax(". -print");

sub check_syntax {
  my @​options = @​_;
  my($fh, $file) = tempfile(UNLINK => 1, SUFFIX => ".pl");
  my($errfh, $errfile) = tempfile(UNLINK => 1, SUFFIX => ".log");
  open(F2P, "$f2p @​options|") or die $!;
  print $fh join "", <F2P>;
  close F2P;
  close $fh;
  system("$^X -c $file >" . $errfile . " 2>&1");
  is($?, 0) or do {
  open(ERR, $errfile);
  diag join "", <ERR>;
  close ERR;
  };
  unlink $file;
  unlink $errfile;
}
__END__



Flags​:
  category=utilities
  severity=medium


Site configuration information for perl v5.8.0​:

Configured by davidk at Sun Apr 6 15​:15​:05 CEST 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration​:
  Platform​:
  osname=linux, osvers=2.4.18-14, archname=i686-linux
  uname='linux devpc01.iconmobile.de 2.4.18-14 #1 wed sep 4 13​:35​:50 edt 2002 i686 i686 i386 gnulinux '
  config_args='-de'
  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=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
  optimize='-O3',
  cppflags='-fno-strict-aliasing -I/usr/include/gdbm'
  ccversion='', gccversion='3.2 20020903 (Red Hat Linux 8.0 3.2-7)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lutil
  perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
  libc=/lib/libc-2.2.93.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.2.93'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl v5.8.0​:
  /usr/local/lib/perl5/5.8.0/i686-linux
  /usr/local/lib/perl5/5.8.0
  /usr/local/lib/perl5/site_perl/5.8.0/i686-linux
  /usr/local/lib/perl5/site_perl/5.8.0
  /usr/local/lib/perl5/site_perl
  .


Environment for perl v5.8.0​:
  HOME=/home/slavenr
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/X11R6/bin​:/usr/X11/bin​:/usr/local/bin​:/usr/ucb​:/usr/bin​:/bin​:/usr/gnu/bin​:/usr/TeX/bin​:/usr/etc​:/usr/local/lib​:/usr/local/etc​:/usr/local/sbin​:/usr/sbin​:/sbin​:/home/slavenr/bin/linux​:/home/slavenr/bin/sh​:/home/slavenr/bin​:/usr/www/bin​:/usr/sepia/bin​:/usr/informix/online/bin​:/usr/local/Hughes/bin​:/usr/motif/bin​:/usr/cctb/bin​:/usr/sas​:/usr/ocs/bin​:/home/autos/bin​:/usr/games​:/home/pub/bin/linux​:/home/pub/bin​:/home/pub/bin/pbmplus​:/home/slavenr/devel/fahrinfo​:/home/slavenr/devel​:/opt/kde2/bin​:/opt/kde/bin​:/opt/gnome/bin
  PERL_BADLANG (unset)
  SHELL=/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2004

From @rgs

slaven@​rezic.de (via RT) wrote​:

Some invocations of find2perl cause wrong perl code to be created, e.h.

find2perl \.

or

find2perl \. \-follow \-type d \-print

No fix here, but an additional test which could go to t/x2p/f2p.t​:

I've committed a hackish fix as change

Change 22749 by rgs@​valis on 2004/04/28 18​:28​:07

  Fix for [perl #28963]​: find2perl was sometimes generating
  invalid code.

Affected files ...

... //depot/perl/x2p/find2perl.PL#23 edit

Differences ...

==== //depot/perl/x2p/find2perl.PL#23 (text) ====

@​@​ -266,7 +266,9 @​@​
}

if ($print_needed) {
- $out .= "\n" . tab . '&& print("$name\n")';
+ my $t = tab;
+ if ($t !~ /&amp;&amp;\s*$/) { $t .= '&& ' }
+ $out .= "\n" . $t . 'print("$name\n")';
}

Your test file is nice, but I suspect it's highly unportable.
For example​: as it execs find2perl directly, it won't work with an
uninstalled perl. Command-line arguments aren't probably quoted properly
for VMS. You need to -I../lib as well... Maybe extending the runperl()
function from t/test.pl will do.

#!./perl -w

BEGIN {
if ($ENV{'PERL_CORE'}){
chdir 't';
unshift @​INC, '../lib';
}
}

use Test​::More;
use File​::Spec;
use File​::Temp qw(tempfile);

plan tests => 4;

my $f2p = File​::Spec->catfile( File​::Spec->updir(), 'x2p', 'find2perl' );
if ($^O eq 'VMS') {
# default in the .com extenson if it's not already there
$f2p = VMS​::Filespec​::rmsexpand($f2p, '.com');
}

TODO​: {
local $TODO = "Syntax errors";

check\_syntax\("\."\);
check\_syntax\("\. \-follow"\);
check\_syntax\("\. \-follow \-type d"\);

}

check_syntax(". -print");

sub check_syntax {
my @​options = @​_;
my($fh, $file) = tempfile(UNLINK => 1, SUFFIX => ".pl");
my($errfh, $errfile) = tempfile(UNLINK => 1, SUFFIX => ".log");
open(F2P, "$f2p @​options|") or die $!;
print $fh join "", <F2P>;
close F2P;
close $fh;
system("$^X -c $file >" . $errfile . " 2>&1");
is($?, 0) or do {
open(ERR, $errfile);
diag join "", <ERR>;
close ERR;
};
unlink $file;
unlink $errfile;
}

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2004

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

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2004

@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