<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

# Copyright 2012-2022, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SPLinT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SPLinT.  If not, see &lt;http://www.gnu.org/licenses/&gt;.

use Getopt::Long;
use Pod::Usage;

my $man = 0;
my $help = 0;

#Getopt::Long::Configure ("bundling"); # to allow -abc to set a, b, and c

GetOptions ("help|?" =&gt; \$help, 
             man =&gt; \$man,
    ) or pod2usage(2);

pod2usage(-exitval =&gt; 0, -verbose =&gt; 1) if $help;
pod2usage(-exitval =&gt; 0, -verbose =&gt; 2) if $man;

for ($i = 0; $i &lt;= $#ARGV; $i++) {

    open FILE, "&lt;$ARGV[$i]" or die "Cannot open file $ARGV[$i]!\n";
    $filename = $ARGV[$i];

    while(&lt;FILE&gt;) {

        $text = $_;
        
        while( $text =~ /(\\newcount|\\newtoks|\\newdimen|\\newif|\\let|\\([exg]|char|toks|count)?def)\w*(\\[a-zA-Z@]+)/g ) {

            $cs = $3;
	    push @all, $cs;

	    if ( defined $secse{$cs}-&gt;{$filename} ) { $secse{$cs}-&gt;{$filename}++; }
	    else { $secse{$cs}-&gt;{$filename} = 1; };
	    
	}
	
    }
}
#print keys %secse;
@alphsecs = sort keys %secse;

foreach $ocs (@alphsecs) {

    print "$ocs \% ". ref $secse{$osc};
    @fnames = sort keys %{$secse{$ocs}};
    foreach $fname (@fnames) { 
	print " $fname ($secse{$ocs}-&gt;{$fname} occurence";
        if ( $secse{$ocs}-&gt;{$fname} &gt; 1 ) {print "s";}   
        print ")"; 
    }
    print "\n";
}

print "\n";
$i = $#alphsecs;
$i++;
print "total sequences: $i\n";

__END__

=head1 CSLIST

cslist.pl - output a list of all control sequences in the input files.

=head1 SYNOPSIS

cslist.pl [options] input_files


 Options:
   --help|-h|-?      brief help message
   --man|-m          full documentation

=head1 OPTIONS

=over 8

=item B&lt;--help&gt;

Print a brief help message and exit.

=item B&lt;--man&gt;

Print the manual page and exit.

=back

=head1 DESCRIPTION

B&lt;cslist.pl&gt; will read the given &lt;input_files&gt;, and produce a list of all the
B&lt;TeX&gt; control sequences defined in those files (a contorl sequence is considered
I&lt;defined&gt; in a file B&lt;foo.tex&gt; if one of B&lt;\def&gt;, B&lt;\let&gt;, B&lt;\new...&gt;, or similar
preceeds it in B&lt;foo.tex&gt;. 

=cut
</pre></body></html>