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

Missing \\ in perlre #7761

Closed
p5pRT opened this issue Jan 23, 2005 · 4 comments
Closed

Missing \\ in perlre #7761

p5pRT opened this issue Jan 23, 2005 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 23, 2005

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

Searchable as RT33906$

@p5pRT
Copy link
Author

p5pRT commented Jan 23, 2005

From andrew@ugh.net.au

Created by andrew@paivi.local

In perlre there is a section entitled "Creating custom RE
engines". The sample code given maps \\ to \ inside regular
expressions and thus prevents you from using \\ to represent a
literal \. I think this is unintentional and a patch is included
below.

It might also be useful to put in some explanation as to why the
\\ is required at all as I don't think it is immeadiately clear.
That said I'm not volunteering to do the writing just now :-/

Thanks,

Andrew

Inline Patch
--- perlre.pod.orig	Tue Jan 13 21:46:44 2004
+++ perlre.pod	Sun Jan 23 13:31:26 2005
@@ -1288,7 +1288,7 @@

      sub invalid { die "/$_[0]/: invalid escape '\\$_[1]'"}

-    my %rules = ( '\\' => '\\',
+    my %rules = ( '\\' => '\\\\',
  		  'Y|' => qr/(?=\S)(?<!\S)|(?!\S)(?<=\S)/ );
      sub convert {
        my $re = shift;
Perl Info

Flags:
     category=docs
     severity=medium

Site configuration information for perl v5.8.4:

Configured by andrew at Thu Aug 26 14:31:08 BST 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
   Platform:
     osname=darwin, osvers=7.5.0, archname=darwin-2level
     uname='darwin paivi.local 7.5.0 darwin kernel version 7.5.0: thu  
aug 5 19:26:16 pdt 2004; root:xnuxnu-517.7.21.obj~3release_ppc power  
macintosh powerpc '
     config_args='-des -Dprefix=/opt/local  
-Dccflags=-I'/opt/local/include' -Dldflags=-L/opt/local/lib  
-Dvendorprefix=/opt/local'
     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 ='-I/opt/local/include -pipe -fno-common  
-DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing  
-I/opt/local/include',
     optimize='-Os',
     cppflags='-no-cpp-precomp -I/opt/local/include -pipe -fno-common  
-DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing  
-I/opt/local/include'
     ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build  
1666)', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',  
lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags  
='-L/opt/local/lib -L/usr/local/lib'
     libpth=/usr/local/lib /opt/local/lib /usr/lib
     libs=-ldbm -ldl -lm -lc
     perllibs=-ldl -lm -lc
     libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,  
libperl=libperl.a
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-L/opt/local/lib -bundle -undefined  
dynamic_lookup -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.4:
     /opt/local/lib/perl5/5.8.4/darwin-2level
     /opt/local/lib/perl5/5.8.4
     /opt/local/lib/perl5/site_perl/5.8.4/darwin-2level
     /opt/local/lib/perl5/site_perl/5.8.4
     /opt/local/lib/perl5/site_perl
     /opt/local/lib/perl5/vendor_perl/5.8.4/darwin-2level
     /opt/local/lib/perl5/vendor_perl/5.8.4
     /opt/local/lib/perl5/vendor_perl
     .


Environment for perl v5.8.4:
     DYLD_LIBRARY_PATH (unset)
     HOME=/Users/andrew
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
      
PATH=/Users/andrew/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/ 
opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/Developer/Tools
     PERL_BADLANG (unset)
     SHELL=/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2005

From @rgs

Andrew (via RT) wrote​:

In perlre there is a section entitled "Creating custom RE
engines". The sample code given maps \\ to \ inside regular
expressions and thus prevents you from using \\ to represent a
literal \. I think this is unintentional and a patch is included
below.

Good catch.

It might also be useful to put in some explanation as to why the
\\ is required at all as I don't think it is immeadiately clear.
That said I'm not volunteering to do the writing just now :-/

What about :

  We must also take care of not escaping the legitimate \\Y|
  sequence, hence the presence of '\\' in the conversion rules.

--- perlre.pod.orig Tue Jan 13 21​:46​:44 2004
+++ perlre.pod Sun Jan 23 13​:31​:26 2005

Thanks, applied to the development docs as change #23872.

@​@​ -1288,7 +1288,7 @​@​

  sub invalid \{ die "/$\_\[0\]/&#8203;: invalid escape '\\\\$\_\[1\]'"\}

- my %rules = ( '\\' => '\\',
+ my %rules = ( '\\' => '\\\\',
'Y|' => qr/(?=\S)(?<!\S)|(?!\S)(?<=\S)/ );

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2005

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

@p5pRT p5pRT closed this as completed Jan 24, 2005
@p5pRT
Copy link
Author

p5pRT commented Jan 24, 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
Projects
None yet
Development

No branches or pull requests

1 participant