Hi.
I've added a new option to smart_change.pl
-S REGEXP
the difference to -s is that the regexp is applied on the whole text
instead of line by line
I've attached the patch. If noone objects I will commit it.
Frank
--
*** Frank Lichtenheld <[EMAIL PROTECTED]> ***
*** http://www.djpig.de/ ***
see also: - http://www.usta.de/
- http://fachschaft.physik.uni-karlsruhe.de/
Index: smart_change.pl
===================================================================
RCS file: /cvs/webwml/webwml/smart_change.pl,v
retrieving revision 1.3
diff -u -r1.3 smart_change.pl
--- smart_change.pl 21 Feb 2003 12:37:12 -0000 1.3
+++ smart_change.pl 16 Apr 2003 18:03:56 -0000
@@ -12,7 +12,7 @@
use Webwml::TransCheck;
use Webwml::Langs;
-our ($opt_h, $opt_v, $opt_n, $opt_p, @opt_l, @opt_s);
+our ($opt_h, $opt_v, $opt_n, $opt_p, @opt_l, @opt_s, @opt_S);
sub usage {
print <<'EOT';
@@ -26,6 +26,11 @@
-s, --substitute=REGEXP
Perl regexp applied to source files
(may be used more than once)
+ the regexp is applied line by line
+ -S, --textsubst=REGEXP
+ Perl regexp applied to source files
+ (may used more than once)
+ the regexp is applied on the whole text
EOT
exit(0);
}
@@ -37,6 +42,7 @@
p|previous
l|lang=s@
s|substitute=s@
+ S|textsubst=s@
))) {
warn "Try `$0 --help' for more information.\n";
exit(1);
@@ -67,6 +73,14 @@
my $substitute = eval "sub { \$_ = shift; $eval_opt_s; die \$@ if \$@; return
\$_}";
die "Invalid -s option" if $@;
+my $eval_opt_S = '1';
+foreach (@opt_S) {
+ $eval_opt_S .= "; $_";
+}
+verbose("-S flags: $eval_opt_S");
+my $textsubst = eval "sub { \$_ = shift; $eval_opt_S; die \$@ if \$@; return
\$_}";
+die "Invalid -S option" if $@;
+
my $cvs = Local::Cvsinfo->new();
$cvs->options(matchfile => [ $file ]);
$cvs->readinfo($path);
@@ -106,6 +120,7 @@
$transtext .= &$substitute($_);
}
close (TRANS);
+ $transtext = &$textsubst($transtext);
if ($origtext ne $transtext) {
verbose("Writing $transfile");
open (TRANS, "> $transfile");