Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 555 forks source link

sysread and syswrite do not process CRLF correctly #6357

Open p5pRT opened 21 years ago

p5pRT commented 21 years ago

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

Searchable as RT21473$

p5pRT commented 21 years ago

From hirschk@labcorp.com

Created by kenhirsch@myself.com

sysread() does not change CR-LF to "\n". It does not appear to matter how the file is opened.   e.g.   sysopen(F\, $filename\, O_RDONLY|O_TEXT)   does not help   open F\, "\<​:crlf"\, $filename   also does not help

Function readline() works properly.

This behavior is different from earlier versions of Perl. Among other things\, it means that Net​::FTP adds an extra CR when sending in ASCII mode from Windows\, as an anonymous user complained at   http​://perlmonks.org/index.pl?node_id=240189

The same problem exists with syswrite(). In previous versions of Perl it translated "\n" to "\015\012". In this version it does not.

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.8.0: Configured by ActiveState at Tue Feb 4 18:07:44 2003. Summary of my perl5 (revision 5 version 8 subversion 0) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE _DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL _MSVCRT_READFIX', optimize='-MD -Zi -DNDEBUG -O1', cppflags='-DWIN32' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags '-nologo -nodefaultlib -release -libpath:"C:\Perl\lib\CORE" -machine:x86' libpth="C:\Perl\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib gnulibc_version='undef' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', ddlflags='-dll -nologo -nodefaultlib -release -libpath:"C:\Perl\lib\CORE" -machine:x86' Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY @INC for perl v5.8.0: C:/Perl/lib C:/Perl/site/lib . Environment for perl v5.8.0: CYGWIN=tty HOME=C:\home\Hirschk LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\perl\bin;C:\Program Files\MiKTeX\miktex\bin;C:\usr\local\bin;C:\\bin;C:\bin;C:\perl\bin;C:\PROGR A~1\Borland\Delphi5\Projects\Bpl;C:\PROGRA~1\Borland\Delphi5\Bin;C:\PROGRA~1 \Borland\CBUILD~1\Projects\Bpl;C:\PROGRA~1\Borland\CBUILD~1\Bin;C:\bin;C:\Py thon21\;C:\Perl\bin\;C:\PROGRA~1\REFLEC~1;C:\emacs-20.7\bin;C:\vim\vim61;C:\ Program Files\Reflection;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\WINNT\ system32\nls;C:\WINNT\system32\nls\English;C:\bin;C:\Program Files\CWEB\bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Program Files\MiKTeX\miktex\bin;Z;.;Y;.;. PERL_BADLANG (unset) SHELL (unset) ```
p5pRT commented 21 years ago

From enache@rdslink.ro

On Wed\, Mar 05\, 2003 at 10​:36​:50PM -0000\, Ken Hirsch wrote​:

sysread() does not change CR-LF to "\n". It does not appear to matter how the file is opened. e.g. sysopen(F\, $filename\, O_RDONLY|O_TEXT) does not help

Does it still not help if you say just   sysopen F\, $filename\, 0x4000; or add   use Fcntl qw(​:DEFAULT); at the beginning of the script ?

(I don't have a Windows system to check\, but Fcntl does _not_ seem to export O_* constants by default)

open F\, "\<&#8203;:crlf"\, $filename
  also does not help

Function readline() works properly.

I think i/o layers affect only read\, readline\, etc not sysread.

Regards

Adi

p5pRT commented 21 years ago

From hirschk@labcorp.com

On Wed\, Mar 05\, 2003 at 10​:36​:50PM -0000\, Ken Hirsch wrote​:

sysread() does not change CR-LF to "\n". It does not appear to matter how the file is opened. e.g. sysopen(F\, $filename\, O_RDONLY|O_TEXT) does not help

Does it still not help if you say just sysopen F\, $filename\, 0x4000; or add use Fcntl qw(​:DEFAULT); at the beginning of the script ?

My test already explictly imported O_TEXT and checked the value​:   use Fcntl qw(O_WRONLY O_RDONLY O_APPEND O_CREAT O_TRUNC O_TEXT);   print "O_TEXT = "\, O_TEXT\, "\n"; and O_TEXT was 16384.

[...]

I think i/o layers affect only read\, readline\, etc not sysread.

In previous versions of Perl\, binmode() definitely did affect sysread. The documentation for binmode in perlfunc (last paragraph) says that it does.

Leont commented 4 years ago

Do we still want to change this 18 years later? I don't think we should.

Grinnz commented 4 years ago

binmode still mentions it affects sysread and syswrite, but it's unclear what it means by that. Certainly its main effect now is to cause sysread/syswrite to die if you set an encoding layer. These functions already bypass buffered I/O.