|Anonymous | Login | Signup for a new account||2019-02-18 02:11 CET|
|Main | My View | View Issues | Change Log | Roadmap | Docs|
|Viewing Issue Simple Details|
|ID||Category||Severity||Reproducibility||Date Submitted||Last Update|
|0005463||[JEDI VCL] 00 JVCL Components||minor||always||2011-01-19 15:27||2011-09-21 14:10|
|Status||resolved||Product Version||Daily / GIT|
|Summary||0005463: SubStrBySeparator function doesn't work with 'empty' substring|
SubStrBySeparator function does not return 'empty' substring when two 1-character separators are placed one by one.
Sample string is: EQD+CN++2200+++4. Separator is '+'. When I want to get third substring I call SubStrBySeparator('EQD+CN++2200+++4', 2, '+'). It should return empty string but it returns +2200.
The reason of such result is following line:
I := PosIdx(Separator, S, StartIndex + 1);
while StartIndex was increased earlier in the 'for' loop by:
When I change it to:
I := PosIdx(Separator, S, StartIndex);
everything works great I get empty substrings where I expect to get.
|Additional Information||It should not take too much time to correct this, right?|
|Tags||No tags attached.|
Changing the behavior of the function is not desirable, some people might rely on it.
It would be better to add a parameter (AllowEmpty for instance) that controls the activation of new behavior (and that is off by default)
Can you try to do this?
Sure, I can try adding the AllowEmpty parameters defaulted to False, and modify "I" variable accordingly. That is not a problem.
But I cannot understand what is the purpose relying on behavior that instead of empty string next item is returned, and with separator.
The point is that the result of the function should be correct. In my opinion the correct result of this function when it happens that two separators are placed one by one is empty string.
I'm not saying anyone relies on this, but if we change it and that breaks their code, they're gonna blame us.
So if you could submit a patch with the changes, that would make inclusion easier
Fixed in svn revision 13060.
@obones: This code was definitely wrong. And I doubt that anybody would have expected the function to return '+2200' for Index=2 and '2200' for Index=3.
|2011-01-19 15:27||mbury||New Issue|
|2011-02-15 13:50||obones||Note Added: 0018354|
|2011-02-15 13:50||obones||Status||new => feedback|
|2011-04-15 10:42||mbury||Note Added: 0018520|
|2011-06-08 13:27||obones||Status||feedback => acknowledged|
|2011-06-08 16:31||obones||Note Added: 0018694|
|2011-06-11 11:33||AHUser||Assigned To||=> AHUser|
|2011-06-11 12:05||AHUser||Note Added: 0018737|
|2011-06-11 12:05||AHUser||Status||acknowledged => resolved|
|2011-06-11 12:05||AHUser||Fixed in Version||=> Daily / SVN|
|2011-06-11 12:05||AHUser||Resolution||open => fixed|
|2011-09-21 14:10||obones||Fixed in Version||Daily / SVN => 3.45|
|Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group|