mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 06:08:16 +02:00
Try to fix error introduced in commit 28925 leading to corruption of HelpFiles and SourceDirList
git-svn-id: trunk@30447 -
This commit is contained in:
parent
1114089d25
commit
c59e8733d6
@ -614,7 +614,7 @@ begin
|
||||
{ Files }
|
||||
{ avoid keeping old files }
|
||||
INIFile^.DeleteSection(secFiles);
|
||||
INIFile^.SetEntry(secFiles,ieOpenExts,'"'+OpenExts+'"');
|
||||
INIFile^.SetEntry(secFiles,ieOpenExts,EscapeIniText(OpenExts));
|
||||
for I:=1 to High(RecentFiles) do
|
||||
begin
|
||||
if I<=RecentFileCount then
|
||||
@ -682,17 +682,17 @@ begin
|
||||
{ Help }
|
||||
S:='';
|
||||
HelpFiles^.ForEach(@ConcatName);
|
||||
INIFile^.SetEntry(secHelp,ieHelpFiles,'"'+S+'"');
|
||||
INIFile^.SetEntry(secHelp,ieHelpFiles,EscapeIniText(S));
|
||||
{ Editor }
|
||||
INIFile^.SetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
|
||||
INIFile^.SetIntEntry(secEditor,ieDefaultIndentSize,DefaultIndentSize);
|
||||
INIFile^.SetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
|
||||
INIFile^.SetEntry(secEditor,ieDefaultSaveExt,DefaultSaveExt);
|
||||
{ Highlight }
|
||||
INIFile^.SetEntry(secHighlight,ieHighlightExts,'"'+HighlightExts+'"');
|
||||
INIFile^.SetEntry(secHighlight,ieTabsPattern,'"'+TabsPattern+'"');
|
||||
INIFile^.SetEntry(secHighlight,ieHighlightExts,EscapeIniText(HighlightExts));
|
||||
INIFile^.SetEntry(secHighlight,ieTabsPattern,EscapeIniText(TabsPattern));
|
||||
{ SourcePath }
|
||||
INIFile^.SetEntry(secSourcePath,ieSourceList,'"'+SourceDirs+'"');
|
||||
INIFile^.SetEntry(secSourcePath,ieSourceList,EscapeIniText(SourceDirs));
|
||||
{ Mouse }
|
||||
INIFile^.SetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
|
||||
INIFile^.SetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse));
|
||||
@ -722,9 +722,9 @@ begin
|
||||
begin
|
||||
S:=IntToStr(I);
|
||||
GetToolParams(I-1,S1,S2,S3,W);
|
||||
if S1<>'' then S1:='"'+S1+'"';
|
||||
if S2<>'' then S2:='"'+S2+'"';
|
||||
if S3<>'' then S3:='"'+S3+'"';
|
||||
if S1<>'' then S1:=EscapeIniText(S1);
|
||||
if S2<>'' then S2:=EscapeIniText(S2);
|
||||
if S3<>'' then S3:=EscapeIniText(S3);
|
||||
INIFile^.SetEntry(secTools,ieToolName+S,S1);
|
||||
INIFile^.SetEntry(secTools,ieToolProgram+S,S2);
|
||||
INIFile^.SetEntry(secTools,ieToolParams+S,S3);
|
||||
|
49
ide/wini.pas
49
ide/wini.pas
@ -83,6 +83,8 @@ const MainSectionName : string[40] = 'MainSection';
|
||||
CommentChar : char = ';';
|
||||
ValidStrDelimiters: set of char = ['''','"'];
|
||||
|
||||
function EscapeIniText(S : string) : String;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -97,6 +99,30 @@ uses
|
||||
{$DEFINE REENABLE_R}
|
||||
{$ENDIF}
|
||||
|
||||
function EscapeIniText(S : string) : String;
|
||||
var
|
||||
delimiter : char;
|
||||
i: integer;
|
||||
begin
|
||||
delimiter:=#0;
|
||||
while delimiter < #255 do
|
||||
begin
|
||||
if (delimiter in ValidStrDelimiters) and
|
||||
(pos(delimiter,S)=0) then
|
||||
break;
|
||||
delimiter:=succ(delimiter);
|
||||
end;
|
||||
if delimiter=#255 then
|
||||
delimiter:='"';
|
||||
{ we use \", but we also need to escape \ itself }
|
||||
for i:=length(s) downto 1 do
|
||||
if (s[i]=delimiter) then
|
||||
s:=copy(s,1,i-1)+'\'+delimiter+copy(s,i+1,length(s))
|
||||
else if (s[i]='\') then
|
||||
s:=copy(s,1,i-1)+'\\'+copy(s,i+1,length(s));
|
||||
EscapeIniText:=delimiter+s+delimiter;
|
||||
end;
|
||||
|
||||
function CalcHash(const s: String): Cardinal;
|
||||
var
|
||||
i: integer;
|
||||
@ -123,8 +149,6 @@ end;
|
||||
|
||||
function TINIEntry.GetText: string;
|
||||
var S,CoS: string;
|
||||
delimiter : char;
|
||||
i : longint;
|
||||
begin
|
||||
if Text=nil then
|
||||
begin
|
||||
@ -135,26 +159,7 @@ begin
|
||||
begin
|
||||
{ if Value contains CommentChar, we need to add delimiters }
|
||||
if pos(CommentChar,S)>0 then
|
||||
begin
|
||||
delimiter:=#0;
|
||||
while delimiter < #255 do
|
||||
begin
|
||||
if (delimiter in ValidStrDelimiters) and
|
||||
(pos(delimiter,S)=0) then
|
||||
break;
|
||||
delimiter:=succ(delimiter);
|
||||
end;
|
||||
if delimiter=#255 then
|
||||
delimiter:='"';
|
||||
{ we use \", but we also need to escape \ itself }
|
||||
for i:=length(s) downto 1 do
|
||||
if (s[i]=delimiter) then
|
||||
s:=copy(s,1,i-1)+'\'+delimiter+copy(s,i+1,length(s))
|
||||
else if (s[i]='\') then
|
||||
s:=copy(s,1,i-1)+'\\'+copy(s,i+1,length(s));
|
||||
|
||||
s:=delimiter+s+delimiter;
|
||||
end;
|
||||
S:=EscapeIniText(S);
|
||||
S:=S+' '+CommentChar+' '+CoS;
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user