On Thu, Jan 16, 2014 at 15:30 (-0600), Darrell Anderson wrote:
I'm not really clear on what it is you want to search for.
Here is a sample of the type of multiple line strings I want to search:
TQWhatsThis::add( clickRaiseOn, i18n("When this option is enabled, the active window will be brought to the" " front when you click somewhere into the window contents. To change" " it for inactive windows, you need to change the settings" " in the Actions tab.") );
The important point is the string is multiple lines. The only known constants are the first line contains a call to TQWhatsThis and the end of the string is a semi-colon.
More than likely, the last two characters are known: a closing parentheses and a semi-colon.
The shell command I sent out this morning already narrowed it down to the TQWhatsThis calls which have kde in them. Admittedly, I gave you the list of files, and not the actual string.
I want to run a comprehensive check against the entire source tree looking inside these types of strings for references to "KDE" or "kde."
That's what I (think I) did. Except I showed the files, not the strings.
This example string does not contain a KDE/kde reference. I would not want this particular string to bubble up in my search. Only those multiple line strings that contain "KDE or "kde."
Makes sense.
There are legitimate strings where KDE/kde should be left as is, such as accreditations to past developers.
I don't want to perform a search-and-replace. I only want to perform a search. I want to manually read any remaining KDE/kde remnants in context to decide whether to update to TDE/tde.
grep won't do the job.
Not by itself, but sed and tr are its friends.
Something likely could be wrangled out of the -A option. but I suspect that kind of script would be slow, needing to continually test whether the last line contains a closing parentheses and a semi-colon.
Consider this:
cd <top-level-dir-of-the-files-you-want-to-search> find . -type f | while read f do if tr $'\n' ' ' < $f \ | sed 's/"[ \t][ \t]*"/ /g' \ | grep -o 'TQWhatsThis[^"]*"[^"]*[kK][Dd][Ee][^"]*"' then echo THE ABOVE CAME FROM $f echo fi done
This would output stuff like
TQWhatsThis::add(m_fontpath, i18n("When using font embedding you can select additional directories where KDE should search for embeddable font files. By default, the X server font path is used, so adding those directories is not needed. The default search path should be sufficient in most cases." THE ABOVE CAME FROM ./main/tdelibs/tdeprint/management/kmconfigfonts.cpp
Is that the sort of thing that would help you? Admittedly the line breaks and spacing have changed, but I'm guessing that doesn't matter to you.
If you like it, be very careful with your copy/paste operation.
I also want to perform the same type of search against TQTooTip multiple line strings.
Change 'WhatsThis' to 'ToolTip' (I assume you meant 'tool' and not 'too') in the grep line above.
There are also multiple line strings in *.ui files containing What's This and Tooltip strings. There the usage is different:
<property name="whatsThis" stdset="0"> <string>Enter the command you wish to execute or the address of the resource you want to open. This can be a remote URL like "www.kde.org" or a local one like "~/.tderc".</string> </property>
<property name="toolTip" stdset="0"> <string>Slow processors perform poorly with effects</string> </property>
In the *.ui files the known constants are <property name=xxx > and </property>.
Not <string> and </string> ?? If <string> is always after <property ...> in the strings you want, and there is no other <tag>, you could give this a whirl:
find . -type f | while read f do if tr $'\n' ' ' < $f \ | sed 's/"[ \t][ \t]*"/ /g' \ | grep -o '<property name="whatsThis"[^>]*> *<string>[^<]*[kK][Dd][Ee][^>]*>' then echo THE ABOVE CAME FROM $f echo fi done
On the file main/tdelibs/tdehtml/kjserrordlg.ui that outputs
<property name="whatsThis" stdset="0"> <string>This dialog provides you with notification and details of scripting errors that occur on web pages. In many cases it is due to an error in the web site as designed by its author. In other cases it is the result of a programming error in Konqueror. If you suspect the former, please contact the webmaster of the site in question. Conversely if you suspect an error in Konqueror, please file a bug report at http://bugs.kde.org/. A test case which illustrates the problem will be appreciated.</string>
Is that helpful?
I won't spend more time on this now in case I am still barking up the wrong tree. If, indeed, I am barking in the wrong place, and you have the energy to try to explain once more, please do and I'll see what I can come up with.
Jim