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

View File

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

View File

@ -1136,18 +1136,16 @@ end;
procedure TPreprocessor.SendMsg(const Msg: string; Typ: TIsppMessageType); procedure TPreprocessor.SendMsg(const Msg: string; Typ: TIsppMessageType);
const const
MsgFormats: array[TIsppMessageType] of string = MsgPrefixes: array[TIsppMessageType] of string = ('', 'Warning: ');
('%s', 'Warning: %s');
var var
S: string; S: string;
begin begin
S := GetFileName(-1); S := GetFileName(-1);
if S <> '' then 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 else
S := Format('Line %d: %s', [GetLineNumber(-1), Msg]); S := Format('Line %d: %s%s', [GetLineNumber(-1), MsgPrefixes[Typ], Msg]);
FCompilerParams.StatusProc(FCompilerParams.CompilerData, FCompilerParams.StatusProc(FCompilerParams.CompilerData, PChar(S), Typ = imtWarning);
PChar(Format(MsgFormats[Typ], [S])));
end; end;
function TPreprocessor.DimOf(const Name: String): Integer; 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> <ul>
<li>Using <tt>#pragma verboselevel</tt> now automatically turns on verbose mode.</li> <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>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> </ul>
<li>Various documentation improvements.</li> <li>Various documentation improvements.</li>
<li>Minor tweaks.</li> <li>Minor tweaks.</li>