1 |
%% |
2 |
%% This is file `makebst.tex', |
3 |
%% generated with the docstrip utility. |
4 |
%% |
5 |
%% The original source files were: |
6 |
%% |
7 |
%% makebst.dtx (with options: `program,optlist') |
8 |
%% |
9 |
%% This is the `program' part of the source file. |
10 |
%% It may be run either with TeX or LaTeX. |
11 |
%% |
12 |
\def\ProvidesFile#1 [#2 #3 #4]{\def\filename{#1}% |
13 |
\def\fileversion{#3}\def\filedate{#2}} |
14 |
\ProvidesFile{makebst} |
15 |
[1995/03/15 3.0 (PWD)] |
16 |
%------------------------------------------------------------------- |
17 |
% NOTICE: |
18 |
% This file may be used for non-profit purposes. |
19 |
% It may not be distributed in exchange for money, |
20 |
% other than distribution costs. |
21 |
% |
22 |
% The author provides it `as is' and does not guarantee it in any way. |
23 |
% |
24 |
%% Copyright (C) 1994, 1995 Patrick W. Daly |
25 |
% Max-Planck-Institut f\"ur Aeronomie |
26 |
% Postfach 20 |
27 |
% D-37189 Katlenburg-Lindau |
28 |
% Germany |
29 |
% |
30 |
% E-mail: |
31 |
% SPAN-- nsp::linmpi::daly |
32 |
% Internet-- daly@linmpi.dnet.gwdg.de |
33 |
%----------------------------------------------------------- |
34 |
% This file is to be run under TeX (or even LaTeX) |
35 |
% It interactively asks questions about the bibliographic style file |
36 |
% that you want to produce. When it is finished, it writes a docstrip |
37 |
% driver file that produces that .bst file from the generic .mbs that |
38 |
% you specified; optionally, it will call the docstrip run immediately. |
39 |
% For details, read the documentation in the source file makebst.dtx. |
40 |
%-------------------------------------------------------------------- |
41 |
\newwrite\outfile |
42 |
\newread\ttyin |
43 |
\newread\infile |
44 |
\newwrite\ttyout |
45 |
\def\mes{\immediate\write\ttyout} |
46 |
\def\wr#1{\immediate\write\outfile{#1}} |
47 |
\newlinechar=`\^^J |
48 |
\def\MBswitch{\catcode`\{=12 \catcode`\}=12 |
49 |
\catcode`\(=1 \catcode`\)=2\relax} |
50 |
\def\defpar{\par} |
51 |
\def\remblk#1 @@{#1} |
52 |
\def\ask#1#2{\mes{#2}\read\ttyin to #1\ifx#1\defpar\def#1{}\else |
53 |
\edef#1{\expandafter\remblk#1@@}\fi} |
54 |
\def\groot#1.#2@@{#1} |
55 |
\def\getroot#1{\expandafter\groot#1.@@} |
56 |
\def\gext#1.#2.#3@@{#2} |
57 |
\def\getext#1{\expandafter\gext#1..@@} |
58 |
\def\MBaskfile#1(#2.#3)#4#5{% |
59 |
\loop |
60 |
\def\ans{#2.#3} |
61 |
\if!#2! |
62 |
\if!#3!\ask{#5}{#1}\fi |
63 |
\ask{#5}{#1 (default extension=#3)}\else |
64 |
\ask{#5}{#1 (default=\ans)} |
65 |
\fi |
66 |
\ifx#5\empty \edef#5{\ans}\fi |
67 |
\edef\froot{\getroot#5} |
68 |
\edef\fext{\getext#5} |
69 |
\ifx\fext\empty \def\fext{#3}\fi |
70 |
\edef#5{\froot.\fext} |
71 |
\if#4i |
72 |
\def\temp{Cannot find file `#5'} |
73 |
\openin\infile#5\relax |
74 |
\ifeof\infile \def\ans{}\fi \closein\infile |
75 |
\else |
76 |
\def\temp{There is no default} |
77 |
\ifx\froot\empty \def\ans{}\fi |
78 |
\fi |
79 |
\ifx\ans\empty \mes{*** \temp} |
80 |
\repeat} |
81 |
{\catcode`\%=12 |
82 |
\gdef\pc{%} |
83 |
\gdef\pcpc{%% } |
84 |
} |
85 |
\def\spsp{\space\space} |
86 |
\newcount\hours |
87 |
\newcount\minutes |
88 |
\def\SetTime{\hours=\time |
89 |
\global\divide\hours by 60 |
90 |
\minutes=\hours |
91 |
\multiply\minutes by 60 |
92 |
\advance\minutes by-\time |
93 |
\global\multiply\minutes by-1 } |
94 |
\SetTime |
95 |
\def\now{\number\hours:\ifnum\minutes<10 0\fi\number\minutes} |
96 |
\def\today{\number\year/\ifnum\month<10 0\fi\number\month |
97 |
/\ifnum\day<10 0\fi\number\day} |
98 |
\def\Now{\today\space at \now} |
99 |
\def\optdef#1#2#3#4{\expandafter\def\csname opt@#1\endcsname{#2}% |
100 |
\expandafter\def\csname txt@#1\endcsname{#3}% |
101 |
\edef\optlist{#1,\optlist}% |
102 |
\mes{(#1) #3\space #4}} |
103 |
|
104 |
\def\optlist{?,} |
105 |
|
106 |
\def\nxtopt#1,#2@@{#1} \def\rstopt#1,#2@@{#2} |
107 |
|
108 |
\newif\ifsw |
109 |
\def\getans{\ask{\ans}{\spsp Select:} |
110 |
\expandafter\ifx\csname opt@\ans\endcsname\relax \def\ans{*}\fi |
111 |
\expandafter\ifx\csname opt@\ans\endcsname\relax |
112 |
\edef\ans{\expandafter\nxtopt\optlist@@}\fi |
113 |
\swtrue \loop |
114 |
\edef\temp{\expandafter\nxtopt\optlist@@}% |
115 |
\edef\optlist{\expandafter\rstopt\optlist@@}% |
116 |
\if\temp?\swfalse\else |
117 |
\if\temp\ans\wropt\ans |
118 |
\else\wrxopt\temp |
119 |
\fi |
120 |
\expandafter\let\csname opt@\temp\endcsname\relax |
121 |
\fi |
122 |
\ifsw \repeat |
123 |
\def\optlist{?,}% |
124 |
\wr{\pc--------------------}% |
125 |
} |
126 |
\def\wropt#1{\edef\tempx{\csname opt@#1\endcsname}\if!\tempx! |
127 |
\wr{\spsp\spsp\pc: (def) \csname txt@#1\endcsname}\else |
128 |
\wr{\spsp\sep\csname opt@#1\endcsname\pc: \csname txt@#1\endcsname} |
129 |
\def\sep{,}\fi |
130 |
\mes{\spsp You have selected: \csname txt@#1\endcsname}} |
131 |
\def\wrxopt#1{\edef\tempx{\csname opt@#1\endcsname}\if!\tempx! |
132 |
\wr{\pc\spsp\pc(def) \csname txt@#1\endcsname}\else |
133 |
\wr{\pc\spsp\sep\csname opt@#1\endcsname\pc: \csname txt@#1\endcsname} |
134 |
\def\sep{,}\fi} |
135 |
\mes{***********************************^^J% |
136 |
* This is Make Bibliography Style *^^J% |
137 |
***********************************^^J% |
138 |
It makes up a docstrip batch job to produce^^J% |
139 |
a customized .bst file for running with BibTeX} |
140 |
|
141 |
\ask{\yn}{Do you want a description of the usage? (NO)} |
142 |
|
143 |
\if!\yn!\else\if\yn n\else\if\yn N\else |
144 |
\mes{In the interactive dialogue that follows,^^J% |
145 |
you will be presented with a series of menus.^^J% |
146 |
In each case, one answer is the default, marked as (*),^^J% |
147 |
and a mere carriage-return is sufficient to select it.^^J% |
148 |
(If there is no * choice, then the default is the last choice.)^^J% |
149 |
For the other choices, a letter is indicated^^J% |
150 |
in brackets for selecting that option. If you select^^J% |
151 |
a letter not in the list, default is taken.^^J^^J% |
152 |
The final output is a file containing a batch job^^J% |
153 |
which may be (La)TeXed to produce the desired BibTeX^^J% |
154 |
bibliography style file. The batch job may be edited^^J% |
155 |
to make minor changes, rather than running this program^^J% |
156 |
once again.} |
157 |
\fi\fi\fi |
158 |
\MBaskfile{^^JEnter the name of the MASTER file}(merlin.mbs)i\mfile |
159 |
\let\mroot=\froot |
160 |
\let\mext=\fext |
161 |
\edef\temp{\mroot.opt} |
162 |
\openin\infile\temp\relax |
163 |
\let\mnext=\mext |
164 |
\ifeof\infile\else |
165 |
\ask{\yn}{** Warning: a file `\temp' also exists^^J |
166 |
\spsp Shall I read it for the menu information? (NO)^^J |
167 |
\spsp (Answer `yes' only if you really know what you are doing)} |
168 |
\if\yn y\def\mnext{opt}\else\if\yn Y\def\mnext{opt}\fi\fi |
169 |
\mes{Menu information read from `\mroot.\mnext'} |
170 |
\fi |
171 |
\closein\infile |
172 |
\MBaskfile{^^JName of the final OUTPUT .bst file?}(.bst)o\ofile |
173 |
\let\oroot=\froot |
174 |
\let\oext=\fext |
175 |
\ask{\ans}{^^JGive a comment line to include in the style file.^^J% |
176 |
Something like for which journals it is applicable.} |
177 |
\immediate\openout\outfile\oroot.dbj |
178 |
\wr{\pcpc Driver file to produce \oroot.\oext\space from \mroot.\mext} |
179 |
\wr{\pcpc Generated with \filename, version \fileversion\space (\filedate)} |
180 |
\wr{\pcpc Produced on \Now} |
181 |
\wr{\pcpc} |
182 |
\wr{\string\def\string\batchfile{\oroot.dbj}} |
183 |
\wr{\string\input\space docstrip} |
184 |
\wr{} |
185 |
\wr{\string\preamble} |
186 |
\wr{----------------------------------------} |
187 |
\wr{*** \ans\space ***} |
188 |
\wr{} |
189 |
\wr{\string\endpreamble} |
190 |
\wr{} |
191 |
\wr{\string\postamble} |
192 |
\wr{End of customized bst file} |
193 |
\wr{\string\endpostamble} |
194 |
\wr{} |
195 |
\wr{\string\keepsilent} |
196 |
\wr{} |
197 |
\begingroup\MBswitch |
198 |
\wr(\string\def\string\MBopts{\string\from{\mroot.\mext}{\pc) |
199 |
\endgroup |
200 |
\def\sep{} |
201 |
|
202 |
\edef\temp{\mroot.\mnext} |
203 |
\let\endoptions=\endinput |
204 |
\input\temp |
205 |
\begingroup\MBswitch |
206 |
\wr(\spsp}}) |
207 |
\endgroup |
208 |
\wr{\string\generateFile{\oroot.\oext}{f}{\string\MBopts}} |
209 |
|
210 |
\immediate\closeout\outfile |
211 |
\mes{^^JFinished!!^^J% |
212 |
Batch job written to file `\oroot.dbj'} |
213 |
\def\ofile{\oroot.dbj} |
214 |
\ask{\yn}{Shall I now run this batch job? (NO)} |
215 |
\def\temp{\relax} |
216 |
\if!\yn!\else\if\yn n\else\if\yn N\else |
217 |
\def\temp{\input\ofile}\fi\fi\fi |
218 |
{\catcode`\@=11 \ifx\@@end\undefined\else |
219 |
\global\let\end=\@@end\fi} |
220 |
\temp |
221 |
\end |
222 |
%% <<<<< End of decommented file <<<<<< |
223 |
%% |
224 |
%% End of file makebst.tex. |
225 |
%% |
226 |
%% End of file `makebst.tex'. |