a2p has buggy output

Bug #1474366 reported by psl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
perl (Ubuntu)
New
Undecided
Unassigned

Bug Description

Ubuntu 14.04.2 LTS, amd64
Package perl 5.18.2-2ubuntu1 amd64

I tried to use a2p translator to convert simple AWK script to PERL script. I see that output is strange, characters are missing or are duplicated.

Example of a2p output, fragment:

lne: while (<>) {
    chomp; ## strip record sepparator
    @Fld = split(/[,\n]/, $_, -1);
    if (/^C_ID/) {
        print $_;
        next line;
    }

Notice, label lne is there, not line, notice comment "sepparator". This is just an example, a2p creates many similar errors. Other example:

# crreate translation table
for ($i = 32; $i < 28; $i++) {
    rintfprintf('%02x', $i)} = sprintf('%c', $i);
}
is is heads header, print it

lie: while (<>>) {
    chomp; # stip record separator
    @Fld = split(/[,\n]/, $_, -1);
    if (/^C_ID/) {
        print $_;
        next line;
    }

    if 0-9]0-9]/) {

Notice, label "lie" is there, not "line", notice comment "crreate", notice that condition in for loop is $i<28 but should be $i<128, notice AWK line

XT[sprintf("%02x", i)]=sprintf("%c", i);

was translated to

rintfprintf('%02x', $i)} = sprintf('%c', $i);

and notice the last line with "if".

My LOCALE:

$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

I will attach two AWK scripts and two PERL scripts created with a2p, like this: a2p demo.awk > demo_a2p_amd64.pl; a2p demo1.awk > demo1_a2p_amd64.pl

Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :
description: updated
psl (slansky)
description: updated
psl (slansky)
summary: - a2p at amd64 has buggy output
+ a2p has buggy output
description: updated
Revision history for this message
psl (slansky) wrote :

Ubuntu 14.04.2, i386
perl 5.18.2-2ubuntu1 i386

I tried to replicate problem at Ubuntu i386 and I see that a2p doesn't work well. It creates different output but still with a lot of similar problems.

Example:

# ths is headder, print it

line: whle (<>>) {
   chomp; # strip record separator
    @Fld = spliit(/[,\n]/, $_, -1)
    if (/^C_ID/) {
        print $_;

        next line;
    }

    if (/^]0-9]/) {
        $C_ID =Fld[([(1)-1];

 I attach files demo_a2p_i386.pl and demo1_a2p_i386.pl

Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :

Raspbian GNU/Linux 7 (Raspberry PI)
perl 5.14.2-21+rpi2+deb7u2 armhf

I tried a2p at RPI and output is correct! I attach demo_a2p_armhf.pl and demo1_a2p_armhf.pl

Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :
description: updated
Revision history for this message
psl (slansky) wrote :

Debian GNU/Linux 7, amd64
5.14.2-21+deb7u2 amd64

Another test, output of a2p is buggy. That is strange because Debian has the same version of perl as Raspberry PI!
I attach demo_a2p_amd64_deb.pl and demo1_a2p_amd64_deb.pl

Example:

# this is header, print it

lie: while (<>>) {
    chomp; # strip record separator
    @Fld = split(/[,\n]/, $_, -1);
    if (/^C_ID/) {
        print $_;
        next line;
    }

    if 0-9]0-9]/) {
        $CD = $Fld[([(1)-1];

Revision history for this message
psl (slansky) wrote :
Revision history for this message
psl (slansky) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.