1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/perl -w
#######################################################################################
# A tool for computing the module reuse factor for TEX files. #
# Copyright (c) 2005, Ioan Sucan, released under the Gnu General Public License (GPL) #
# see http://www.gnu.org/copyleft/gpl.html #
# $URL: svn://kwarc.eecs.iu-bremen.de/repos/kwarc/projects/content/bin/rf$ #
# $Date: 2005-06-29 23:08:10 +0200 (Wed, 29 Jun 2005) $ $Rev: 3147 $ #
#######################################################################################
use strict;
use Getopt::Long;
use Modparse;
use Pod::Usage;
my $input = "-", my $verbose=0, my $stop_at_end=0;
my %arg_snippath; my @snippathList;
GetOptions("path=s" => \%arg_snippath,
"defpath=s" => \@snippathList,
"verbose" => sub { $verbose=1; },
"stop" => sub { $stop_at_end=1; },
"help" => sub { pod2usage(2)});
$input = $ARGV[0] if ($#ARGV>=0);
$main::lc1 = 0; $main::lc2 = 0;
my $mp = Modparse->new(snippathList=>\@snippathList,
snippath=>\%arg_snippath,
stopAtEnd=>$stop_at_end,
verbose=>$verbose,
onEveryLine=>sub {
$main::lc1++;
$main::lc2++ if $_[0]->{depth}==1; });
$mp->execute($input);
my $f = ($main::lc2>0)?$main::lc1/$main::lc2:0;
print "Reuse factor: $f\n";
__END__
=head1 SYNOPSIS
rf <input filename> [options]
This program computes the reuse factor for a .tex document
Options:
--path XXX specify the value of \XXX (some snippath) in case it is
= somePath not defined in the processed .tex file
--defpath XXX specify which \XXX (snippath definitions) to look for
--stop stop when \end{document} is found; default is to go on
--verbose verbose on
--help this screen
Example usage:
./rf slides.tex -d snippath -v
Interpretation:
compute the reuse factor for the file slides.tex, look for definitions
of \snippath, in verbose mode
|