summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/eplain/base/merge
blob: b300b936bcafb19189ea1b204fd624ca42b02d0f (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
#!/bin/sh
# This file is public domain.

# Merge the constituent files with xeplain.tex to produce eplain.tex.
 
# Usually we are called from the Makefile, and the `version' variable is set.
if test -z "$version"; then
  echo "No version number, using xx!"
  version=xx
fi

btxtmp=/tmp/mergebtx$$
common1tmp=/tmp/mergec1$$
common2tmp=/tmp/mergec2$$
common3tmp=/tmp/mergec3$$
eplaintmp=/tmp/mergepl$$
arrow1tmp=/tmp/mergea1$$
arrow2tmp=/tmp/mergea2$$
pathtmp=/tmp/mergepa$$
ifpdftmp=/tmp/mergeif$$

rm -f eplain.tex

# Use this regexp to strip comments with egrep.
commentre='^ *%([^%]|$)'

# Extract the relevant parts of btxmac.tex (without comments).
egrep -v "$commentre" btxmac.tex					\
  | sed -n								\
        -e "1,/^%% \[\[\[start .*\]\]\]/w $common1tmp"			\
        -e "/^%% \[\[\[start .*\]\]\]/,/^%% \[\[\[end .*\]\]\]/w $btxtmp" \
        -e "/^%% \[\[\[end .*\]\]\]/,\$w $common2tmp"

# Get texnames.sty and path.sty.  Remove the announcement, as well as
# the comments.
egrep -v "$commentre|immediate" texnames.sty > $common3tmp
egrep -v "$commentre|immediate" path.sty > $pathtmp

# Get arrow.tex.
egrep -v "$commentre" arrow.tex \
  | sed -n							\
        -e '1,/catcode.*\&.*4/w '"$arrow1tmp"			\
        -e '/catcode.*\&.*4/,$w '"$arrow2tmp"

# Get ifpdf.sty
egrep -v "$commentre"'|^ {0,6}\\immediate' ifpdf.sty > $ifpdftmp

# Merge the above into xeplain, calling the result eplain.  Also change the
# `filename' in the comment.%%
egrep -v "$commentre" xeplain.tex					\
  | sed -e 's/"xeplain.tex"/"eplain.tex"/'						\
        -e "/^%% \[\[\[here is the first.*\]\]\]/r $common1tmp"		\
        -e "/^  %% \[\[\[here are the BibTeX.*\]\]\]/r $btxtmp"		\
        -e "/^%% \[\[\[here is the second.*\]\]\]/r $common2tmp"	\
        -e "/^%% \[\[\[include texnames.*\]\]\]/r $common3tmp"		\
        -e "/^%% \[\[\[include path.*\]\]\]/r $pathtmp"			\
        -e "/^  %% \[\[\[include arrow1\]\]\]/r $arrow1tmp"		\
        -e "/^  %% \[\[\[include arrow2\]\]\]/r $arrow2tmp"		\
        -e "/^%% \[\[\[include ifpdf.*\]\]\]/r $ifpdftmp"		\
    > $eplaintmp

# Remove our [[[...]]] markers and \endinput's.
egrep -v '\[\[\[|^ *$|\\endinput' $eplaintmp > eplain.tex

# Fix header fields.
./add-date eplain.tex
./add-version $version eplain.tex
./fix-checksum eplain.tex

# Old checksum computation:
#checksum=`wc < $eplaintmp | sed -n "s/^ *//"`
# Replace the checksum in the old file.  We really should loop here,
# since one iteration may not be enough.  Only replace the first
# checksum, since the second is for btxmac.
#sed -e "1,50s/checksum = .*,/checksum = \"$checksum\",/" $eplaintmp \
#  > eplain.tex

chmod a-w eplain.tex
#ls -lt btxmac.tex path.sty texnames.sty xeplain.tex eplain.tex arrow.tex
#wc eplain.tex
#grep 'checksum.*=' eplain.tex

rm -f $btxtmp $eplaintmp $common1tmp $common2tmp $common3tmp
rm -f $arrow1tmp $arrow2tmp $pathtmp $ifpdftmp