summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/exteps/delfin
blob: e3f7c2b692d6d4ba927fae97a8b82a7c43545c2c (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /usr/bin/perl -w
#
# Program for inserting EPS files into MetaPost output files. Requires
# the extpeps module for MetaPost -- and it is probably not even
# necessary to run this program
#
# Copyright (C) 2005  Palle Jorgensen <hamselv@pallej.dk>
#                     http://pallej.dk/exteps/
#                     http://pallej.dk/
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# Bugs and comments can be reported to Palle Jorgensen,
# <hamselv@pallej.dk>.
#
# This is version 0.12 Mon Dec 26 2005

use strict;
our($opt_h,$opt_q,$opt_v,$opt_V,$opt_i);

use Getopt::Std;
getopts('-helpvqVi');

use Env qw(HOME);

my $progversion = 0.12;
my $progname = "delfin";
my $prognamelong = "Delfin, the Exteps Large File INserter";
if ($opt_h) { version(); help(); exit; }
if ($opt_v) { version(); exit; }
if ($opt_V) { versionbrief(); exit; }

unless ( $opt_q ) {
    print "This is $progname version $progversion\n";
    print "$prognamelong\n";
}

foreach ( @ARGV ) {
    my $mpsfile = $_;
    my $elffound = 0;
    open (MPSIN, "$mpsfile") or die "Cannot open file $mpsfile";
    my @OUT;
    foreach ( <MPSIN> ) {
	if ($_ =~ /^%% MetaPost exteps large file->/) {
	    $elffound = 1;
	    my $epsfile = (split(/->|\n/,$_))[1];
	    unless ( $opt_q ) {
		print "Inserting $epsfile into $mpsfile\n";
	    }
	    open(EPS, "$epsfile") or die "cannot open file $epsfile";
	    push (@OUT, <EPS>);
	} else {
	    push (@OUT, $_);
	}
    }
    close MPSIN;
    if ( $elffound ) {
	open (MPSOUT, ">$_") or die "Cannot write to file $_";
	print MPSOUT @OUT;
	close MPSOUT;
    }
    else {
	unless ( $opt_q ) {
	    print "No file to insert into $mpsfile\n"
	}
    }
}

sub help {
    print << "EOF";
Usage:
$progname [options] file.n [file.m [file.l ... ]]
Options:
    -h\tPrint this message end exit
    -q\tBe quiet
    -i\tIgnore configuration file
    -v\tDisplay version and license and exit
    -V\tDisplay version number and exit
See exteps.pdf for further documentation
(texdoc exteps on most unix systems)
EOF
}

sub version {
    print << "EOF"
This is $progname version $progversion
$prognamelong
Copyright 2005 by Palle Jorgensen
The license of $progname is GNU General Public License (GPL)
EOF
}

sub versionbrief {
    print "$progversion\n";
}