Bogus call to OUString::matchAsciiL in /framework/source/lomenubar/MenuItemStatusListener.cxx ?
Lubos Lunak
l.lunak at suse.cz
Mon Jul 9 04:32:34 PDT 2012
On Monday 09 of July 2012, David Tardon wrote:
> Hi,
>
> On Sun, Jul 08, 2012 at 02:37:49PM +0200, Christophe JAILLET wrote:
> > Hi,
> > At line 60 of
> > /framework/source/lomenubar/MenuItemStatusListener.cxx, we can find
> >
> >
> > if ((Event.State >>= oULabel) &&
> > !oULabel.matchAsciiL ("private:", 8, 0) &&
> > !oULabel.matchAsciiL (".uno:", 5, 0) &&
> > !oULabel.matchAsciiL ("slot:", 5, 0) &&
> > !oULabel.matchAsciiL ("service:", 8, 0) &&
> > !oULabel.matchAsciiL (".cmd:", 5, 0) &&
> > !oULabel.matchAsciiL ("macro:///", 5, 0))
> >
> > Q1) Why "macro:///" and 5 ? Shouldn't it be 9 ???
>
> Copy-and-paste bug, I guess?
>
> > Q2) In other places, matchAscii is used in conjunction of
> > RTL_CONSTASCII_STRINGPARAM. This way, the length of the string is
> > computed by the compiler.
> >
> > Is it the preferred way to do, in order to avoid hard coded constant ?
>
> Yes, it is.
No, not anymore. The AsciiL variants and RTL_CONSTASCII_(U)STRINGPARAM macros
are obsolete, with string literals it is now possible to use the "normal"
version of the function. IOW,
oULabel.matchAsciiL ("private:", 8, 0)
is now best written simply as
oULabel.match("private:", 0)
.
--
Lubos Lunak
l.lunak at suse.cz
More information about the LibreOffice
mailing list