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

another matching finding by pcre author #835

Closed
p5pRT opened this issue Nov 10, 1999 · 2 comments
Closed

another matching finding by pcre author #835

p5pRT opened this issue Nov 10, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 10, 1999

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

Searchable as RT1763$

@p5pRT
Copy link
Author

p5pRT commented Nov 10, 1999

From @jhi

One more from PCRE (ftp​://ftp.cus.cam.ac.uk/pub/software/programs/pcre/)
author Philip Hazel. If this (rightly) fails to match

./perl -wle '"a" =~ /^(a)?a$/;print $1'
Use of uninitialized value at -e line 1.

why does this match?

./perl -wle '"a" =~ /^(a)?(?(1)a|b)+$/;print $1'
a

Perl Info


Site configuration information for perl 5.00562:

Configured by jhi at Wed Nov 10 01:04:17 EET 1999.

Summary of my perl5 (revision 5.0 version 5 subversion 62) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris
    uname='sunos mimosa.hut.fi 5.7 generic_106541-05 sun4u sparc '
    config_args='-ders -Dcc=gcc'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    use64bits=undef usemultiplicity=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.8.1
    cppflags='-DUSE_LARGE_FILES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccflags ='-DUSE_LARGE_FILES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' '
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G'

Locally applied patches:
    


@INC for perl 5.00562:
    lib
    /u/vieraat/vieraat/jhi/Perl/lib
    /opt/lib/perl5/5.00562/sun4-solaris
    /opt/lib/perl5/5.00562
    /opt/lib/site_perl/5.00562/sun4-solaris
    /opt/lib/site_perl
    .


Environment for perl 5.00562:
    HOME=/u/vieraat/vieraat/jhi
    LANG=C
    LANGUAGE (unset)
    LC_CTYPE=iso_8859_1
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/u/vieraat/vieraat/jhi/.s:/p/bin:/p/adm/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/ccs/bin:/usr/lib:/etc:/lib:/p/X6/bin:/usr/bin/X11:/usr/lib/acct:/usr/5bin:/u/vieraat/vieraat/jhi
    PERLLIB=/u/vieraat/vieraat/jhi/Perl/lib
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Nov 10, 1999

From [Unknown Contact. See original ticket]

In message <199911101300.PAA16873@​mimosa.hut.fi>,
  Jarkko Hietaniemi writes​:

: One more from PCRE (ftp​://ftp.cus.cam.ac.uk/pub/software/programs/pcre/)
: author Philip Hazel. If this (rightly) fails to match
:
: ./perl -wle '"a" =~ /^(a)?a$/;print $1'
: Use of uninitialized value at -e line 1.

It does match, but greed makes the ? give up its a, leaving $1 empty​:

  #! /usr/bin/perl -w

  use strict;

  print q{"a" =~ /^(a)?a$/}, "\n";
  if ("a" =~ /^(a)?a$/) {
  print "\$1 = `", defined $1 ? $1 : "<undef>", "'\n";
  }
  else {
  print "No match.\n";
  }
  [9​:05] ruby% ./try
  "a" =~ /^(a)?a$/
  $1 = `<undef>'

: why does this match?
:
: ./perl -wle '"a" =~ /^(a)?(?(1)a|b)+$/;print $1'
: a

That looks like a bug to me. It should match, but $1 should be empty
in that case.

Greg

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