${Ini} and other strings

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

Grumpy
a hill giant
a hill giant
Posts: 167
Joined: Sun Nov 10, 2002 4:22 pm

${Ini} and other strings

Post by Grumpy » Wed Oct 13, 2004 12:28 pm

While messing with a bazaar search macro, I discovered a glitch of sorts.

Relating to ${Ini[${filename}, ${sectionname}]}, which returns a tokenized list of keys in the ini file section.

"Key 1|Key 2|...|Key n|Key last||"

If you have an ini file with lots of keys (or more long keys), the return string can be corrupt. Apparently (haven't looked at source), the return string is limited to 2k characters (or so), and truncates. This is better than having a buffer overrun, but not ideal.

Problem occurs when you try and tokenize the returned string, if you are looking for the || at the end of the key list, you aren't going to find it. Can we have ${Ini[${filename}, ${sectionname}]} check the return string length and truncate before the limit is reached? Thus not processing all the keys?

A better solution (more flexible) would be to add ${Ini.Count[${filename}, ${sectionname}]}, which would just return the number of keys in that section of the file. This is mostly what people want (so they can create a dynamic array of the correct size to hold all the keys).

As I say, I haven't checked, but other functions returning strings may have similar problems with truncation.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Wed Oct 13, 2004 3:38 pm

Strings are limited to 2047 characters.

Grumpy
a hill giant
a hill giant
Posts: 167
Joined: Sun Nov 10, 2002 4:22 pm

Post by Grumpy » Wed Oct 13, 2004 10:34 pm

Right, but my point is that the return string from $Ini is supposed to be in a standard format, I'd rather have it return:

Key1|Key2|...|Last Key that will fit in the 2047 alloted and still leave 2 chars for||

than:

Key1|Key2|...|Last Key that will fit in the 2047 alloted and still leave 2 chars for|Key that won't quite fit

without the promised || at the end of the String.

I'm not worried about the limit on string length, I'm concerned about the corrupted return string.

Adding ${Ini.Count[]) function (returns an int with number of keys in file or in section) would also be very nice.