Possible problem with super-long INI values.

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Possible problem with super-long INI values.

Post 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.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Possible problem with super-long INI values.

Post 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...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Possible problem with super-long INI values.

Post 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. ;)

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Possible problem with super-long INI values.

Post by admin »

#1-3 are even harder to handle, if at all. These are hard limitations of Windows controls...

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Possible problem with super-long INI values.

Post 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...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Possible problem with super-long INI values.

Post by TheQwerty »

Yay - my trust in GetSectionList has been restored!

Post Reply