>
>>
>>>
>>>> On 24/12/2009 05:08 م, Andre Poenitz wrote:
>>>>>
>>>>>> 3. Is there any tool for adding tr() function automatically for
>>>>>> whole
>>>>>> strings in specific project?
>>>>>>
>>>>> No, unless you call perl/sed 'automatic'.
>>>>>
>>>> Do you know how I can it? or I've to write a script by myself.
>>> how about a one liner like:
>>>
>>> perl -p -e 's/([^(tr\()\s]\s*)(\"[^\"]*\")/$1tr\($2\)/g' *.{h,c}pp
>>>
>>> replace the hpp/cpp for the extensions that you're using...
>>>
>>>
>> that regexp is still not 100% correct. it fails with stuff like
>> \wrt\s*(.
>> ex:
>> str("")
>> Wait a bit...
>>
> Ok, the best I can get in such short notice is ex:
>
> perl -i.old -p -e
> 's/(^|\W+)(?<!\Wtr\()(^|\W+)(\"[^\"]*\")/$1$2tr($3)/' *.{h,c}pp
>
> the problem is if you have things in your code like:
> tr ("");
> where there's a variable number of spaces between tr and ( this wont
> work, and will output
> tr (tr(""));
>
> cheers
>
lol I was thinking and just remembered that the previous one still does
not work for things like \w\W\" like
string s="";
sore here's another that works for these cases.
perl -i.old -p -e
's/(?<!^tr)(?<!\Wtr)(^|\(|,|=)(\s*)(\"[^\"]*\")/$1$2tr($3)/' *.hxx
this one also has the "tr (" problem though.
hehe
actually you could do almost everything with one of these, and just deal
with the rest case by case.
merry christmas.
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator