[gnu.gcc.bug] 1.35 #pragma once bug/fix

rfg@MCC.COM (Ron Guilmette) (05/08/89)

If any of you out there in GNU-land have tried to use the new cpp
#pragma once feature, will no doubt have realized that it is broke.
Essentially, files which contain #pragma once in them are re-opened
for the second and subsequent includes (don't ask me why).
Unfortunately in these "second and subsequent" cases, there is no
corresponding close(), so you end up with too many open files
eventually.  The following patch fixes the problem.  The line
numbers may be a little off from those in an "out-of-the-box"
1.35 distribution, but don't worry about that.


diff -rc2 1.35--/cccp.c 1.35-+/cccp.c
*** 1.35--/cccp.c	Mon Apr 10 16:53:16 1989
--- 1.35-+/cccp.c	Wed Apr 26 18:37:58 1989
***************
*** 2492,2497 ****
  
      for (ptr = dont_repeat_files; ptr; ptr = ptr->next) {
!       if (!strcmp (ptr->fname, fname))
          return;				/* This file was once'd. */
      }
  
--- 2520,2527 ----
  
      for (ptr = dont_repeat_files; ptr; ptr = ptr->next) {
!       if (!strcmp (ptr->fname, fname)) {
!         close (f);
          return;				/* This file was once'd. */
+       }
      }
  


// Ron Guilmette  -  MCC  -  Experimental Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg