Closed p5pRT closed 20 years ago
--
To: perlbug@perl.com Subject: wrong SWASHNEW call Cc: nonw Reply-To: laurent.besson@st.com
This is a bug report for perl from laurent.besson@st.com\, generated with the help of perlbug 1.26 running under perl 5.00554.
Report:
When I run the following command : perl toto.pl debug.com
I got the following message:
Can't locate object method "SWASHNEW" via package "utf8" at toto.pl line 90\, \<> chunk 4.
I include here both the perl program and the file to process. I hope to have inserted enough information to reproduce the bug. Don't hesitate to e-mail me for further precision.
Laurent Besson.
--> file debug.com
%ANA1_ASRC0! INAME XIOEND2|XREAGND1|XIBIAS_DAC|XREAGND2|XREAGND3|XREDVDD1|XREDVDD2|XREAVDD1|XREAVDD2|XREDGND1|XREDGND2|XTX_DACP|XTX_DACM|XREPGND|XREPVDD|XIOEND3 MNAME .* PNAME ASRC0x CNAME PAD|ENDCAP
--> end of file
--> perl code (toto.pl):
#!/bin/sh -- # -*- perl -w -*- eval 'exec perl $0 "$@"' if 0;
use utils; use ParserUtil; use strict; use Benchmark;
my $handle; my $struct; my %hash; my $line;
WHILE: while (\<>) {
$line = $_;
# erase begin and end spaces
$line =~ s/(^\s+)|(\s+$)//;
# erase end of line if a ';' occur
$line =~ s/;.*//;
if ($line =~ /\%($TIdent)/) {
if (defined %hash) {
push @$struct\, {%hash};
%hash=();
}
$hash{cname}=$1;
next WHILE;
}
if ($line =~ /\INAME\s+($TRegExp+)/) {
$hash{iname}=$1;
#$hash{iname} =~s/(\[|\]|\||\*|\+|\"|\(|\)|\{|\}|\$|\^|\.|\?)/\\$1/;
next WHILE;
}
if ($line =~ /\MNAME\s+($TRegExp)/) {
$hash{mname}=$1;
#$hash{mname} =~s/(\[|\]|\||\*|\+|\"|\(|\)|\{|\}|\$|\^|\.|\?)/\\$1/;
next WHILE;
}
if ($line =~ /\PNAME\s+($TIdent)/) {
$hash{pname}=$1;
next WHILE;
}
if ($line =~ /\CNAME\s+($TIdent)/) {
$hash{tname}=$1;
next WHILE;
}
}
if (defined %hash) { push @$struct\, {%hash}; }
--> end of code
Laurent Besson writes: : if ($line =~ /\PNAME\s+($TIdent)/) {
It is an error to backslash random letters in Perl\, because backslashed letters are all reserved as meta-sequences. In this case\, you've run into the fact that we've now defined a Unicodish meaning for \P (as the negation of \p\, which matches characters having a particular Unicode property).
If there is a bug here\, it is that Perl doesn't disallow the backslashing of random letters in the first place. But I must confess that I am genuinely curious as to the perceived benefit of the backslash in this case. What did the original writer of the code in question hope to accomplish?
Larry
If there is a bug here\, it is that Perl doesn't disallow the backslashing of random letters in the first place.
It's getting better\, at last with warnings:
% perl -wle 'print "\s"' Unrecognized escape \s passed through at -e line 1. s
But I think I just found some sort of parser bug\, which appears to be my third this morning:
% perl -wle 'print "\LHI"' hi
% perl -wle 'print "\L\LHI"' syntax error at -e line 1\, near "\L\L" Execution of -e aborted due to compilation errors.
--tom
: if ($line =~ /\PNAME\s+($TIdent)/) {
If there is a bug here\, it is that Perl doesn't disallow the backslashing of random letters in the first place. But I must confess that I am genuinely curious as to the perceived benefit of the backslash in this case. What did the original writer of the code in question hope to accomplish?
Well\, PCC allowed \P and simply passed it along as P. Why should Perl reject what PCC allowed? :-) Perhaps the original poster has a long memory and some old habits? (Or could it have been a typo? Nah\, nobody makes typpos anymore.)
Andy Dougherty
--who just dealt with a similar issue on the groff mailing list and
how traditional troff would pass that along as \P.
On Thu\, Feb 03\, 2000 at 10:34:18AM -0700\, Tom Christiansen wrote:
But I think I just found some sort of parser bug\, which appears to be my third this morning:
% perl \-wle 'print "\\LHI"' hi % perl \-wle 'print "\\L\\LHI"' syntax error at \-e line 1\, near "\\L\\L" Execution of \-e aborted due to compilation errors\.
I'm think that this one has been discussed in the past. If the archives were being more responsive\, I would know for sure. :) I don't remember what was concluded.
Ronald
I'm think that this one has been discussed in the past. If the archives were being more responsive\, I would know for sure. :)
That performance issue is what keeps me from searching the archives save for times of truly dire need.
--tom
Andy Dougherty writes: : > : if ($line =~ /\PNAME\s+($TIdent)/) { : > : > If there is a bug here\, it is that Perl doesn't disallow the : > backslashing of random letters in the first place. But I must confess : > that I am genuinely curious as to the perceived benefit of the : > backslash in this case. What did the original writer of the code : > in question hope to accomplish? : : Well\, PCC allowed \P and simply passed it along as P. Why should Perl : reject what PCC allowed? :-)
That explains the motivation for installing the bug into Perl in the first place\, but it doesn't explain why someone would want to say \P in the first place.
: Perhaps the original poster has a long memory : and some old habits? (Or could it have been a typo? Nah\, nobody makes : typpos anymore.)
Uh huh. Actually I doubt this could be a typo anyway because it happens several times in several different ways. It looks more like a braino.
My guess would be some kind of superstitious believe that it's always better to backslash something when in doubt\, presumably based on exposure to PCC or some other Unix subculture in which unrecognized backslashes are ignored.
Alternately\, if the input was TeX-like\, maybe they were trying to match a backslash?
As I said\, I'm genuinely curious. I consider it part of my job to know how people think\, especially when they think differently from me. I'm not looking to castigate anyone for being themselves. (Unless\, of course\, I wish they were someone else.)
Larry
Migrated from rt.perl.org#2065 (status was 'resolved')
Searchable as RT2065$