By the way, using the below regexps (best run in a C locale) should find
even more instances, and should avoid false positives of the form "if
(foo) delete bar;" or (unlikely) "#if (foo) \n delete foo;":
foreach (@ARGV) {
my $file = $_;
open(FH, "<$file");
my $data = "";
while (<FH>) { $data .= $_; }
close(FH);
while ($data =~ /((?<!#)\s*\bif\s*\(\s*(\w+)\s*\)\s*delete\s+\2\s*;)/g) {
print "found <$1>\n";
}
while ($data =~
/((?<!#)\s*\bif\s*\(\s*(\w+)\s*\)\s*{\s*delete\s+\2\s*;\s*})/g) {
print "found <$1>\n";
}
}
(The outer parentheses are only there for print "found <$1>\n" to work
-- no idea how Perl makes available the complete match without that
hack... The leading "(?<!#)\s*" should really read "(?<!#\s*)", but then
Perl complains that "Variable length lookbehind [is] not implemented.")
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.