View Issue Details

IDProjectCategoryView StatusLast Update
0033052FPCFCLpublic2018-01-29 21:38
Reporterjk987Assigned ToMichael Van Canneyt 
Status resolvedResolutionfixed 
PlatformOSWindowsOS Version7
Product Version3.0.2Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0033052: Possible bug with setting StripQuotes in TIniFile.Create
DescriptionWhen I'm looking into IniFiles unit then I can see there something like:

constructor TIniFile.Create(const AFileName: string; AOptions : TIniFileOptions = []);
  slLines: TStringList;
  FBOM := '';
  If Not (self is TMemIniFile) then
  inherited Create(AFileName,AOptions);

I suppose that the idea of "If Not (self is TMemIniFile) then StripQuotes:=True;" part was that after calling "ini := TIniFile.Create(filename);" the StripQuotes property should be automatically set to true.

But I think that the following line "inherited Create(AFileName,AOptions);" resets it to false because default options are "[]". So the whole "if self is not TMemIniFile" idea goes to nowhere.
Additional InformationI haven't investigated it too much yet.
I was only wondering why application rebuilt in upgraded Lazarus (1.6.4) behaves differently when reading quoted strings from ini-files than two years ago (Lazarus 1.6.0 / FPC 3.0.0).

TagsNo tags attached.
Fixed in Revision38018
Attached Files


Michael Van Canneyt

2018-01-20 15:46

administrator   ~0105958

This bug was most likely introduced when an overloaded version was added to the constructor.


2018-01-29 21:22

reporter   ~0106123

I'm looking on your commit here:

And I think I've found one trap in your solution.

If anybody calls "ini := TIniFile.Create(filename, [])" then it will strip quotes even if user/programmer explicitly specified in the second parameter that he doesn't want to strip them. (Is this situation possible?)

If we admit that such situation is possible then I'm not sure how to solve it.
Perhaps two constructors:

constructor TIniFile.Create(const AFileName: string); overload;
  ifo: TIniFileoptions;
  FBOM := '';
  If Not (self is TMemIniFile) then Include(ifo, ifoStripQuotes);
  inherited Create(AFileName, ifo);
  FStream := nil;

constructor TIniFile.Create(const AFileName: string; AOptions: TIniFileoptions); overload;
  FBOM := '';
  inherited Create(AFileName, AOptions);
  FStream := nil;

But I would prefer avoiding defaults like this:
constructor Create(const AFileName: string; AOptions : TIniFileoptions = []); overload;
In this case it behaves bit weird.

But it's only my idea and I'm the only one. If you or other friends decide that my idea is silly then I'll draw back.

Michael Van Canneyt

2018-01-29 21:38

administrator   ~0106124

That is as designed.

Issue History

Date Modified Username Field Change
2018-01-19 15:18 jk987 New Issue
2018-01-19 16:32 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-01-19 16:32 Michael Van Canneyt Status new => assigned
2018-01-20 15:46 Michael Van Canneyt Fixed in Revision => 38018
2018-01-20 15:46 Michael Van Canneyt Note Added: 0105958
2018-01-20 15:46 Michael Van Canneyt Status assigned => resolved
2018-01-20 15:46 Michael Van Canneyt Fixed in Version => 3.1.1
2018-01-20 15:46 Michael Van Canneyt Resolution open => fixed
2018-01-20 15:46 Michael Van Canneyt Target Version => 3.2.0
2018-01-29 21:22 jk987 Note Added: 0106123
2018-01-29 21:22 jk987 Status resolved => feedback
2018-01-29 21:22 jk987 Resolution fixed => reopened
2018-01-29 21:38 Michael Van Canneyt Note Added: 0106124
2018-01-29 21:38 Michael Van Canneyt Status feedback => resolved
2018-01-29 21:38 Michael Van Canneyt Resolution reopened => fixed