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

PATCH: move binmode method to IO::Handle from IO::File [rt.cpan.org #65107] #17457

Closed
toddr opened this issue Apr 19, 2018 · 1 comment · Fixed by #21696
Closed

PATCH: move binmode method to IO::Handle from IO::File [rt.cpan.org #65107] #17457

toddr opened this issue Apr 19, 2018 · 1 comment · Fixed by #21696
Assignees
Labels
dist-IO issues in the dual-life blead-first IO distribution

Comments

@toddr
Copy link
Member

toddr commented Apr 19, 2018

Migrated from rt.cpan.org#65107 (status was 'new')

Requestors:

From ambrus@math.bme.hu on 2011-01-25 16:06:08:

This is a bug report for perl from ambrus@math.bme.hu,
generated with the help of perlbug 1.39 running under perl 5.12.3.


[Please describe your issue here]

The binmode method belongs to the IO::Handle class, because PerlIO
layers can be applied to any kind of file descriptor, not the IO::File
subclass where it currently is. The patch below (based on perl 5.13.9)
moves the method to the IO::Handle class.

Perl Info
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=low
    module=IO::Handle
---
Site configuration information for perl 5.12.3:

Configured by ambrus at Tue Jan 25 14:12:12 CET 2011.

Summary of my perl5 (revision 5 version 12 subversion 3) configuration:

  Platform:
    osname=linux, osvers=2.6.34.1, archname=x86_64-linux
    uname='linux king 2.6.34.1 Perl/IO#1 smp sat jul 10 18:21:56 cest 2010
x86_64 gnulinux '
    config_args='-Dinc_version_list=5.12.2/x86_64-linux 5.12.2
5.12.1/x86_64-linux 5.12.1 5.12.0/x86_64-linux 5.12.0 -d'
    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.5.1', 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 /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  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.12.3:
    /usr/local/lib/perl5/site_perl/5.12.3/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.12.3
    /usr/local/lib/perl5/5.12.3/x86_64-linux
    /usr/local/lib/perl5/5.12.3
    /usr/local/lib/perl5/site_perl/5.12.2/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.12.2
    /usr/local/lib/perl5/site_perl/5.12.1/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.12.1
    /usr/local/lib/perl5/site_perl/5.12.0/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.12.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl 5.12.3:
    HOME=/home/ambrus
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=hu_HU
    LD_LIBRARY_PATH=/home/ambrus/local/lib/
    LOGDIR (unset)
    PATH=/home/ambrus/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash
@toddr toddr transferred this issue from Dual-Life/IO Jan 20, 2020
@toddr toddr added Needs Triage dist-IO issues in the dual-life blead-first IO distribution labels Jan 20, 2020
@toddr
Copy link
Member Author

toddr commented Jan 31, 2020

diff --git a/dist/IO/lib/IO/File.pm b/dist/IO/lib/IO/File.pm
index d33d090..c26ccf3 100644
--- a/dist/IO/lib/IO/File.pm
+++ b/dist/IO/lib/IO/File.pm
@@ -93,14 +93,6 @@ it passes all the three arguments to the three-argument C<open> operator.
 For convenience, C<IO::File> exports the O_XXX constants from the
 Fcntl module, if this module is available.
 
-=item binmode( [LAYER] )
-
-C<binmode> sets C<binmode> on the underlying C<IO> object, as documented
-in C<perldoc -f binmode>.
-
-C<binmode> accepts one optional parameter, which is the layer to be
-passed on to the C<binmode> call.
-
 =back
 
 =head1 NOTE
@@ -188,17 +180,4 @@ sub open {
     open($fh, $file);
 }
 
-################################################
-## Binmode
-##
-
-sub binmode {
-    ( @_ == 1 or @_ == 2 ) or croak 'usage $fh->binmode([LAYER])';
-
-    my($fh, $layer) = @_;
-
-    return binmode $$fh unless $layer;
-    return binmode $$fh, $layer;
-}
-
 1;
diff --git a/dist/IO/lib/IO/Handle.pm b/dist/IO/lib/IO/Handle.pm
index f4114ad..7de9bcb 100644
--- a/dist/IO/lib/IO/Handle.pm
+++ b/dist/IO/lib/IO/Handle.pm
@@ -188,6 +188,14 @@ current setting if C<BOOL> is not given.
 
 If an error occurs C<blocking> will return undef and C<$!> will be set.
 
+=item binmode( [LAYER] )
+
+C<binmode> sets C<binmode> on the underlying C<IO> object, as documented
+in C<perldoc -f binmode>.
+
+C<binmode> accepts one optional parameter, which is the layer to be
+passed on to the C<binmode> call.
+
 =back
 
 
@@ -632,4 +640,17 @@ sub printflush {
     }
 }
 
+################################################
+## Binmode
+##
+
+sub binmode {
+    ( @_ == 1 or @_ == 2 ) or croak 'usage $fh->binmode([LAYER])';
+
+    my($fh, $layer) = @_;
+
+    return binmode $$fh unless $layer;
+    return binmode $$fh, $layer;
+}
+
 1;

@tonycoz tonycoz self-assigned this May 13, 2020
tonycoz added a commit to tonycoz/perl5 that referenced this issue Oct 23, 2023
since you can binmode() any handle.

Fixes Perl#17457 which is most of this change, I only added tests, such
as they are.
tonycoz added a commit to tonycoz/perl5 that referenced this issue Oct 30, 2023
since you can binmode() any handle.

Fixes Perl#17457 which is most of this change, I only added tests, such
as they are.
tonycoz added a commit to tonycoz/perl5 that referenced this issue Dec 6, 2023
since you can binmode() any handle.

Fixes Perl#17457 which is most of this change, I only added tests, such
as they are.
tonycoz added a commit that referenced this issue Dec 7, 2023
since you can binmode() any handle.

Fixes #17457 which is most of this change, I only added tests, such
as they are.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dist-IO issues in the dual-life blead-first IO distribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants