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

Inconsistent warning for hex escape #9644

Closed
p5pRT opened this issue Feb 9, 2009 · 5 comments
Closed

Inconsistent warning for hex escape #9644

p5pRT opened this issue Feb 9, 2009 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 9, 2009

Migrated from rt.perl.org#63124 (status was 'open')

Searchable as RT63124$

@p5pRT
Copy link
Author

p5pRT commented Feb 9, 2009

From hmbrand@cpan.org

Created by hmbrand@cpan.org

$ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

The documented syntax for hex escapes is \xHH

* Why do I get a double warning
* Why does the assignment not warn

$ perl -wle'$_="a\x1)"'
Illegal hexadecimal digit ')' ignored at -e line 1.

Here it *does* warn

Same behaviour in 5.8.8

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.10.0:

Configured by merijn at Tue Dec 18 13:34:32 CET 2007.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.6.22.13-0.3-default, archname=i686-linux-64int
    uname='linux nb09 2.6.22.13-0.3-default #1 smp 20071119 15:02:58 utc i686 i686 i386 gnulinux '
    config_args='-Duse64bitint -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-fno-strict-aliasing -pipe -I/pro/local/include'
    ccversion='', gccversion='4.2.1 (SUSE Linux)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-L/pro/local/lib'
    libpth=/pro/local/lib /lib /usr/lib /usr/local/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.6.1.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.6.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/pro/local/lib'

Locally applied patches:
    


@INC for perl 5.10.0:
    /pro/lib/perl5/5.10.0/i686-linux-64int
    /pro/lib/perl5/5.10.0
    /pro/lib/perl5/site_perl/5.10.0/i686-linux-64int
    /pro/lib/perl5/site_perl/5.10.0
    .


Environment for perl 5.10.0:
    HOME=/home/merijn
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/lib/mpi/gcc/openmpi/lib
    LOGDIR (unset)
    PATH=.:/home/merijn/bin/private:/home/merijn/bin:/pro/local/bin:/pro/bin:/usr/local/bin:/usr/lib/mpi/gcc/openmpi/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/opt/cross/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/gnome/bin:/usr/lib/qt3/bin:/pro/to/bin:/pro/local/sbin:/pro/lib/PTLinux/Helpers:/usr/libexec/git-core:/pro/3gl/CPAN/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2009

From p5p@spam.wizbit.be

$ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

The documented syntax for hex escapes is \xHH

* Why do I get a double warning
* Why does the assignment not warn

$ perl -wle'$_="a\x1)"'
Illegal hexadecimal digit ')' ignored at -e line 1.

Here it *does* warn

Same behaviour in 5.8.8

(also said on #p5p)

$_="a\x1"; does not warn since there are no characters after the 1.
m/a\x1/; also does not warn

If we look at octal​:

$ perl -wle 'print "\01A";'
A

$ perl -wle 'print "\018";'
Illegal octal digit '8' ignored at -e line 1.
8

Doing a similar thing for hex should be possible (only warn if the
symbol is in the [G-Zg-z] range) but I personally see very little value
in this warning.

A warning about \018 is useful since the user might be confusing
decimal with octal... But with what can you possible confuse \x1Z ?

Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2009

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

@jkeenan
Copy link
Contributor

jkeenan commented Feb 22, 2020

From p5p@spam.wizbit.be

$ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
The documented syntax for hex escapes is \xHH

  • Why do I get a double warning
  • Why does the assignment not warn
    $ perl -wle'$_="a\x1)"'
    Illegal hexadecimal digit ')' ignored at -e line 1.
    Here it does warn
    Same behaviour in 5.8.8

(also said on #p5p)

$_="a\x1"; does not warn since there are no characters after the 1.
m/a\x1/; also does not warn

If we look at octal​:

$ perl -wle 'print "\01A";'
A

$ perl -wle 'print "\018";'
Illegal octal digit '8' ignored at -e line 1.
8

Doing a similar thing for hex should be possible (only warn if the
symbol is in the [G-Zg-z] range) but I personally see very little value
in this warning.

A warning about \018 is useful since the user might be confusing
decimal with octal... But with what can you possible confuse \x1Z ?

Kind regards,

Bram

The double warning was eliminated in perl-5.22.

$ perlbrew use perl-5.20.0
$ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

$ perlbrew use perl-5.22.0
[p5p] 564 $ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

Taking this ticket for the purpose of closing it within 7 days unless someone objects.

@Tux

@jkeenan jkeenan self-assigned this Feb 22, 2020
@jkeenan
Copy link
Contributor

jkeenan commented Mar 1, 2020

From p5p@spam.wizbit.be

$ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
The documented syntax for hex escapes is \xHH

  • Why do I get a double warning
  • Why does the assignment not warn
    $ perl -wle'$_="a\x1)"'
    Illegal hexadecimal digit ')' ignored at -e line 1.
    Here it does warn
    Same behaviour in 5.8.8

(also said on #p5p)
$_="a\x1"; does not warn since there are no characters after the 1.
m/a\x1/; also does not warn
If we look at octal​:
$ perl -wle 'print "\01A";'
A
$ perl -wle 'print "\018";'
Illegal octal digit '8' ignored at -e line 1.
8
Doing a similar thing for hex should be possible (only warn if the
symbol is in the [G-Zg-z] range) but I personally see very little value
in this warning.
A warning about \018 is useful since the user might be confusing
decimal with octal... But with what can you possible confuse \x1Z ?
Kind regards,
Bram

The double warning was eliminated in perl-5.22.

$ perlbrew use perl-5.20.0
$ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

$ perlbrew use perl-5.22.0
[p5p] 564 $ perl -wle'"a\x1"=~s/a(?=\x1)//'
Illegal hexadecimal digit ')' ignored at -e line 1.
Can't modify constant item in substitution (s///) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

Taking this ticket for the purpose of closing it within 7 days unless someone objects.

@Tux

Closing as per schedule.

@jkeenan jkeenan closed this as completed Mar 1, 2020
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

2 participants