summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/eplain/base/merge
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/eplain/base/merge')
-rw-r--r--Master/texmf-dist/source/eplain/base/merge84
1 files changed, 84 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/eplain/base/merge b/Master/texmf-dist/source/eplain/base/merge
new file mode 100644
index 00000000000..b300b936bca
--- /dev/null
+++ b/Master/texmf-dist/source/eplain/base/merge
@@ -0,0 +1,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