summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/bin/old/symdef
blob: b5c789a1c72bc93d7e97abea9e319dc8c6016fe1 (plain)
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
#!/usr/bin/perl -w

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

my $output = "-";
my $input = "-";

GetOptions("output=s",\$output);

$input = $ARGV[0] if @ARGV;

open(FIN,$input) or die "Can't open input file.";
open(FOUT,">$output");

my $line;

while ($line=<FIN>){
    if ($line !~ m/symdef/ && $line !~ m/elldef/ && $line !~ m/abbrdef/){
	print FOUT $line;
	next;
    }
    if ($line =~ m/\}\[\d,/){
	print FOUT $line;
	next;
    }
    
    if ($line =~ m/\\(sym|abbr|ell)def\{\\([^\}]+)\}\[(\d)\]([^\n\%]+)(.*)/){
	print FOUT "\\$1def{\\$2}[$3,name=$2]$4$5\n";
    } else {
	if ($line =~ m/\\(sym|ell|abbr)def\{\\([^\}]+)\}([^\n\%]+)(.*)/){
	    print FOUT "\\$1def{\\$2}[0,name=$2]$3$4\n";
	}
    }
}

close(FIN);
close(FOUT);


__END__

=head1 SYNOPSIS

symdef [--output=outputfile] [texfile]