[Libreoffice] Funny piece of code.

Stephan Bergmann sbergman at redhat.com
Mon Jan 2 07:46:33 PST 2012


On 01/02/2012 04:40 PM, Olivier Hallot wrote:
> I stumbled on this piece of code in
>
> registry/tools/regcompare.cxx
>
> There must be a finesse in lines 326, 330, and so on that I missed
> miserably...
>
> Any advise welcome, or I will rip off the ternary operator.

note the leading commas in the !isEmpty() cases

Stephan

>
> Thanks
>
> Olivier
>
> static OString getFieldAccess(RTFieldAccess fieldAccess)
>      318 {
>      319     OString ret;
>      320     if ( (fieldAccess&  RT_ACCESS_INVALID) == RT_ACCESS_INVALID )
>      321     {
>      322         ret += OString("INVALID");
>      323     }
>      324     if ( (fieldAccess&  RT_ACCESS_READONLY) == RT_ACCESS_READONLY )
>      325     {
>      326         ret += OString(ret.getLength()>  0 ? ",READONLY" :
> "READONLY");
>      327     }
>      328     if ( (fieldAccess&  RT_ACCESS_OPTIONAL) == RT_ACCESS_OPTIONAL )
>      329     {
>      330         ret += OString(ret.getLength()>  0 ? ",OPTIONAL" :
> "OPTIONAL");


More information about the LibreOffice mailing list