[SCRIPT] automated removal of RTL_CONSTASCII_USTRINGPARAM for quoted ...

Stephan Bergmann sbergman at redhat.com
Wed Mar 20 10:04:53 PDT 2013


On 03/20/2013 02:53 PM, Thomas Arnhold wrote:
> On 20.03.2013 12:09, Stephan Bergmann wrote:
>> On 03/19/2013 07:38 PM, Thomas Arnhold wrote:
>>> #!/usr/bin/perl
>>>
>>> # git grep 'RTL_CONSTASCII_USTRINGPARAM' -- '*.[hc]xx' | cut -d':' -f1
>>> | sort -u | xargs perl constascii.pl
>>>
>>> foreach (@ARGV) {
>>>     my $file = $_;
>>>     my $data = "";
>>>     my $fh;
>>>
>>>     open($fh, "<$file");
>>>     while (<$fh>) { $data .= $_; }
>>>     close($fh);
>>>
>>>     # replace OUString(RTL_...)
>>>     $data =~
>>> s/OUString\s*\(\s*RTL_CONSTASCII_USTRINGPARAM\s*\((\s*"[^")]*?"\s*)\)\s*\)/OUString\($1\)/gms;
>>>
>>>
>>
>> BTW, did this work by luck, not causing any damage in cases like
>>
>>    OUString(RTL_CONSTASCII_USTRINGPARAM("\")"))
>
> More or less, because I found no occurrences of that (the two closing
> brackets after " are limiting it. It would look quite behind \" for two
> closing brackets.

Yeah, the example of what would get damaged should rather have been

   OUString(RTL_CONSTASCII_USTRINGPARAM("\"))"))

> Indeed this regex isn't safe for other conversions of this macro, where
> this case may occur. There [^")\\]*? should be used to omit those.

But why drop legitimate cases instead of doing it properly, i.e.,

   "([^"\\]|\\.)*"

Stephan


More information about the LibreOffice mailing list