diff --git a/CCommon.pas b/CCommon.pas index cb1974c..40f01f8 100644 --- a/CCommon.pas +++ b/CCommon.pas @@ -498,6 +498,7 @@ var oldincludeFileGS: gsosOutString; {previous includeFile value} outFileGS: gsosOutString; {keep file name} partialFileGS: gsosOutString; {partial compile list} + pragmaKeepFile: gsosOutStringPtr; {filename specified in #pragma keep} sourceFileGS: gsosOutString; {presumed source file name} tempList: tempPtr; {list of temp work variables} longlong0: longlong; {the value 0 as a longlong} diff --git a/Header.pas b/Header.pas index 494dc27..ad7c061 100644 --- a/Header.pas +++ b/Header.pas @@ -798,7 +798,7 @@ procedure EndInclude {chPtr: ptr}; WriteWord(floatSlot); end; - p_keep: WriteLongString(@outFileGS.theString); + p_keep: WriteLongString(@pragmaKeepFile^.theString); p_line: begin WriteWord(lineNumber); @@ -1444,11 +1444,13 @@ var end; p_keep: begin - liDCBGS.kFlag := 1; lsPtr := ReadLongString; - outFileGS.theString.size := lsPtr^.length; - for i := 1 to outFileGS.theString.size do - outFileGS.theString.theString[i] := lsPtr^.str[i]; + if liDCBGS.kFlag = 0 then begin + liDCBGS.kFlag := 1; + outFileGS.theString.size := lsPtr^.length; + for i := 1 to outFileGS.theString.size do + outFileGS.theString.theString[i] := lsPtr^.str[i]; + end; {if} end; p_line: begin diff --git a/Scanner.pas b/Scanner.pas index 42fa95e..c7004a1 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -2776,8 +2776,15 @@ var { #pragma keep FILENAME } begin {DoKeep} - FlagPragmas(p_keep); if GetFileName(false) then begin {read the file name} + FlagPragmas(p_keep); + if not ignoreSymbols then + if pragmaKeepFile = nil then begin + new(pragmaKeepFile); + pragmaKeepFile^.maxSize := maxPath + 4; + pragmaKeepFile^.theString.theString := workString; + pragmaKeepFile^.theString.size := length(workString); + end; {if} if foundFunction then Error(17); if liDCBGS.kFlag = 0 then begin {use the old name if there is one...} @@ -4105,6 +4112,7 @@ lintIsError := true; {lint messages are considered errors} fenvAccess := false; {not accessing fp environment} charStrPrefix := prefix_none; {no char/str prefix seen} mergingStrings := false; {not currently merging strings} +pragmaKeepFile := nil; {no #pragma keep file so far} {error codes for lint messages} {if changed, also change maxLint} diff --git a/cc.notes b/cc.notes index f917767..3d31663 100644 --- a/cc.notes +++ b/cc.notes @@ -1746,6 +1746,8 @@ int foo(int[42]); 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 (or portions of functions) within an include file would not have the proper file name recorded in their debugging information. +178. Keep names specified via the KEEP= portion of the command line or the {KeepName} shell variable could sometimes be saved in the .sym file and applied to subsequent compilations, even if they were no longer specified for the later compilation. Also, if a .sym file was used, the keep name specified via #pragma keep might override the one specified on the command line or via {KeepName}. + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.