Diab Jerius on Fri, 2 Jul 1999 14:56:50 -0400 (EDT)
Perceps heads into infinite loop land (well, it
seems that way) when it comes across code like
this:
// search for the continuation escape
char\* ptr = strrchr\( \*txt, '\\\' \);
It doesn't like the '\\'. The problem seems to be
in MASKSPECIAL:
# Handle escaped quotes
$str=~s/\\\"/&&QUOTD/g;
$str=~s/\\\'/&&QUOTS/g;
It blithely wacks the second backslash. I'm not
sure what happens next, but that seems to send it
whimpering into the corner. Now, I've concocted a
fix, which may actually be the correct one:
# Handle escaped backslashes
$str=~s/\\\\/&&ESCBACKSL/g;
# Handle escaped quotes
$str=~s/\\\"/&&QUOTD/g;
$str=~s/\\\'/&&QUOTS/g;
with the requisite fix to REPLACE_SPECIAL:
$str=~s/&&ESCBACKSL/\\\\/g;
HOWEVER, I notice in REPLACE_SPECIAL that all
quotes, regardless of whether they were escaped in
the original text, are replaced with an unescaped
quote. Is this valid?
So, here are my proposed fixes, with a fix for
what I percieve to be a an additional bug in the
handling of escaped quotes:
*** perceps.pl.orig Mon May 3 22:01:31 1999
--- perceps.pl Fri Jul 2 14:17:53 1999
***************
*** 1517,1525 ****
local($str)=@_;
local($tmp1,$tmp2);
# Handle escaped quotes
! $str=~s/\\\"/&&QUOTD/g;
! $str=~s/\\\'/&&QUOTS/g;
while ( $str=~/(\'|\"|\/\*|\/\/)/ ) {
$tmp1=$1;
--- 1517,1528 ----
local($str)=@_;
local($tmp1,$tmp2);
+ # Handle escaped backslashes
+ $str=~s/\\\\/&&ESCBACKSL/g;
+
# Handle escaped quotes
! $str=~s/\\\"/&&ESCQUOTD/g;
! $str=~s/\\\'/&&ESCQUOTS/g;
while ( $str=~/(\'|\"|\/\*|\/\/)/ ) {
$tmp1=$1;
***************
*** 1610,1615 ****
--- 1613,1621 ----
$str=~s/&&CCOMMC/*\//g;
$str=~s/&&CPCOMM/\/\//g;
$str=~s/&&NEWLINE/\n/g;
+ $str=~s/&&ESCBACKSL/\\\\/g;
+ $str=~s/&&ESCQUOTD/\\\"/g;
+ $str=~s/&&ESCQUOTS/\\\'/g;
}
return $str;