mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 18:40:41 +02:00
IDE: checking package Makefile.fpc changes ignoring comments and empty lines
git-svn-id: trunk@14613 -
This commit is contained in:
parent
1e130f9f61
commit
3e15890632
@ -4,11 +4,11 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: cgimodules:serrnomainmodule
|
||||
msgid "No CGI datamodule to handle CGI request."
|
||||
msgstr ""
|
||||
|
||||
#: cgimodules:serrnorequesthandler
|
||||
msgid "%s: No CGI request handler set."
|
||||
msgstr ""
|
||||
|
||||
#: cgimodules:serrnomainmodule
|
||||
msgid "No CGI datamodule to handle CGI request."
|
||||
msgstr ""
|
||||
|
||||
|
@ -50,7 +50,7 @@ begin
|
||||
Filename:=GetCurrentDir+'/scanexamples/test.h';
|
||||
if ParamCount=1 then
|
||||
Filename:=ParamStr(1);
|
||||
|
||||
|
||||
// Step 1: load the file
|
||||
CCode:=CodeToolBoss.LoadFile(Filename,false,false);
|
||||
if CCode=nil then
|
||||
|
@ -42,6 +42,8 @@ procedure ReadNextCAtom(const Source: string;
|
||||
var Position: integer; out AtomStart: integer);
|
||||
procedure ReadRawNextCAtom(const Source: string;
|
||||
var Position: integer; out AtomStart: integer);
|
||||
|
||||
function ExtractCodeFromMakefile(const Source: string): string;
|
||||
|
||||
function CConstantToInt64(const s: string; out i: int64): boolean;
|
||||
|
||||
@ -343,6 +345,89 @@ begin
|
||||
{$IFDEF RangeChecking}{$R+}{$UNDEF RangeChecking}{$ENDIF}
|
||||
end;
|
||||
|
||||
function ExtractCodeFromMakefile(const Source: string): string;
|
||||
// remove comments, empty lines, double spaces, replace newline chars with #10
|
||||
|
||||
procedure Run(var NewSrc: string; out NewLength: integer);
|
||||
var
|
||||
SrcLen: Integer;
|
||||
SrcPos: Integer;
|
||||
DestPos: Integer;
|
||||
LastChar: Char;
|
||||
LineEndPos: LongInt;
|
||||
EndPos: LongInt;
|
||||
IsEmptyLine: Boolean;
|
||||
CommentStartPos: Integer;
|
||||
begin
|
||||
SrcPos:=1;
|
||||
SrcLen:=length(Source);
|
||||
DestPos:=1;
|
||||
while SrcPos<=SrcLen do begin
|
||||
// check if line is empty
|
||||
LineEndPos:=SrcPos;
|
||||
IsEmptyLine:=true;
|
||||
CommentStartPos:=0;
|
||||
while (LineEndPos<=SrcLen) and (not (Source[LineEndPos] in [#10,#13])) do
|
||||
begin
|
||||
case Source[LineEndPos] of
|
||||
#10,#13: break;
|
||||
' ',#9: ;
|
||||
'#': if (CommentStartPos<1) then CommentStartPos:=LineEndPos;
|
||||
else
|
||||
if IsEmptyLine and (CommentStartPos<1) then
|
||||
IsEmptyLine:=false;
|
||||
end;
|
||||
inc(LineEndPos);
|
||||
end;
|
||||
//DebugLn(['Run SrcPos=',SrcPos,' LineEndPos=',LineEndPos,' Line="',dbgstr(copy(Source,SrcPos,LineEndPos-SrcPos)),'" IsEmpty=',IsEmptyLine]);
|
||||
|
||||
// copy line content
|
||||
if not IsEmptyLine then begin
|
||||
LastChar:=#0;
|
||||
if Source[SrcPos]=#9 then begin
|
||||
// first character is tab
|
||||
LastChar:=#9;
|
||||
if NewSrc<>'' then
|
||||
NewSrc[DestPos]:=LastChar;
|
||||
inc(DestPos);
|
||||
inc(SrcPos);
|
||||
end;
|
||||
EndPos:=LineEndPos;
|
||||
if CommentStartPos>0 then
|
||||
EndPos:=CommentStartPos;
|
||||
while SrcPos<EndPos do begin
|
||||
if (not (Source[SrcPos] in [' ',#9]))
|
||||
or (not (LastChar in [' ',#9])) then begin
|
||||
LastChar:=Source[SrcPos];
|
||||
if NewSrc<>'' then
|
||||
NewSrc[DestPos]:=LastChar;
|
||||
inc(DestPos);
|
||||
end;
|
||||
inc(SrcPos);
|
||||
end;
|
||||
if NewSrc<>'' then
|
||||
NewSrc[DestPos]:=#10;
|
||||
inc(DestPos);
|
||||
end;
|
||||
|
||||
// next line
|
||||
SrcPos:=LineEndPos+1;
|
||||
if (SrcPos<=SrcLen) and (Source[SrcLen] in [#10,#13])
|
||||
and (Source[SrcLen]<>Source[SrcLen-1]) then
|
||||
inc(SrcPos);
|
||||
end;
|
||||
NewLength:=DestPos-1;
|
||||
end;
|
||||
|
||||
var
|
||||
NewLength: integer;
|
||||
begin
|
||||
Result:='';
|
||||
Run(Result,NewLength);
|
||||
SetLength(Result,NewLength);
|
||||
Run(Result,NewLength);
|
||||
end;
|
||||
|
||||
function CConstantToInt64(const s: string; out i: int64): boolean;
|
||||
var
|
||||
p: Integer;
|
||||
|
@ -48,8 +48,8 @@ uses
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, Dialogs, Menus,
|
||||
StringHashList, Translations,
|
||||
// codetools
|
||||
CodeToolManager, CodeCache, BasicCodeTools, DefineTemplates, FileProcs,
|
||||
AVL_Tree, Laz_XMLCfg,
|
||||
CodeToolManager, CodeCache, NonPascalCodeTools, BasicCodeTools,
|
||||
DefineTemplates, FileProcs, AVL_Tree, Laz_XMLCfg,
|
||||
// IDE Interface
|
||||
IDEExternToolIntf, NewItemIntf, ProjectIntf, PackageIntf, MenuIntf,
|
||||
PropEdits, IDEMsgIntf, MacroIntf, LazIDEIntf,
|
||||
@ -1368,7 +1368,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if CompareTextIgnoringSpace(CodeBuffer.Source,s,false)=0 then begin
|
||||
if ExtractCodeFromMakefile(CodeBuffer.Source)=ExtractCodeFromMakefile(s)
|
||||
then begin
|
||||
// Makefile.fpc not changed
|
||||
Result:=mrOk;
|
||||
exit;
|
||||
|
Loading…
Reference in New Issue
Block a user