Colorize ISPP warnings.

This commit is contained in:
Martijn Laan 2020-08-09 02:05:24 +02:00
parent 01e7e91c80
commit f20a683349
4 changed files with 14 additions and 14 deletions

View File

@ -2,17 +2,18 @@ unit CompPreprocInt;
{
Inno Setup
Copyright (C) 1997-2010 Jordan Russell
Copyright (C) 1997-2020 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Compiler preprocessor interface
$jrsoftware: issrc/Projects/CompPreprocInt.pas,v 1.4 2010/12/10 05:14:33 jr Exp $
}
interface
uses
Windows;
const
ispeSuccess = 0;
ispeInvalidParam = 1;
@ -36,7 +37,7 @@ type
procedure(CompilerData: TPreprocCompilerData; ErrorMsg: PChar;
ErrorFilename: PChar; ErrorLine: Integer; ErrorColumn: Integer); stdcall;
TPreprocStatusProc =
procedure(CompilerData: TPreprocCompilerData; StatusMsg: PChar); stdcall;
procedure(CompilerData: TPreprocCompilerData; StatusMsg: PChar; Warning: BOOL); stdcall;
TPreprocPrependDirNameProc =
function(CompilerData: TPreprocCompilerData; Filename: PChar; Dir: PChar;
ErrorFilename: PChar; ErrorLine: Integer; ErrorColumn: Integer): PChar; stdcall;

View File

@ -1210,7 +1210,8 @@ var
should have already called ErrorProc itself }
RaiseError(LineFilename, LineNumber, 'PrependDirNameProc failed');
end;
Params.StatusProc(Params.CompilerData, PChar(Format(SBuiltinPreprocessStatusIncludingFile, [IncludeFilename])));
Params.StatusProc(Params.CompilerData,
PChar(Format(SBuiltinPreprocessStatusIncludingFile, [IncludeFilename])), False);
ProcessLinesFromFile(LineFilename, LineNumber, PathExpand(IncludeFilename));
end
else
@ -2011,12 +2012,12 @@ begin
end;
procedure PreStatusProc(CompilerData: TPreprocCompilerData;
StatusMsg: PChar); stdcall;
StatusMsg: PChar; Warning: BOOL); stdcall;
var
Data: PPreCompilerData;
begin
Data := CompilerData;
Data.Compiler.AddStatus(Format(SCompilerStatusPreprocessorStatus, [StatusMsg]));
Data.Compiler.AddStatus(Format(SCompilerStatusPreprocessorStatus, [StatusMsg]), Warning);
end;
procedure PreErrorProc(CompilerData: TPreprocCompilerData; ErrorMsg: PChar;

View File

@ -1136,18 +1136,16 @@ end;
procedure TPreprocessor.SendMsg(const Msg: string; Typ: TIsppMessageType);
const
MsgFormats: array[TIsppMessageType] of string =
('%s', 'Warning: %s');
MsgPrefixes: array[TIsppMessageType] of string = ('', 'Warning: ');
var
S: string;
begin
S := GetFileName(-1);
if S <> '' then
S := Format('Line %d of %s: %s', [GetLineNumber(-1), PathExtractName(S), Msg])
S := Format('Line %d of %s: %s%s', [GetLineNumber(-1), PathExtractName(S), MsgPrefixes[Typ], Msg])
else
S := Format('Line %d: %s', [GetLineNumber(-1), Msg]);
FCompilerParams.StatusProc(FCompilerParams.CompilerData,
PChar(Format(MsgFormats[Typ], [S])));
S := Format('Line %d: %s%s', [GetLineNumber(-1), MsgPrefixes[Typ], Msg]);
FCompilerParams.StatusProc(FCompilerParams.CompilerData, PChar(S), Typ = imtWarning);
end;
function TPreprocessor.DimOf(const Name: String): Integer;

View File

@ -104,7 +104,7 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
<ul>
<li>Using <tt>#pragma verboselevel</tt> now automatically turns on verbose mode.</li>
<li>Added new <tt>Message</tt>, <tt>Warning</tt>, and <tt>Error</tt> support functions.</li>
<li>ISPP's output is now cleaner.</li>
<li>ISPP's output is now cleaner and warnings are colorized.</li>
</ul>
<li>Various documentation improvements.</li>
<li>Minor tweaks.</li>