Front page | perl.perl5.porters |
Postings from June 2012
[perl #113868] formline mis-counts characters
From:
dakkar
Date:
June 29, 2012 03:53
Subject:
[perl #113868] formline mis-counts characters
Message ID:
rt-3.6.HEAD-28836-1340811475-1402.113868-75-0@perl.org
# New Ticket Created by dakkar
# Please include the string: [perl #113868]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=113868 >
This is a bug report for perl from dakkar@thenautilus.net,
generated with the help of perlbug 1.39 running under perl 5.17.2.
-----------------------------------------------------------------
This is essentially a duplicate of bug #33832.
When using formats with character strings containing characters outside of ASCII, formline cuts the string at the wrong place, resulting in weird output.
The following test shows the issue:
#!/usr/bin/env perl
use Test::More;
use strict;
use warnings;
use utf8;
use feature 'unicode_strings';
sub check_format_lines {
my ($format,$count) = @_;
my $output='';
open my $fh,'>:utf8',\$output;
my $oldfh=select $fh;
$~=$format;
write;
select $oldfh;
close $fh;
my $lines_count = () = $output =~ m{^}mg;
is($lines_count,$count)
or note $output;
}
my $test;
format TEST =
{^<<<<<<}~~
$test
.
$test ='TEST[ààèèììòòùù123456789]';
check_format_lines('TEST',4);
$test ='TEST[ààèèììòòùù123456789ß]';
check_format_lines('TEST',4);
$test ='TEST[à]';
check_format_lines('TEST',1);
$test ='[à]';
check_format_lines('TEST',1);
$test ='[a]';
check_format_lines('TEST',1);
$test ='TEST[a]';
check_format_lines('TEST',1);
done_testing();
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl 5.17.2:
Configured by dakkar at Wed Jun 27 14:54:57 BST 2012.
Summary of my perl5 (revision 5 version 17 subversion 2) configuration:
Snapshot of: 989843c833048f47253702c8ffd749d2315cbe3c
Platform:
osname=linux, osvers=3.2.12-gentoo, archname=x86_64-linux
uname='linux exelion 3.2.12-gentoo #7 smp preempt mon may 28 14:42:47 bst 2012 x86_64 intel(r) xeon(r) cpu e5430 @ 2.66ghz genuineintel gnulinux '
config_args='-de -Dprefix=/home/dakkar/perl5/perlbrew/perls/perl-blead -Dusedevel'
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 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector'
ccversion='', gccversion='4.5.3', 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/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.14.1.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.14.1'
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.17.2:
/home/dakkar/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.2/x86_64-linux
/home/dakkar/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.2
/home/dakkar/perl5/perlbrew/perls/perl-blead/lib/5.17.2/x86_64-linux
/home/dakkar/perl5/perlbrew/perls/perl-blead/lib/5.17.2
.
---
Environment for perl 5.17.2:
HOME=/home/dakkar
LANG (unset)
LANGUAGE (unset)
LC_ALL=en_US.UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/dakkar/perl5/perlbrew/bin:/home/dakkar/perl5/perlbrew/perls/perl-blead/bin:/home/dakkar/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3
PERLBREW_BASHRC_VERSION=0.41
PERLBREW_HOME=/home/dakkar/.perlbrew
PERLBREW_MANPATH=/home/dakkar/perl5/perlbrew/perls/perl-blead/man
PERLBREW_PATH=/home/dakkar/perl5/perlbrew/bin:/home/dakkar/perl5/perlbrew/perls/perl-blead/bin
PERLBREW_PERL=perl-blead
PERLBREW_ROOT=/home/dakkar/perl5/perlbrew
PERLBREW_VERSION=0.41
PERL_BADLANG (unset)
SHELL=/bin/bash
-
[perl #113868] formline mis-counts characters
by dakkar