summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-02-20 10:40:21 +0100
committerErich Eckner <git@eckner.net>2018-02-20 10:40:21 +0100
commite6f770890d32de90309fb7951677735645c09fd1 (patch)
tree291215f8031e377de88ddbbb60fdd9488a4abe99
parent3721fafc7478dea3168a1e15960f4721d3abf563 (diff)
downloadMake-e6f770890d32de90309fb7951677735645c09fd1.tar.xz
dateibeziehungen.pas: quell-"Regex" darf nun auch ein String sein
-rw-r--r--Make.1.in10
-rw-r--r--Make.lps117
-rw-r--r--dateibeziehungen.pas111
3 files changed, 127 insertions, 111 deletions
diff --git a/Make.1.in b/Make.1.in
index 8cb4ddf..228d7ad 100644
--- a/Make.1.in
+++ b/Make.1.in
@@ -39,7 +39,7 @@ The file consists of four types of lines:
.TP
2. Definitions of targets.
.TP
-3. Regular expressions matching sources
+3. Definition of sources.
.TP
4. Commands to execute for compiling targets from sources.
.SH WATCH FILE DEFINITIONS
@@ -57,7 +57,13 @@ These lines must end on \fB:\fP.
Substitutions marked with (*) are allowed in this type of line.
Multiple targets may be defined in one line if separated by spaces or in common bash syntax: \fB*\fP, \fB{one,two,three}\fP, \fB{1..3}\fP are expanded.
Alternatively multiple targets may be defined in multiple consecutive lines.
-A single line containing the source regex must follow a set of target definition lines.
+.SH SOURCE DEFINITIONS
+A set of lines containing the source regexes or source names must follow a set of target definition lines.
+These lines can either be a regex or a verbatim source file name.
+Regexes must start with \fI^\fP and end with \fI$\fP.
+Literal source lines must be quoted in \fI"\fP.
+Substitutions marked with (*) are partially allowed in these types of lines:
+The referenced source must appear before the line referencing it.
.SH COMMAND DEFINITIONS
Each of these lines must end on \fB;\fP.
Substitutions marked with (*) are allowed in this type of line.
diff --git a/Make.lps b/Make.lps
index eab90cf..6f89b0f 100644
--- a/Make.lps
+++ b/Make.lps
@@ -8,24 +8,24 @@
<Filename Value="Make.lpr"/>
<IsPartOfProject Value="True"/>
<TopLine Value="46"/>
- <CursorPos X="61" Y="68"/>
- <UsageCount Value="116"/>
+ <CursorPos Y="68"/>
+ <UsageCount Value="120"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="Machdatei.txt"/>
<IsPartOfProject Value="True"/>
- <UsageCount Value="116"/>
+ <UsageCount Value="120"/>
<DefaultSyntaxHighlighter Value="None"/>
</Unit1>
<Unit2>
<Filename Value="tools.pas"/>
<IsPartOfProject Value="True"/>
- <IsVisibleTab Value="True"/>
<EditorIndex Value="5"/>
- <TopLine Value="259"/>
- <CursorPos X="15" Y="288"/>
- <UsageCount Value="95"/>
+ <TopLine Value="200"/>
+ <CursorPos Y="254"/>
+ <FoldState Value=" T3ie059 piejO057 pj5jQ0M]9lLmI0D5]I6jV032O"/>
+ <UsageCount Value="99"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
@@ -34,17 +34,18 @@
<EditorIndex Value="3"/>
<TopLine Value="459"/>
<CursorPos X="36" Y="377"/>
- <UsageCount Value="92"/>
+ <UsageCount Value="96"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="dateibeziehungen.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dateiBeziehungen"/>
+ <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
- <TopLine Value="793"/>
- <CursorPos X="44" Y="813"/>
- <UsageCount Value="84"/>
+ <CursorPos X="38" Y="7"/>
+ <FoldState Value=" T3jc03C pjYkO0B4 pk5kQ0l312 piXmO066]T4jQ0F1[K5fld0G2[K733u"/>
+ <UsageCount Value="88"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
@@ -64,7 +65,7 @@
<EditorIndex Value="4"/>
<TopLine Value="121"/>
<CursorPos Y="154"/>
- <UsageCount Value="25"/>
+ <UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
@@ -105,7 +106,7 @@
<EditorIndex Value="2"/>
<TopLine Value="188"/>
<CursorPos X="17" Y="204"/>
- <UsageCount Value="19"/>
+ <UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
@@ -140,122 +141,122 @@
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
- <Filename Value="dateibeziehungen.pas"/>
- <Caret Line="102" Column="33" TopLine="84"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="29" Column="13"/>
</Position1>
<Position2>
- <Filename Value="dateibeziehungen.pas"/>
- <Caret Line="765" Column="29" TopLine="737"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="96" Column="21" TopLine="67"/>
</Position2>
<Position3>
- <Filename Value="dateibeziehungen.pas"/>
- <Caret Line="915" Column="56" TopLine="903"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="102" Column="21" TopLine="73"/>
</Position3>
<Position4>
<Filename Value="tools.pas"/>
- <Caret Line="514" Column="17" TopLine="504"/>
+ <Caret Line="112" Column="21" TopLine="83"/>
</Position4>
<Position5>
<Filename Value="tools.pas"/>
- <Caret Line="527" Column="90" TopLine="498"/>
+ <Caret Line="113" Column="30" TopLine="84"/>
</Position5>
<Position6>
<Filename Value="tools.pas"/>
- <Caret Line="517" Column="29" TopLine="510"/>
+ <Caret Line="114" Column="13" TopLine="85"/>
</Position6>
<Position7>
<Filename Value="tools.pas"/>
- <Caret Line="519" Column="75" TopLine="502"/>
+ <Caret Line="128" Column="47" TopLine="117"/>
</Position7>
<Position8>
- <Filename Value="dateibeziehungen.pas"/>
- <Caret Line="917" Column="43" TopLine="903"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="134" Column="24" TopLine="117"/>
</Position8>
<Position9>
<Filename Value="tools.pas"/>
- <Caret Line="519" Column="35" TopLine="502"/>
+ <Caret Line="138" Column="69" TopLine="117"/>
</Position9>
<Position10>
<Filename Value="tools.pas"/>
- <Caret Line="513" Column="25" TopLine="499"/>
+ <Caret Line="137" Column="55" TopLine="117"/>
</Position10>
<Position11>
- <Filename Value="dateibeziehungen.pas"/>
- <Caret Line="813" Column="94" TopLine="793"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="138" Column="69" TopLine="117"/>
</Position11>
<Position12>
- <Filename Value="../units/mystringlistunit.pas"/>
- <Caret Line="40" Column="26" TopLine="25"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="140" Column="55" TopLine="117"/>
</Position12>
<Position13>
- <Filename Value="../units/systemunit.pas"/>
- <Caret Line="18" Column="21"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="143" Column="20" TopLine="117"/>
</Position13>
<Position14>
- <Filename Value="../units/systemunit.pas"/>
- <Caret Line="19" Column="22"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="144" Column="28" TopLine="117"/>
</Position14>
<Position15>
- <Filename Value="../units/systemunit.pas"/>
- <Caret Line="20" Column="22"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="145" Column="15" TopLine="117"/>
</Position15>
<Position16>
- <Filename Value="../units/lowlevelunit.pas"/>
- <Caret Line="154" TopLine="121"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="170" Column="25" TopLine="133"/>
</Position16>
<Position17>
- <Filename Value="../units/systemunit.pas"/>
- <Caret Line="276" TopLine="254"/>
+ <Filename Value="tools.pas"/>
+ <Caret Line="178" Column="84" TopLine="141"/>
</Position17>
<Position18>
<Filename Value="tools.pas"/>
- <Caret Line="520" Column="25" TopLine="503"/>
+ <Caret Line="190" Column="21" TopLine="153"/>
</Position18>
<Position19>
<Filename Value="tools.pas"/>
- <Caret Line="276" Column="16" TopLine="258"/>
+ <Caret Line="230" Column="29" TopLine="177"/>
</Position19>
<Position20>
<Filename Value="tools.pas"/>
- <Caret Line="315" Column="9" TopLine="287"/>
+ <Caret Line="232" Column="26" TopLine="179"/>
</Position20>
<Position21>
<Filename Value="tools.pas"/>
- <Caret Line="322" Column="9" TopLine="294"/>
+ <Caret Line="268" Column="39" TopLine="227"/>
</Position21>
<Position22>
<Filename Value="tools.pas"/>
- <Caret Line="330" Column="9" TopLine="302"/>
+ <Caret Line="269" Column="27" TopLine="228"/>
</Position22>
<Position23>
<Filename Value="tools.pas"/>
- <Caret Line="356" Column="9" TopLine="328"/>
+ <Caret Line="270" Column="28" TopLine="229"/>
</Position23>
<Position24>
<Filename Value="tools.pas"/>
- <Caret Line="367" Column="10" TopLine="339"/>
+ <Caret Line="271" Column="13" TopLine="230"/>
</Position24>
<Position25>
- <Filename Value="tools.pas"/>
- <Caret Line="382" Column="21" TopLine="348"/>
+ <Filename Value="dateibeziehungen.pas"/>
+ <Caret Line="499" TopLine="311"/>
</Position25>
<Position26>
- <Filename Value="tools.pas"/>
- <Caret Line="385" Column="20" TopLine="357"/>
+ <Filename Value="dateibeziehungen.pas"/>
</Position26>
<Position27>
- <Filename Value="tools.pas"/>
- <Caret Line="196" Column="28" TopLine="179"/>
+ <Filename Value="dateibeziehungen.pas"/>
+ <Caret Line="546" Column="9" TopLine="518"/>
</Position27>
<Position28>
- <Filename Value="tools.pas"/>
+ <Filename Value="dateibeziehungen.pas"/>
+ <Caret Line="499" TopLine="70"/>
</Position28>
<Position29>
- <Filename Value="tools.pas"/>
- <Caret Line="304" TopLine="275"/>
+ <Filename Value="dateibeziehungen.pas"/>
</Position29>
<Position30>
- <Filename Value="tools.pas"/>
+ <Filename Value="dateibeziehungen.pas"/>
+ <Caret Line="1151" TopLine="700"/>
</Position30>
</JumpHistory>
</ProjectSession>
diff --git a/dateibeziehungen.pas b/dateibeziehungen.pas
index 5aa60dd..d9b30dd 100644
--- a/dateibeziehungen.pas
+++ b/dateibeziehungen.pas
@@ -498,11 +498,37 @@ end;
function tGenerischeAbhaengigkeit.findeQuellen(dats: tDateienMitDaten): boolean;
var
- i,lastI: longint;
- idx: array of longint;
+ i: longint;
+ idxs: array of tLongintArray;
tmpQs: tDateienMitDaten; // hierin wird die momentan betrachte Kombination von Quellen gespeichert
+
+procedure fuelleStelle(ii: longint);
+var
s: string;
- tmpRE: tRegExpr;
+begin
+ if ii>0 then begin // vorherige Stelle "verbrauchen"
+ tmpQs.add(dats[idxs[ii-1][length(idxs[ii-1])-1]]);
+ setLength(idxs[ii-1],length(idxs[ii-1])-1);
+ end;
+ s:=quellenREs[ii];
+ if (leftStr(s,1)='^') and (rightStr(s,1)='$') then begin // es handelt sich um einen regex
+ if not quellErsetzung(s,rtFpc,tmpQs,ii) then // regex-Substitution nicht erfolgreich -
+ tmpQs.delete(tmpQs.count-1) // wird behandelt wie nie passender regex
+ else
+ dats.matchAll(s,idxs[ii],true);
+ end
+ else if (leftStr(s,1)='"') and (rightStr(s,1)='"') then begin // es handelt sich um einen regulären String
+ delete(s,1,1);
+ delete(s,length(s),1);
+ if not quellErsetzung(s,rtKein,tmpQs,ii) then // Substitution nicht erfolgreich -
+ tmpQs.delete(tmpQs.count-1) // wird behandelt wie nicht existente Datei
+ else
+ dats.matchAll(s,idxs[ii],false);
+ end
+ else
+ fehler('Unbekannte Quell-Syntax: '''+s+''' - weder ''"/pfad/zur/Quelle"'' noch ''^/regex/der/auf/Quelle\.passt$''!');
+end;
+
begin
result:=false;
for i:=0 to length(_quellens)-1 do
@@ -514,61 +540,44 @@ begin
if length(quellenREs)=0 then exit;
- tmpRE:=tRegExpr.create;
tmpQs:=tDateienMitDaten.create;
- tmpQs.count:=length(quellenREs);
- setLength(idx,tmpQs.count);
- for i:=0 to length(idx)-1 do begin
- idx[i]:=-1;
- tmpQs[i]:=nil;
- end;
+ setLength(idxs,length(quellenREs));
+ for i:=0 to length(idxs)-1 do
+ setLength(idxs[i],0);
- lastI:=-1;
+ fuelleStelle(0);
repeat
- if assigned(tmpQs[0]) then
- i:=length(idx)-1
- else
- i:=0;
- while (i>=0) and (i<length(idx)) do begin // alle Stellen von idx müssen gefüllt werden!
- if i<>lastI then begin // wir betrachten eine neue Stelle,
- s:=quellenREs[i]; // daher ist der RegEx nicht mehr aktuell
- if not quellErsetzung(s,rtFpc,tmpQs,i) then begin // regex-substitution nicht erfolgreich -
- idx[i]:=-1; // wird behandelt wie nie passender regex
- tmpQs[i]:=nil;
- dec(i);
- continue;
- end;
- tmpRE.expression:=s;
- lastI:=i;
- end;
- repeat
- inc(idx[i]);
- until (idx[i]>=dats.count) or (tmpRE.exec(dats[idx[i]].name));
-
- if idx[i]>=dats.count then begin // Überlauf
- idx[i]:=-1;
- tmpQs[i]:=nil;
- dec(i);
- continue;
- end;
+ while (tmpQs.count>0) and (length(idxs[tmpQs.count])=0) do
+ tmpQs.delete(tmpQs.count-1);
+ // jetzt gibt es genau so viele tmpQs bis eins vor der letzten idxs-Position
+ // mit einem Wert <> 0
- tmpQs[i]:=dats[idx[i]];
- inc(i); // nächste Stelle
- if i>=length(idx) then // zu weit?
- break; // dann fertig
- idx[i]:=-1; // sonst initialisieren
+ if length(idxs[tmpQs.count])=0 then // das bedeutet einen Übertrag von der 0.
+ break; // auf die -1. Stelle
+
+ for i:=tmpQs.count+1 to length(idxs)-1 do begin // um die Stelle i zu füllen, benötigen wir
+ fuelleStelle(i); // i-1 tmpQs, denn die i-te wird gewählt
+ if i>tmpQs.count then // die neue Stelle wurde nicht befüllt
+ break;
end;
- if i<0 then break; // Überlauf auf -1 => fertig
- setLength(_quellens,length(_quellens)+1);
- _quellens[length(_quellens)-1]:=tDateienMitDaten.create;
- for i:=0 to tmpQs.count-1 do
- _quellens[length(_quellens)-1].add(tmpQs[i]);
+ if tmpQs.count<length(idxs)-1 then // eine Quellersetzung ist fehlgeschlagen -
+ continue; // wir starten die Runde neu
+
+ for i:=0 to length(idxs[length(idxs)-1])-1 do begin
+ tmpQs.add(dats[idxs[length(idxs)-1][i]]);
+ setLength(_quellens,length(_quellens)+1);
+ _quellens[length(_quellens)-1]:=tDateienMitDaten.create;
+ _quellens[length(_quellens)-1].append(tmpQs);
+ tmpQs.delete(tmpQs.count-1);
+ end;
+ setLength(idxs[length(idxs)-1],0);
until false;
- tmpRE.free;
tmpQs.free;
- setLength(idx,0);
+ for i:=0 to length(idxs)-1 do
+ setLength(idxs[i],0);
+ setLength(idxs,0);
setLength(_zieles,length(_quellens));
for i:=0 to length(_zieles)-1 do begin
@@ -825,8 +834,8 @@ begin
else if rightStr(s,1)=':' then
// ein Ziel
wasIst:=ztZiel
- else if (leftStr(s,1)='^') and (rightStr(s,1)='$') then
- // eine Quelle
+ else if ((leftStr(s,1)='^') and (rightStr(s,1)='$')) or // ein Quell-Regex
+ ((leftStr(s,1)='"') and (rightStr(s,1)='"')) then // ein Quell-String
wasIst:=ztQuelle
else
// eine zu überwachende Datei