Page 1 of 1

Possible problem with super-long INI values.

Posted: 22 Mar 2016 20:03
by TheQwerty
Ran into this using GetSectionList on my <xyini> to retrieve the LookIn section.

I discovered that a few of my entries here are extremely long - biggest is 241,877 characters, next is 163,280.
I believe they came from performing Search in List on a set of search results - perhaps repeated once or twice.

These entries show up just fine in the Find Files > Location MRU drop-down and the reading/saving of them to the INI file is apparently working.

However there are a couple of side-affects:
  1. List Management > Find Files: Location has empty lines for these long entries in normal mode.
  2. In Editor Mode the entries are shown in their entirety (I think), but they are wrapped after 1024 characters making the display really ugly and the editing difficult.
  3. Similarly, showing text like this in the SC Text dialog suffers the same wrapping when wrapping is disabled.
  4. SC GetSectionList cannot return the full section ending just after these lines.
I think we can live with all but the last one - since it unfortunately renders GetSectionList entirely untrustworthy.

Re: Possible problem with super-long INI values.

Posted: 05 Apr 2016 20:37
by admin
Tricky. I use API GetPrivateProfileSection for this, a very old API with very old-fashioned limitations. See https://msdn.microsoft.com/en-us/librar ... 2147217396
nSize [in]

The size of the buffer pointed to by the lpReturnedString parameter, in characters. The maximum profile section size is 32,767 characters.
To improve this I would have to write a native version of GetPrivateProfileSection. Possible, but I have so many better things to do... let me sleep over it...

Re: Possible problem with super-long INI values.

Posted: 05 Apr 2016 21:33
by TheQwerty
Ah...

Well that explains #4 and I suppose if the limitation were documented that would be enough to consider it resolved. (I can put my trust back in GSL() so long as the returned string is less than the max buffer size.) It's unfortunate but doesn't sound like it would be worth the hassle - especially considering I could take the slower method of enumerating the keys and values with GetKey.

#1-3 though are presumably unrelated to GetPrivateProfileSection but also of less annoyance. Knowing that you're aware is enough for me. At least until I forget and "discover" them again in the future. ;)

Re: Possible problem with super-long INI values.

Posted: 05 Apr 2016 21:36
by admin
#1-3 are even harder to handle, if at all. These are hard limitations of Windows controls...

Re: Possible problem with super-long INI values.

Posted: 06 Apr 2016 10:06
by admin
Did it:

Code: Select all

    ! SC getsectionlist: The function suffered from a limit in the 
      GetPrivateProfileSection API ("The maximum profile section size is 32,767 
      characters"). Fixed. Wrote my own function. No limits.
      FYI, you could reach such a limit e.g. when performing Search in List on a 
      set of search results, and having that search stored in the INI file.
Next beta...

Re: Possible problem with super-long INI values.

Posted: 06 Apr 2016 14:37
by TheQwerty
Yay - my trust in GetSectionList has been restored!