Front page | perl.perl5.porters |
Postings from January 2017
[perl #130668] poor argument parsing in pragma 'use open'
From:
perlbug-followup
Date:
January 30, 2017 04:24
Subject:
[perl #130668] poor argument parsing in pragma 'use open'
Message ID:
rt-4.0.24-22381-1485696735-1382.130668-75-0@perl.org
# New Ticket Created by
# Please include the string: [perl #130668]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=130668 >
This is a bug report for perl from sur98ke@gmail.com,
generated with the help of perlbug 1.40 running under perl 5.22.3.
?Today I tried to work with UCS-2-LE-BOM encoded data using ARGV and
STDOUT filehandles.
To do so I had to use binmode (STDOUT, ...)
for STDOUT and use open 'IN', ...
for ARGV.
What I found out is that format of argument for "use open" pragma is
much more strict than format for open and binmode subroutines. i.e.:
binmode(STDOUT, "raw pop encoding(ucs-2le) crlf utf8"); # works well
binmode(STDOUT, " raw pop encoding(ucs-2le) crlf utf8"); # works well
binmode(STDOUT, ":raw:pop:encoding(ucs-2le):crlf:utf8"); # works well
open (F, '<encoding(ucs-2le) crlf utf8', 'vlc-assoc.reg'); # works well
open (F, '< encoding(ucs-2le) crlf utf8', 'vlc-assoc.reg'); # works well
open (F, '<:encoding(ucs-2le):crlf:utf8', 'vlc-assoc.reg'); # works well
use open ('IN' , 'encoding(ucs-2le) crlf utf8'); # works well
use open ('IN' , ' encoding(ucs-2le) crlf utf8'); # Unknown PerlIO layer
'' at myscript.pl line ...
use open ('IN' , ':encoding(ucs-2le):crlf:utf8'); # Unknown PerlIO layer
'encoding(ucs-2le):crlf:utf8' at myscript.pl line ...
And this difference in interpreting arguments IS NOT mentioned at
http://perldoc.perl.org/open.html
http://perldoc.perl.org/functions/binmode.html
http://perldoc.perl.org/functions/open.html
http://perldoc.perl.org/PerlIO.html
I couldn't even find the example of proper "use open" usage over
internet. I had to look into the file "open.pm" to find the line number 73:
https://perl5.git.perl.org/perl.git/blob/HEAD:/lib/open.pm#l73
foreach my $layer (split(/\s+/,$dscp)) {
which splits the argument by spaces.
In both of distributions on my machine files:
<install path>\Strawberry\perl\lib\open.pm
<install path>\cygwin64\lib\perl5\5.22\open.pm
are equal to
https://perl5.git.perl.org/perl.git/blob_plain/HEAD:/lib/open.pm
on 29 Jan 2017.
Could you please fix this in such a way that examples:
use open ('IN' , ' encoding(ucs-2le) crlf utf8');
use open ('IN' , ':encoding(ucs-2le):crlf:utf8');
would work well.
Or, at least add explanation of this limitation to perldoc:
http://perldoc.perl.org/open.html
Thank you.
Best regards,
Artur Mansurov.
---
Flags:
category=library
severity=low
module=open
---
Site configuration information for perl 5.22.3:
Configured by ASSI at Sun Jan 15 13:05:43 CET 2017.
Summary of my perl5 (revision 5 version 22 subversion 3) configuration:
Platform:
osname=cygwin, osvers=2.6.1(0.30553), archname=cygwin-thread-multi
uname='cygwin_nt-6.3 cygwin 2.6.1(0.30553) 2016-12-16 11:55 x86_64
cygwin '
config_args='-des -Dprefix=/usr -Dmksymlinks
-Darchname=x86_64-cygwin-threads -Dlibperl=cygperl5_22.dll -Dcc=gcc
-Dld=g++ -Accflags=-ggdb -O2 -pipe -Wimplicit-function-declaration
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.22.3-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.22.3=/usr/src/debug/perl-5.22.3-1
-fwrapv'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -D_GNU_SOURCE
-U__STRICT_ANSI__ -ggdb -O2 -pipe -Wimplicit-function-declaration
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.22.3-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.22.3=/usr/src/debug/perl-5.22.3-1
-fwrapv -fno-strict-aliasing -fstack-protector-strong -D_FORTIFY_SOURCE=2',
optimize='-O3',
cppflags='-DPERL_USE_SAFE_PUTENV -D_GNU_SOURCE -U__STRICT_ANSI__
-ggdb -O2 -pipe -Wimplicit-function-declaration
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.22.3-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.22.3=/usr/src/debug/perl-5.22.3-1
-fwrapv -fno-strict-aliasing -fstack-protector-strong'
ccversion='', gccversion='5.4.0', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678,
doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=16, longdblkind=3
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='g++', ldflags =' -Wl,--enable-auto-import
-Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'
libpth=/usr/lib
libs=-lpthread -lgdbm -ldb -ldl -lcrypt -lgdbm_compat
perllibs=-lpthread -ldl -lcrypt
libc=/usr/lib/libcygwin.a, so=dll, useshrplib=true,
libperl=cygperl5_22.dll
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' --shared -Wl,--enable-auto-import
-Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'
---
@INC for perl 5.22.3:
/usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads
/usr/lib/perl5/site_perl/5.22
/usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads
/usr/lib/perl5/vendor_perl/5.22
/usr/lib/perl5/5.22/x86_64-cygwin-threads
/usr/lib/perl5/5.22
---
Environment for perl 5.22.3:
CYGWIN_HOME=c:\home\sur
HOME=/home/sur
LANG=ru_RU.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/win/c/Windows/system32:/win/c/Windows:/win/c/Windows/System32/Wbem:/win/c/Windows/System32/WindowsPowerShell/v1.0:/win/c/bin:/win/c/prog32/SysinternalsSuite:/win/c/Program
Files/Microsoft/Web Platform Installer:/win/c/Program Files
(x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0:/win/c/Program Files
(x86)/Windows Kits/8.0/Windows Performance Toolkit:/win/c/Program
Files/Microsoft SQL
Server/110/Tools/Binn:/win/c/prog32/MATLAB/R2014a/runtime/win32:/win/c/prog32/MATLAB/R2014a/bin:/win/c/prog32/MATLAB/R2014a/polyspace/bin:/win/c/prog64/Python34:/win/c/prog64/Python34/Scripts:/win/c/prog32/Borland/CBUILD~1/Bin:/win/c/prog32/Borland/CBUILD~1/Projects/Bpl:/win/c/Program
Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0
Tools:/win/c/Program Files (x86)/Microsoft SQL
Server/110/Tools/Binn:/win/c/Program Files/Microsoft SQL
Server/110/DTS/Binn:/win/c/Program Files (x86)/Microsoft SQL
Server/110/DTS/Binn:/win/c/prog32/GnuPG/pub:/win/c/home/ProgramData/Oracle/Java/javapath:/win/c/prog64/Strawberry/c/bin:/win/c/prog64/Strawberry/perl/site/bin:/win/c/prog64/Strawberry/perl/bin:/win/c/prog32/Skype/Phone:/win/c/prog64/Java/jdk1.8.0_45:/win/c/Program
Files/TortoiseGit/bin:/win/c/home/sur/scripts:/win/c/home/sur/bin:/win/c/prog32/GMT4/bin:/media/pri1/intelFPGA_lite/16.1/modelsim_ase/win32aloem:/usr/lib/lapack
PERL_BADLANG (unset)
SHELL=/bin/bash
-
[perl #130668] poor argument parsing in pragma 'use open'
by perlbug-followup