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

open pragma ignored for all 3-arg opens #8168

Closed
p5pRT opened this issue Oct 25, 2005 · 7 comments
Closed

open pragma ignored for all 3-arg opens #8168

p5pRT opened this issue Oct 25, 2005 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 25, 2005

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

Searchable as RT37533$

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2005

From kenhirsch@ftml.net

Created by kenhirsch@ftml.net

use open '​:encoding(iso-8859-7)';
open OUT, ">test1.txt" or die "cannot open test1.txt​: $!\n";
print OUT chr(0x3b1), "\n";
__END__
The above program works fine, printing a "\xe1" character to test1.txt

____
use open '​:encoding(iso-8859-7)';
open OUT, ">", "test2.txt" or die "cannot open test2.txt​: $!\n";
print OUT chr(0x3b1), "\n";
__END__
This program, however, prints "\xce\xb1" to file and warns
"Wide character in print at bug4.pl line 3."

The documentation for open in perlfunc says
  "(Note that if layers are specified in the three-arg form then default
  layers set by the C<open> pragma are ignored.)"

But, the default layers appear to be ignored for all three-arg opens.

The documentation for the open pragma says​:
  "When open() is given an explicit list of layers they are appended to
  the list declared using this pragma."

which is even more wrong.
#
# Applies to perl versions 5.8.x to bleadperl 5.9.3 patch 25712 2005-10-25

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.5:

Configured by gerrit at Thu Aug 19 19:39:49     2004.

Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
  Platform:
    osname=cygwin, osvers=1.5.10(0.11642), 
archname=cygwin-thread-multi-64int
    uname='cygwin_nt-5.1 inspiron 1.5.10(0.11642) 2004-05-25 22:07 i686 
unknown unknown cygwin '
    config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads 
-Doptimize=-O2 -Dman3ext=3pm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define 
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing 
-pipe -I/usr/local/include',
    optimize='-O2',
    cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe 
-I/usr/local/include'
    ccversion='', gccversion='3.3.3 (cygwin special)', 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=8, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -ldb -lcrypt -lgdbm_compat
    perllibs=-lcrypt -lgdbm_compat
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.5:
    /usr/lib/perl5/5.8.5/cygwin-thread-multi-64int
    /usr/lib/perl5/5.8.5
    /usr/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.5/cygwin-thread-multi-64int
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl
    .


Environment for perl v5.8.5:
    CYGWIN=tty
    HOME=/home/Hirschk
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/bin:/home/Hirschk/bin:/perl/bin:/usr/local/bin:/usr/bin:/bin:/Perl/bin/:/usr/bin:/Python21/:/Program 
Files/Reflection:/emacs-20.7/bin:/vim/current:/Program 
Files/Reflection:/WINNT/system32:/WINNT:/WINNT/System32/Wbem:/WINNT/system32/nls:/WINNT/system32/nls/English:/Program 
Files/Novell/ZENworks/:/Program Files/thinktecture/WsContractFirst 
0.4/:/Program 
Files/Reflection/:/PROGRA~1/CHEZSC~1/csv6.9c/i3nt:/PROGRA~1/Tcl/bin:/Program 
Files/Microsoft Visual Studio/Common/Tools/WinNT:/Program 
Files/Microsoft Visual Studio/Common/MSDev98/Bin:/Program 
Files/Microsoft Visual Studio/Common/Tools:/Program Files/Microsoft 
Visual Studio/VC98/bin:/Program Files/MiKTeX/miktex/bin:/Program 
Files/Hugs98:Z:.:.
    PERL_BADLANG (unset)
    SHELL (unset)


@p5pRT
Copy link
Author

p5pRT commented Oct 26, 2005

From @rgs

Ken Hirsch (via RT) wrote​:

use open '​:encoding(iso-8859-7)';
open OUT, ">test1.txt" or die "cannot open test1.txt​: $!\n";
print OUT chr(0x3b1), "\n";
__END__
The above program works fine, printing a "\xe1" character to test1.txt

____
use open '​:encoding(iso-8859-7)';
open OUT, ">", "test2.txt" or die "cannot open test2.txt​: $!\n";
print OUT chr(0x3b1), "\n";
__END__
This program, however, prints "\xce\xb1" to file and warns
"Wide character in print at bug4.pl line 3."

The documentation for open in perlfunc says
"(Note that if layers are specified in the three-arg form then default
layers set by the C<open> pragma are ignored.)"

But, the default layers appear to be ignored for all three-arg opens.

The patch appended to this mail appears to fix that.

The documentation for the open pragma says​:
"When open() is given an explicit list of layers they are appended to
the list declared using this pragma."

which is even more wrong.

Nice; this is in direct contradiction with what perlfunc states.
I'm tempted to make the perlfunc behaviour the correct one, it seems to
be more useful to me. Other opinions ?

--- perlio.c (révision 5878)
+++ perlio.c (copie de travail)
@​@​ -1458,7 +1458,7 @​@​
  */
  }
  }
- if (!layers)
+ if (!layers || !*layers)
  layers = PerlIO_context_layers(aTHX_ mode);
  if (layers && *layers) {
  PerlIO_list_t *av;

@p5pRT
Copy link
Author

p5pRT commented Oct 26, 2005

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

@p5pRT
Copy link
Author

p5pRT commented Oct 26, 2005

From kenhirsch@ftml.net

Rafael Garcia-Suarez wrote​:

The documentation for the open pragma says​:
"When open() is given an explicit list of layers they are appended to
the list declared using this pragma."

which is even more wrong.

Nice; this is in direct contradiction with what perlfunc states.
I'm tempted to make the perlfunc behaviour the correct one, it seems to
be more useful to me. Other opinions ?

I definitely agree--the specific should override the more general.
Especially since if there are :encoding layers in both, perl blows up
(see https://rt-archive.perl.org/perl5/Ticket/Display.html?id=37526).

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2005

From @ysth

On Tue, Oct 25, 2005 at 01​:46​:27PM -0700, Ken Hirsch wrote​:

use open '​:encoding(iso-8859-7)';
open OUT, ">test1.txt" or die "cannot open test1.txt​: $!\n";
print OUT chr(0x3b1), "\n";
__END__
The above program works fine, printing a "\xe1" character to test1.txt

____
use open '​:encoding(iso-8859-7)';
open OUT, ">", "test2.txt" or die "cannot open test2.txt​: $!\n";
print OUT chr(0x3b1), "\n";
__END__
This program, however, prints "\xce\xb1" to file and warns
"Wide character in print at bug4.pl line 3."

The documentation for open in perlfunc says
"(Note that if layers are specified in the three-arg form then default
layers set by the C<open> pragma are ignored.)"

But, the default layers appear to be ignored for all three-arg opens.

I have noticed this before, cursed, and thought it was intentional.
-C behaves the same last I checked.

@p5pRT
Copy link
Author

p5pRT commented Oct 31, 2005

From @rgs

Ken Hirsch wrote​:

Rafael Garcia-Suarez wrote​:

The documentation for the open pragma says​:
"When open() is given an explicit list of layers they are appended to
the list declared using this pragma."

which is even more wrong.

Nice; this is in direct contradiction with what perlfunc states.
I'm tempted to make the perlfunc behaviour the correct one, it seems to
be more useful to me. Other opinions ?

I definitely agree--the specific should override the more general.
Especially since if there are :encoding layers in both, perl blows up
(see https://rt-archive.perl.org/perl5/Ticket/Display.html?id=37526).

I thus applied an enhanced version of my patch, plus a doc fix in
lib/open.pm, to bleadperl as change #25925.

@p5pRT
Copy link
Author

p5pRT commented Oct 31, 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