summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2003-11-09 20:36:54 -0800
committerSteve Reinhardt <stever@eecs.umich.edu>2003-11-09 20:36:54 -0800
commit7651e19cd1e04c69eb8b81990f08e27180981244 (patch)
treeaac79c0ee448bfd37477b87e41b7efba488a5ffa
parentebaecd1b6cde06044f05a4ae8921d6309215d875 (diff)
downloadgem5-7651e19cd1e04c69eb8b81990f08e27180981244.tar.xz
Minor enhancements to rundiff script.
util/rundiff: Make sure Algorithm::Diff is loaded only if you need it (so it's ok if you don't have it installed). Add command-line options for things you might want to change: - diff algorithm - # of context lines - # of lines of lookahead --HG-- extra : convert_revision : b3ba02e1816eee286f47eb28ab578fa4734bac3a
-rwxr-xr-xutil/rundiff47
1 files changed, 34 insertions, 13 deletions
diff --git a/util/rundiff b/util/rundiff
index 732b84d21..05beba84b 100755
--- a/util/rundiff
+++ b/util/rundiff
@@ -41,21 +41,42 @@
use strict;
+use Getopt::Std;
+
+#
+# Options:
+# -c <n> : print n lines of context before & after changes
+# -l <n> : use n lines of lookahead
+# -x : use "complex" diff from Algorithm::Diff (see below)
+#
+our ($opt_c, $opt_l, $opt_x);
+getopts('c:l:x');
+
#
# For the highest-quality (minimal) diffs, we can use the
-# Algorithm::Diff package. If you don't have this installed, or want
-# the script to run faster (like 3-4x faster, based on informal
-# observation), set $use_complexdiff to 0; then a built-in, simple,
-# and generally quite adequate algorithm will be used instead.
-my $use_complexdiff = 0;
-
-#if ($use_complexdiff) {
-# use Algorithm::Diff qw(traverse_sequences);
-#};
-
-my $lookahead_lines = 200;
-my $precontext_lines = 3;
-my $postcontext_lines = 3;
+# Algorithm::Diff package. By default, a built-in, simple, and
+# generally quite adequate algorithm will be used. If you have
+# Algorithm::Diff installed on your system, and don't mind having the
+# script go slower (like 3-4x slower, based on informal observation),
+# then specify '-x' on the command line to use it.
+my $use_complexdiff = defined($opt_x);
+
+if ($use_complexdiff) {
+ # Don't use 'use', as that's a compile-time option and will fail
+ # on systems that don't have Algorithm::Diff installed even if
+ # $use_complexdiff is false. 'require' is evaluated at runtime,
+ # so it's OK.
+ require Algorithm::Diff;
+ import Algorithm::Diff qw(traverse_sequences);
+};
+
+my $lookahead_lines = $opt_l || 200;
+
+# in theory you could have different amounts of context before and
+# after a diff, but until someone needs that there's only one arg to
+# set both.
+my $precontext_lines = $opt_c || 3;
+my $postcontext_lines = $precontext_lines;
my $file1 = $ARGV[0];
my $file2 = $ARGV[1];