[comp.lang.perl] bug in pl41

merlyn@iwarp.intel.com (Randal Schwartz) (12/06/90)

Found this bug while working on the index in pl41...

##################################################
perl -pe 's/ /\\0/g,s/\\0/ / if /^\.XX/' <<\EOF
.XX integers,\0large,\0manipulating
Input values may be of the form
$FNUM = fneg($FNUM);		    # negation
The routine returns the number of warnings issued.
EOF
##################################################

The third line should not be touched, but is incorrectly altered to read:
$FNUM = fneg($FNUM);		    # negattio

This is very wrong.  Larry has already recieved this bug report in
private mail.  Perl pl28 worked fine on this.  Interestingly enough,
deleting *any* of the four lines makes it go away (including the
*following* line).  This one's weird.

By the way, after initially noting the bug, but noticing that just
feeding a bad line wouldn't trigger it, I had to reduce the "trigger"
set down to something manageable.  I did it with the following quickly
written test harness, which you may find interesting:

##################################################
#!/local/usr/bin/perl

open(B,"book.B") || die;
@B = <B>;
close(B);

while (++$n < 10) {
	@copy = @B;
	print "deleting one line of ", 0+@copy, " lines\n";
	splice(@copy, rand($#copy), 1); # deletes it
	open(T,">T") || die;
	print T @copy;
	close(T);
	$ret = system <<'EOF';;
perl -pe 's/ /\\0/g,s/\\0/ / if /^\.XX/;' T >TT;
diff T TT
EOF
	if ($ret) {
		@B = @copy;
		$n = 0;
	}
}

print "minimal set:\n", @B;
exit 0;
##################################################

Yes, book.B is appendix B of "the book".  So look here, you get four
lines of the book for free. :-) The algorithm starts with the whole
chapter, and deletes one line at a time at random until it can't
delete any more.  It found the minimal set pretty fast.  (The diff was
for my benefit... for silent operation, I would have replaced it with
cmp).

print "Just another [puzzled] Perl hacker,"
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/