aboutsummaryrefslogtreecommitdiffstats
path: root/smart_change.pl
diff options
context:
space:
mode:
authorDenis Barbier <barbier>2003-04-24 12:38:21 +0000
committerDenis Barbier <barbier>2003-04-24 12:38:21 +0000
commit4e0a960fbc37160eb589dbe8c92807904d734ba4 (patch)
tree6d054462184a37a701029861d9a1ac534a6b8392 /smart_change.pl
parent1ca5b4376fb6ea0980753375db9c57150ff9184d (diff)
Accepts several input files
CVS version numbers smart_change.pl: 1.4 -> 1.5
Diffstat (limited to 'smart_change.pl')
-rwxr-xr-xsmart_change.pl100
1 files changed, 52 insertions, 48 deletions
diff --git a/smart_change.pl b/smart_change.pl
index d0e64e4abaa..0e34982bac3 100755
--- a/smart_change.pl
+++ b/smart_change.pl
@@ -16,7 +16,7 @@ our ($opt_h, $opt_v, $opt_n, $opt_p, @opt_l, @opt_s);
sub usage {
print <<'EOT';
-Usage: smart_change.pl [options] origfile
+Usage: smart_change.pl [options] origfile [origfile ...]
Options:
-h, --help display this message
-v, --verbose run verbosely
@@ -43,6 +43,7 @@ if (not Getopt::Long::GetOptions(qw(
}
$opt_h && usage;
+die "Invalid number of arguments\n" unless @ARGV;
sub verbose {
print STDERR $_[0] . "\n" if $opt_v;
@@ -55,62 +56,65 @@ if (not @opt_l) {
@opt_l = $l->names();
}
-my $argfile = $ARGV[0] or die "Invalid number of arguments";
-$argfile =~ m+^(english.*)/(.*\.wml)+ or die "pattern does not match";
-my ($path, $file) = ($1, $2);
-
my $eval_opt_s = '1';
foreach (@opt_s) {
$eval_opt_s .= "; $_";
}
verbose("-s flags: $eval_opt_s");
+
my $substitute = 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);
-my $origrev = $cvs->revision($argfile) || "1.0";
-if ($opt_p) {
- $origrev =~ s/(\d+)$/($1 - 1)/e;
-}
-verbose("Original revision: $origrev");
-
-my $nextrev = $origrev;
-$nextrev =~ s/(\d+)$/(1+$1)/e;
-verbose("Next revision: $nextrev");
-
-foreach my $lang (@opt_l) {
- my $transfile = $argfile;
- $transfile =~ s/^english/$lang/ || next;
- next unless -f $transfile;
- verbose("Now checking $transfile");
-
- # Parse the translated file
- my $transcheck = Webwml::TransCheck->new($transfile);
- next unless $transcheck->revision() || $lang eq 'english';
- my $langrev = $transcheck->revision();
-
- my $origtext = '';
- my $transtext = '';
- open (TRANS, "< $transfile");
- while (<TRANS>) {
- $origtext .= $_;
- if (m/^#use wml::debian::translation-check/ && !$opt_n &&
- ($langrev eq $origrev || $langrev eq $nextrev)) {
- # Also check for $nextrev in case this script
- # is run several times
- s/(translation="?)($origrev|$nextrev)("?)/$1$nextrev$3/;
- verbose("Bump version number to $nextrev");
- }
- $transtext .= $_;
+foreach my $argfile (@ARGV) {
+ $argfile =~ m+^(english.*)/(.*\.wml)+ or die "pattern does not match";
+ my ($path, $file) = ($1, $2);
+
+ verbose("File: $argfile");
+ my $cvs = Local::Cvsinfo->new();
+ $cvs->options(matchfile => [ $file ]);
+ $cvs->readinfo($path);
+ my $origrev = $cvs->revision($argfile) || "1.0";
+ if ($opt_p) {
+ $origrev =~ s/(\d+)$/($1 - 1)/e;
}
- close (TRANS);
- $transtext = &$substitute($transtext);
- if ($origtext ne $transtext) {
- verbose("Writing $transfile");
- open (TRANS, "> $transfile");
- print TRANS $transtext;
+ verbose("Original revision: $origrev");
+
+ my $nextrev = $origrev;
+ $nextrev =~ s/(\d+)$/(1+$1)/e;
+ verbose("Next revision: $nextrev");
+
+ foreach my $lang (@opt_l) {
+ my $transfile = $argfile;
+ $transfile =~ s/^english/$lang/ || next;
+ next unless -f $transfile;
+ verbose("Now checking $transfile");
+
+ # Parse the translated file
+ my $transcheck = Webwml::TransCheck->new($transfile);
+ next unless $transcheck->revision() || $lang eq 'english';
+ my $langrev = $transcheck->revision();
+
+ my $origtext = '';
+ my $transtext = '';
+ open (TRANS, "< $transfile");
+ while (<TRANS>) {
+ $origtext .= $_;
+ if (m/^#use wml::debian::translation-check/ && !$opt_n &&
+ ($langrev eq $origrev || $langrev eq $nextrev)) {
+ # Also check for $nextrev in case this script
+ # is run several times
+ s/(translation="?)($origrev|$nextrev)("?)/$1$nextrev$3/;
+ verbose("Bump version number to $nextrev");
+ }
+ $transtext .= $_;
+ }
close (TRANS);
+ $transtext = &$substitute($transtext);
+ if ($origtext ne $transtext) {
+ verbose("Writing $transfile");
+ open (TRANS, "> $transfile");
+ print TRANS $transtext;
+ close (TRANS);
+ }
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy