🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #175

Bug in indent.

#175
From: Duncan C White
Date: Mon, 23 Jul 1990 14:32
52 lines
1942 bytes
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
Technical Details
Message-ID: <2125@gould.doc.ic.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!ukc!icdoc!doc.ic.ac.uk!dcw

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!ukc!icdoc!doc.ic.ac.uk!dcw
From: dcw@doc.ic.ac.uk (Duncan C White)
Newsgroups: comp.bugs.4bsd
Subject: Bug in indent.
Message-ID: <2125@gould.doc.ic.ac.uk>
Date: 23 Jul 90 14:32:35 GMT
Sender: dcw@doc.ic.ac.uk
Reply-To: dcw@doc.ic.ac.uk (Duncan C White)
Organization: Dept. of Computing, Imperial College, London, UK.
Lines: 52