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.
I want to run a comprehensive check against the entire source tree looking inside these types of strings for references to "KDE" or "kde." For branding purposes we want to update most of those references to "TDE" and "tde" respectively.
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."
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. 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.
I presumed somebody skilled in perl would be able to see the light but I am not a perl user.
I also want to perform the same type of search against TQTooTip multiple line strings.
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>.
Darrell
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
On Thu, Jan 16, 2014 at 19:24 (-0400), Jim wrote:
Consider this:
cd <top-level-dir-of-the-files-you-want-to-search> find . -type f | while read f
...
Better yet, add a ; to the first [] expression 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
The regexp may still not be as specific as possible, but it might get things down to a manageable level.
By the way, are you only looking for those in .cpp files? If so, the first line wants to be find . -type f -name *.cpp | while read f which speeds things up considerably. (It only finds 10 matches in total.)
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
Changing that to only look in .ui files
find . -name *.ui | 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
I get
<property name="whatsThis" stdset="0"> <string>This information points to the the ftp server. HOST can either be a standard ip adress like 192.168.2.1 or a domain name. PORT is the port number on which the ftp server listens. In most cases this is 21. Both are seperated by a ":" character. A legit input would be "ftp.kde.org:21".</string> THE ABOVE CAME FROM ./main/applications/kasablanca/src/Q_bookmarkdialog.ui
<property name="whatsThis" stdset="0"> <string>This information points to the the ftp server. HOST can either be a standard ip adress like "192.168.2.1" or a domain name. PORT is the port number on which the ftp server listens. In most cases this is 21. Both are seperated by a ":" character. A legit input would be "ftp.kde.org:21".</string> THE ABOVE CAME FROM ./main/applications/kasablanca/src/Q_customconnectdialog.ui
<property name="whatsThis" stdset="0"> <string>Pressing the button will launch konqueror and go to the KBFX Themes Section on www.kde-look.org</string> THE ABOVE CAME FROM ./main/applications/kbfx/configdialog/kbfxconfigdlgthemes.ui
<property name="whatsThis" stdset="0"> <string>In Gtk, the list that is attached to a combo-box appears in the same style as a popup-menu. KDE4 has the ability to mimic this look.</string> THE ABOVE CAME FROM ./main/applications/tde-style-qtcurve/config/qtcurveconfigbase.ui
<property name="whatsThis" stdset="0"> <string>Storing passwords is often a security problem. Kdesvn itself doesn't store any passwords, but the subversion itself inside the configuration area of subversion. If this area is readable from others you should not set it, but you may select for single non critical accounts inside the authentication dialog.</string> <property name="whatsThis" stdset="0"> <string><p>Tells if your passwords set in tdesvn should stored into kde wallet instead of simple cleartext storage of subversion.</p> <p>This would be a little bit more secure because TDE wallet is (mostly) encrypted with a password. On other hand you must re-enter your passwords with other subversion clients not accessing TDE wallet (eg. svn commandline itself, rapidsvn and so on).</p> <p>If you're HOME storage eg. subversions configfolder is on a network drive you should hard think about not storing passwords in a plain text file like subversion does but put it into an encrypted storage like kde wallet or don't save passwords.</p></string> THE ABOVE CAME FROM ./main/applications/tdesvn/src/settings/subversion_settings.ui
<property name="whatsThis" stdset="0"> <string><p align="left"> Enter an external program for opening file on doubleclick in form <br> <tt>&lt;program&gt;</tt> </p> <p> When kde-default is wanted for opening on double click, enter &quot;default&quot; and kde selects action. </p></string> THE ABOVE CAME FROM ./main/applications/tdesvn/src/settings/display_settings.ui
<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> THE ABOVE CAME FROM ./main/tdelibs/tdehtml/kjserrordlg.ui
<property name="whatsThis" stdset="0"> <string><p>Not all editors are well suited for inverse search. For instance, many editors have no command like 'If the file is not yet loaded, load it. Otherwise, bring the window with the file to the front'. If you are using an editor like this, clicking into the DVI file will always open a new editor, even if the TeX file is already open. Likewise, many editors have no command line argument that would allow KDVI to specify the exact line which you wish to edit.</p> <p>If you feel that KDVI's support for a certain editor is inadequate, please write to kebekus@kde.org.</p></string> THE ABOVE CAME FROM ./main/tdegraphics/kdvi/optionDialogSpecialWidget_base.ui
<property name="whatsThis" stdset="0"> <string><qt> Here you can modify the default browser-identification text or set a site <code>(eg. www.kde.org)</code> or a domain <code>(eg. kde.org)</code> specific identification text.<p> To add a new site specific identification text, click the <code>New</code> button and supply the necessary information. To change an existing site specific entry, click on the <code>Change</code> button. The <code>Delete</code> button will remove the selected site specific identification text, causing the setting to be used for that site or domain. </qt></string> THE ABOVE CAME FROM ./main/tdebase/kcontrol/tdeio/useragentdlg_ui.ui
<property name="whatsThis" stdset="0"> <string><qt> Enter the site or domain name where a fake browser identification should be used.<p> <u>NOTE:</u> Wildcard syntax such as "*,?" is NOT allowed: instead, use the top level address of a site to make generic matches; for example, if you want all TDE sites to receive a fake browser identification, you would enter <code>.kde.org</code> - the fake identity would then be sent to any TDE site that ends with <code>.kde.org</code>. </qt></string> <property name="whatsThis" stdset="0"> <string><qt> Enter the site or domain name where a fake browser identification should be used.<p> <u>NOTE:</u> Wildcard syntax such as "*,?" is NOT allowed: instead, use the top level address of a site to make generic matches; for example, if you want all TDE sites to receive a fake browser identification, you would enter <code>.kde.org</code> - the fake identity would then be sent to any TDE site that ends with <code>.kde.org</code>. </qt></string> THE ABOVE CAME FROM ./main/tdebase/kcontrol/tdeio/uagentproviderdlg_ui.ui
<property name="whatsThis" stdset="0"> <string><qt> Automatically detect and configure the proxy settings.<p> Automatic detection is performed using the <b>Web Proxy Auto-Discovery Protocol (WPAD)</b>.<p> <b>NOTE:</b> This option might not work properly or not work at all in some UNIX/Linux distributions. If you encounter a problem when using this option, please check the FAQ section at http://konqueror.kde.org. </qt></string> THE ABOVE CAME FROM ./main/tdebase/kcontrol/tdeio/kproxydlg_ui.ui
<property name="whatsThis" stdset="0"> <string><qt> Enter the host or domain to which this policy applies, e.g. <b>www.kde.org</b> or <b>.kde.org</b>. </qt></string> <property name="whatsThis" stdset="0"> <string><qt> Enter the host or domain to which this policy applies, e.g. <b>www.kde.org</b> or <b>.kde.org</b>. </qt></string> THE ABOVE CAME FROM ./main/tdebase/kcontrol/tdeio/policydlg_ui.ui
<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 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> THE ABOVE CAME FROM ./main/tdebase/kdesktop/minicli_ui.ui
Having said that, I also see things like (in ./main/dependencies/tqt3/tools/designer/designer/previewwidget.ui) <property name="text"> <string><p> <a href="http://www.trolltech.com/%22%3Ehttp://www.trolltech.com%3C/a%3E; </p> <p> <a href="http://www.kde.org/%22%3Ehttp://www.kde.org%3C/a%3E; </p></string>
Is it safe to assume you also want to catch those?
Jim