summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/custom-bib/makebst.tex
blob: c5ad0c1065494189acb4a965a3bdbe2c217f67b3 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
%%
%% This is file `makebst.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% makebst.dtx  (with options: `program,optlist,')
%% =============================================
%% IMPORTANT NOTICE:
%% This is a generated file.
%% 
%% It is subject to the same copyright conditions (see below)
%% as in the original file: makebst.dtx.
%% It may not be distributed without makebst.dtx.
%% 
%% Full documentation can be obtained by LaTeXing that original file.
%% Only a few abbreviated comments remain here to describe the usage.
%% =============================================
%% Copyright 1993-2003 Patrick W Daly
%% Max-Planck-Institut f\"ur Sonnensystemforschung
%% Max-Planck-Str. 2
%% D-37191 Katlenburg-Lindau
%% Germany
%% E-mail: daly@mps.mpg.de
%%
%% With additions by Arthur Ogawa
%% E-mai: ogawa@teleport.com
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt; either
%% version 1 of the License, or any later version.
%%
%% This is a contributed file to the LaTeX2e system.
%% -------------------------------------------------
\def\ProvidesFile#1 [#2 #3 #4]{\def\filename{#1}%
  \def\fileversion{#3}\def\filedate{#2}}
 \ProvidesFile{makebst}
    [2003/09/08 4.1 (PWD, AO)]
 % This file is to be run under TeX (or even LaTeX)
 % It interactively asks questions about the bibliographic style file
 % that you want to produce. When it is finished, it writes a docstrip
 % driver file that produces that .bst file from the generic .mbs that
 % you specified; optionally, it will call the docstrip run immediately.
 % For details, read the documentation in the source file makebst.dtx.
 %--------------------------------------------------------------------
\newwrite\outfile
\newread\ttyin
\newread\infile
\newwrite\ttyout
\def\mes{\immediate\write\ttyout}
\def\wr#1{\immediate\write\outfile{#1}}
\def\umes#1{\mes{^^J#1}\wr{\pc#1}}%
\newlinechar=`\^^J
\def\MBswitch{\catcode`\{=12 \catcode`\}=12
              \catcode`\(=1 \catcode`\)=2\relax}
\def\defpar{\par}
\def\remblk#1 @@{#1}
\def\ask#1#2{\mes{#2}\read\ttyin to #1\ifx#1\defpar\def#1{}\else
   \edef#1{\expandafter\remblk#1@@}\fi}
\def\groot#1.#2@@{#1}
\def\getroot#1{\expandafter\groot#1.@@}
\def\gext#1.#2.#3@@{#2}
\def\getext#1{\expandafter\gext#1..@@}
\def\MBaskfile#1(#2.#3)#4#5{%
\loop
  \def\ans{#2.#3}
\if!#2!
 \if!#3!\ask{#5}{#1}\fi
  \ask{#5}{#1 (default extension=#3)}\else
  \ask{#5}{#1 (default=\ans)}
\fi
  \ifx#5\empty \edef#5{\ans}\fi
  \edef\froot{\getroot#5}
  \edef\fext{\getext#5}
  \ifx\fext\empty \def\fext{#3}\fi
  \edef#5{\froot.\fext}
\if#4i
  \def\temp{Cannot find file `#5'}
  \openin\infile#5\relax
  \ifeof\infile \def\ans{}\fi \closein\infile
\else
 \def\temp{There is no default}
 \ifx\froot\empty \def\ans{}\fi
\fi
  \ifx\ans\empty \mes{*** \temp}
\repeat}
{\catcode`\%=12
 \gdef\pc{%}
 \gdef\pcpc{%% }
}
\def\spsp{\space\space}
\newcount\hours
\newcount\minutes
\def\SetTime{\hours=\time
        \global\divide\hours by 60
        \minutes=\hours
        \multiply\minutes by 60
        \advance\minutes by-\time
        \global\multiply\minutes by-1 }
\SetTime
\def\now{\number\hours:\ifnum\minutes<10 0\fi\number\minutes}
\def\today{\number\year/\ifnum\month<10 0\fi\number\month
   /\ifnum\day<10 0\fi\number\day}
\def\Now{\today\space at \now}
\def\optdef#1#2#3#4{%
  \expandafter\def\csname opt@#1\endcsname{#2}%
  \expandafter\def\csname txt@#1\endcsname{#3}%
  \expandafter\def\csname cmt@#1\endcsname{#4}%
  \edef\optlist{\optlist#1,}%
  \def\OptAns{#1}%
  \mes{(#1) #3\space #4}%
}
\def\optlist{}
\def\nxtopt#1,#2@@{#1} \def\rstopt#1,#2@@{#2}
\newif\ifsw
\def\getans{%
 \edef\optlist{\optlist\pc,}%
 \ask{\ans}{\spsp Select:}%
  \expandafter\ifx\csname opt@\ans\endcsname\relax
  \def\ans{*}%
 \fi
 \expandafter\ifx\csname opt@\ans\endcsname\relax
  \let\ans\OptAns
 \fi
  \edef\ansx{\csname opt@\ans\endcsname}
  \swtrue \loop
    \edef\temp{\expandafter\nxtopt\optlist@@}%
    \edef\optlist{\expandafter\rstopt\optlist@@}%
  \if\temp\pc\swfalse\else
   \if\temp\ans
    \wropt\ans
   \else
    \ifoptlist\wrxopt\temp\fi
      \fi
      \expandafter\let\csname opt@\temp\endcsname\relax
    \fi
  \ifsw \repeat
 \def\optlist{}%
 \ifoptverbose
  \wr{\pc------\string\ans=\ans (==\ansx)-------}%
 \else
   \ifoptlist
     \wr{\pc--------------------}%
   \fi
 \fi
}
\def\wropt#1{%
 \edef\tempx{\csname opt@#1\endcsname}%
 \if!\tempx!
  \wr{\spsp\spsp\pc: (def)
   \csname txt@#1\endcsname
   \ifoptverbose\space\csname cmt@#1\endcsname\fi
  }%
 \else
  \wr{\spsp\tempx,\pc:
   \csname txt@#1\endcsname
   \ifoptverbose\space\csname cmt@#1\endcsname\fi
  }%
 \fi
 \mes{\spsp You have selected: \csname txt@#1\endcsname}%
}
\def\wrxopt#1{%
 \edef\tempx{\csname opt@#1\endcsname}%
 \if!\tempx!
  \wr{\pc\space\spsp\pc: (def)
   \csname txt@#1\endcsname
   \ifoptverbose\space\csname cmt@#1\endcsname\fi
  }%
 \else
  \wr{\pc\space\tempx,\pc:
   \csname txt@#1\endcsname
   \ifoptverbose\space\csname cmt@#1\endcsname\fi
  }%
 \fi
}
\def\beginoptiongroup#1{\begingroup\activatestar\OGcontinue{#1}}%
\def\OGcontinue#1#2{%
 \endgroup
 \begingroup
  \let\OGswitch\secondoftwo\def\tempa{#2}%
  \ifx\tempa\empty\expandafter\firstoftwo\else\expandafter\secondoftwo\fi
  {%
   \activestar
  }{%
   \tempa
  }%
  \OGswitch{}{%
    \let\wropt\wrxopt
    \let\ask\nilans
    \def\mes##1{}%
  }%
  \def\OGmessage{#1}%
  \umes{\ifoptverbose<<\fi\OGmessage}%
}
\def\endoptiongroup{%
  \ifoptverbose\umes{>>\OGmessage}\fi
  \aftergroup\let\aftergroup\ans\expandafter
 \endgroup
 \ans
}
\def\activestar{\let\OGswitch\firstoftwo}
\def\activatestar{\catcode`\*13\relax}
{\activatestar\gdef*{\activestar}}
\def\firstoftwo#1#2{#1}
\def\secondoftwo#1#2{#2}
{\catcode`\$=12\gdef\nilans#1#2{\def\ans{$}}}
\mes{***********************************^^J%
     * This is Make Bibliography Style *^^J%
     ***********************************^^J%
     It makes up a docstrip batch job to produce^^J%
     a customized .bst file for running with BibTeX}

\ask{\yn}{Do you want a description of the usage? (NO)}

\if!\yn!\else\if\yn n\else\if\yn N\else
\mes{In the interactive dialogue that follows,^^J%
     you will be presented with a series of menus.^^J%
     In each case, one answer is the default, marked as (*),^^J%
     and a mere carriage-return is sufficient to select it.^^J%
     (If there is no * choice, then the default is the last choice.)^^J%
     For the other choices, a letter is indicated^^J%
     in brackets for selecting that option. If you select^^J%
     a letter not in the list, default is taken.^^J^^J%
     The final output is a file containing a batch job^^J%
     which may be (La)TeXed to produce the desired BibTeX^^J%
     bibliography style file. The batch job may be edited^^J%
     to make minor changes, rather than running this program^^J%
     once again.}
\fi\fi\fi
\MBaskfile{^^JEnter the name of the MASTER file}(merlin.mbs)i\mfile
\let\mroot=\froot
\let\mext=\fext
\edef\temp{\mroot.opt}
\openin\infile\temp\relax
\let\mnext=\mext
\ifeof\infile\else
  \ask{\yn}{** Warning: a file `\temp' also exists^^J
       \spsp Shall I read it for the menu information? (NO)^^J
       \spsp (Answer `yes' only if you really know what you are doing)}
\if\yn y\def\mnext{opt}\else\if\yn Y\def\mnext{opt}\fi\fi
\mes{Menu information read from `\mroot.\mnext'}
\fi
\closein\infile
\MBaskfile{^^JName of the final OUTPUT .bst file?}(.bst)o\ofile
\let\oroot=\froot
\let\oext=\fext
\ask{\ans}{^^JGive a comment line to include in the style file.^^J%
           Something like for which journals it is applicable.}
\immediate\openout\outfile\oroot.dbj
\wr{\pcpc Driver file to produce \oroot.\oext\space from \mroot.\mext}
\wr{\pcpc Generated with \filename, version \fileversion\space (\filedate)}
\wr{\pcpc Produced on \Now}
\wr{\pcpc}
\wr{\string\input\space docstrip}
\wr{}
\wr{\string\preamble}
\wr{----------------------------------------}
\wr{*** \ans\space ***}
\wr{}
\wr{\string\endpreamble}
\wr{}
\wr{\string\postamble}
\wr{End of customized bst file}
\wr{\string\endpostamble}
\wr{}
\wr{\string\keepsilent}
\wr{}
\wr{\string\askforoverwritefalse}
\begingroup\MBswitch
\wr(\string\def\string\MBopts{\string\from{\mroot.\mext}{\pc)
\endgroup
\newif\ifoptlist
\optlisttrue
\ifoptlist\else
 \ask\yn{Do you want the unused option lines^^J%
         \spsp to appear as comments in the output? (NO)}
 \if!\yn!\else\if\yn n\else\if\yn N\else\optlisttrue\fi\fi\fi
\fi
\newif\ifoptverbose
\ifoptlist
 \ifoptverbose\else
  \ask\yn{Do you want verbose comments? (NO)}
  \if!\yn!\else\if\yn n\else\if\yn N\else\optverbosetrue\fi\fi\fi
 \fi
\fi
\edef\temp{\mroot.\mnext}
\let\endoptions=\endinput
\input\temp
\begingroup\MBswitch
\wr(\spsp}})
\endgroup
\wr{\string\generate{\string\file{\oroot.\oext}{\string\MBopts}}}
\wr{\string\endbatchfile}

\immediate\closeout\outfile
\mes{^^JFinished!!^^J%
     Batch job written to file `\oroot.dbj'}
\def\ofile{\oroot.dbj}
\ask{\yn}{Shall I now run this batch job? (NO)}
\def\temp{\relax}
\if!\yn!\else\if\yn n\else\if\yn N\else
\def\temp{\input\ofile}\fi\fi\fi
{\catcode`\@=11 \ifx\@@end\undefined\else
  \global\let\end=\@@end\fi}
\temp
\end
%% <<<<< End of generated file <<<<<<
%%
%% End of file `makebst.tex'.