Bug in indent.
Duncan C White
dcw at doc.ic.ac.uk
Tue Jul 24 00:32:35 AEST 1990
Greetings,
I have found a bug in indent.. I hope this is the right place
to report it. If it matters, it was on a Sun 3 running SunOS
4.0.3..
It appears that indent is quite happy to rewrite '=!' as '!='
if you omit a space between the = and the !
Here is a little program which shows the problem:
/*
* Try running this, then run it through indent
* and run it again!
*/
#include <stdio.h>
main()
{
int x = 0;
printf("before: x=%d\n", x);
x=!x;
printf("after: x=%d\n", x);
}
Before running indent, the program correctly prints 0 followed by 1.
After running indent, the program prints 0 followed by 0 (!)
On examination, this is because the x=!x line has been rewritten as:
x != x;
[ie. compare x against itself, and then discard the result]
I know the manual page says that indent has a "forgiving parser" but
really! A parser that rewrites your program for you?
NB: This problem was "enhanced" :-) by lint, which did not flag x != x
as suspicious.
Duncan White.
----------------------------------------------------------------------------
Duncan White, | Doctor: "I'm sure I've forgotten something.."
Dept. Of Computing, | Shopkeeper: "Haven't you forgotten something?"
Imperial College, | Doctor: "Yes..but what?"
London SW7 | Shopkeeper: "Money"
England, | Doctor: "Oh no, that wasn't it"
The Earth. | (wanders off looking puzzled, without paying)
(or Gallifrey?) | Survival episode I, 22nd Nov 1989
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list