mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 11:39:19 +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-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: cgimodules:serrnomainmodule
|
|
||||||
msgid "No CGI datamodule to handle CGI request."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: cgimodules:serrnorequesthandler
|
#: cgimodules:serrnorequesthandler
|
||||||
msgid "%s: No CGI request handler set."
|
msgid "%s: No CGI request handler set."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: cgimodules:serrnomainmodule
|
||||||
|
msgid "No CGI datamodule to handle CGI request."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ begin
|
|||||||
Filename:=GetCurrentDir+'/scanexamples/test.h';
|
Filename:=GetCurrentDir+'/scanexamples/test.h';
|
||||||
if ParamCount=1 then
|
if ParamCount=1 then
|
||||||
Filename:=ParamStr(1);
|
Filename:=ParamStr(1);
|
||||||
|
|
||||||
// Step 1: load the file
|
// Step 1: load the file
|
||||||
CCode:=CodeToolBoss.LoadFile(Filename,false,false);
|
CCode:=CodeToolBoss.LoadFile(Filename,false,false);
|
||||||
if CCode=nil then
|
if CCode=nil then
|
||||||
|
@ -42,6 +42,8 @@ procedure ReadNextCAtom(const Source: string;
|
|||||||
var Position: integer; out AtomStart: integer);
|
var Position: integer; out AtomStart: integer);
|
||||||
procedure ReadRawNextCAtom(const Source: string;
|
procedure ReadRawNextCAtom(const Source: string;
|
||||||
var Position: integer; out AtomStart: integer);
|
var Position: integer; out AtomStart: integer);
|
||||||
|
|
||||||
|
function ExtractCodeFromMakefile(const Source: string): string;
|
||||||
|
|
||||||
function CConstantToInt64(const s: string; out i: int64): boolean;
|
function CConstantToInt64(const s: string; out i: int64): boolean;
|
||||||
|
|
||||||
@ -343,6 +345,89 @@ begin
|
|||||||
{$IFDEF RangeChecking}{$R+}{$UNDEF RangeChecking}{$ENDIF}
|
{$IFDEF RangeChecking}{$R+}{$UNDEF RangeChecking}{$ENDIF}
|
||||||
end;
|
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;
|
function CConstantToInt64(const s: string; out i: int64): boolean;
|
||||||
var
|
var
|
||||||
p: Integer;
|
p: Integer;
|
||||||
|
@ -48,8 +48,8 @@ uses
|
|||||||
Classes, SysUtils, LCLProc, Forms, Controls, Dialogs, Menus,
|
Classes, SysUtils, LCLProc, Forms, Controls, Dialogs, Menus,
|
||||||
StringHashList, Translations,
|
StringHashList, Translations,
|
||||||
// codetools
|
// codetools
|
||||||
CodeToolManager, CodeCache, BasicCodeTools, DefineTemplates, FileProcs,
|
CodeToolManager, CodeCache, NonPascalCodeTools, BasicCodeTools,
|
||||||
AVL_Tree, Laz_XMLCfg,
|
DefineTemplates, FileProcs, AVL_Tree, Laz_XMLCfg,
|
||||||
// IDE Interface
|
// IDE Interface
|
||||||
IDEExternToolIntf, NewItemIntf, ProjectIntf, PackageIntf, MenuIntf,
|
IDEExternToolIntf, NewItemIntf, ProjectIntf, PackageIntf, MenuIntf,
|
||||||
PropEdits, IDEMsgIntf, MacroIntf, LazIDEIntf,
|
PropEdits, IDEMsgIntf, MacroIntf, LazIDEIntf,
|
||||||
@ -1368,7 +1368,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if CompareTextIgnoringSpace(CodeBuffer.Source,s,false)=0 then begin
|
if ExtractCodeFromMakefile(CodeBuffer.Source)=ExtractCodeFromMakefile(s)
|
||||||
|
then begin
|
||||||
// Makefile.fpc not changed
|
// Makefile.fpc not changed
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
exit;
|
exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user