summaryrefslogtreecommitdiff
path: root/packages/fcl-base
diff options
context:
space:
mode:
authorAlmindor <Almindor@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-05-16 10:35:42 +0000
committerAlmindor <Almindor@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-05-16 10:35:42 +0000
commitf1d482b3b27097341370fe4ce810398069a21e7e (patch)
treee859208246b6c14d0439f35ad24e39678f41376f /packages/fcl-base
parent69094d072f877565ffc1e41ea385f2d7090be5a1 (diff)
downloadfpc-f1d482b3b27097341370fe4ce810398069a21e7e.tar.gz
* apply quoting patch for inifile from A. Klein
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@15280 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-base')
-rw-r--r--packages/fcl-base/src/inifiles.pp39
1 files changed, 25 insertions, 14 deletions
diff --git a/packages/fcl-base/src/inifiles.pp b/packages/fcl-base/src/inifiles.pp
index f03a4ae782..c3193dee2d 100644
--- a/packages/fcl-base/src/inifiles.pp
+++ b/packages/fcl-base/src/inifiles.pp
@@ -726,16 +726,7 @@ begin
else
begin
sIdent:=Trim(Copy(sLine, 1, j - 1));
- sValue:=Trim(Copy(sLine, j + 1, Length(sLine) - j));
- If StripQuotes then
- begin
- J:=Length(sValue);
- // Joost, 2-jan-2007: The check (J>1) is there for the case that
- // the value consist of a single double-quote character. (see
- // mantis bug 6555)
- If (J>1) and ((sValue[1] in ['"','''']) and (sValue[J]=sValue[1])) then
- sValue:=Copy(sValue,2,J-2);
- end;
+ sValue:=Trim(Copy(sLine, j + 1, Length(sLine) - j));
end;
end;
oSection.KeyList.Add(TIniFileKey.Create(sIdent, sValue));
@@ -748,15 +739,25 @@ function TIniFile.ReadString(const Section, Ident, Default: string): string;
var
oSection: TIniFileSection;
oKey: TIniFileKey;
+ J: integer;
begin
Result := Default;
oSection := FSectionList.SectionByName(Section,CaseSensitive);
if oSection <> nil then begin
oKey := oSection.KeyList.KeyByName(Ident,CaseSensitive);
if oKey <> nil then
- Result := oKey.Value;
+ If StripQuotes then
+ begin
+ J:=Length(oKey.Value);
+ // Joost, 2-jan-2007: The check (J>1) is there for the case that
+ // the value consist of a single double-quote character. (see
+ // mantis bug 6555)
+ If (J>1) and ((oKey.Value[1] in ['"','''']) and (oKey.Value[J]=oKey.Value[1])) then
+ Result:=Copy(oKey.Value,2,J-2);
+ end
+ else Result:=oKey.Value;
+ end;
end;
-end;
procedure TIniFile.SetCacheUpdates(const AValue: Boolean);
begin
@@ -856,7 +857,7 @@ procedure TIniFile.ReadSectionValues(const Section: string; Strings: TStrings);
var
oSection: TIniFileSection;
s: string;
- i: integer;
+ i,J: integer;
begin
Strings.BeginUpdate;
try
@@ -864,7 +865,17 @@ begin
oSection := FSectionList.SectionByName(Section,CaseSensitive);
if oSection <> nil then with oSection.KeyList do
for i := 0 to Count-1 do begin
- s := Items[i].Ident+Separator+Items[i].Value;
+ s := Items[i].Value;
+ If StripQuotes then
+ begin
+ J:=Length(s);
+ // Joost, 2-jan-2007: The check (J>1) is there for the case that
+ // the value consist of a single double-quote character. (see
+ // mantis bug 6555)
+ If (J>1) and ((s[1] in ['"','''']) and (s[J]=s[1])) then
+ s:=Copy(s,2,J-2);
+ end;
+ s:=Items[i].Ident+Separator+s;
Strings.Add(s);
end;
finally