summaryrefslogtreecommitdiff
path: root/info/digests/texhax/txh/muller.txh
blob: 63419b1f4016d2d6f5aeff445b6e29f24bbbe2b1 (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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
Date: Tue 6 Jan 87 17:39:42-PST
From: Eric Muller <EM@Score.Stanford.EDU>
To: texhax@Score.Stanford.EDU
Subject: How to cite all the keys of a bibtex database.


I have made a simple modification to Bibtex so that it can behave as
if all the entries of a (set of) bibliography file had been cited.
Namely, I have added a ".aux" file command, "\citeall{}" which is
equivalent to the list all "\citation{xxx}" commands where xxx is
replaced by the cite-key of each entry.

In conjunction with a bst-format that produces "\nocite{xxx}" as the
bibliographic entry, where xxx is the cite-key of the entry (instead
of the normal LaTeX commands to format the entry) and a ".aux" file of
the form :

\relax 
\bibdata{cs}		% the name of the .bib file
\citeall{}		% to get all the entries of it
\bibstyle{cite-all}	% to produce a \nocite for each entry

what you get after processing by Bibtex is a list of all the "\nocite"
commands in the ".bbl" file, which you can then \input where you want.

I also have a "author-index.bst" format that will produce a list of
"\index" commands, one for each author in each entry, the text of the
index entry being the author name and the "page number" replaced by
the cite-key of the entry. 

You can also use a standard format in the "\bibstyle". The reason for
the two step process (with the cite-all format) is linked to the
memory allocation scheme of Bibtex I did not want to change too much.
That is, if the format you want to use utilizes less than a certain number
of fields in the entries (if think it is 20) then everything is fine;
otherwise use the two step process.

The rest of this message is the files mentioned above, starting with
the change file for bibtex (I am running the modified version on a
Tops-20 system, so that these may have to be merged with changes for
your system), and the two format files. Files are separated by
"@@@@@@@ <file name>" line. If you need any help, just send me mail.

There may be a bug in these modifications : the last entry in the
database may no appear; just add a dummy entry at the end (or find the
bug !).

Last detail : the modified bibtex will do whatever the old one does,
it just has one additional command; the code for the modification is
not really clean (especially on the Web side); you can forward this to
anyone interested.

Good luck,
Eric Muller					 (em@score.stanford.edu)


@@@@@@@ bibtex.ch
@x
@d n_aux_bibdata = 0	{\.{\\bibdata}}
@d n_aux_bibstyle = 1	{\.{\\bibstyle}}
@d n_aux_citation = 2	{\.{\\citation}}
@d n_aux_input = 3	{\.{\\@@input}}
@y
@d n_aux_bibdata = 0	{\.{\\bibdata}}
@d n_aux_bibstyle = 1	{\.{\\bibstyle}}
@d n_aux_citation = 2	{\.{\\citation}}
@d n_aux_input = 3	{\.{\\@@input}}
@d n_aux_citeall = 4	{\.{\\citeall}}
@z

@x
@<Pre-define certain strings@>=
pre_define('\citation   ',9,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_citation;
pre_define('\bibdata    ',8,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_bibdata;
pre_define('\bibstyle   ',9,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_bibstyle;
pre_define('\@@input     ',7,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_input;
@y
@<Pre-define certain strings@>=
pre_define('\citation   ',9,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_citation;
pre_define('\bibdata    ',8,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_bibdata;
pre_define('\bibstyle   ',9,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_bibstyle;
pre_define('\@@input     ',7,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_input;
pre_define('\citeall    ',8,aux_command_ilk);
ilk_info[pre_def_loc] := n_aux_citeall;
@z

@x
    case command_num of
	n_aux_bibdata : aux_bib_data_command;
	n_aux_bibstyle : aux_bib_style_command;
	n_aux_citation : aux_citation_command;
	n_aux_input : aux_input_command;
@y
    case command_num of
	n_aux_bibdata : aux_bib_data_command;
	n_aux_bibstyle : aux_bib_style_command;
	n_aux_citation : aux_citation_command;
	n_aux_input : aux_input_command;
	n_aux_citeall : aux_citeall_command;
@z

@x
procedure aux_citation_command;
label exit;
begin
@y
procedure aux_citation_command;
label exit;
begin
if citeall_seen then aux_err ('illegal, \citation after a \citeall');
@z

@x
That's it for processing \.{.aux} commands, except for finishing the
procedural gymnastics.

@<Procedures and functions for the reading and processing of input files@>=
@<Scan for and process an \.{.aux} command@>
@y
That's it for processing \.{.aux} commands, except for finishing the
procedural gymnastics.

@<Procedures and functions for the reading and processing of input files@>=
@<Procedure for processing the citeall command@>
@<Scan for and process an \.{.aux} command@>
@z

@x
num_cites := cite_ptr;		{record the number of distinct cite keys}
num_bib_files := bib_ptr;	{and the number of \.{.bib} files}
if (not citation_seen) then
    aux_end_err ('I found no \citation commands')
  else if (num_cites = 0) then
    aux_end_err ('I found no \cite keys');
@y
if citeall_seen then num_cites := max_cites else num_cites := cite_ptr;
num_bib_files := bib_ptr;	{and the number of \.{.bib} files}
if (not citeall_seen) and (not citation_seen) then
  aux_end_err ('I found no \citeall nor \citation commands')
else if (citation_seen) and (num_cites = 0) then
    aux_end_err ('I found no \cite keys');
@z

@x
  trace_pr_ln ('finished reading the database file(s)');
  ecart@/
@<Check for missing entries@>;
@y
  trace_pr_ln ('finished reading the database file(s)');
  ecart@/
if citeall_seen then 
  num_cites := real_num_cites
else begin
  @<Check for missing entries@>; end;
@z

@x
@<Check for a database key of interest@>=
  trace
  trace_pr_token;
  trace_pr_ln (' is a database key');
  ecart@/
tmp_ptr := buf_ptr1;
while (tmp_ptr < buf_ptr2) do
    begin
    sv_buf2[tmp_ptr] := buffer[tmp_ptr];
    incr(tmp_ptr);
    end;
lower_case (sv_buf2, buf_ptr1, token_len);	{convert to `canonical' form}
lc_cite_loc := str_lookup(sv_buf2,buf_ptr1,token_len,lc_cite_ilk,dont_insert);
if (not hash_found) then
    store_entry := false	{no such cite key read on |cite_list|}
  else
    begin
    store_entry := true;
    @<Make sure this entry is ok before proceeding@>;
    end;
@y
@<Check for a database key of interest@>=
  trace
  trace_pr_token;
  trace_pr_ln (' is a database key');
  ecart@/
tmp_ptr := buf_ptr1;
while (tmp_ptr < buf_ptr2) do
    begin
    sv_buf2[tmp_ptr] := buffer[tmp_ptr];
    incr(tmp_ptr);
    end;
lower_case (sv_buf2, buf_ptr1, token_len);	{convert to `canonical' form}
lc_cite_loc := str_lookup(sv_buf2,buf_ptr1,token_len,lc_cite_ilk,dont_insert);

if citeall_seen then begin
  if not hash_found then begin
    lc_cite_loc := str_lookup(sv_buf2,buf_ptr1,
			      token_len,lc_cite_ilk,do_insert);
    trace
    trace_pr_newline;
    ecart@/
    if (real_num_cites = max_cites) then
       overflow('number of \cite keys ',max_cites);
    cite_loc := str_lookup(buffer,buf_ptr1,token_len,cite_ilk,do_insert);
    if (hash_found) then
      aux_err ('this can''t happen---cite hash error');
    cite_list[real_num_cites] := hash_text[cite_loc];
    ilk_info[cite_loc] := real_num_cites;
    ilk_info[lc_cite_loc] := real_num_cites;
    incr(real_num_cites); end;
  store_entry := true;
  @<Make sure this entry is ok before proceeding@>; end

else
  if (not hash_found) then
    store_entry := false	{no such cite key read on |cite_list|}
  else begin
    store_entry := true;
    @<Make sure this entry is ok before proceeding@>; end;
@z

@x
@* System-dependent changes.
@^system dependencies@>
This section should be replaced, if necessary, by changes to the program
that are necessary to make \BibTeX\ work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@y
@ Here are the new modules for the citation of all entries.
We need a global variable to remember that we must cite all entries, 
and another to count the real number of entries :

@<Globals in the outer block@>=
citeall_seen : boolean;
real_num_cites : cite_number;

@ Of course, this needs some initialization.

@<Set initial values of key variables@>=
citeall_seen := false;
real_num_cites := 0;

@ Currently, we do not process arguments of the \.{\\citeall} command, but
skip over them. However, the \.{\{} and \.{\}} must be there.

@<Procedure for processing the citeall command@>=
procedure aux_citeall_command;
label exit;
begin
if citeall_seen then aux_err ('illegal, another \citeall command');
if citation_seen then aux_err ('illegal, \citall command after some \citation command');

citeall_seen := true;
incr(buf_ptr2);
if (not scan1 (right_brace)) then
  aux_err ('no "',xchr[right_brace],'" for \citeall command');
if (last > buf_ptr2 + 1) then
  aux_err ('stuff after "', xchr[right_brace], '" for \citeall command');
exit: end;


@* System-dependent changes.
@^system dependencies@>
This section should be replaced, if necessary, by changes to the program
that are necessary to make \BibTeX\ work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@z

@@@@@@@ cite-all.bst
ENTRY
  {none}
  {}
  {}

FUNCTION {default.type}
{ newline$
  "\nocite{" write$
  cite$ write$
  "}" write$
}

FUNCTION {article} { default.type }
FUNCTION {book} { default.type }
FUNCTION {booklet} { default.type }
FUNCTION {inbook} { default.type }
FUNCTION {incollection} { default.type }
FUNCTION {inproceedings} { default.type }
FUNCTION {conference} { default.type }
FUNCTION {manual} { default.type }
FUNCTION {mastersthesis} { default.type }
FUNCTION {misc} { default.type }
FUNCTION {phdthesis} { default.type }
FUNCTION {proceedings} { default.type }
FUNCTION {techreport} { default.type }
FUNCTION {unpublished} { default.type }

READ

ITERATE {call.type$}

@@@@@@@ author-index.bst
ENTRY
  { author
    editor
  }
  {}
  {label}


STRINGS { s t }

INTEGERS { nameptr namesleft numnames }


FUNCTION {format.names}
{ 's swap$ :=
  'nameptr #1 :=
  'numnames s num.names$ :=
  'namesleft numnames :=
    { namesleft #0 > }
    {
      "\index{" write$
      s nameptr "{vv~}{ll}{ jj}{, ff}" format.name$ write$
      "}{\cite{" write$ cite$ write$ "}}" write$ newline$
      'nameptr nameptr #1 + :=
      'namesleft namesleft #1 - :=
    }
  while$
}

FUNCTION {default.type}
  { author missing$
    { editor missing$
      { skip$ }
      { editor format.names }
      if$ }
    { author format.names }
    if$ }

FUNCTION {article} { default.type }
FUNCTION {book} { default.type }
FUNCTION {booklet} { default.type }
FUNCTION {inbook} { default.type }
FUNCTION {incollection} { default.type }
FUNCTION {inproceedings} { default.type }
FUNCTION {conference} { default.type }
FUNCTION {manual} { default.type }
FUNCTION {mastersthesis} { default.type }
FUNCTION {misc} { default.type }
FUNCTION {phdthesis} { default.type }
FUNCTION {proceedings} { default.type }
FUNCTION {techreport} { default.type }
FUNCTION {unpublished} { default.type }

READ

ITERATE {call.type$}

-------