[Lazarus] IsAccel bug?

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Nov 17 14:54:22 CET 2011


Hans-Peter Diettrich <DrDiettrich1 at aol.com> hat am 17. November 2011 um 09:33

> In forms.IsAccel I suspect an bug, which manifests in very rare cases only:
>    position := UTF8Pos(AmpersandChar, ACaption);
> This is the position of the &
> ...
>        UTF8Delete(ACaption, 1, position+1);
> This IMO removes the character *after* the ampersand 
Yes, which is another ampersand (&&). So it deletes both ampersands. 

>, so that>
>        position := UTF8Pos(AmpersandChar, ACaption);
> finds the same & over and over again, while it should find the next one. 
Have you tested it? It looks correct to me. 

> Now for some questionable constructs:
> A simple Pos would be sufficient, because '&' is an ASCII character. 
Yes. The whole UTF8 in there unneeded, except for the comparison of the one
character with the VK. 

> It would be sufficient to replace the found '&' by something else, in place.
> Or a loop until the last char could be used, which eliminates any string
> time and memory consuming string manipulation. 
Feel free to provide a patch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20111117/44516b53/attachment-0003.html>

More information about the Lazarus mailing list