Quantcast

Re: .: sw/source

classic Classic list List threaded Threaded
2 messages Options
Michael Stahl-2 Michael Stahl-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: .: sw/source

On 09/08/12 11:09, Caolán McNamara wrote:

>  sw/source/filter/ww1/fltshell.cxx |   11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> New commits:
> commit 3a1c8eeb694e26835f6f9c010b5d305b57ddd0d5
> Author: Caolán McNamara <[hidden email]>
> Date:   Thu Aug 9 10:06:44 2012 +0100
>
>     rtl::OUStrings are supposed to be immutable
>    
>     The cast away of constness in d64ecf4e94a81d9c1fd4be74c098eb0e58345c60 makes me
>     feel icky

not only that, it can be a real bug as well (though isn't in this case).
the OUString, or more precisely the buffer it holds, is immutable by
design, and has a intern() method that effectively enters it into a
global hash-table; if an intern()ed string is later modified then that
hash table is going to be very unhappy (about unhappy hashtables, see
also 3ea6b1c1594fa3fdb7e13c544b3beecd369b67d0).

> -    OUString sOut( rIn );
> +    OUStringBuffer sOut( rIn );

>              if( bAllowCr )
> -            {
> -                sal_Unicode* pStr = (sal_Unicode*)sOut.getStr();
> -                pStr[n] = (sal_Unicode)'\n';
> -            }
> +                sOut[n] = '\n';

right: if you want to modify an OUString, use OUStringBuffer, that's why
it exists.


_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Miklos Vajna-2 Miklos Vajna-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: .: sw/source

On Thu, Aug 09, 2012 at 11:36:50AM +0200, Michael Stahl <[hidden email]> wrote:

> > -    OUString sOut( rIn );
> > +    OUStringBuffer sOut( rIn );
>
> >              if( bAllowCr )
> > -            {
> > -                sal_Unicode* pStr = (sal_Unicode*)sOut.getStr();
> > -                pStr[n] = (sal_Unicode)'\n';
> > -            }
> > +                sOut[n] = '\n';
>
> right: if you want to modify an OUString, use OUStringBuffer, that's why
> it exists.

Thanks for the info, I don't remember where did I saw that, but if I see
again, I'll correct it there as well. ;-)
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Loading...