>
>>
>>>  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
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator

Reply via email to