On 26/12/2009 12:31 م, paulo wrote:
>>
>>>
>>>>
>>>>> 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.
>
Wow, Paulo that's perfect (although I don't have any experience in Perl)
but as you know using Perl like this will create many problems, thus
everytime I run Perl I've to clean up the result. Is it?
--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator