[gnu.gcc] "Too many open files" from cpp and FIX

jgrace@bbn.com (Joe Grace) (11/26/89)

I just found a bug in gcc-cpp where it fails to close files which have
been "#pragma once"d.  The error is a message that "foo.h: bar.h: Too
many files are open" (or somesuch).  I believe this message originates
from the operating system (perror()?) and is indicated when cpp tries
to open its 31st (Sun OS3.5) or so (simultaneous) file. 

The patch to (gcc v1.35: cccp.c) is simple and follows:
2493c2497,2500
<         return;				/* This file was once'd. */
---
> 	{
> 	  close( f);
> 	  return;				/* This file was once'd. */
> 	}

On another note, I noticed that gcc-cpp does not warn the user when an
#endif without an #if occurs.  I have no enhancement for this, but
thought I would mention it since it too can (I think --- and did for
me :-) lead to the same "Too many open files problem".  Maybe someone
who knows gcc-cpp inside out will know just where to fix this problem.

The combination of bugs was tricky to find.  /lib/cpp (Sun OS3.5)
pointed out the problem with the unbalanced #endif and made the rest
easy. 

By the way, I find the software very good --- which is why I guess
I am even bothering to point out the above.

Thanks for good quality software,

= Joe =
Joe Grace
ARPA: jgrace@bbn.com
UUCP: {harvard,husc6,decvax,etc.}!bbn!jgrace
#include <StandardDisclaimer.h>