From 4cb2106ee4f7fb962aa976fa0f575b0296fe97de Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 3 Feb 2022 22:22:33 -0600 Subject: [PATCH] Change the name of the current source file on an #include or #append. This causes __FILE__ to give the name of an include file if used within it, which seems to be what the standards intend (and what other compilers do). It also affects the file name recorded in debugging information for functions declared in an include file. (Note that occ will generate a #line directive before an #append, essentially to work around the problem this patch fixes. After the patch, such a #line directive is effectively ignored. This should be OK, although it may result in a difference in whether a full or partial pathname is used for __FILE__ and in debug info.) --- Scanner.pas | 1 + cc.notes | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Scanner.pas b/Scanner.pas index 9b9be0e..3cf4c5f 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -2164,6 +2164,7 @@ if gotName then begin {read the file name from the line} oldincludeFileGS := includeFileGS; {set the file name} includeFileGS.theString.theString := workString; includeFileGS.theString.size := length(workString); + sourceFileGS := includeFileGS; ReadFile; {read the file} chPtr := bofPtr; {set the start, end pointers} eofPtr := pointer(ord4(bofPtr)+ffDCBGS.fileLength); diff --git a/cc.notes b/cc.notes index a160030..fc2de67 100644 --- a/cc.notes +++ b/cc.notes @@ -1731,6 +1731,8 @@ int foo(int[42]); (Devin Reade) +177. The name of the current source file was not updated when processing an #include or #append. As a result, uses of the __FILE__ macro within an include file would not give the name of that file, and functions within an include file would not have the proper file name recorded in their debugging information. + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.