Recent

Author Topic: TiniFile has bugs!  (Read 1736 times)

jamie

  • Hero Member
  • *****
  • Posts: 6130
TiniFile has bugs!
« on: June 10, 2019, 12:32:12 am »
If I read a string from a INI file I created using a Key that does not yet exist and
set the default to '' , nothing, I would expect to get a string returned with zero length..

 what I get back is a string, a length of 1 with the first character being a #0
 
 For example...

 ASTring :=  AIniFileInstance.ReadString(SectionName, KeyName, '');
 
 If the Key does not exist and as you can see I indicated a Empty string as the default, I
get back a String that is #0 with a length of 1.

If I do indicate a default then I get back the default but I should be getting back nothing!

Also I Found if I set  ifoEscapeLineFeeds after I create an instance of the class, it crashes.


 This is from Lazarus 2.0.2 release.

The only true wisdom is knowing you know nothing

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: TiniFile has bugs!
« Reply #1 on: June 10, 2019, 12:06:47 pm »
I have no problems, it works as is should.
Tested with:
Lazarus 1.8.5, fpc 3.0.4
Lazarus 2.0.3 r61029, fpc 3.0.4
both 32 bit
Window 10 pro 64bit

I uploaded my test programm.

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TiniFile has bugs!
« Reply #2 on: June 10, 2019, 10:49:39 pm »
I can look at it however, you need to put that in a ZIP format my windows understands, I am not
installing a reader for that file.
The only true wisdom is knowing you know nothing

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: TiniFile has bugs!
« Reply #3 on: June 10, 2019, 11:14:36 pm »
 :)
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TiniFile has bugs!
« Reply #4 on: June 11, 2019, 12:34:00 am »
I wrote a small test app and I can randomly generate the bug.

All I have to do is change the section name or Keyname to something that does not exist
in the file and it randomly fails with returning a String of #0

 It almost acts like there is something strange happening with memory alignment because if I
simply insert and delete some variables or code that have nothing to do with it, the behavior changes to working properly or returning a single Char string of #0.

 I'll have to get back to this later. the test I did for now seems to work around it when it happens..

 If S > #0 then....
 
 because sometimes the empty string is a #0 or it is an actual empty string.

Thanks for helping.
The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: TiniFile has bugs!
« Reply #5 on: June 11, 2019, 11:13:19 pm »
I cannot reproduce that at all.
I've done 1 million reads from an existing TIniFile reading a random non existent Ident and the return value is always an empty string.
Also I can set [ifoEscapeLineFeeds] withiut the instance crashing.
Tested with 3.0.4 and fpc trunk.

Please attach a compilable sample project (not depending on Lazarus, since TIniFile is fpc) and a sample ini-file that demonstrates the problem.
Also give us the compiler options used.

Bart

 

TinyPortal © 2005-2018