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

bytes pragma error in substitution operator #7804

Closed
p5pRT opened this issue Feb 17, 2005 · 5 comments
Closed

bytes pragma error in substitution operator #7804

p5pRT opened this issue Feb 17, 2005 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 17, 2005

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

Searchable as RT34171$

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2005

From dgeorge@cas.org

Created by dgeorge@cas.org

Please try the following perl script​:

#!/usr/local/perl5/bin/perl -w

use strict;
use bytes;
use XML​::DOM;

# XML document
my $xml = "<doc>\xe2\x80\x98WOW\xe2\x80\x99</doc>";

# XML parser
my $parser = new XML​::DOM​::Parser;

# Document Object Model
my $dom = $parser->parse($xml, ProtocolEncoding => 'UTF-8');

# Element content
my $content = $dom->getDocumentElement()->getFirstChild()->getNodeValue();

# Print length of $content(should be 9 and is 9)
print 'Length of $content = ', unpack("H*", $content), ' is ', length($content), "\n";

# Print length of $1(should be 3 1 1 1 3 and is 1 1 1 1 3)
$content =~ s/([\x00-\x7f]|[\xc0-\xdf].|[\xe0-\xef]..|[\xf0-\xf7]...|[\xf8-\xfb]....|[\xfc-\xfd].....)/print 'Length of $1 = ', unpack("H*", $1), ' is ', length($1), "\n"/eg;

exit;

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.4:

Configured by cwu21 at Thu Apr 22 16:01:31 EDT 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos cwu21awu 5.8 generic_108528-29 sun4u sparc sunw,sun-blade-100 '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/opt/SUNWspro/bin/cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags=''
    ccversion='Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6U2/lib -L/usr/local/lib '
    libpth=/usr/lib /usr/ccs/lib /opt/SUNWspro/WS6U2/lib /usr/local/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6U2/lib -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.4:
    /home/dlg24/lib/perl
    /vol/stnfb/lib/perl
    /vol/sec/lib/perl

    /usr/local/perl5/lib/5.8.4/sun4-solaris
    /usr/local/perl5/lib/5.8.4
    /usr/local/perl5/lib/site_perl/5.8.4/sun4-solaris
    /usr/local/perl5/lib/site_perl/5.8.4
    /usr/local/perl5/lib/site_perl
    .


Environment for perl v5.8.4:
    HOME=/home/dlg24
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/vol/stnfb/lib/sun5:/cas/lib/sun4:/usr/openwin/lib:/usr/lib:/usr/dt/lib
    LOGDIR (unset)
    PATH=/bin::/home/dlg24/bin/sun5:/home/dlg24/bin:/vol/stnfb/bin/sun5:/vol/sec/bin/sun5:/usr/local/bin:/usr/dt/bin:/usr/openwin/bin:/bin:/opt/SUNWsmtv/bin:/cas/bin/sun4:/cas/abin/sun4:/cas/X11/sun4/bin:/usr/ccs/bin:/lprod/bin:/usr/sbin:/usr/ucb:/cas/tools/bin/sun4:/cas/X11/sun4/tools/bin:/opt/staroffice7/program:/home/dlg24/bin:/usr/atria/bin:/support/d24/dept24/bin:/projects/n462files/stnfile/tools/bin:/vol/ccase/bin:/usr/perl5/bin:/projects/clearcase/bin
    PERL5LIB=/home/dlg24/lib/perl:/vol/stnfb/lib/perl:/vol/sec/lib/perl::
    PERLLIB=/home/dlg24/lib/perl:/vol/stnfb/lib/perl:/vol/sec/lib/perl::
    PERL_BADLANG (unset)
    SHELL=/bin/ksh

@p5pRT
Copy link
Author

p5pRT commented Feb 18, 2005

From @ysth

On Thu, Feb 17, 2005 at 09​:24​:53PM -0000, dgeorge @​ cas. org wrote​:

This is a bug report for perl from dgeorge@​cas.org,
generated with the help of perlbug 1.35 running under perl v5.8.4.

use bytes;

The bytes pragma was important under the not-so-great way utf8 was
handled in perl5.6.x. IMO, in the 5.8.x series, there is almost no good
reason to use it.

@p5pRT
Copy link
Author

p5pRT commented Feb 18, 2005

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

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2005

From @iabyn

On Thu, Feb 17, 2005 at 09​:24​:53PM -0000, dgeorge @​ cas. org wrote​:

use strict;
use bytes;
use XML​::DOM;

# XML document
my $xml = "<doc>\xe2\x80\x98WOW\xe2\x80\x99</doc>";

# XML parser
my $parser = new XML​::DOM​::Parser;

# Document Object Model
my $dom = $parser->parse($xml, ProtocolEncoding => 'UTF-8');

# Element content
my $content = $dom->getDocumentElement()->getFirstChild()->getNodeValue();

# Print length of $content(should be 9 and is 9)
print 'Length of $content = ', unpack("H*", $content), ' is ', length($content), "\n";

# Print length of $1(should be 3 1 1 1 3 and is 1 1 1 1 3)
$content =~ s/([\x00-\x7f]|[\xc0-\xdf].|[\xe0-\xef]..|[\xf0-\xf7]...|[\xf8-\xfb]....|[\xfc-\xfd].....)/print 'Length of $1 = ', unpack("H*", $1), ' is ', length($1), "\n"/eg;

Fixed in bleedperl by the change below

--
In my day, we used to edit the inodes by hand. With magnets.

Change 25088 by davem@​davem-splatty on 2005/07/07 00​:11​:00

  [perl #34171] bytes pragma error in substitution operator

Affected files ...

... //depot/perl/pp_ctl.c#464 edit
... //depot/perl/t/op/subst.t#43 edit

Differences ...

==== //depot/perl/pp_ctl.c#464 (text) ====

@​@​ -204,7 +204,7 @​@​
  }

  rxres_restore(&cx->sb_rxres, rx);
- RX_MATCH_UTF8_set(rx, SvUTF8(cx->sb_targ));
+ RX_MATCH_UTF8_set(rx, DO_UTF8(cx->sb_targ));

  if (cx->sb_iters++) {
  const I32 saviters = cx->sb_iters;

==== //depot/perl/t/op/subst.t#43 (xtext) ====

@​@​ -7,7 +7,7 @​@​
}

require './test.pl';
-plan( tests => 130 );
+plan( tests => 131 );

$x = 'foo';
$_ = "x";
@​@​ -539,3 +539,17 @​@​
  $name =~ s/hr//e;
}
is($name, "cis", q[#22351 bug with 'e' substitution modifier]);
+
+
+# [perl #34171] $1 didn't honour 'use bytes' in s//e
+{
+ my $s="\x{100}";
+ my $x;
+ {
+ use bytes;
+ $s=~ s/(..)/$x=$1/e
+ }
+ is(length($x), 2, '[perl #34171]');
+}
+
+

@p5pRT p5pRT closed this as completed Jul 7, 2005
@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2005

@iabyn - 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