Skip to content

meta character in //x comment #12836

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

Closed
p5pRT opened this issue Mar 6, 2013 · 7 comments
Closed

meta character in //x comment #12836

p5pRT opened this issue Mar 6, 2013 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 6, 2013

Migrated from rt.perl.org#117061 (status was 'rejected')

Searchable as RT117061$

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

From @tokuhirom

Created by [email protected]

In this code, Perl5 does not replace anything without any warnings.
It makes confusion for //x users.

use 5.014000;

my $s = 'gfx';
$s =~ s![
gfx # Fuji Gorou]
]!SurCen!gx;
say $s;

Following ruby code output warnings.

puts "gfx".gsub(/[
gfx # Fuji Gorou]
]/x, 'SurCen')

Output​:

hoge.rb​:3​: warning​: regexp has `]' without escape
gfx

I guess, perl5 should output warnings, or ignore meta characters in regexp comment in //x mode.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.17.7:

Configured by tokuhirom at Tue Jan 15 09:48:05 JST 2013.

Summary of my perl5 (revision 5 version 17 subversion 7) configuration:
   
  Platform:
    osname=linux, osvers=3.2.0-23-generic, archname=x86_64-linux
    uname='linux www4071uf 3.2.0-23-generic #36-ubuntu smp tue apr 10 20:39:51 utc 2012 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Dprefix=/home/tokuhirom/.plenv/versions/5.17.7 -de -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.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/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  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.17.7:
    /home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/site_perl/5.17.7/x86_64-linux
    /home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/site_perl/5.17.7
    /home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/5.17.7/x86_64-linux
    /home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/5.17.7
    .


Environment for perl 5.17.7:
    HOME=/home/tokuhirom
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_ALL=en_US.UTF-8
    LC_CTYPE=UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/tokuhirom/.plenv/versions/5.17.7/bin/:/home/tokuhirom/.plenv/shims:/home/tokuhirom/.plenv/bin/:/home/tokuhirom/.rbenv/shims:/home/tokuhirom/.rbenv/bin:/home/tokuhirom/dotfiles/local/bin/:/home/tokuhirom/bin:/home/tokuhirom/local/bin/:/usr/local/mysql/bin/:/usr/local/bin/:/home/tokuhirom/.plenv/shims:/home/tokuhirom/.plenv/bin/:/home/tokuhirom/.rbenv/shims:/home/tokuhirom/.rbenv/bin:/home/tokuhirom/dotfiles/local/bin/:/home/tokuhirom/bin:/home/tokuhirom/local/bin/:/usr/local/mysql/bin/:/usr/local/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
    PERL_AUTOINSTALL=--defaultdeps
    PERL_BADLANG=0
    PERL_CPANM_OPT=--notest --no-man-pages
    SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

From @tokuhirom

In more detail, here is a test code. But this test can't pass.
```
use 5.014000;
use Test​::More tests => 1;

my $s = 'gfx';
$s =~ s![
  gfx # Fuji Gorou]
]!SurCen!gx;
is($s, 'SurCenSurCenSurCen');
```

Output in my environment is here​:
```
1..1
not ok 1
# Failed test at hoge.pl line 8.
# got​: 'gfx'
# expected​: 'SurCenSurCenSurCen'
# Looks like you failed 1 test of 1.
```

I know parsing s///x is hard, but I hope it works correctly or output
warnings.

(Note, Ruby1.8.7 can't parse ']' character after '#', but it output
warnings.)

--
tokuhirom

On Wed, Mar 6, 2013 at 3​:06 PM, Tokuhiro Matsuno
<perlbug-followup@​perl.org>wrote​:

# New Ticket Created by "Tokuhiro Matsuno"
# Please include the string​: [perl #117061]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=117061 >

This is a bug report for perl from tokuhirom@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.17.7.

-----------------------------------------------------------------
[Please describe your issue here]

In this code, Perl5 does not replace anything without any warnings.
It makes confusion for //x users.

use 5.014000;

my $s = 'gfx';
$s =~ s![
gfx # Fuji Gorou]
]!SurCen!gx;
say $s;

Following ruby code output warnings.

puts "gfx".gsub(/[
gfx # Fuji Gorou]
]/x, 'SurCen')

Output​:

hoge.rb​:3​: warning​: regexp has `]' without escape
gfx

I guess, perl5 should output warnings, or ignore meta characters in regexp
comment in //x mode.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=core
severity=low
---
Site configuration information for perl 5.17.7​:

Configured by tokuhirom at Tue Jan 15 09​:48​:05 JST 2013.

Summary of my perl5 (revision 5 version 17 subversion 7) configuration​:

Platform​:
osname=linux, osvers=3.2.0-23-generic, archname=x86_64-linux
uname='linux www4071uf 3.2.0-23-generic #36-ubuntu smp tue apr 10
20​:39​:51 utc 2012 x86_64 x86_64 x86_64 gnulinux '
config_args='-Dprefix=/home/tokuhirom/.plenv/versions/5.17.7 -de
-Dusedevel'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.6.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/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.15'
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.17.7​:

/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/site_perl/5.17.7/x86_64-linux
/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/site_perl/5.17.7
/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/5.17.7/x86_64-linux
/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/5.17.7
.

---
Environment for perl 5.17.7​:
HOME=/home/tokuhirom
LANG=en_US.UTF-8
LANGUAGE (unset)
LC_ALL=en_US.UTF-8
LC_CTYPE=UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=/home/tokuhirom/.plenv/versions/5.17.7/bin/​:/home/tokuhirom/.plenv/shims​:/home/tokuhirom/.plenv/bin/​:/home/tokuhirom/.rbenv/shims​:/home/tokuhirom/.rbenv/bin​:/home/tokuhirom/dotfiles/local/bin/​:/home/tokuhirom/bin​:/home/tokuhirom/local/bin/​:/usr/local/mysql/bin/​:/usr/local/bin/​:/home/tokuhirom/.plenv/shims​:/home/tokuhirom/.plenv/bin/​:/home/tokuhirom/.rbenv/shims​:/home/tokuhirom/.rbenv/bin​:/home/tokuhirom/dotfiles/local/bin/​:/home/tokuhirom/bin​:/home/tokuhirom/local/bin/​:/usr/local/mysql/bin/​:/usr/local/bin/​:/usr/local/sbin​:/usr/local/bin​:/usr/sbin​:/usr/bin​:/sbin​:/bin​:/usr/bin/X11​:/usr/games
PERL_AUTOINSTALL=--defaultdeps
PERL_BADLANG=0
PERL_CPANM_OPT=--notest --no-man-pages
SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

From @tokuhirom

I hope to process "]" character in comment as comment, in //x mode regexp
literal.

But Perl5 uses "]" character in comment is Bracketed Character class
closing operator.

```
$s =~ s![
  abc # ] ←←←
]!x!gx;
```

--
tokuhirom

On Wed, Mar 6, 2013 at 3​:31 PM, Tokuhiro Matsuno <tokuhirom@​gmail.com>wrote​:

In more detail, here is a test code. But this test can't pass.
```
use 5.014000;
use Test​::More tests => 1;

my $s = 'gfx';
$s =~ s![
gfx # Fuji Gorou]
]!SurCen!gx;
is($s, 'SurCenSurCenSurCen');
```

Output in my environment is here​:
```
1..1
not ok 1
# Failed test at hoge.pl line 8.
# got​: 'gfx'
# expected​: 'SurCenSurCenSurCen'
# Looks like you failed 1 test of 1.
```

I know parsing s///x is hard, but I hope it works correctly or output
warnings.

(Note, Ruby1.8.7 can't parse ']' character after '#', but it output
warnings.)

--
tokuhirom

On Wed, Mar 6, 2013 at 3​:06 PM, Tokuhiro Matsuno <
perlbug-followup@​perl.org> wrote​:

