new tpl syntax [^section] will prepend to [section]

This commit is contained in:
Massimo Melina 2020-08-01 20:46:07 +02:00
parent a47541286a
commit db2ad83c77

View File

@ -1127,7 +1127,7 @@ var
ss: TStringDynArray; ss: TStringDynArray;
s, si: string; s, si: string;
till: pchar; till: pchar;
append: boolean; append, prepend, add: boolean;
sect, from: PtplSection; sect, from: PtplSection;
begin begin
till:=pred(bos); till:=pred(bos);
@ -1143,8 +1143,10 @@ var
if not parseFlagsAndAcceptSection(ss) then if not parseFlagsAndAcceptSection(ss) then
exit; exit;
append:=ansiStartsStr('+', cur_section); prepend:=startsStr('^', cur_section);
if append then append:=startsStr('+', cur_section);
add:=prepend or append;
if add then
delete(cur_section,1,1); delete(cur_section,1,1);
// there may be several section names separated by = // there may be several section names separated by =
@ -1160,16 +1162,19 @@ var
from:=NIL; from:=NIL;
if sect = NIL then // not found if sect = NIL then // not found
begin begin
if append then if add then
from:=getSection(s); from:=getSection(s);
sect:=newSection(s); sect:=newSection(s);
end end
else else
if append then if add then
from:=sect; from:=sect;
if from<>NIL then if from<>NIL then
begin // inherit from it begin // inherit from it
sect.txt:=from.txt+base.txt; if append then
sect.txt:=from.txt+base.txt
else
sect.txt:=base.txt+CRLF+from.txt;
sect.nolog:=from.nolog or base.nolog; sect.nolog:=from.nolog or base.nolog;
sect.public:=from.public or base.public; sect.public:=from.public or base.public;
sect.noList:=from.noList or base.noList; sect.noList:=from.noList or base.noList;