# New Ticket Created by "Tokuhiro Matsuno"
# Please include the string​: [perl #117061]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=117061 >

This is a bug report for perl from tokuhirom@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.17.7.

-----------------------------------------------------------------
[Please describe your issue here]

In this code, Perl5 does not replace anything without any warnings.
It makes confusion for //x users.

use 5.014000;

my $s = 'gfx';
$s =~ s![
gfx # Fuji Gorou]
]!SurCen!gx;
say $s;

Following ruby code output warnings.

puts "gfx".gsub(/[
gfx # Fuji Gorou]
]/x, 'SurCen')

Output​:

hoge.rb​:3​: warning​: regexp has `]' without escape
gfx

I guess, perl5 should output warnings, or ignore meta characters in
regexp comment in //x mode.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=core
severity=low
---
Site configuration information for perl 5.17.7​:

Configured by tokuhirom at Tue Jan 15 09​:48​:05 JST 2013.

Summary of my perl5 (revision 5 version 17 subversion 7) configuration​:

Platform​:
osname=linux, osvers=3.2.0-23-generic, archname=x86_64-linux
uname='linux www4071uf 3.2.0-23-generic #36-ubuntu smp tue apr 10
20​:39​:51 utc 2012 x86_64 x86_64 x86_64 gnulinux '
config_args='-Dprefix=/home/tokuhirom/.plenv/versions/5.17.7 -de
-Dusedevel'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.6.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/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.15'
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.17.7​:

/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/site_perl/5.17.7/x86_64-linux
/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/site_perl/5.17.7
/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/5.17.7/x86_64-linux
/home/tokuhirom/.plenv/versions/5.17.7/lib/perl5/5.17.7
.

---
Environment for perl 5.17.7​:
HOME=/home/tokuhirom
LANG=en_US.UTF-8
LANGUAGE (unset)
LC_ALL=en_US.UTF-8
LC_CTYPE=UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=/home/tokuhirom/.plenv/versions/5.17.7/bin/​:/home/tokuhirom/.plenv/shims​:/home/tokuhirom/.plenv/bin/​:/home/tokuhirom/.rbenv/shims​:/home/tokuhirom/.rbenv/bin​:/home/tokuhirom/dotfiles/local/bin/​:/home/tokuhirom/bin​:/home/tokuhirom/local/bin/​:/usr/local/mysql/bin/​:/usr/local/bin/​:/home/tokuhirom/.plenv/shims​:/home/tokuhirom/.plenv/bin/​:/home/tokuhirom/.rbenv/shims​:/home/tokuhirom/.rbenv/bin​:/home/tokuhirom/dotfiles/local/bin/​:/home/tokuhirom/bin​:/home/tokuhirom/local/bin/​:/usr/local/mysql/bin/​:/usr/local/bin/​:/usr/local/sbin​:/usr/local/bin​:/usr/sbin​:/usr/bin​:/sbin​:/bin​:/usr/bin/X11​:/usr/games
PERL_AUTOINSTALL=--defaultdeps
PERL_BADLANG=0
PERL_CPANM_OPT=--notest --no-man-pages
SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

From @tokuhirom

Oops. it's not bug.
s/[
  f # x
]//x

means,
s/[f#x]/x

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

From [Unknown Contact. See original ticket]

Oops. it's not bug.
s/[
  f # x
]//x

means,
s/[f#x]/x

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

@iabyn - Status changed from 'new' to 'rejected'

@p5pRT p5pRT closed this as completed Mar 6, 2013
@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2013

From @ikegami

On Wed, Mar 6, 2013 at 1​:55 AM, Tokuhiro Matsuno via RT <
perlbug-comment@​perl.org> wrote​:

Oops. it's not bug.
s/[
f # x
]//x

means,
s/[f#x]/x

Actually,

s/[ f#x]/x

Basically, comments aren't allowed in character classes.

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