Debian Codegraph @

texk/bibtex-x/bibtex-2.c

raw
1 /*-
2 ******************************************************************************
3 ******************************************************************************
4 **
5 ** MODULE
6 **
7 ** file: bibtex-2.c
8 **
9 ** DESCRIPTION
10 **
11 ** A 32-bit implementation of BibTeX v0.99c for MS-DOS, OS/2 2.x,
12 ** Unix and VMS. This C language implementation is based on the
13 ** original WEB source but it has been enhanced to support 8-bit input
14 ** characters and a very large processing capacity.
15 **
16 ** For documentation describing how to use and build this program,
17 ** see the 00README.TXT file that accompanies this distribution.
18 **
19 ** MODULE CONTENTS
20 **
21 ** This is the second of 4 source modules for BibTeX. The source has
22 ** been split into 4 parts so that some of the more primitive editors
23 ** can cope. This code mimics the BibTeX WEB source as closely as
24 ** possible and there should be NO system dependent code in any of the
25 ** bibtex-#.c modules.
26 **
27 ** The functions defined in this module are:
28 **
29 ** execute_fn
30 ** figure_out_the_formatted_name
31 ** find_cite_locs_for_this_cite_ke
32 ** get_aux_command_and_process
33 ** get_bib_command_or_entry_and_pr
34 ** get_bst_command_and_process
35 ** get_the_top_level_aux_file_name
36 ** hash_cite_confusion
37 ** id_scanning_confusion
38 ** illegl_literal_confusion
39 ** init_command_execution
40 ** initialize
41 ** input_ln
42 ** int_to_ASCII
43 ** last_check_for_aux_errors
44 ** less_than
45 ** lower_case
46 ** macro_warn_print
47 ** make_string
48 ** mark_error
49 ** mark_fatal
50 ** mark_warning
51 ** name_scan_for_and
52 ** non_existent_cross_reference_er
53 ** out_pool_str
54 ** output_bbl_line
55 ** out_token
56 ** pool_overflow
57 ** pop_lit_stk
58 ** pop_the_aux_stack
59 ** pop_top_and_print
60 ** pop_whole_stack
61 **
62 ** AUTHORS
63 **
64 ** Original WEB translation to C, conversion to "big" (32-bit) capacity,
65 ** addition of run-time selectable capacity and 8-bit support extensions
66 ** by:
67 **
68 ** Niel Kempson
69 ** Snowy Owl Systems Limited, Cheltenham, England
70 ** E-mail: [email protected]
71 **
72 ** 8-bit support extensions also by:
73 **
74 ** Alejandro Aguilar-Sierra
75 ** Centro de Ciencias de la Atm\'osfera,
76 ** Universidad Nacional Aut\'onoma de M\'exico, M\'exico
77 ** E-mail: [email protected]
78 **
79 ** COPYRIGHT
80 **
81 ** This implementation copyright (c) 1991-1995 by Niel Kempson
82 ** and copyright (c) 1995 by Alejandro Aguilar-Sierra.
83 **
84 ** This program is free software; you can redistribute it and/or
85 ** modify it under the terms of the GNU General Public License as
86 ** published by the Free Software Foundation; either version 1, or
87 ** (at your option) any later version.
88 **
89 ** This program is distributed in the hope that it will be useful,
90 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
91 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
92 ** General Public License for more details.
93 **
94 ** You should have received a copy of the GNU General Public License
95 ** along with this program; if not, write to the Free Software
96 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
97 **
98 ** In other words, you are welcome to use, share and improve this
99 ** program. You are forbidden to forbid anyone else to use, share
100 ** and improve what you give them. Help stamp out software-hoarding!
101 **
102 ** ACKNOWLEDGEMENT
103 **
104 ** The original BibTeX was written by Oren Patashnik using Donald
105 ** Knuth's WEB system. This format produces a PASCAL program for
106 ** execution and a TeX documented version of the source code. This
107 ** program started as a (manual) translation of the WEB source into C.
108 **
109 ** CHANGE LOG
110 **
111 ** $Log: bibtex-2.c,v $
112 ** Revision 3.71 1996/08/18 20:47:30 kempson
113 ** Official release 3.71 (see HISTORY file for details).
114 **
115 ** Revision 3.70 1996/04/08 10:08:40 kempson
116 ** Final documentation & cosmetic changes for official release 3.70.
117 **
118 ** Revision 3.6 1995/10/21 22:19:33 kempson
119 ** Removed previous WEB-imposed limit on the maximum value of Hash_Prime.
120 **
121 ** Revision 3.5 1995/09/24 20:44:37 kempson
122 ** Many changes for final beta test version.
123 **
124 ** Revision 3.4 1995/04/09 22:15:39 kempson
125 ** Placed under RCS control
126 **
127 ******************************************************************************
128 ******************************************************************************
129 */
130
131 #ifdef HAVE_CONFIG_H
132 #include <config.h>
133 #endif
134
135 #include "sysdep.h"
136 #include "bibtex.h"
137 #include "datatype.h"
138 #include "gblprocs.h"
139 #include "gblvars.h"
140 #include "utils.h"
141 #include "version.h"
142
143
144 /***************************************************************************
145 * WEB section number: 325
146 * ~~~~~~~~~~~~~~~~~~~
147 * This procedure executes a single specified function; it is the single
148 * execution-primitive that does everything (except windows, and it takes
149 * Tuesdays off).
150 ***************************************************************************/
151 void execute_fn (HashLoc_T ex_fn_loc)
152 BEGIN
153
154 /***************************************************************************
155 * WEB section number: 343
156 * ~~~~~~~~~~~~~~~~~~~
157 * Now it's time to declare some things for executing |built_in|
158 * functions only. These (and only these) variables are used
159 * recursively, so they can't be global.
160 ***************************************************************************/
161 Integer_T r_pop_lt1,
162 r_pop_lt2;
163 StkType_T r_pop_tp1,
164 r_pop_tp2;
165 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 343 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
166
167 WizFnLoc_T wiz_ptr;
168
169 #ifdef TRACE
170 if (Flag_trace) {
171 TRACE_PR ("execute_fn `");
172 TRACE_PR_POOL_STR (hash_text[ex_fn_loc]);
173 TRACE_PR_LN ("'");
174 }
175 #endif /* TRACE */
176
177 switch (fn_type[ex_fn_loc])
178 BEGIN
179 case BUILT_IN:
180 /***************************************************************************
181 * WEB section number: 341
182 * ~~~~~~~~~~~~~~~~~~~
183 * This module branches to the code for the appropriate |built_in|
184 * function. Only three---call.type$, if$, and while$---do a recursive call.
185 ***************************************************************************/
186 BEGIN
187
188 #ifdef STAT
189 if (Flag_stats)
190 INCR (execution_count[FN_INFO[ex_fn_loc]]);
191 #endif /* STAT */
192
193 switch (FN_INFO[ex_fn_loc])
194 BEGIN
195 case N_EQUALS:
196 x_equals ();
197 break;
198 case N_GREATER_THAN:
199 x_greater_than ();
200 break;
201 case N_LESS_THAN:
202 x_less_than ();
203 break;
204 case N_PLUS:
205 x_plus ();
206 break;
207 case N_MINUS:
208 x_minus ();
209 break;
210 case N_BIT_AND:
211 x_bit_and ();
212 break;
213 case N_BIT_OR:
214 x_bit_or ();
215 break;
216 case N_CONCATENATE:
217 x_concatenate ();
218 break;
219 case N_GETS:
220 x_gets ();
221 break;
222 case N_ADD_PERIOD:
223 x_add_period ();
224 break;
225 case N_CALL_TYPE:
226
227 /***************************************************************************
228 * WEB section number: 363
229 * ~~~~~~~~~~~~~~~~~~~
230 * The |built_in| function call.type$ executes the function
231 * specified in |type_list| for this entry unless it's |undefined|, in
232 * which case it executes the default function default.type defined
233 * in the .bst file, or unless it's |empty|, in which case it does
234 * nothing.
235 ***************************************************************************/
236 BEGIN
237 if ( ! mess_with_entries)
238 BEGIN
239 bst_cant_mess_with_entries_prin ();
240 END
241 else if (type_list[cite_ptr] == UNDEFINED)
242 BEGIN
243 execute_fn (b_default);
244 END
245 else if (type_list[cite_ptr] == EMPTY)
246 BEGIN
247 DO_NOTHING;
248 END
249 else
250 BEGIN
251 execute_fn (type_list[cite_ptr]);
252 END
253 END
254 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 363 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
255
256 break;
257 case N_CHANGE_CASE:
258 x_change_case ();
259 break;
260 case N_CHR_TO_INT:
261 x_chr_to_int ();
262 break;
263 case N_CITE:
264 x_cite ();
265 break;
266 case N_DUPLICATE:
267 x_duplicate ();
268 break;
269 case N_EMPTY:
270 x_empty ();
271 break;
272 case N_FORMAT_NAME:
273 x_format_name ();
274 break;
275 case N_IF:
276
277 /***************************************************************************
278 * WEB section number: 421
279 * ~~~~~~~~~~~~~~~~~~~
280 * The |built_in| function if$ pops the top three literals (they
281 * are two function literals and an integer literal, in that order); if
282 * the integer is greater than 0, it executes the second literal, else it
283 * executes the first. If any of the types is incorrect, it complains
284 * but does nothing else.
285 ***************************************************************************/
286 BEGIN
287 pop_lit_stk (&pop_lit1, &pop_typ1);
288 pop_lit_stk (&pop_lit2, &pop_typ2);
289 pop_lit_stk (&pop_lit3, &pop_typ3);
290 if (pop_typ1 != STK_FN)
291 BEGIN
292 print_wrong_stk_lit (pop_lit1, pop_typ1, STK_FN);
293 END
294 else if (pop_typ2 != STK_FN)
295 BEGIN
296 print_wrong_stk_lit (pop_lit2, pop_typ2, STK_FN);
297 END
298 else if (pop_typ3 != STK_INT)
299 BEGIN
300 print_wrong_stk_lit (pop_lit3, pop_typ3, STK_INT);
301 END
302 else if (pop_lit3 > 0)
303 BEGIN
304 execute_fn (pop_lit2);
305 END
306 else
307 BEGIN
308 execute_fn (pop_lit1);
309 END
310 END
311 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 421 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
312
313 break;
314 case N_INT_TO_CHR:
315 x_int_to_chr ();
316 break;
317 case N_INT_TO_STR:
318 x_int_to_str ();
319 break;
320 case N_MISSING:
321 x_missing ();
322 break;
323 case N_NEWLINE:
324
325 /***************************************************************************
326 * WEB section number: 425
327 * ~~~~~~~~~~~~~~~~~~~
328 * The |built_in| function newline$ writes whatever has
329 * accumulated in the output buffer |out_buf| onto the .bbl file.
330 ***************************************************************************/
331 BEGIN
332 output_bbl_line ();
333 END
334 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 425 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
335
336 break;
337 case N_NUM_NAMES:
338 x_num_names ();
339 break;
340 case N_POP:
341
342 /***************************************************************************
343 * WEB section number: 428
344 * ~~~~~~~~~~~~~~~~~~~
345 * The |built_in| function pop$ pops the top of the stack but
346 * doesn't print it.
347 ***************************************************************************/
348 BEGIN
349 pop_lit_stk (&pop_lit1, &pop_typ1);
350 END
351 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 428 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
352
353 break;
354 case N_PREAMBLE:
355 x_preamble ();
356 break;
357 case N_PURIFY:
358 x_purify ();
359 break;
360 case N_QUOTE:
361 x_quote ();
362 break;
363 case N_SKIP:
364
365 /***************************************************************************
366 * WEB section number: 435
367 * ~~~~~~~~~~~~~~~~~~~
368 * The |built_in| function skip$ is a no-op.
369 ***************************************************************************/
370 BEGIN
371 DO_NOTHING;
372 END
373 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 435 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
374
375 break;
376 case N_STACK:
377
378 /***************************************************************************
379 * WEB section number: 436
380 * ~~~~~~~~~~~~~~~~~~~
381 * The |built_in| function stack$ pops and prints the whole stack; it's
382 * meant to be used for style designers while debugging.
383 ***************************************************************************/
384 BEGIN
385 pop_whole_stack ();
386 END
387 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 436 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
388
389 break;
390 case N_SUBSTRING:
391 x_substring ();
392 break;
393 case N_SWAP:
394 x_swap ();
395 break;
396 case N_TEXT_LENGTH:
397 x_text_length ();
398 break;
399 case N_TEXT_PREFIX:
400 x_text_prefix ();
401 break;
402 case N_TOP_STACK:
403
404 /***************************************************************************
405 * WEB section number: 446
406 * ~~~~~~~~~~~~~~~~~~~
407 * The |built_in| function top$ pops and prints the top of the
408 * stack.
409 ***************************************************************************/
410 BEGIN
411 pop_top_and_print ();
412 END
413 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 446 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
414
415 break;
416 case N_TYPE:
417 x_type ();
418 break;
419 case N_WARNING:
420 x_warning ();
421 break;
422 case N_WHILE:
423
424 /***************************************************************************
425 * WEB section number: 449
426 * ~~~~~~~~~~~~~~~~~~~
427 * The |built_in| function while$ pops the top two (function)
428 * literals, and keeps executing the second as long as the (integer)
429 * value left on the stack by executing the first is greater than 0. If
430 * either type is incorrect, it complains but does nothing else.
431 ***************************************************************************/
432 BEGIN
433 pop_lit_stk (&r_pop_lt1, &r_pop_tp1);
434 pop_lit_stk (&r_pop_lt2, &r_pop_tp2);
435 if (r_pop_tp1 != STK_FN)
436 BEGIN
437 print_wrong_stk_lit (r_pop_lt1, r_pop_tp1, STK_FN);
438 END
439 else if (r_pop_tp2 != STK_FN)
440 BEGIN
441 print_wrong_stk_lit (r_pop_lt2, r_pop_tp2, STK_FN);
442 END
443 else
444 BEGIN
445 LOOP
446 BEGIN
447 execute_fn (r_pop_lt2);
448 pop_lit_stk (&pop_lit1, &pop_typ1);
449 if (pop_typ1 != STK_INT)
450 BEGIN
451 print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
452 goto End_While_Label;
453 END
454 else if (pop_lit1 > 0)
455 BEGIN
456 execute_fn (r_pop_lt1);
457 END
458 else
459 BEGIN
460 goto End_While_Label;
461 END
462 END
463 END
464 End_While_Label: DO_NOTHING;
465 END
466 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 449 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
467
468 break;
469 case N_WIDTH:
470 x_width ();
471 break;
472 case N_WRITE:
473 x_write ();
474 break;
475 #ifdef UTF_8
476 case N_IS_CJK_STRING:
477 x_is_cjk_string ();
478 break;
479 #endif
480 default:
481 CONFUSION ("Unknown built-in function");
482 break;
483 END
484 END
485 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 341 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
486
487 break;
488 case WIZ_DEFINED:
489
490 /***************************************************************************
491 * WEB section number: 326
492 * ~~~~~~~~~~~~~~~~~~~
493 * To execute a |wiz_defined| function, we just execute all those
494 * functions in its definition, except that the special marker
495 * |quote_next_fn| means we push the next function onto the stack.
496 ***************************************************************************/
497 BEGIN
498 wiz_ptr = FN_INFO[ex_fn_loc];
499 while (wiz_functions[wiz_ptr] != END_OF_DEF)
500 BEGIN
501 if (wiz_functions[wiz_ptr] != QUOTE_NEXT_FN)
502 BEGIN
503 execute_fn (wiz_functions[wiz_ptr]);
504 END
505 else
506 BEGIN
507 INCR (wiz_ptr);
508 push_lit_stk (wiz_functions[wiz_ptr], STK_FN);
509 END
510 INCR (wiz_ptr);
511 END
512 END
513 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 326 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
514
515 break;
516 case INT_LITERAL:
517 push_lit_stk (FN_INFO[ex_fn_loc], STK_INT);
518 break;
519 case STR_LITERAL:
520 push_lit_stk (hash_text[ex_fn_loc], STK_STR);
521 break;
522 case FIELD:
523
524 /***************************************************************************
525 * WEB section number: 327
526 * ~~~~~~~~~~~~~~~~~~~
527 * This module pushes the string given by the field onto the literal
528 * stack unless it's |missing|, in which case it pushes a special value
529 * onto the stack.
530 ***************************************************************************/
531 BEGIN
532 if ( ! mess_with_entries)
533 BEGIN
534 bst_cant_mess_with_entries_prin ();
535 END
536 else
537 BEGIN
538 field_ptr = (cite_ptr * num_fields) + FN_INFO[ex_fn_loc];
539 if (field_info[field_ptr] == MISSING)
540 BEGIN
541 push_lit_stk (hash_text[ex_fn_loc], STK_FIELD_MISSING);
542 END
543 else
544 BEGIN
545 push_lit_stk (field_info[field_ptr], STK_STR);
546 END
547 END
548 END
549 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 327 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
550
551 break;
552 case INT_ENTRY_VAR:
553
554 /***************************************************************************
555 * WEB section number: 328
556 * ~~~~~~~~~~~~~~~~~~~
557 * This module pushes the integer given by an |int_entry_var| onto the
558 * literal stack.
559 ***************************************************************************/
560 BEGIN
561 if ( ! mess_with_entries)
562 BEGIN
563 bst_cant_mess_with_entries_prin ();
564 END
565 else
566 BEGIN
567 push_lit_stk (entry_ints[(cite_ptr * num_ent_ints)
568 + FN_INFO[ex_fn_loc]], STK_INT);
569 END
570 END
571 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 328 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
572
573 break;
574 case STR_ENTRY_VAR:
575
576 /***************************************************************************
577 * WEB section number: 329
578 * ~~~~~~~~~~~~~~~~~~~
579 * This module adds the string given by a |str_entry_var| to |str_pool|
580 * via the execution buffer and pushes it onto the literal stack.
581 ***************************************************************************/
582 BEGIN
583 if ( ! mess_with_entries)
584 BEGIN
585 bst_cant_mess_with_entries_prin ();
586 END
587 else
588 BEGIN
589 str_ent_ptr = (cite_ptr * num_ent_strs) + FN_INFO[ex_fn_loc];
590 ex_buf_ptr = 0;
591 while (ENTRY_STRS(str_ent_ptr, ex_buf_ptr) != END_OF_STRING)
592 BEGIN
593 APPEND_EX_BUF_CHAR (ENTRY_STRS(str_ent_ptr, ex_buf_ptr));
594 END
595 ex_buf_length = ex_buf_ptr;
596 add_pool_buf_and_push ();
597 END
598 END
599 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 329 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
600
601 break;
602 case INT_GLOBAL_VAR:
603 push_lit_stk (FN_INFO[ex_fn_loc], STK_INT);
604 break;
605 case STR_GLOBAL_VAR:
606
607 /***************************************************************************
608 * WEB section number: 330
609 * ~~~~~~~~~~~~~~~~~~~
610 * This module pushes the string given by a |str_global_var| onto the
611 * literal stack, but it copies the string to |str_pool| (character by
612 * character) only if it has to---it BEGIN\it doesn't\/END have to if the
613 * string is static (that is, if the string isn't at the top, temporary
614 * part of the string pool).
615 ***************************************************************************/
616 BEGIN
617 str_glb_ptr = FN_INFO[ex_fn_loc];
618 if (glb_str_ptr[str_glb_ptr] > 0)
619 BEGIN
620 push_lit_stk (glb_str_ptr[str_glb_ptr], STK_STR);
621 END
622 else
623 BEGIN
624 STR_ROOM (glb_str_end[str_glb_ptr]);
625 glob_chr_ptr = 0;
626 while (glob_chr_ptr < glb_str_end[str_glb_ptr])
627 BEGIN
628 APPEND_CHAR (GLOBAL_STRS(str_glb_ptr, glob_chr_ptr));
629 INCR (glob_chr_ptr);
630 END
631 push_lit_stk (make_string (), STK_STR);
632 END
633 END
634 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 330 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
635
636 break;
637 default:
638 unknwn_function_class_confusion ();
639 break;
640 END
641 END
642 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 325 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
643
644
645
646
647 /***************************************************************************
648 * WEB section number: 420
649 * ~~~~~~~~~~~~~~~~~~~
650 * This is a procedure so that |x_format_name| is smaller.
651 ***************************************************************************/
652 void figure_out_the_formatted_name (void)
653 BEGIN
654
655 /***************************************************************************
656 * WEB section number: 402
657 * ~~~~~~~~~~~~~~~~~~~
658 * This module uses the information in |pop_lit1| to format the name.
659 * Everything at |sp_brace_level = 0| is copied verbatim to the formatted
660 * string; the rest is described in the succeeding modules.
661 ***************************************************************************/
662 BEGIN
663 ex_buf_ptr = 0;
664 sp_brace_level = 0;
665 sp_ptr = str_start[pop_lit1];
666 sp_end = str_start[pop_lit1 + 1];
667 while (sp_ptr < sp_end)
668 BEGIN
669 if (str_pool[sp_ptr] == LEFT_BRACE)
670 BEGIN
671 INCR (sp_brace_level);
672 INCR (sp_ptr);
673
674 /***************************************************************************
675 * WEB section number: 403
676 * ~~~~~~~~~~~~~~~~~~~
677 * When we arrive here we're at |sp_brace_level = 1|, just past the
678 * |left_brace|. Letters at this |sp_brace_level| other than those
679 * denoting the parts of the name (i.e., the first letters of `first,'
680 * `last,' `von,' and `jr,' ignoring case) are illegal. We do two passes
681 * over this group; the first determines whether we're to output
682 * anything, and, if we are, the second actually outputs it.
683 ***************************************************************************/
684 BEGIN
685 sp_xptr1 = sp_ptr;
686 alpha_found = FALSE;
687 double_letter = FALSE;
688 end_of_group = FALSE;
689 to_be_written = TRUE;
690 while (( ! end_of_group) && (sp_ptr < sp_end))
691 BEGIN
692 if (lex_class[str_pool[sp_ptr]] == ALPHA)
693 BEGIN
694 INCR (sp_ptr);
695
696 /***************************************************************************
697 * WEB section number: 405
698 * ~~~~~~~~~~~~~~~~~~~
699 * We won't output anything for this part of the name if this is a second
700 * occurrence of an |sp_brace_level = 1| letter, if it's an illegal
701 * letter, or if there are no tokens corresponding to this part. We also
702 * determine if we're we to output complete tokens (indicated by a double
703 * letter).
704 ***************************************************************************/
705 BEGIN
706 if (alpha_found)
707 BEGIN
708 brace_lvl_one_letters_complaint ();
709 to_be_written = FALSE;
710 END
711 else
712 BEGIN
713 switch (str_pool[sp_ptr - 1])
714 BEGIN
715 case 'f':
716 case 'F':
717
718 /***************************************************************************
719 * WEB section number: 407
720 * ~~~~~~~~~~~~~~~~~~~
721 * Here we set pointers into |name_tok| and note whether we'll be dealing
722 * with a full first-name tokens (|double_letter = true|) or
723 * abbreviations (|double_letter = false|).
724 ***************************************************************************/
725 BEGIN
726 cur_token = first_start;
727 last_token = first_end;
728 if (cur_token == last_token)
729 BEGIN
730 to_be_written = FALSE;
731 END
732 if ((str_pool[sp_ptr] == 'f')
733 || (str_pool[sp_ptr] == 'F'))
734 BEGIN
735 double_letter = TRUE;
736 END
737 END
738 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 407 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
739
740 break;
741 case 'v':
742 case 'V':
743
744 /***************************************************************************
745 * WEB section number: 408
746 * ~~~~~~~~~~~~~~~~~~~
747 * The same as above but for von-name tokens.
748 ***************************************************************************/
749 BEGIN
750 cur_token = von_start;
751 last_token = von_end;
752 if (cur_token == last_token)
753 BEGIN
754 to_be_written = FALSE;
755 END
756 if ((str_pool[sp_ptr] == 'v')
757 || (str_pool[sp_ptr] == 'V'))
758 BEGIN
759 double_letter = TRUE;
760 END
761 END
762 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 408 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
763
764 break;
765 case 'l':
766 case 'L':
767
768 /***************************************************************************
769 * WEB section number: 409
770 * ~~~~~~~~~~~~~~~~~~~
771 * The same as above but for last-name tokens.
772 ***************************************************************************/
773 BEGIN
774 cur_token = von_end;
775 last_token = last_end;
776 if (cur_token == last_token)
777 BEGIN
778 to_be_written = FALSE;
779 END
780 if ((str_pool[sp_ptr] == 'l')
781 || (str_pool[sp_ptr] == 'L'))
782 BEGIN
783 double_letter = TRUE;
784 END
785 END
786 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 409 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
787
788 break;
789 case 'j':
790 case 'J':
791
792 /***************************************************************************
793 * WEB section number: 410
794 * ~~~~~~~~~~~~~~~~~~~
795 * The same as above but for jr-name tokens.
796 ***************************************************************************/
797 BEGIN
798 cur_token = last_end;
799 last_token = jr_end;
800 if (cur_token == last_token)
801 BEGIN
802 to_be_written = FALSE;
803 END
804 if ((str_pool[sp_ptr] == 'j')
805 || (str_pool[sp_ptr] == 'J'))
806 BEGIN
807 double_letter = TRUE;
808 END
809 END
810 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 410 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
811
812 break;
813 default:
814 brace_lvl_one_letters_complaint ();
815 to_be_written = FALSE;
816 break;
817 END
818 if (double_letter)
819 BEGIN
820 INCR (sp_ptr);
821 END
822 END
823 alpha_found = TRUE;
824 END
825 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 405 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
826
827 END
828 else if (str_pool[sp_ptr] == RIGHT_BRACE)
829 BEGIN
830 DECR (sp_brace_level);
831 INCR (sp_ptr);
832 end_of_group = TRUE;
833 END
834 else if (str_pool[sp_ptr] == LEFT_BRACE)
835 BEGIN
836 INCR (sp_brace_level);
837 INCR (sp_ptr);
838 skip_stuff_at_sp_brace_level_gr ();
839 END
840 else
841 BEGIN
842 INCR (sp_ptr);
843 END
844 END
845 if ((end_of_group) && (to_be_written))
846 BEGIN
847
848 /***************************************************************************
849 * WEB section number: 411
850 * ~~~~~~~~~~~~~~~~~~~
851 * This is the second pass over this part of the name; here we actually
852 * write stuff out to |ex_buf|.
853 ***************************************************************************/
854 ex_buf_xptr = ex_buf_ptr;
855 sp_ptr = sp_xptr1;
856 sp_brace_level = 1;
857 while (sp_brace_level > 0)
858 BEGIN
859 if ((lex_class[str_pool[sp_ptr]] == ALPHA)
860 && (sp_brace_level == 1))
861 BEGIN
862 INCR (sp_ptr);
863
864 /***************************************************************************
865 * WEB section number: 412
866 * ~~~~~~~~~~~~~~~~~~~
867 * When we come here, |sp_ptr| is just past the letter indicating the
868 * part of the name for which we're about to output tokens. When we
869 * leave, it's at the first character of the rest of the group.
870 ***************************************************************************/
871 BEGIN
872 if (double_letter)
873 BEGIN
874 INCR (sp_ptr);
875 END
876 use_default = TRUE;
877 sp_xptr2 = sp_ptr;
878 if (str_pool[sp_ptr] == LEFT_BRACE)
879 BEGIN
880 use_default = FALSE;
881 INCR (sp_brace_level);
882 INCR (sp_ptr);
883 sp_xptr1 = sp_ptr;
884 skip_stuff_at_sp_brace_level_gr ();
885 sp_xptr2 = sp_ptr - 1;
886 END
887
888 /***************************************************************************
889 * WEB section number: 413
890 * ~~~~~~~~~~~~~~~~~~~
891 * Here, for each token in this part, we output either a full or an
892 * abbreviated token and the inter-token string for all but the last
893 * token of this part.
894 ***************************************************************************/
895 BEGIN
896 while (cur_token < last_token)
897 BEGIN
898 if (double_letter)
899
900 /***************************************************************************
901 * WEB section number: 414
902 * ~~~~~~~~~~~~~~~~~~~
903 * Here we output all the characters in the token, verbatim.
904 ***************************************************************************/
905 BEGIN
906 name_bf_ptr = name_tok[cur_token];
907 name_bf_xptr = name_tok[cur_token + 1];
908 if (ex_buf_length + (name_bf_xptr - name_bf_ptr)
909 > Buf_Size)
910 BEGIN
911 buffer_overflow ();
912 END
913 while (name_bf_ptr < name_bf_xptr)
914 BEGIN
915 APPEND_EX_BUF_CHAR (NAME_BUF[name_bf_ptr]);
916 INCR (name_bf_ptr);
917 END
918 END
919 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 414 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
920
921 else
922
923 /***************************************************************************
924 * WEB section number: 415
925 * ~~~~~~~~~~~~~~~~~~~
926 * Here we output the first alphabetic or special character of the token;
927 * brace level is irrelevant for an alphabetic (but not a special)
928 * character.
929 ***************************************************************************/
930 BEGIN
931 name_bf_ptr = name_tok[cur_token];
932 name_bf_xptr = name_tok[cur_token + 1];
933 while (name_bf_ptr < name_bf_xptr)
934 BEGIN
935 #ifdef UTF_8
936 /*
937 For output the first character which is encodage UTF-8, we sould discuter different length of character. 23/sep/2009
938 */
939 if((lex_class[NAME_BUF[name_bf_ptr]] != WHITE_SPACE) && (NAME_BUF[name_bf_ptr] != LEFT_BRACE))
940 BEGIN
941 DO_UTF8(NAME_BUF[name_bf_ptr],
942 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]),
943 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]);
944 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]),
945 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]);
946 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]);
947 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]),
948 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]);
949 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]);
950 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]);
951 APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+3]));
952 #else
953 if (lex_class[NAME_BUF[name_bf_ptr]] == ALPHA)
954 BEGIN
955 APPEND_EX_BUF_CHAR_AND_CHECK (
956 NAME_BUF[name_bf_ptr]);
957 #endif
958 goto Loop_Exit_Label;
959 END
960 else if ((NAME_BUF[name_bf_ptr] == LEFT_BRACE)
961 && ((name_bf_ptr + 1) < name_bf_xptr))
962 BEGIN
963 if (NAME_BUF[name_bf_ptr + 1] == BACKSLASH)
964
965 /***************************************************************************
966 * WEB section number: 416
967 * ~~~~~~~~~~~~~~~~~~~
968 * We output a special character here even if the user has been silly
969 * enough to make it nonalphabetic (and even if the user has been sillier
970 * still by not having a matching |right_brace|).
971 ***************************************************************************/
972 BEGIN
973 if ((ex_buf_ptr + 2) > Buf_Size)
974 BEGIN
975 buffer_overflow ();
976 END
977 APPEND_EX_BUF_CHAR (LEFT_BRACE);
978 APPEND_EX_BUF_CHAR (BACKSLASH);
979 name_bf_ptr = name_bf_ptr + 2;
980 nm_brace_level = 1;
981 while ((name_bf_ptr < name_bf_xptr)
982 && (nm_brace_level > 0))
983 BEGIN
984 if (NAME_BUF[name_bf_ptr] == RIGHT_BRACE)
985 BEGIN
986 DECR (nm_brace_level);
987 END
988 else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE)
989 BEGIN
990 INCR (nm_brace_level);
991 END
992 APPEND_EX_BUF_CHAR_AND_CHECK (
993 NAME_BUF[name_bf_ptr]);
994 INCR (name_bf_ptr);
995 END
996 goto Loop_Exit_Label;
997 END
998 END
999 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 416 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1000
1001 INCR (name_bf_ptr);
1002 END
1003 Loop_Exit_Label: DO_NOTHING;
1004 END
1005 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 415 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1006
1007 INCR (cur_token);
1008 if (cur_token < last_token)
1009
1010 /***************************************************************************
1011 * WEB section number: 417
1012 * ~~~~~~~~~~~~~~~~~~~
1013 * Here we output either the .bst given string if it exists, or else
1014 * the .bib |sep_char| if it exists, or else the default string. A
1015 * |tie| is the default space character between the last two tokens of
1016 * the name part, and between the first two tokens if the first token is
1017 * short enough; otherwise, a |space| is the default.
1018 ***************************************************************************/
1019 BEGIN
1020 if (use_default)
1021 BEGIN
1022 if ( ! double_letter)
1023 BEGIN
1024 APPEND_EX_BUF_CHAR_AND_CHECK (PERIOD);
1025 END
1026 if (lex_class[name_sep_char[cur_token]]
1027 == SEP_CHAR)
1028 BEGIN
1029 APPEND_EX_BUF_CHAR_AND_CHECK (
1030 name_sep_char[cur_token]);
1031 END
1032 else if ((cur_token == (last_token - 1))
1033 || ( ! enough_text_chars (LONG_TOKEN)))
1034 BEGIN
1035 APPEND_EX_BUF_CHAR_AND_CHECK (TIE);
1036 END
1037 else
1038 BEGIN
1039 APPEND_EX_BUF_CHAR_AND_CHECK (SPACE);
1040 END
1041 END
1042 else
1043 BEGIN
1044 if ((ex_buf_length + (sp_xptr2 - sp_xptr1))
1045 > Buf_Size)
1046 BEGIN
1047 buffer_overflow ();
1048 END
1049 sp_ptr = sp_xptr1;
1050 while (sp_ptr < sp_xptr2)
1051 BEGIN
1052 APPEND_EX_BUF_CHAR (str_pool[sp_ptr]);
1053 INCR (sp_ptr);
1054 END
1055 END
1056 END
1057 END
1058 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 417 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1059
1060 END
1061 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 413 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1062
1063 if ( ! use_default)
1064 BEGIN
1065 sp_ptr = sp_xptr2 + 1;
1066 END
1067 END
1068 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 412 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1069
1070 END
1071 else if (str_pool[sp_ptr] == RIGHT_BRACE)
1072 BEGIN
1073 DECR (sp_brace_level);
1074 INCR (sp_ptr);
1075 if (sp_brace_level > 0)
1076 BEGIN
1077 APPEND_EX_BUF_CHAR_AND_CHECK (RIGHT_BRACE);
1078 END
1079 END
1080 else if (str_pool[sp_ptr] == LEFT_BRACE)
1081 BEGIN
1082 INCR (sp_brace_level);
1083 INCR (sp_ptr);
1084 APPEND_EX_BUF_CHAR_AND_CHECK (LEFT_BRACE);
1085 END
1086 else
1087 BEGIN
1088 APPEND_EX_BUF_CHAR_AND_CHECK (str_pool[sp_ptr]);
1089 INCR (sp_ptr);
1090 END
1091 END
1092 if (ex_buf_ptr > 0)
1093 BEGIN
1094 if (ex_buf[ex_buf_ptr - 1] == TIE)
1095
1096 /***************************************************************************
1097 * WEB section number: 419
1098 * ~~~~~~~~~~~~~~~~~~~
1099 * If the last character output for this name part is a |tie| but the
1100 * previous character it isn't, we're dealing with a discretionary |tie|;
1101 * thus we replace it by a |space| if there are enough characters in the
1102 * rest of the name part.
1103 ***************************************************************************/
1104 BEGIN
1105 DECR (ex_buf_ptr);
1106 if (ex_buf[ex_buf_ptr - 1] == TIE)
1107 BEGIN
1108 DO_NOTHING;
1109 END
1110 else if ( ! enough_text_chars (LONG_NAME))
1111 BEGIN
1112 INCR (ex_buf_ptr);
1113 END
1114 else
1115 BEGIN
1116 APPEND_EX_BUF_CHAR (SPACE);
1117 END
1118 END
1119 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 419 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1120
1121 END
1122 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 411 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1123
1124 END
1125 END
1126 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 403 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1127
1128 END
1129 else if (str_pool[sp_ptr] == RIGHT_BRACE)
1130 BEGIN
1131 braces_unbalanced_complaint (pop_lit1);
1132 INCR (sp_ptr);
1133 END
1134 else
1135 BEGIN
1136 APPEND_EX_BUF_CHAR_AND_CHECK (str_pool[sp_ptr]);
1137 INCR (sp_ptr);
1138 END
1139 END
1140 if (sp_brace_level > 0)
1141 BEGIN
1142 braces_unbalanced_complaint (pop_lit1);
1143 END
1144 ex_buf_length = ex_buf_ptr;
1145 END
1146 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1147
1148 END
1149 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 420 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1150
1151
1152
1153
1154 /***************************************************************************
1155 * WEB section number: 59
1156 * ~~~~~~~~~~~~~~~~~~~
1157 * Yet another complaint-before-quiting.
1158 *
1159 * REMOVED: |file_nm_size_overflow|.
1160 ***************************************************************************/
1161
1162 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1163
1164
1165
1166
1167 /***************************************************************************
1168 * WEB section number: 278
1169 * ~~~~~~~~~~~~~~~~~~~
1170 * Occasionally we need to figure out the hash-table location of a given
1171 * cite-key string and its lower-case equivalent. This function does
1172 * that. To perform the task it needs to borrow a buffer, a need that
1173 * gives rise to the alias kludge---it helps make the stack space not
1174 * overflow on some machines (and while it's at it, it'll borrow a
1175 * pointer, too). Finally, the function returns |true| if the cite key
1176 * exists on |cite_list|, and its sets |cite_hash_found| according to
1177 * whether or not it found the actual version (before |lower_case|ing) of
1178 * the cite key; however, its raison d'etre
1179 * (literally, ``to eat a raisin'') is to compute |cite_loc| and
1180 * |lc_cite_loc|.
1181 ***************************************************************************/
1182 Boolean_T find_cite_locs_for_this_cite_ke (StrNumber_T cite_str)
1183 BEGIN
1184 Boolean_T find_cite_locs_for_this_cite_ke;
1185
1186 EX_BUF5_PTR = 0;
1187 tmp_ptr = str_start[cite_str];
1188 tmp_end_ptr = str_start[cite_str + 1];
1189 while (tmp_ptr < tmp_end_ptr)
1190 BEGIN
1191 EX_BUF5[EX_BUF5_PTR] = str_pool[tmp_ptr];
1192 INCR (EX_BUF5_PTR);
1193 INCR (tmp_ptr);
1194 END
1195 cite_loc = str_lookup (ex_buf, 0, LENGTH (cite_str), CITE_ILK, DONT_INSERT);
1196 cite_hash_found = hash_found;
1197 lower_case (EX_BUF5, 0, LENGTH (cite_str));
1198 lc_cite_loc = str_lookup (EX_BUF5, 0, LENGTH (cite_str), LC_CITE_ILK,
1199 DONT_INSERT);
1200 if (hash_found)
1201 BEGIN
1202 find_cite_locs_for_this_cite_ke = TRUE;
1203 END
1204 else
1205 BEGIN
1206 find_cite_locs_for_this_cite_ke = FALSE;
1207 END
1208 return (find_cite_locs_for_this_cite_ke);
1209 END
1210 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 278 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1211
1212
1213
1214
1215 /***************************************************************************
1216 * WEB section number: 116
1217 * ~~~~~~~~~~~~~~~~~~~
1218 * We're not at the end of an .aux file, so we see if the current line
1219 * might be a command of interest. A command of interest will be a line
1220 * without blanks, consisting of a command name, a |left_brace|, one or
1221 * more arguments separated by commas, and a |right_brace|.
1222 ***************************************************************************/
1223 void get_aux_command_and_process (void)
1224 BEGIN
1225 buf_ptr2 = 0;
1226 if ( ! scan1 (LEFT_BRACE))
1227 BEGIN
1228 goto Exit_Label;
1229 END
1230 command_num = ilk_info[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
1231 AUX_COMMAND_ILK, DONT_INSERT)];
1232 if (hash_found)
1233 BEGIN
1234 switch (command_num)
1235 BEGIN
1236 case N_AUX_BIBDATA:
1237 aux_bib_data_command ();
1238 break;
1239 case N_AUX_BIBSTYLE:
1240 aux_bib_style_command ();
1241 break;
1242 case N_AUX_CITATION:
1243 aux_citation_command ();
1244 break;
1245 case N_AUX_INPUT:
1246 aux_input_command ();
1247 break;
1248 default:
1249 CONFUSION ("Unknown auxiliary-file command");
1250 break;
1251 END
1252 END
1253 Exit_Label: DO_NOTHING;
1254 END
1255 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 116 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1256
1257
1258
1259
1260 /***************************************************************************
1261 * WEB section number: 236
1262 * ~~~~~~~~~~~~~~~~~~~
1263 * This module either reads a database entry, whose three main components
1264 * are an entry type, a database key, and a list of fields, or it reads a
1265 * .bib command, whose structure is command dependent and explained
1266 * later.
1267 ***************************************************************************/
1268 void get_bib_command_or_entry_and_pr (void)
1269 BEGIN
1270 at_bib_command = FALSE;
1271
1272 /***************************************************************************
1273 * WEB section number: 237
1274 * ~~~~~~~~~~~~~~~~~~~
1275 * This module skips over everything until hitting an |at_sign| or the
1276 * end of the file. It also updates |bib_line_num|, the line counter.
1277 ***************************************************************************/
1278 while ( ! scan1 (AT_SIGN))
1279 BEGIN
1280 if ( ! input_ln (CUR_BIB_FILE))
1281 BEGIN
1282 goto Exit_Label;
1283 END
1284 INCR (bib_line_num);
1285 buf_ptr2 = 0;
1286 END
1287 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 237 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1288
1289 /***************************************************************************
1290 * WEB section number: 238
1291 * ~~~~~~~~~~~~~~~~~~~
1292 * This module reads an |at_sign| and an entry type (like `book' or
1293 * `article') or a .bib command. If it's an entry type, it must be
1294 * defined in the .bst file if this entry is to be included in the
1295 * reference list.
1296 ***************************************************************************/
1297 BEGIN
1298 if (SCAN_CHAR != AT_SIGN)
1299 BEGIN
1300 CONFUSION2 ("An \"%c\" disappeared", xchr[AT_SIGN]);
1301 END
1302 INCR (buf_ptr2);
1303 EAT_BIB_WHITE_AND_EOF_CHECK;
1304 scan_identifier (LEFT_BRACE, LEFT_PAREN, LEFT_PAREN);
1305 BIB_IDENTIFIER_SCAN_CHECK ("an entry type");
1306
1307 #ifdef TRACE
1308 if (Flag_trace) {
1309 TRACE_PR_TOKEN;
1310 TRACE_PR_LN (" is an entry type or a database-file command");
1311 }
1312 #endif /* TRACE */
1313
1314 lower_case (buffer, buf_ptr1, TOKEN_LEN);
1315 command_num = ilk_info[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
1316 BIB_COMMAND_ILK, DONT_INSERT)];
1317 if (hash_found)
1318
1319 /***************************************************************************
1320 * WEB section number: 239
1321 * ~~~~~~~~~~~~~~~~~~~
1322 * Here we determine which .bib command we're about to process, then
1323 * go to it.
1324 ***************************************************************************/
1325 BEGIN
1326 at_bib_command = TRUE;
1327 switch (command_num)
1328 BEGIN
1329 case N_BIB_COMMENT:
1330
1331 /***************************************************************************
1332 * WEB section number: 241
1333 * ~~~~~~~~~~~~~~~~~~~
1334 * The comment command is implemented for SCRIBE compatibility. It's
1335 * not really needed because \BibTeX\ treats (flushes) everything not
1336 * within an entry as a comment anyway.
1337 ***************************************************************************/
1338 BEGIN
1339 goto Exit_Label;
1340 END
1341 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 239 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1342
1343 case N_BIB_PREAMBLE:
1344
1345 /***************************************************************************
1346 * WEB section number: 242
1347 * ~~~~~~~~~~~~~~~~~~~
1348 * The preamble command lets a user have \TeX\ stuff inserted (by the
1349 * standard styles, at least) directly into the .bbl file. It is
1350 * intended primarily for allowing \TeX\ macro definitions used within
1351 * the bibliography entries (for better sorting, for example). One
1352 * preamble command per .bib file should suffice.
1353 *
1354 * A preamble command has either braces or parentheses as outer
1355 * delimiters. Inside is the preamble string, which has the same syntax
1356 * as a field value: a nonempty list of field tokens separated by
1357 * |concat_char|s. There are three types of field tokens---nonnegative
1358 * numbers, macro names, and delimited strings.
1359 *
1360 * This module does all the scanning (that's not subcontracted), but the
1361 * .bib-specific scanning function
1362 * |scan_and_store_the_field_value_and_eat_white| actually stores the
1363 * value.
1364 ***************************************************************************/
1365 BEGIN
1366 if (preamble_ptr == Max_Bib_Files)
1367 BEGIN
1368 BIB_XRETALLOC_NOSET ("bib_file", bib_file, AlphaFile_T,
1369 Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
1370 BIB_XRETALLOC_NOSET ("bib_list", bib_list, StrNumber_T,
1371 Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
1372 BIB_XRETALLOC ("s_preamble", s_preamble, StrNumber_T,
1373 Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
1374 END
1375 EAT_BIB_WHITE_AND_EOF_CHECK;
1376 if (SCAN_CHAR == LEFT_BRACE)
1377 BEGIN
1378 right_outer_delim = RIGHT_BRACE;
1379 END
1380 else if (SCAN_CHAR == LEFT_PAREN)
1381 BEGIN
1382 right_outer_delim = RIGHT_PAREN;
1383 END
1384 else
1385 BEGIN
1386 BIB_ONE_OF_TWO_EXPECTED_ERR (LEFT_BRACE, LEFT_PAREN);
1387 END
1388 INCR (buf_ptr2);
1389 EAT_BIB_WHITE_AND_EOF_CHECK;
1390 store_field = TRUE;
1391 if ( ! scan_and_store_the_field_value ())
1392 BEGIN
1393 goto Exit_Label;
1394 END
1395 if (SCAN_CHAR != right_outer_delim)
1396 BEGIN
1397 BIB_ERR2 ("Missing \"%c\" in preamble command",
1398 xchr[right_outer_delim]);
1399 END
1400 INCR (buf_ptr2);
1401 goto Exit_Label;
1402 END
1403 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 242 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1404 break;
1405 case N_BIB_STRING:
1406
1407 /***************************************************************************
1408 * WEB section number: 243
1409 * ~~~~~~~~~~~~~~~~~~~
1410 * The string command is implemented both for SCRIBE compatibility
1411 * and for allowing a user: to override a .bst-file macro
1412 * command, to define one that the .bst file doesn't, or to engage in
1413 * good, wholesome, typing laziness.
1414 *
1415 * The string command does mostly the same thing as the
1416 * .bst-file's macro command (but the syntax is different and the
1417 * string command compresses |white_space|). In fact, later in this
1418 * program, the term ``macro'' refers to either a .bst ``macro'' or a
1419 * .bib ``string'' (when it's clear from the context that it's not
1420 * a WEB macro).
1421 *
1422 * A string command has either braces or parentheses as outer
1423 * delimiters. Inside is the string's name (it must be a legal
1424 * identifier, and case differences are ignored---all upper-case letters
1425 * are converted to lower case), then an |equals_sign|, and the string's
1426 * definition, which has the same syntax as a field value: a nonempty
1427 * list of field tokens separated by |concat_char|s. There are three
1428 * types of field tokens---nonnegative numbers, macro names, and
1429 * delimited strings.
1430 ***************************************************************************/
1431 BEGIN
1432 EAT_BIB_WHITE_AND_EOF_CHECK;
1433
1434 /***************************************************************************
1435 * WEB section number: 244
1436 * ~~~~~~~~~~~~~~~~~~~
1437 * This module reads a left outer-delimiter and a string name.
1438 ***************************************************************************/
1439 BEGIN
1440 if (SCAN_CHAR == LEFT_BRACE)
1441 BEGIN
1442 right_outer_delim = RIGHT_BRACE;
1443 END
1444 else if (SCAN_CHAR == LEFT_PAREN)
1445 BEGIN
1446 right_outer_delim = RIGHT_PAREN;
1447 END
1448 else
1449 BEGIN
1450 BIB_ONE_OF_TWO_EXPECTED_ERR (LEFT_BRACE, LEFT_PAREN);
1451 END
1452 INCR (buf_ptr2);
1453 EAT_BIB_WHITE_AND_EOF_CHECK;
1454 scan_identifier (EQUALS_SIGN, EQUALS_SIGN, EQUALS_SIGN);
1455 BIB_IDENTIFIER_SCAN_CHECK ("a string name");
1456
1457 /***************************************************************************
1458 * WEB section number: 245
1459 * ~~~~~~~~~~~~~~~~~~~
1460 * This module marks this string as |macro_ilk|; the commented-out code
1461 * will give a warning message when overwriting a previously defined
1462 * macro.
1463 ***************************************************************************/
1464 BEGIN
1465 #ifdef TRACE
1466 if (Flag_trace) {
1467 TRACE_PR_TOKEN;
1468 TRACE_PR_LN (" is a database-defined macro");
1469 }
1470 #endif /* TRACE */
1471
1472 lower_case (buffer, buf_ptr1, TOKEN_LEN);
1473 cur_macro_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
1474 MACRO_ILK, DO_INSERT);
1475 ilk_info[cur_macro_loc] = hash_text[cur_macro_loc];
1476 /*-------------------------------------------------------------------
1477 * if (hash_found)
1478 * BEGIN
1479 * MACRO_NAME_WARNING ("having its definition overwritten");
1480 * END
1481 *------------------------------------------------------------------*/
1482 END
1483 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 245 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1484
1485 END
1486 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 244 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1487
1488 EAT_BIB_WHITE_AND_EOF_CHECK;
1489
1490 /***************************************************************************
1491 * WEB section number: 246
1492 * ~~~~~~~~~~~~~~~~~~~
1493 * This module skips over the |equals_sign|, reads and stores the list of
1494 * field tokens that defines this macro (compressing |white_space|), and
1495 * reads a |right_outer_delim|.
1496 ***************************************************************************/
1497 BEGIN
1498 if (SCAN_CHAR != EQUALS_SIGN)
1499 BEGIN
1500 BIB_EQUALS_SIGN_EXPECTED_ERR;
1501 END
1502 INCR (buf_ptr2);
1503 EAT_BIB_WHITE_AND_EOF_CHECK;
1504 store_field = TRUE;
1505 if ( ! scan_and_store_the_field_value ())
1506 BEGIN
1507 goto Exit_Label;
1508 END
1509 if (SCAN_CHAR != right_outer_delim)
1510 BEGIN
1511 BIB_ERR2 ("Missing \"%c\" in string command",
1512 xchr[right_outer_delim]);
1513 END
1514 INCR (buf_ptr2);
1515 END
1516 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 246 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1517
1518 goto Exit_Label;
1519 END
1520 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 243 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1521
1522 break;
1523 default:
1524 bib_cmd_confusion ();
1525 break;
1526 END
1527 END
1528 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 239 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1529
1530 else
1531 BEGIN
1532 entry_type_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK,
1533 DONT_INSERT);
1534 if (( ! hash_found) || (fn_type[entry_type_loc] != WIZ_DEFINED))
1535 BEGIN
1536 type_exists = FALSE;
1537 END
1538 else
1539 BEGIN
1540 type_exists = TRUE;
1541 END
1542 END
1543 END
1544 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 238 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1545
1546 EAT_BIB_WHITE_AND_EOF_CHECK;
1547
1548 /***************************************************************************
1549 * WEB section number: 266
1550 * ~~~~~~~~~~~~~~~~~~~
1551 * And now, back to processing an entry (rather than a command). This
1552 * module reads a left outer-delimiter and a database key.
1553 ***************************************************************************/
1554 BEGIN
1555 if (SCAN_CHAR == LEFT_BRACE)
1556 BEGIN
1557 right_outer_delim = RIGHT_BRACE;
1558 END
1559 else if (SCAN_CHAR == LEFT_PAREN)
1560 BEGIN
1561 right_outer_delim = RIGHT_PAREN;
1562 END
1563 else
1564 BEGIN
1565 BIB_ONE_OF_TWO_EXPECTED_ERR (LEFT_BRACE, LEFT_PAREN);
1566 END
1567 INCR (buf_ptr2);
1568 EAT_BIB_WHITE_AND_EOF_CHECK;
1569 if (right_outer_delim == RIGHT_PAREN)
1570 BEGIN
1571 if (scan1_white (COMMA))
1572 BEGIN
1573 DO_NOTHING;
1574 END
1575 END
1576 else if (scan2_white (COMMA, RIGHT_BRACE))
1577 BEGIN
1578 DO_NOTHING;
1579 END
1580
1581 /***************************************************************************
1582 * WEB section number: 267
1583 * ~~~~~~~~~~~~~~~~~~~
1584 * The lower-case version of this database key must correspond to one in
1585 * |cite_list|, or else |all_entries| must be |true|, if this entry is to
1586 * be included in the reference list. Accordingly, this module sets
1587 * |store_entry|, which determines whether the relevant information for
1588 * this entry is stored. The alias kludge helps make the stack space not
1589 * overflow on some machines.
1590 ***************************************************************************/
1591 BEGIN
1592 #ifdef TRACE
1593 if (Flag_trace) {
1594 TRACE_PR_TOKEN;
1595 TRACE_PR_LN (" is a database key");
1596 }
1597 #endif /* TRACE */
1598
1599 tmp_ptr = buf_ptr1;
1600 while (tmp_ptr < buf_ptr2)
1601 BEGIN
1602 EX_BUF3[tmp_ptr] = buffer[tmp_ptr];
1603 INCR (tmp_ptr);
1604 END
1605 lower_case (EX_BUF3, buf_ptr1, TOKEN_LEN);
1606 if (all_entries)
1607 BEGIN
1608 lc_cite_loc = str_lookup (EX_BUF3, buf_ptr1, TOKEN_LEN, LC_CITE_ILK,
1609 DO_INSERT);
1610 END
1611 else
1612 BEGIN
1613 lc_cite_loc = str_lookup (EX_BUF3, buf_ptr1, TOKEN_LEN, LC_CITE_ILK,
1614 DONT_INSERT);
1615 END
1616 if (hash_found)
1617 BEGIN
1618 entry_cite_ptr = ilk_info[ilk_info[lc_cite_loc]];
1619
1620 /***************************************************************************
1621 * WEB section number: 268
1622 * ~~~~~~~~~~~~~~~~~~~
1623 * It's illegal to have two (or more) entries with the same database key
1624 * (even if there are case differrences), and we skip the rest of the
1625 * entry for such a repeat occurrence. Also, we make this entry's
1626 * database key the official |cite_list| key if it's on |cite_list| only
1627 * because of cross references.
1628 ***************************************************************************/
1629 BEGIN
1630 if (( ! all_entries) || (entry_cite_ptr < all_marker)
1631 || (entry_cite_ptr >= old_num_cites))
1632 BEGIN
1633 if (type_list[entry_cite_ptr] == EMPTY)
1634 BEGIN
1635
1636 /***************************************************************************
1637 * WEB section number: 269
1638 * ~~~~~~~~~~~~~~~~~~~
1639 * An entry that's on |cite_list| only because of cross referencing must
1640 * have its database key (rather than one of the crossref keys) as
1641 * the official |cite_list| string. Here's where we assure that. The
1642 * variable |hash_found| is |true| upon entrance to and exit from this
1643 * module.
1644 ***************************************************************************/
1645 BEGIN
1646 if (( ! all_entries) && (entry_cite_ptr >= old_num_cites))
1647 BEGIN
1648 cite_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
1649 CITE_ILK, DO_INSERT);
1650 if ( ! hash_found)
1651 BEGIN
1652 ilk_info[lc_cite_loc] = cite_loc;
1653 ilk_info[cite_loc] = entry_cite_ptr;
1654 cite_list[entry_cite_ptr] = hash_text[cite_loc];
1655 hash_found = TRUE;
1656 END
1657 END
1658 END
1659 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 269 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1660
1661 goto First_Time_Entry_Label;
1662 END
1663 END
1664 else if ( ! entry_exists[entry_cite_ptr])
1665 BEGIN
1666
1667 /***************************************************************************
1668 * WEB section number: 270
1669 * ~~~~~~~~~~~~~~~~~~~
1670 * This module, a simpler version of the
1671 * |find_cite_locs_for_this_cite_key| function, exists primarily to
1672 * compute |lc_xcite_loc|. When this code is executed we have
1673 * |(all_entries) and (entry_cite_ptr >= all_marker) and (not
1674 * entry_exists[entry_cite_ptr])|. The alias kludge helps make the stack
1675 * space not overflow on some machines.
1676 ***************************************************************************/
1677 BEGIN
1678 EX_BUF4_PTR = 0;
1679 tmp_ptr = str_start[cite_info[entry_cite_ptr]];
1680 tmp_end_ptr = str_start[cite_info[entry_cite_ptr] + 1];
1681 while (tmp_ptr < tmp_end_ptr)
1682 BEGIN
1683 EX_BUF4[EX_BUF4_PTR] = str_pool[tmp_ptr];
1684 INCR (EX_BUF4_PTR);
1685 INCR (tmp_ptr);
1686 END
1687 lower_case (EX_BUF4, 0, LENGTH (cite_info[entry_cite_ptr]));
1688 lc_xcite_loc = str_lookup (EX_BUF4, 0,
1689 LENGTH (cite_info[entry_cite_ptr]),
1690 LC_CITE_ILK, DONT_INSERT);
1691 if ( ! hash_found)
1692 BEGIN
1693 cite_key_disappeared_confusion ();
1694 END
1695 END
1696 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 270 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1697
1698 if (lc_xcite_loc == lc_cite_loc)
1699 BEGIN
1700 goto First_Time_Entry_Label;
1701 END
1702 END
1703 if (type_list[entry_cite_ptr] == EMPTY)
1704 BEGIN
1705 CONFUSION ("The cite list is messed up");
1706 END
1707 BIB_ERR ("Repeated entry");
1708 First_Time_Entry_Label: DO_NOTHING;
1709 END
1710 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 268 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1711
1712 END
1713 store_entry = TRUE;
1714 if (all_entries)
1715
1716 /***************************************************************************
1717 * WEB section number: 272
1718 * ~~~~~~~~~~~~~~~~~~~
1719 * This module, which gets executed only when |all_entries| is |true|,
1720 * does one of three things, depending on whether or not, and where, the
1721 * cite key appears on |cite_list|: If it's on |cite_list| before
1722 * |all_marker|, there's nothing to be done; if it's after |all_marker|,
1723 * it must be reinserted (at the current place) and we must note that its
1724 * corresponding entry exists; and if it's not on |cite_list| at all, it
1725 * must be inserted for the first time. The |goto| construct must stay
1726 * as is, partly because some \PASCAL\ compilers might complain if
1727 * ``|and|'' were to connect the two boolean expressions (since
1728 * |entry_cite_ptr| could be uninitialized when |hash_found| is |false|).
1729 ***************************************************************************/
1730 BEGIN
1731 if (hash_found)
1732 BEGIN
1733 if (entry_cite_ptr < all_marker)
1734 BEGIN
1735 goto Cite_Already_Set_Label;
1736 END
1737 else
1738 BEGIN
1739 entry_exists[entry_cite_ptr] = TRUE;
1740 cite_loc = ilk_info[lc_cite_loc];
1741 END
1742 END
1743 else
1744 BEGIN
1745 cite_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, CITE_ILK,
1746 DO_INSERT);
1747 if (hash_found)
1748 BEGIN
1749 hash_cite_confusion ();
1750 END
1751 END
1752 entry_cite_ptr = cite_ptr;
1753 add_database_cite (&cite_ptr);
1754 Cite_Already_Set_Label: DO_NOTHING;
1755 END
1756 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 272 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1757
1758 else if ( ! hash_found)
1759 BEGIN
1760 store_entry = FALSE;
1761 END
1762 if (store_entry)
1763
1764 /***************************************************************************
1765 * WEB section number: 273
1766 * ~~~~~~~~~~~~~~~~~~~
1767 * We must give a warning if this entry type doesn't exist. Also, we
1768 * point the appropriate entry of |type_list| to the entry type just read
1769 * above.
1770 *
1771 * For SCRIBE compatibility, the code to give a warning for a case
1772 * mismatch between a cite key and a database key has been commented out.
1773 * In fact, SCRIBE is the reason that it doesn't produce an error message
1774 * outright. (Note: Case mismatches between two cite keys produce
1775 * full-blown errors.)
1776 ***************************************************************************/
1777 BEGIN
1778 /*----------------------------------------------------------------------
1779 * dummy_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, CITE_ILK,
1780 * DONT_INSERT);
1781 * if ( ! hash_found)
1782 * BEGIN
1783 * PRINT ("Warning--case mismatch, database key \"");
1784 * PRINT_TOKEN;
1785 * PRINT ("\", cite key \"");
1786 * PRINT_POOL_STR (cite_list[entry_cite_ptr]);
1787 * BIB_WARN_NEWLINE ("\"");
1788 * END
1789 *---------------------------------------------------------------------*/
1790 if (type_exists)
1791 BEGIN
1792 type_list[entry_cite_ptr] = entry_type_loc;
1793 END
1794 else
1795 BEGIN
1796 type_list[entry_cite_ptr] = UNDEFINED;
1797 PRINT ("Warning--entry type for \"");
1798 PRINT_TOKEN;
1799 BIB_WARN_NEWLINE ("\" isn't style-file defined");
1800 END
1801 END
1802 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 273 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1803
1804 END
1805 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 267 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1806
1807 END
1808 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 266 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1809
1810 EAT_BIB_WHITE_AND_EOF_CHECK;
1811
1812 /***************************************************************************
1813 * WEB section number: 274
1814 * ~~~~~~~~~~~~~~~~~~~
1815 * This module reads a |comma| and a field as many times as it can, and
1816 * then reads a |right_outer_delim|, ending the current entry.
1817 ***************************************************************************/
1818 BEGIN
1819 while (SCAN_CHAR != right_outer_delim)
1820 BEGIN
1821 if (SCAN_CHAR != COMMA)
1822 BEGIN
1823 BIB_ONE_OF_TWO_EXPECTED_ERR (COMMA, right_outer_delim);
1824 END
1825 INCR (buf_ptr2);
1826 EAT_BIB_WHITE_AND_EOF_CHECK;
1827 if (SCAN_CHAR == right_outer_delim)
1828 BEGIN
1829 goto Loop_Exit_Label;
1830 END
1831
1832 /***************************************************************************
1833 * WEB section number: 275
1834 * ~~~~~~~~~~~~~~~~~~~
1835 * This module reads a field name; its contents won't be stored unless it
1836 * was declared in the .bst file and |store_entry = true|.
1837 ***************************************************************************/
1838 BEGIN
1839 scan_identifier (EQUALS_SIGN, EQUALS_SIGN, EQUALS_SIGN);
1840 BIB_IDENTIFIER_SCAN_CHECK ("a field name");
1841
1842 #ifdef TRACE
1843 if (Flag_trace) {
1844 TRACE_PR_TOKEN;
1845 TRACE_PR_LN (" is a field name");
1846 }
1847 #endif /* TRACE */
1848
1849 store_field = FALSE;
1850 if (store_entry)
1851 BEGIN
1852 lower_case (buffer, buf_ptr1, TOKEN_LEN);
1853 field_name_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
1854 BST_FN_ILK, DONT_INSERT);
1855 if (hash_found)
1856 BEGIN
1857 if (fn_type[field_name_loc] == FIELD)
1858 BEGIN
1859 store_field = TRUE;
1860 END
1861 END
1862 END
1863 EAT_BIB_WHITE_AND_EOF_CHECK;
1864 if (SCAN_CHAR != EQUALS_SIGN)
1865 BEGIN
1866 BIB_EQUALS_SIGN_EXPECTED_ERR;
1867 END
1868 INCR (buf_ptr2);
1869 END
1870 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 275 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1871
1872 EAT_BIB_WHITE_AND_EOF_CHECK;
1873 if ( ! scan_and_store_the_field_value ())
1874 BEGIN
1875 goto Exit_Label;
1876 END
1877 END
1878 Loop_Exit_Label: DO_NOTHING;
1879 INCR (buf_ptr2);
1880 END
1881 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 274 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1882
1883 Exit_Label: DO_NOTHING;
1884 END
1885 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 236 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1886
1887
1888 /***************************************************************************
1889 * WEB section number: 154
1890 * ~~~~~~~~~~~~~~~~~~~
1891 * We must attend to a few details before getting to work on this .bst
1892 * command.
1893 ***************************************************************************/
1894 void get_bst_command_and_process (void)
1895 BEGIN
1896 if ( ! scan_alpha ())
1897 BEGIN
1898 BST_ERR2 ("\"%c\"can't start a style-file command", xchr[SCAN_CHAR]);
1899 END
1900 lower_case (buffer, buf_ptr1, TOKEN_LEN);
1901 command_num = ilk_info[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
1902 BST_COMMAND_ILK, DONT_INSERT)];
1903 if ( ! hash_found)
1904 BEGIN
1905 PRINT_TOKEN;
1906 BST_ERR (" is an illegal style-file command");
1907 END
1908
1909 /***************************************************************************
1910 * WEB section number: 155
1911 * ~~~~~~~~~~~~~~~~~~~
1912 * Here we determine which .bst command we're about to process, and
1913 * then go to it.
1914 ***************************************************************************/
1915 switch (command_num)
1916 BEGIN
1917 case N_BST_ENTRY:
1918 bst_entry_command ();
1919 break;
1920 case N_BST_EXECUTE:
1921 bst_execute_command ();
1922 break;
1923 case N_BST_FUNCTION:
1924 bst_function_command ();
1925 break;
1926 case N_BST_INTEGERS:
1927 bst_integers_command ();
1928 break;
1929 case N_BST_ITERATE:
1930 bst_iterate_command ();
1931 break;
1932 case N_BST_MACRO:
1933 bst_macro_command ();
1934 break;
1935 case N_BST_READ:
1936 bst_read_command ();
1937 break;
1938 case N_BST_REVERSE:
1939 bst_reverse_command ();
1940 break;
1941 case N_BST_SORT:
1942 bst_sort_command ();
1943 break;
1944 case N_BST_STRINGS:
1945 bst_strings_command ();
1946 break;
1947 default:
1948 CONFUSION ("Unknown style-file command");
1949 break;
1950 END
1951 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 155 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1952
1953 Exit_Label: DO_NOTHING;
1954 END
1955 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 154 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1956
1957
1958
1959
1960 /***************************************************************************
1961 * WEB section number: 100
1962 * ~~~~~~~~~~~~~~~~~~~
1963 * This procedure consists of a loop that reads and processes a (nonnull)
1964 * .aux file name. It's this module and the next two that must be
1965 * changed on those systems using command-line arguments. Note: The
1966 * |TERM_OUT| and |term_in| files are system dependent.
1967 *
1968 * This procedure now does almost nothing because the command line has
1969 * already been parsed and checked for us.
1970 ***************************************************************************/
1971 void get_the_top_level_aux_file_name (void)
1972 BEGIN
1973
1974 /***************************************************************************
1975 * WEB section number: 101
1976 * ~~~~~~~~~~~~~~~~~~~
1977 * The switch |check_cmnd_line| tells us whether we're to check for a
1978 * possible command-line argument.
1979 *
1980 * This procedure now does nothing because the command line has already
1981 * been parsed and checked for us.
1982 ***************************************************************************/
1983 Boolean_T check_cmnd_line;
1984 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 101 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1985
1986 check_cmnd_line = TRUE;
1987 LOOP
1988 BEGIN
1989 if (check_cmnd_line)
1990
1991 /***************************************************************************
1992 * WEB section number: 102
1993 * ~~~~~~~~~~~~~~~~~~~
1994 * Here's where we do the real command line work. Actually, the command
1995 * line has already been parsed for us and the .aux file name stored in
1996 * Str_Auxfile. If an .aux file was not specified, BibTeX will have
1997 * already stopped after issuing a "Usage" error.
1998 ***************************************************************************/
1999 BEGIN
2000 /*
2001 ** Leave room for the extension and the null byte at the end.
2002 */
2003 aux_name_length = strlen (Str_auxfile);
2004 name_of_file = (unsigned char *) mymalloc (aux_name_length + 5, "name_of_file");
2005 strncpy ((char *) name_of_file, Str_auxfile, aux_name_length);
2006
2007 /*
2008 ** If the auxilliary file was specified with the ".aux" part already
2009 ** appended, we strip it off here.
2010 */
2011 if (aux_name_length > 4) {
2012 if ((Str_auxfile[aux_name_length-4] == '.')
2013 && ((Str_auxfile[aux_name_length-3] == 'a') || (Str_auxfile[aux_name_length-3] == 'A'))
2014 && ((Str_auxfile[aux_name_length-2] == 'u') || (Str_auxfile[aux_name_length-2] == 'U'))
2015 && ((Str_auxfile[aux_name_length-1] == 'x') || (Str_auxfile[aux_name_length-1] == 'X')))
2016 aux_name_length -= 4;
2017 }
2018
2019 name_of_file[aux_name_length] = 0;
2020 END
2021
2022 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 102 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2023
2024
2025 /***************************************************************************
2026 * WEB section number: 103
2027 * ~~~~~~~~~~~~~~~~~~~
2028 * Here we orchestrate this .aux name's handling: we add the various
2029 * extensions, try to open the files with the resulting name, and
2030 * store the name strings we'll need later.
2031 ***************************************************************************/
2032 BEGIN
2033
2034 /***************************************************************************
2035 * WEB section number: 106
2036 * ~~~~~~~~~~~~~~~~~~~
2037 * We must make sure the (top-level) .aux, .blg, and .bbl
2038 * files can be opened.
2039 ***************************************************************************/
2040 BEGIN
2041 name_length = aux_name_length;
2042 add_extension (s_aux_extension);
2043 aux_ptr = 0;
2044 if ( ! a_open_in (&CUR_AUX_FILE, AUX_FILE_SEARCH_PATH))
2045 BEGIN
2046 SAM_YOU_MADE_THE_FILE_NAME_WRON;
2047 END
2048
2049 name_length = aux_name_length;
2050 add_extension (s_log_extension);
2051 if ( ! a_open_out (&log_file))
2052 BEGIN
2053 SAM_YOU_MADE_THE_FILE_NAME_WRON;
2054 END
2055
2056 name_length = aux_name_length;
2057 add_extension (s_bbl_extension);
2058 if ( ! a_open_out (&bbl_file))
2059 BEGIN
2060 SAM_YOU_MADE_THE_FILE_NAME_WRON;
2061 END
2062 END
2063 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 106 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2064
2065 /***************************************************************************
2066 * WEB section number: 107
2067 * ~~~~~~~~~~~~~~~~~~~
2068 * This code puts the .aux file name, both with and without the
2069 * extension, into the hash table, and it initializes |aux_list|. Note
2070 * that all previous top-level .aux-file stuff must have been
2071 * successful.
2072 ***************************************************************************/
2073 BEGIN
2074 name_length = aux_name_length;
2075 add_extension (s_aux_extension);
2076 name_ptr = 1;
2077 while (name_ptr <= name_length)
2078 BEGIN
2079 buffer[name_ptr] = xord[name_of_file[name_ptr - 1]];
2080 INCR (name_ptr);
2081 END
2082 top_lev_str = hash_text[str_lookup (buffer, 1, aux_name_length,
2083 TEXT_ILK, DO_INSERT)];
2084 CUR_AUX_STR = hash_text[str_lookup (buffer, 1, name_length,
2085 AUX_FILE_ILK, DO_INSERT)];
2086 if (hash_found)
2087 BEGIN
2088
2089 #ifdef TRACE
2090 if (Flag_trace)
2091 print_aux_name ();
2092 #endif /* TRACE */
2093
2094 CONFUSION ("Already encountered auxiliary file");
2095 END
2096 CUR_AUX_LINE = 0;
2097 END
2098 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 107 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2099
2100 goto Aux_Found_Label;
2101 END
2102 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 103 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2103
2104 Aux_Not_Found_Label: check_cmnd_line = FALSE;
2105 mark_fatal ();
2106 debug_msg (DBG_MISC,
2107 "calling longjmp (Close_Up_Shop_Flag) ... ");
2108 longjmp (Close_Up_Shop_Flag, 1);
2109
2110 END
2111 Aux_Found_Label: DO_NOTHING;
2112 END
2113 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 100 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2114
2115
2116
2117
2118 /***************************************************************************
2119 * WEB section number: 137
2120 * ~~~~~~~~~~~~~~~~~~~
2121 * Here's a serious complaint (that is, a bug) concerning hash problems.
2122 * This is the first of several similar bug-procedures that exist only
2123 * because they save space.
2124 ***************************************************************************/
2125 void hash_cite_confusion (void)
2126 BEGIN
2127 CONFUSION ("Cite hash error");
2128 END
2129 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 137 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2130
2131
2132 /***************************************************************************
2133 * WEB section number: 165
2134 * ~~~~~~~~~~~~~~~~~~~
2135 * Here's another bug.
2136 ***************************************************************************/
2137 void id_scanning_confusion (void)
2138 BEGIN
2139 CONFUSION ("Identifier scanning error");
2140 END
2141 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 165 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2142
2143
2144
2145
2146 /***************************************************************************
2147 * WEB section number: 310
2148 * ~~~~~~~~~~~~~~~~~~~
2149 * More bug complaints, this time about bad literals.
2150 ***************************************************************************/
2151 void illegl_literal_confusion (void)
2152 BEGIN
2153 CONFUSION ("Illegal literal type");
2154 END
2155 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2156
2157
2158
2159
2160 /***************************************************************************
2161 * WEB section number: 316
2162 * ~~~~~~~~~~~~~~~~~~~
2163 * This module executes a single specified function once. It can't do
2164 * anything with the entries.
2165 ***************************************************************************/
2166 void init_command_execution (void)
2167 BEGIN
2168 lit_stk_ptr = 0;
2169 cmd_str_ptr = str_ptr;
2170 END
2171 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 316 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2172
2173
2174 /***************************************************************************
2175 * WEB section number: 13
2176 * ~~~~~~~~~~~~~~~~~~~
2177 * This procedure gets things started properly.
2178 ***************************************************************************/
2179 void initialize (void)
2180 BEGIN
2181 /***************************************************************************
2182 * WEB section number: 23
2183 * ~~~~~~~~~~~~~~~~~~~
2184 ***************************************************************************/
2185 short i;
2186 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 23 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2187
2188 /***************************************************************************
2189 * WEB section number: 66
2190 * ~~~~~~~~~~~~~~~~~~~
2191 ***************************************************************************/
2192 HashLoc_T k;
2193 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 66 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2194
2195
2196 /***************************************************************************
2197 * WEB section number: 17
2198 * ~~~~~~~~~~~~~~~~~~~
2199 * Each digit-value of |bad| has a specific meaning.
2200 ***************************************************************************/
2201 bad = 0;
2202
2203 if (MIN_PRINT_LINE < 3)
2204 bad = 1;
2205
2206 if (Max_Print_Line <= MIN_PRINT_LINE)
2207 bad = 10 * bad + 2;
2208
2209 if (Max_Print_Line >= Buf_Size)
2210 bad = 10 * bad + 3;
2211
2212 if (Hash_Prime < 128)
2213 bad = 10 * bad + 4;
2214
2215 if (Hash_Prime > Hash_Size)
2216 bad = 10 * bad + 5;
2217
2218 /*
2219 ** The original WEB version of BibTeX imposed a maximum value of
2220 ** 16320 on Hash_Prime. A WEB constant was defined:
2221 **
2222 ** MAX_HASH_VALUE = (Hash_Prime + Hash_Prime - 2 + 127)
2223 **
2224 ** but, because WEB constants are limited to 32767, Hash_Prime was
2225 ** consequently limited to a maximum of (32767 + 2 - 127) / 2 = 16321.
2226 **
2227 ** We're using C #defines, so that limit doesn't apply. The
2228 ** following original sanity check is therefore commented out.
2229 **
2230 ** if (Hash_Prime >= (16384 - 64))
2231 ** bad = 10 * bad + 6;
2232 */
2233
2234 if (Max_Strings > Hash_Size)
2235 bad = 10 * bad + 7;
2236
2237 if (Max_Cites > Max_Strings)
2238 bad = 10 * bad + 8;
2239
2240 /*
2241 ** The following checks have been removed because
2242 ** Buf_Size can be dynamically changed, whereas
2243 ** Ent_Str_Size and Glob_Str_Size are maximum values
2244 ** which are constants.
2245 **
2246 ** if (Ent_Str_Size > Buf_Size)
2247 ** bad = 10 * bad + 9;
2248 **
2249 ** if (Glob_Str_Size > Buf_Size)
2250 ** bad = 100 * bad + 11;
2251 */
2252
2253 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 17 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2254
2255 /***************************************************************************
2256 * WEB section number: 302
2257 * ~~~~~~~~~~~~~~~~~~~
2258 ***************************************************************************/
2259 #if (SHORT_LIST < ((2 * END_OFFSET) + 2))
2260 bad = 100 * bad + 22;
2261 #endif /* (SHORT_LIST < ((2 * END_OFFSET) + 2)) */
2262 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 302 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2263
2264
2265 if (bad > 0)
2266 BEGIN
2267 FPRINTF (TERM_OUT, "%ld is a bad bad\n", (long) bad);
2268 debug_msg (DBG_MISC, "calling longjmp (Exit_Program_Flag) ... ");
2269 longjmp (Exit_Program_Flag, 1);
2270 END
2271
2272 /***************************************************************************
2273 * WEB section number: 20
2274 * ~~~~~~~~~~~~~~~~~~~
2275 * The |err_count| gets set or reset when |history| first changes to
2276 * |warning_message| or |error_message|, so we don't need to initialize
2277 * it.
2278 ***************************************************************************/
2279 history = SPOTLESS;
2280
2281 /***************************************************************************
2282 * WEB section number: 25
2283 * ~~~~~~~~~~~~~~~~~~~
2284 * Since we are assuming that our \PASCAL\ system is able to read and write the
2285 * visible characters of standard ASCII (although not necessarily using the
2286 * ASCII codes to represent them), the following assignment statements
2287 * initialize
2288 * most of the |xchr| array properly, without needing any system-dependent
2289 * changes. On the other hand, it is possible to implement \TeX\ with
2290 * less complete character sets, and in such cases it will be necessary to
2291 * change something here.
2292 ***************************************************************************/
2293 xchr[0040] = ' ';
2294 xchr[0041] = '!';
2295 xchr[0042] = '"';
2296 xchr[0043] = '#';
2297 xchr[0044] = '$';
2298 xchr[0045] = '%';
2299 xchr[0046] = '&';
2300 xchr[0047] = '\'';
2301 xchr[0050] = '(';
2302 xchr[0051] = ')';
2303 xchr[0052] = '*';
2304 xchr[0053] = '+';
2305 xchr[0054] = ',';
2306 xchr[0055] = '-';
2307 xchr[0056] = '.';
2308 xchr[0057] = '/';
2309 xchr[0060] = '0';
2310 xchr[0061] = '1';
2311 xchr[0062] = '2';
2312 xchr[0063] = '3';
2313 xchr[0064] = '4';
2314 xchr[0065] = '5';
2315 xchr[0066] = '6';
2316 xchr[0067] = '7';
2317 xchr[0070] = '8';
2318 xchr[0071] = '9';
2319 xchr[0072] = ':';
2320 xchr[0073] = ';';
2321 xchr[0074] = '<';
2322 xchr[0075] = '=';
2323 xchr[0076] = '>';
2324 xchr[0077] = '?';
2325 xchr[0100] = '@';
2326 xchr[0101] = 'A';
2327 xchr[0102] = 'B';
2328 xchr[0103] = 'C';
2329 xchr[0104] = 'D';
2330 xchr[0105] = 'E';
2331 xchr[0106] = 'F';
2332 xchr[0107] = 'G';
2333 xchr[0110] = 'H';
2334 xchr[0111] = 'I';
2335 xchr[0112] = 'J';
2336 xchr[0113] = 'K';
2337 xchr[0114] = 'L';
2338 xchr[0115] = 'M';
2339 xchr[0116] = 'N';
2340 xchr[0117] = 'O';
2341 xchr[0120] = 'P';
2342 xchr[0121] = 'Q';
2343 xchr[0122] = 'R';
2344 xchr[0123] = 'S';
2345 xchr[0124] = 'T';
2346 xchr[0125] = 'U';
2347 xchr[0126] = 'V';
2348 xchr[0127] = 'W';
2349 xchr[0130] = 'X';
2350 xchr[0131] = 'Y';
2351 xchr[0132] = 'Z';
2352 xchr[0133] = '[';
2353 xchr[0134] = '\\';
2354 xchr[0135] = ']';
2355 xchr[0136] = '^';
2356 xchr[0137] = '_';
2357 xchr[0140] = '`';
2358 xchr[0141] = 'a';
2359 xchr[0142] = 'b';
2360 xchr[0143] = 'c';
2361 xchr[0144] = 'd';
2362 xchr[0145] = 'e';
2363 xchr[0146] = 'f';
2364 xchr[0147] = 'g';
2365 xchr[0150] = 'h';
2366 xchr[0151] = 'i';
2367 xchr[0152] = 'j';
2368 xchr[0153] = 'k';
2369 xchr[0154] = 'l';
2370 xchr[0155] = 'm';
2371 xchr[0156] = 'n';
2372 xchr[0157] = 'o';
2373 xchr[0160] = 'p';
2374 xchr[0161] = 'q';
2375 xchr[0162] = 'r';
2376 xchr[0163] = 's';
2377 xchr[0164] = 't';
2378 xchr[0165] = 'u';
2379 xchr[0166] = 'v';
2380 xchr[0167] = 'w';
2381 xchr[0170] = 'x';
2382 xchr[0171] = 'y';
2383 xchr[0172] = 'z';
2384 xchr[0173] = '{';
2385 xchr[0174] = '|';
2386 xchr[0175] = '}';
2387 xchr[0176] = '~';
2388 xchr[0000] = ' ';
2389 xchr[0177] = ' ';
2390
2391
2392 #ifdef SUPPORT_8BIT
2393 /*
2394 ** Full 8Bit Support Note [ASIERRA95]:
2395 ** BibTeX just must recognize characters greater than 127.
2396 */
2397 for (i=128; i<=255; i++)
2398 xchr [i] = (unsigned char) i;
2399
2400 #endif /* SUPPORT_8BIT */
2401
2402 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 25 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2403
2404 /***************************************************************************
2405 * WEB section number: 27
2406 * ~~~~~~~~~~~~~~~~~~~
2407 * The ASCII code is ``standard'' only to a certain extent, since many
2408 * computer installations have found it advantageous to have ready access
2409 * to more than 94 printing characters. Appendix C of The \TeX book
2410 * gives a complete specification of the intended correspondence between
2411 * characters and \TeX's internal representation.
2412 *
2413 * If \TeX\ is being used
2414 * on a garden-variety \PASCAL\ for which only standard ASCII
2415 * codes will appear in the input and output files, it doesn't really matter
2416 * what codes are specified in |xchr[1..@'37]|, but the safest policy is to
2417 * blank everything out by using the code shown below.
2418 *
2419 * However, other settings of |xchr| will make \TeX\ more friendly on
2420 * computers that have an extended character set, so that users can type things
2421 * like `\.^^Z' instead of `\ne'. At MIT, for example, it would be more
2422 * appropriate to substitute the code
2423 *
2424 * for i:=1 to '37 do xchr[i]:=chr(i);
2425 *
2426 * \TeX's character set is essentially the same as MIT's, even with respect to
2427 * characters less than~@'40. People with extended character sets can
2428 * assign codes arbitrarily, giving an |xchr| equivalent to whatever
2429 * characters the users of \TeX\ are allowed to have in their input files.
2430 * It is best to make the codes correspond to the intended interpretations as
2431 * shown in Appendix~C whenever possible; but this is not necessary. For
2432 * example, in countries with an alphabet of more than 26 letters, it is
2433 * usually best to map the additional letters into codes less than~@'40.
2434 ***************************************************************************/
2435 for (i=1; i<=0037; i++)
2436 BEGIN
2437 xchr[i] = ' ';
2438 END
2439 xchr[TAB] = CHR (TAB);
2440 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 27 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2441
2442 /***************************************************************************
2443 * WEB section number: 28
2444 * ~~~~~~~~~~~~~~~~~~~
2445 * This system-independent code makes the |xord| array contain a suitable
2446 * inverse to the information in |xchr|. Note that if |xchr[i]=xchr[j]|
2447 * where |i<j<@'177|, the value of |xord[xchr[i]]| will turn out to be
2448 * |j| or more; hence, standard ASCII code numbers will be used instead
2449 * of codes below @'40 in case there is a coincidence.
2450 ***************************************************************************/
2451 for (i=FIRST_TEXT_CHAR; i<=LAST_TEXT_CHAR; i++)
2452 BEGIN
2453 xord[CHR (i)] = INVALID_CODE;
2454 END
2455
2456 for (i=1; i<=0176; i++)
2457 BEGIN
2458 xord[xchr[i]] = i;
2459 END
2460
2461 #ifdef SUPPORT_8BIT
2462 for (i=128; i<=LAST_ASCII_CHAR; i++)
2463 BEGIN
2464 xord[xchr[i]] = i;
2465 END
2466 #endif /* SUPPORT_8BIT */
2467
2468 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 28 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2469
2470 /***************************************************************************
2471 * WEB section number: 32
2472 * ~~~~~~~~~~~~~~~~~~~
2473 * Now we initialize the system-dependent |lex_class| array. The |tab|
2474 * character may be system dependent. Note that the order of these
2475 * assignments is important here.
2476 ***************************************************************************/
2477 for (i=0; i<=0177; i++)
2478 BEGIN
2479 lex_class[i] = OTHER_LEX;
2480 END
2481
2482 for (i=0; i<=0037; i++)
2483 BEGIN
2484 lex_class[i] = ILLEGAL;
2485 END
2486
2487 lex_class[INVALID_CODE] = ILLEGAL;
2488 lex_class[TAB] = WHITE_SPACE;
2489 lex_class[SPACE] = WHITE_SPACE;
2490 lex_class[TIE] = SEP_CHAR;
2491 lex_class[HYPHEN] = SEP_CHAR;
2492
2493 for (i=0060; i<=0071; i++)
2494 BEGIN
2495 lex_class[i] = NUMERIC;
2496 END
2497
2498 for (i=0101; i<=0132; i++)
2499 BEGIN
2500 lex_class[i] = ALPHA;
2501 END
2502
2503 for (i=0141; i<=0172; i++)
2504 BEGIN
2505 lex_class[i] = ALPHA;
2506 END
2507
2508 #ifdef SUPPORT_8BIT
2509 /*
2510 ** Full 8Bit Support Note [ASIERRA95]:
2511 **
2512 ** All character that can be case-changed are supposed to be ALPHA.
2513 ** for (i=128; i<=255; i++)
2514 ** if ((c8lowcase[i] != c8upcase[i]) || (Flag_8bit))
2515 ** lex_class[i] = ALPHA;
2516 */
2517 #endif /* SUPPORT_8BIT */
2518
2519
2520 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 32 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2521
2522 /***************************************************************************
2523 * WEB section number: 33
2524 * ~~~~~~~~~~~~~~~~~~~
2525 * And now the |id_class| array.
2526 ***************************************************************************/
2527 for (i=0; i<=0177; i++)
2528 BEGIN
2529 id_class[i] = LEGAL_ID_CHAR;
2530 END
2531
2532 for (i=0; i<=0037; i++)
2533 BEGIN
2534 id_class[i] = ILLEGAL_ID_CHAR;
2535 END
2536
2537 id_class[SPACE] = ILLEGAL_ID_CHAR;
2538 id_class[TAB] = ILLEGAL_ID_CHAR;
2539 id_class[DOUBLE_QUOTE] = ILLEGAL_ID_CHAR;
2540 id_class[NUMBER_SIGN] = ILLEGAL_ID_CHAR;
2541 id_class[COMMENT] = ILLEGAL_ID_CHAR;
2542 id_class[SINGLE_QUOTE] = ILLEGAL_ID_CHAR;
2543 id_class[LEFT_PAREN] = ILLEGAL_ID_CHAR;
2544 id_class[RIGHT_PAREN] = ILLEGAL_ID_CHAR;
2545 id_class[COMMA] = ILLEGAL_ID_CHAR;
2546 id_class[EQUALS_SIGN] = ILLEGAL_ID_CHAR;
2547 id_class[LEFT_BRACE] = ILLEGAL_ID_CHAR;
2548 id_class[RIGHT_BRACE] = ILLEGAL_ID_CHAR;
2549 #ifdef SUPPORT_8BIT
2550 #ifdef UTF_8
2551 for (i=0x80; i<=0xBF; i++)
2552 BEGIN
2553 id_class[i] = LEGAL_ID_CHAR;
2554 END
2555 for (i=0xC2; i<=0xF4; i++)
2556 BEGIN
2557 id_class[i] = LEGAL_ID_CHAR;
2558 END
2559 #else
2560 for (i=0xC0; i<=0xD6; i++)
2561 BEGIN
2562 id_class[i] = LEGAL_ID_CHAR;
2563 END
2564 for (i=0xD8; i<=0xF6; i++)
2565 BEGIN
2566 id_class[i] = LEGAL_ID_CHAR;
2567 END
2568 for (i=0xF8; i<=0xFF; i++)
2569 BEGIN
2570 id_class[i] = LEGAL_ID_CHAR;
2571 END
2572 #endif
2573 #endif
2574 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 33 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2575
2576 /***************************************************************************
2577 * WEB section number: 35
2578 * ~~~~~~~~~~~~~~~~~~~
2579 * Now we initialize the system-dependent |char_width| array, for which
2580 * |space| is the only |white_space| character given a nonzero printing
2581 * width. The widths here are taken from Stanford's June~'87
2582 * $cmr10$~font and represent hundredths of a point (rounded), but since
2583 * they're used only for relative comparisons, the units have no meaning.
2584 ***************************************************************************/
2585 for (i=0; i<=LAST_LATIN_CHAR; i++)
2586 BEGIN
2587 char_width[i] = 0;
2588 END
2589
2590 char_width[0040] = 278;
2591 char_width[0041] = 278;
2592 char_width[0042] = 500;
2593 char_width[0043] = 833;
2594 char_width[0044] = 500;
2595 char_width[0045] = 833;
2596 char_width[0046] = 778;
2597 char_width[0047] = 278;
2598 char_width[0050] = 389;
2599 char_width[0051] = 389;
2600 char_width[0052] = 500;
2601 char_width[0053] = 778;
2602 char_width[0054] = 278;
2603 char_width[0055] = 333;
2604 char_width[0056] = 278;
2605 char_width[0057] = 500;
2606 char_width[0060] = 500;
2607 char_width[0061] = 500;
2608 char_width[0062] = 500;
2609 char_width[0063] = 500;
2610 char_width[0064] = 500;
2611 char_width[0065] = 500;
2612 char_width[0066] = 500;
2613 char_width[0067] = 500;
2614 char_width[0070] = 500;
2615 char_width[0071] = 500;
2616 char_width[0072] = 278; /* :, refer 0x3A in T1 ecrm1000.tfm */
2617 char_width[0073] = 278; /* ;, refer 0x3B in T1 ecrm1000.tfm */
2618 #ifdef SUPPORT_8BIT
2619 char_width[0074] = 472; /* <, refer 0x3C in T1 ecrm1000.tfm */
2620 #else
2621 char_width[0074] = 278; /* ¡, refer 0x3C in OT1 cmr10.tfm */
2622 #endif
2623 char_width[0075] = 778; /* =, refer 0x3D in T1 ecrm1000.tfm */
2624 #ifdef SUPPORT_8BIT
2625 char_width[0076] = 472; /* >, refer 0x3E in T1 ecrm1000.tfm */
2626 #else
2627 char_width[0076] = 472; /* ¿, refer 0x3E in OT1 cmr10.tfm */
2628 #endif
2629 char_width[0077] = 472; /* ?, refer 0x3F in T1 ecrm1000.tfm */
2630 char_width[0100] = 778;
2631 char_width[0101] = 750;
2632 char_width[0102] = 708;
2633 char_width[0103] = 722;
2634 char_width[0104] = 764;
2635 char_width[0105] = 681;
2636 char_width[0106] = 653;
2637 char_width[0107] = 785;
2638 char_width[0110] = 750;
2639 char_width[0111] = 361;
2640 char_width[0112] = 514;
2641 char_width[0113] = 778;
2642 char_width[0114] = 625;
2643 char_width[0115] = 917;
2644 char_width[0116] = 750;
2645 char_width[0117] = 778;
2646 char_width[0120] = 681;
2647 char_width[0121] = 778;
2648 char_width[0122] = 736;
2649 char_width[0123] = 556;
2650 char_width[0124] = 722;
2651 char_width[0125] = 750;
2652 char_width[0126] = 750;
2653 char_width[0127] = 1028;
2654 char_width[0130] = 750;
2655 char_width[0131] = 750;
2656 char_width[0132] = 611;
2657 char_width[0133] = 278; /* [, refer 0x5B in T1 ecrm1000.tfm */
2658 char_width[0134] = 500; /* \, refer 0x5C in T1 ecrm1000.tfm */
2659 char_width[0135] = 278; /* ], refer 0x5D in T1 ecrm1000.tfm */
2660 #ifdef SUPPORT_8BIT
2661 char_width[0136] = 611; /* wide ^, refer 0x5E in T1 ecrm1000.tfm */
2662 char_width[0137] = 778; /* wide _, refer 0x5F in T1 ecrm1000.tfm */
2663 #else
2664 char_width[0136] = 500; /* ^, refer 0x5E in OT1 cmr10.tfm */
2665 char_width[0137] = 278; /* dot above, refer 0x5F in OT1 cmr10.tfm */
2666 #endif
2667 char_width[0140] = 278; /* `, refer 0x60 in T1 ecrm1000.tfm */
2668 char_width[0141] = 500;
2669 char_width[0142] = 556;
2670 char_width[0143] = 444;
2671 char_width[0144] = 556;
2672 char_width[0145] = 444;
2673 char_width[0146] = 306;
2674 char_width[0147] = 500;
2675 char_width[0150] = 556;
2676 char_width[0151] = 278;
2677 char_width[0152] = 306;
2678 char_width[0153] = 528;
2679 char_width[0154] = 278;
2680 char_width[0155] = 833;
2681 char_width[0156] = 556;
2682 char_width[0157] = 500;
2683 char_width[0160] = 556;
2684 char_width[0161] = 528;
2685 char_width[0162] = 392;
2686 char_width[0163] = 394;
2687 char_width[0164] = 389;
2688 char_width[0165] = 556;
2689 char_width[0166] = 528;
2690 char_width[0167] = 722;
2691 char_width[0170] = 528;
2692 char_width[0171] = 528;
2693 char_width[0172] = 444;
2694 char_width[0173] = 500; /* {, refer 0x7B in T1 ecrm1000.tfm */
2695 #ifdef SUPPORT_8BIT
2696 char_width[0174] = 278; /* |, refer 0x7C in T1 ecrm1000.tfm */
2697 #else
2698 char_width[0174] = 1000; /* em-dash, refer 0x7C in OT1 cmr10.tfm */
2699 #endif
2700 char_width[0175] = 500; /* }, refer 0x7D in T1 ecrm1000.tfm */
2701 #ifdef SUPPORT_8BIT
2702 char_width[0176] = 611; /* ~, refer 0x7E in T1 ecrm1000.tfm */
2703 #else
2704 char_width[0176] = 500; /* ??? */
2705 #endif
2706 #ifdef SUPPORT_8BIT
2707 char_width[0xA1] = 278; /* ¡, refer 0xBD in T1 ecrm1000.tfm */
2708 char_width[0xA3] = 639; /* £, refer 0xBF in T1 ecrm1000.tfm */
2709 char_width[0xA7] = 444; /* §, refer 0x9F in T1 ecrm1000.tfm */
2710 char_width[0xAB] = 556; /* «, refer 0x13 in T1 ecrm1000.tfm */
2711 char_width[0xBB] = 556; /* », refer 0x14 in T1 ecrm1000.tfm */
2712 char_width[0xBF] = 472; /* ¿, refer 0xBE in T1 ecrm1000.tfm */
2713 char_width[0xC0] = 750;
2714 char_width[0xC1] = 750;
2715 char_width[0xC2] = 750;
2716 char_width[0xC3] = 750;
2717 char_width[0xC4] = 750;
2718 char_width[0xC5] = 750;
2719 char_width[0xC6] = 903;
2720 char_width[0xC7] = 722;
2721 char_width[0xC8] = 681;
2722 char_width[0xC9] = 681;
2723 char_width[0xCA] = 681;
2724 char_width[0xCB] = 681;
2725 char_width[0xCC] = 361;
2726 char_width[0xCD] = 361;
2727 char_width[0xCE] = 361;
2728 char_width[0xCF] = 361;
2729 char_width[0xD0] = 764;
2730 char_width[0xD1] = 750;
2731 char_width[0xD2] = 778;
2732 char_width[0xD3] = 778;
2733 char_width[0xD4] = 778;
2734 char_width[0xD5] = 778;
2735 char_width[0xD6] = 778;
2736 char_width[0xD7] = 778; /* expect "×" */
2737 char_width[0xD8] = 778;
2738 char_width[0xD9] = 750;
2739 char_width[0xDA] = 750;
2740 char_width[0xDB] = 750;
2741 char_width[0xDC] = 750;
2742 char_width[0xDD] = 750;
2743 char_width[0xDE] = 625;
2744 char_width[0xDF] = 500; /* ß, refer 0xFF in T1 ecrm1000.tfm */
2745 char_width[0xE0] = 500;
2746 char_width[0xE1] = 500;
2747 char_width[0xE2] = 500;
2748 char_width[0xE3] = 500;
2749 char_width[0xE4] = 500;
2750 char_width[0xE5] = 500;
2751 char_width[0xE6] = 722;
2752 char_width[0xE7] = 444;
2753 char_width[0xE8] = 444;
2754 char_width[0xE9] = 444;
2755 char_width[0xEA] = 444;
2756 char_width[0xEB] = 444;
2757 char_width[0xEC] = 278;
2758 char_width[0xED] = 278;
2759 char_width[0xEE] = 278;
2760 char_width[0xEF] = 333;
2761 char_width[0xF0] = 500;
2762 char_width[0xF1] = 556;
2763 char_width[0xF2] = 500;
2764 char_width[0xF3] = 500;
2765 char_width[0xF4] = 500;
2766 char_width[0xF5] = 500;
2767 char_width[0xF6] = 500;
2768 char_width[0xF7] = 778; /* expect "÷" */
2769 char_width[0xF8] = 500;
2770 char_width[0xF9] = 556;
2771 char_width[0xFA] = 556;
2772 char_width[0xFB] = 556;
2773 char_width[0xFC] = 556;
2774 char_width[0xFD] = 528;
2775 char_width[0xFE] = 556;
2776 char_width[0xFF] = 528; /* ÿ, refer 0xB8 in T1 ecrm1000.tfm */
2777 #endif
2778 #ifdef UTF_8
2779 char_width[0x100] = 750;
2780 char_width[0x101] = 500;
2781 char_width[0x102] = 750;
2782 char_width[0x103] = 500;
2783 char_width[0x104] = 750;
2784 char_width[0x105] = 500;
2785 char_width[0x106] = 722;
2786 char_width[0x107] = 444;
2787 char_width[0x108] = 722;
2788 char_width[0x109] = 444;
2789 char_width[0x10A] = 722;
2790 char_width[0x10B] = 444;
2791 char_width[0x10C] = 722;
2792 char_width[0x10D] = 444;
2793 char_width[0x10E] = 764;
2794 char_width[0x10F] = 556;
2795 char_width[0x110] = 764;
2796 char_width[0x111] = 556;
2797 char_width[0x112] = 681;
2798 char_width[0x113] = 444;
2799 char_width[0x114] = 681;
2800 char_width[0x115] = 444;
2801 char_width[0x116] = 681;
2802 char_width[0x117] = 444;
2803 char_width[0x118] = 681;
2804 char_width[0x119] = 444;
2805 char_width[0x11A] = 681;
2806 char_width[0x11B] = 444;
2807 char_width[0x11C] = 785;
2808 char_width[0x11D] = 500;
2809 char_width[0x11E] = 785;
2810 char_width[0x11F] = 500;
2811 char_width[0x120] = 785;
2812 char_width[0x121] = 500;
2813 char_width[0x122] = 785;
2814 char_width[0x123] = 500;
2815 char_width[0x124] = 750;
2816 char_width[0x125] = 556;
2817 char_width[0x126] = 750;
2818 char_width[0x127] = 556;
2819 char_width[0x128] = 361;
2820 char_width[0x129] = 278;
2821 char_width[0x12A] = 361;
2822 char_width[0x12B] = 278;
2823 char_width[0x12C] = 361;
2824 char_width[0x12D] = 278;
2825 char_width[0x12E] = 361;
2826 char_width[0x12F] = 278;
2827 char_width[0x130] = 361;
2828 char_width[0x131] = 278;
2829 char_width[0x132] = 861; /* IJ, refer 0x9C in T1 ecrm1000.tfm */
2830 char_width[0x133] = 583; /* ij, refer 0xBC in T1 ecrm1000.tfm */
2831 char_width[0x134] = 541;
2832 char_width[0x135] = 306;
2833 char_width[0x136] = 778;
2834 char_width[0x137] = 528;
2835 char_width[0x138] = 556; /* ĸ, not found in T1 ecrm1000.tfm */
2836 char_width[0x139] = 625;
2837 char_width[0x13A] = 278;
2838 char_width[0x13B] = 625;
2839 char_width[0x13C] = 278;
2840 char_width[0x13D] = 625;
2841 char_width[0x13E] = 278;
2842 char_width[0x13F] = 625;
2843 char_width[0x140] = 278;
2844 char_width[0x141] = 625;
2845 char_width[0x142] = 278;
2846 char_width[0x143] = 750;
2847 char_width[0x144] = 556;
2848 char_width[0x145] = 750;
2849 char_width[0x146] = 556;
2850 char_width[0x147] = 750;
2851 char_width[0x148] = 556;
2852 char_width[0x149] = 556;
2853 char_width[0x14A] = 792; /* Ŋ, refer 0x8D in T1 ecrm1000.tfm */
2854 char_width[0x14B] = 556; /* ŋ, refer 0xAD in T1 ecrm1000.tfm */
2855 char_width[0x14C] = 778;
2856 char_width[0x14D] = 500;
2857 char_width[0x14E] = 778;
2858 char_width[0x14F] = 500;
2859 char_width[0x150] = 778;
2860 char_width[0x151] = 500;
2861 char_width[0x152] = 1014; /* Œ, refer 0xD7 in T1 ecrm1000.tfm */
2862 char_width[0x153] = 778; /* œ, refer 0xF7 in T1 ecrm1000.tfm */
2863 char_width[0x154] = 736;
2864 char_width[0x155] = 392;
2865 char_width[0x156] = 736;
2866 char_width[0x157] = 392;
2867 char_width[0x158] = 736;
2868 char_width[0x159] = 392;
2869 char_width[0x15A] = 556;
2870 char_width[0x15B] = 394;
2871 char_width[0x15C] = 556;
2872 char_width[0x15D] = 394;
2873 char_width[0x15E] = 556;
2874 char_width[0x15F] = 394;
2875 char_width[0x160] = 556;
2876 char_width[0x161] = 394;
2877 char_width[0x162] = 722;
2878 char_width[0x163] = 389;
2879 char_width[0x164] = 722;
2880 char_width[0x165] = 389;
2881 char_width[0x166] = 722;
2882 char_width[0x167] = 389;
2883 char_width[0x168] = 750;
2884 char_width[0x169] = 556;
2885 char_width[0x16A] = 750;
2886 char_width[0x16B] = 556;
2887 char_width[0x16C] = 750;
2888 char_width[0x16D] = 556;
2889 char_width[0x16E] = 750;
2890 char_width[0x16F] = 556;
2891 char_width[0x170] = 750;
2892 char_width[0x171] = 556;
2893 char_width[0x172] = 750;
2894 char_width[0x173] = 556;
2895 char_width[0x174] = 1028;
2896 char_width[0x175] = 722;
2897 char_width[0x176] = 750;
2898 char_width[0x177] = 528;
2899 char_width[0x178] = 750;
2900 char_width[0x179] = 611;
2901 char_width[0x17A] = 444;
2902 char_width[0x17B] = 611;
2903 char_width[0x17C] = 444;
2904 char_width[0x17D] = 611;
2905 char_width[0x17E] = 444;
2906 char_width[0x17F] = 392; /* ſ, not found in T1 ecrm1000.tfm */
2907 #endif
2908 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 35 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2909
2910 /***************************************************************************
2911 * WEB section number: 67
2912 * ~~~~~~~~~~~~~~~~~~~
2913 * Now it's time to initialize the hash table; note that |str_start[0]|
2914 * must be unused if |hash_text[k] := 0| is to have the desired effect.
2915 ***************************************************************************/
2916 for (k=HASH_BASE; k<=HASH_MAX; k++)
2917 BEGIN
2918 hash_next[k] = EMPTY;
2919 hash_text[k] = 0;
2920 END
2921 hash_used = HASH_MAX + 1;
2922 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 67 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2923
2924 /***************************************************************************
2925 * WEB section number: 72
2926 * ~~~~~~~~~~~~~~~~~~~
2927 * Now that we've defined the hash-table workings we can initialize the
2928 * string pool. Unlike \TeX, \BibTeX\ does not use a |pool_file| for
2929 * string storage; instead it inserts its pre-defined strings into
2930 * |str_pool|---this makes one file fewer for the \BibTeX\ implementor
2931 * to deal with. This section initializes |str_pool|; the pre-defined
2932 * strings will be inserted into it shortly; and other strings are
2933 * inserted while processing the input files.
2934 ***************************************************************************/
2935 pool_ptr = 0;
2936 str_ptr = 1;
2937 str_start[str_ptr] = pool_ptr;
2938 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 72 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2939
2940 /***************************************************************************
2941 * WEB section number: 119
2942 * ~~~~~~~~~~~~~~~~~~~
2943 *
2944 ***************************************************************************/
2945 bib_ptr = 0;
2946 bib_seen = FALSE;
2947 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 119 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2948
2949 /***************************************************************************
2950 * WEB section number: 125
2951 * ~~~~~~~~~~~~~~~~~~~
2952 * And we initialize.
2953 ***************************************************************************/
2954 bst_str = 0;
2955 bst_seen = FALSE;
2956 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 125 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2957
2958 /***************************************************************************
2959 * WEB section number: 131
2960 * ~~~~~~~~~~~~~~~~~~~
2961 *
2962 ***************************************************************************/
2963 cite_ptr = 0;
2964 citation_seen = FALSE;
2965 all_entries = FALSE;
2966 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 131 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2967
2968 /***************************************************************************
2969 * WEB section number: 162
2970 * ~~~~~~~~~~~~~~~~~~~
2971 * Now we initialize storage for the |wiz_defined| functions and we
2972 * initialize variables so that the first |str_entry_var|,
2973 * |int_entry_var|, |str_global_var|, and |field| name will be assigned
2974 * the number~0. Note: The variables |num_ent_strs| and |num_fields|
2975 * will also be set when pre-defining strings.
2976 ***************************************************************************/
2977 wiz_def_ptr = 0;
2978 num_ent_ints = 0;
2979 num_ent_strs = 0;
2980 num_fields = 0;
2981 str_glb_ptr = 0;
2982 while (str_glb_ptr < Max_Glob_Strs)
2983 BEGIN
2984 glb_str_ptr[str_glb_ptr] = 0;
2985 glb_str_end[str_glb_ptr] = 0;
2986 INCR (str_glb_ptr);
2987 END
2988 num_glb_strs = 0;
2989 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 162 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
2990
2991 /***************************************************************************
2992 * WEB section number: 164
2993 * ~~~~~~~~~~~~~~~~~~~
2994 * And we initialize them.
2995 ***************************************************************************/
2996 entry_seen = FALSE;
2997 read_seen = FALSE;
2998 read_performed = FALSE;
2999 reading_completed = FALSE;
3000 read_completed = FALSE;
3001 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 164 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3002
3003 /***************************************************************************
3004 * WEB section number: 196
3005 * ~~~~~~~~~~~~~~~~~~~
3006 * Now we initialize it.
3007 ***************************************************************************/
3008 impl_fn_num = 0;
3009 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 196 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3010
3011 /***************************************************************************
3012 * WEB section number: 292
3013 * ~~~~~~~~~~~~~~~~~~~
3014 * And the first output line requires this initialization.
3015 ***************************************************************************/
3016 out_buf_length = 0;
3017 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 292 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3018
3019 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 20 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3020
3021 pre_def_certain_strings ();
3022 get_the_top_level_aux_file_name ();
3023 END
3024 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 13 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3025
3026
3027
3028 /***************************************************************************
3029 * WEB section number: 47
3030 * ~~~~~~~~~~~~~~~~~~~
3031 * The |input_ln| function brings the next line of input from the
3032 * specified file into available positions of the buffer array and
3033 * returns the value |true|, unless the file has already been entirely
3034 * read, in which case it returns |false| and sets |last:=0|. In
3035 * general, the |ASCII_code| numbers that represent the next line of the
3036 * file are input into |buffer[0]|, |buffer[1]|, \dots, |buffer[last-1]|;
3037 * and the global variable |last| is set equal to the length of the line.
3038 * Trailing |white_space| characters are removed from the line
3039 * (|white_space| characters are explained in the character-set section%
3040 * ---most likely they're blanks); thus, either |last=0| (in which case
3041 * the line was entirely blank) or |lex_class[buffer[last-1]]<>white_space|.
3042 * An overflow error is given if the normal actions of |input_ln| would
3043 * make |last>buf_size|.
3044 ***************************************************************************/
3045 Boolean_T input_ln (AlphaFile_T f)
3046 BEGIN
3047 Boolean_T input_ln;
3048
3049 last = 0;
3050
3051 if (feof (f))
3052 BEGIN
3053 input_ln = FALSE;
3054 END
3055 else
3056 BEGIN
3057 while ( ! eoln (f))
3058 BEGIN
3059 if (last >= Buf_Size)
3060 BEGIN
3061 buffer_overflow ();
3062 END
3063
3064 buffer[last] = xord[getc(f)];
3065 INCR (last);
3066 END
3067 (void) getc (f);
3068
3069 while (last > 0)
3070 BEGIN
3071 if (lex_class[buffer[last - 1]] == WHITE_SPACE)
3072 BEGIN
3073 DECR (last);
3074 END
3075 else
3076 BEGIN
3077 goto Loop_Exit_Label;
3078 END
3079 END
3080 Loop_Exit_Label: input_ln = TRUE;
3081 END
3082 return (input_ln);
3083 END
3084 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 47 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3085
3086
3087
3088 /***************************************************************************
3089 * WEB section number: 198
3090 * ~~~~~~~~~~~~~~~~~~~
3091 * This procedure takes the integer |int|, copies the appropriate
3092 * |ASCII_code| string into |int_buf| starting at |int_begin|, and sets
3093 * the |var| parameter |int_end| to the first unused |int_buf| location.
3094 * The ASCII string will consist of decimal digits, the first of which
3095 * will be not be a~0 if the integer is nonzero, with a prepended minus
3096 * sign if the integer is negative.
3097 ***************************************************************************/
3098 void int_to_ASCII (Integer_T integer, BufType_T int_buf,
3099 BufPointer_T int_begin, BufPointer_T *int_end)
3100 BEGIN
3101 BufPointer_T int_ptr,
3102 int_xptr;
3103 ASCIICode_T int_tmp_val;
3104
3105 int_ptr = int_begin;
3106 if (integer < 0)
3107 BEGIN
3108 APPEND_INT_CHAR (MINUS_SIGN);
3109 integer = -integer;
3110 END
3111 int_xptr = int_ptr;
3112 REPEAT
3113 BEGIN
3114 APPEND_INT_CHAR ('0' + (integer MOD 10));
3115 integer = integer DIV 10;
3116 END UNTIL (integer == 0);
3117 *int_end = int_ptr;
3118 DECR (int_ptr);
3119 while (int_xptr < int_ptr)
3120 BEGIN
3121 int_tmp_val = int_buf[int_xptr];
3122 int_buf[int_xptr] = int_buf[int_ptr];
3123 int_buf[int_ptr] = int_tmp_val;
3124 DECR (int_ptr);
3125 INCR (int_xptr);
3126 END
3127 END
3128 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 198 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3129
3130
3131
3132 /***************************************************************************
3133 * WEB section number: 145
3134 * ~~~~~~~~~~~~~~~~~~~
3135 * Before proceeding, we see if we have any complaints.
3136 ***************************************************************************/
3137 void last_check_for_aux_errors (void)
3138 BEGIN
3139 num_cites = cite_ptr;
3140 num_bib_files = bib_ptr;
3141 if ( ! citation_seen)
3142 BEGIN
3143 AUX_END_ERR ("\\citation commands");
3144 END
3145 else if ((num_cites == 0) && ( ! all_entries))
3146 BEGIN
3147 AUX_END_ERR ("cite keys");
3148 END
3149 if ( ! bib_seen)
3150 BEGIN
3151 AUX_END_ERR ("\\bibdata command");
3152 END
3153 else if (num_bib_files == 0)
3154 BEGIN
3155 AUX_END_ERR ("database files");
3156 END
3157 if ( ! bst_seen)
3158 BEGIN
3159 AUX_END_ERR ("\\bibstyle command");
3160 END
3161 else if (bst_str == 0)
3162 BEGIN
3163 AUX_END_ERR ("style file");
3164 END
3165 END
3166 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 145 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3167
3168
3169
3170 /***************************************************************************
3171 * WEB section number: 301
3172 * ~~~~~~~~~~~~~~~~~~~
3173 * The function |less_than| compares the two sort.key$s indirectly
3174 * pointed to by its arguments and returns |true| if the first argument's
3175 * sort.key$ is lexicographically less than the second's (that is,
3176 * alphabetically earlier). In case of ties the function compares the
3177 * indices |arg1| and |arg2|, which are assumed to be different, and
3178 * returns |true| if the first is smaller. This function uses
3179 * |ASCII_code|s to compare, so it might give ``interesting'' results
3180 * when handling nonletters.
3181 ***************************************************************************/
3182 Boolean_T less_than (CiteNumber_T arg1, CiteNumber_T arg2)
3183 BEGIN
3184 StrEntLoc_T ptr1,
3185 ptr2;
3186 Boolean_T less_than;
3187 #ifdef UTF_8
3188 /*
3189 We use ICU Collator ucol_strcollUTF8() to compare the Unicode in UTF-8.
3190 There is a command line option "-o", "--location" to set the rule of collation.
3191 */
3192 Integer_T lenk1, lenk2;
3193 UBool u_cmp;
3194 UErrorCode err1 = U_ZERO_ERROR;
3195 char *eos1, *eos2;
3196 const char *ustr1, *ustr2;
3197 #else
3198 Integer_T char_ptr;
3199 ASCIICode_T char1,
3200 char2;
3201 #endif
3202
3203 #ifdef TRACE
3204 if (Flag_trace)
3205 TRACE_PR_LN3 ("Comparing entry %ld and %ld ...", arg1, arg2);
3206 #endif /* TRACE */
3207 ptr1 = (arg1 * num_ent_strs) + sort_key_num;
3208 ptr2 = (arg2 * num_ent_strs) + sort_key_num;
3209 #ifdef UTF_8
3210 ustr1 = (const char *)&ENTRY_STRS(ptr1, 0);
3211 ustr2 = (const char *)&ENTRY_STRS(ptr2, 0);
3212 eos1 = strchr(ustr1, END_OF_STRING);
3213 eos2 = strchr(ustr2, END_OF_STRING);
3214 lenk1 = eos1 ? eos1-ustr1 : strlen(ustr1);
3215 lenk2 = eos2 ? eos2-ustr2 : strlen(ustr2);
3216
3217 u_cmp = ucol_strcollUTF8(u_coll, ustr1, lenk1, ustr2, lenk2, &err1);
3218 if (!U_SUCCESS(err1))
3219 BEGIN
3220 printf("Error in ucol_strcollUTF8.\n");
3221 #ifdef TRACE
3222 if (Flag_trace)
3223 TRACE_PR_LN ("Error in ucol_strcollUTF8");
3224 #endif /* TRACE */
3225 END
3226
3227 if (u_cmp==UCOL_EQUAL)
3228 BEGIN
3229 if (arg1 < arg2)
3230 BEGIN
3231 COMPARE_RETURN (TRUE);
3232 END
3233 else if (arg1 > arg2)
3234 BEGIN
3235 COMPARE_RETURN (FALSE);
3236 END
3237 else
3238 BEGIN
3239 CONFUSION ("Duplicate sort key");
3240 END
3241 END
3242 less_than = u_cmp==UCOL_LESS;
3243 #else
3244 char_ptr = 0;
3245 LOOP
3246 BEGIN
3247 char1 = ENTRY_STRS(ptr1, char_ptr);
3248 char2 = ENTRY_STRS(ptr2, char_ptr);
3249 if (char1 == END_OF_STRING)
3250 BEGIN
3251 if (char2 == END_OF_STRING)
3252 BEGIN
3253 if (arg1 < arg2)
3254 BEGIN
3255 COMPARE_RETURN (TRUE);
3256 END
3257 else if (arg1 > arg2)
3258 BEGIN
3259 COMPARE_RETURN (FALSE);
3260 END
3261 else
3262 BEGIN
3263 CONFUSION ("Duplicate sort key");
3264 END
3265 END
3266 else
3267 BEGIN
3268 COMPARE_RETURN (TRUE);
3269 END
3270 END
3271 else if (char2 == END_OF_STRING)
3272 BEGIN
3273 COMPARE_RETURN (FALSE);
3274 END
3275 else if char_less_than(char1, char2)
3276 BEGIN
3277 COMPARE_RETURN (TRUE);
3278 END
3279 else if char_greater_than(char1, char2)
3280 BEGIN
3281 COMPARE_RETURN (FALSE);
3282 END
3283 INCR (char_ptr);
3284 END
3285 #endif
3286 Exit_Label:
3287 #ifdef TRACE
3288 if (Flag_trace)
3289 TRACE_PR_LN2 ("... first is smaller than second? -- %s", (less_than?"T":"F"));
3290 #endif /* TRACE */
3291 return (less_than);
3292 END
3293 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3294
3295
3296
3297
3298 /***************************************************************************
3299 * WEB section number: 62
3300 * ~~~~~~~~~~~~~~~~~~~
3301 * This system-independent procedure converts upper-case characters to
3302 * lower case for the specified part of |buf|. It is system independent
3303 * because it uses only the internal representation for characters.
3304 ***************************************************************************/
3305 void lower_case (BufType_T buf, BufPointer_T bf_ptr,
3306 BufPointer_T len)
3307 BEGIN
3308 BufPointer_T i;
3309
3310 if (len > 0)
3311 BEGIN
3312 for (i = bf_ptr; i <= (bf_ptr + len - 1); i++)
3313 BEGIN
3314
3315 #ifdef SUPPORT_8BIT
3316 if (IsUpper (buf[i]))
3317 BEGIN
3318 buf[i] = ToLower (buf[i]);
3319 END
3320 #else /* NOT SUPPORT_8BIT */
3321 if ((buf[i] >= 'A') && (buf[i] <= 'Z'))
3322 BEGIN
3323 buf[i] = buf[i] + CASE_DIFFERENCE;
3324 END
3325 #endif /* SUPPORT_8BIT */
3326
3327 END
3328 END
3329 END
3330
3331 #ifdef UTF_8
3332 /*
3333 "lower_case_uni" is the function for processing the characters, actually the UTF-8.
3334 We transform UTF-8 to Unicode, then to low case, then back to UTF-8 for output.
3335 When we transform the character, the length have been changed. So we have do
3336 some job for the length. And the output of this function we should be careful
3337 to the length. 23/sep/2009
3338 */
3339 BufPointer_T lower_case_uni (BufType_T buf, BufPointer_T bf_ptr,
3340 BufPointer_T len)
3341 BEGIN
3342
3343 UChar target[BUF_SIZE+1];
3344 int32_t tarcap=BUF_SIZE+1;
3345 int32_t tarlen = icu_toUChars(buf, bf_ptr, len, target, tarcap);
3346
3347 UChar tarlow[BUF_SIZE+1];
3348 int32_t tlcap=BUF_SIZE+1;
3349 int32_t tllen=icu_strToLower(tarlow, tlcap,target, tarlen);
3350
3351 unsigned char dest[BUF_SIZE+1];
3352 int32_t destcap= BUF_SIZE-bf_ptr;
3353
3354 int32_t tblen=icu_fromUChars(dest, destcap, (const UChar *) tarlow, tllen);
3355
3356 BufPointer_T i;
3357 if (tblen > 0)
3358 BEGIN
3359 if (len!=tblen)
3360 BEGIN
3361 unsigned char tmp[BUF_SIZE+1];
3362 BufPointer_T tmppr=0;
3363 for (i=bf_ptr+len;i<=(BUF_SIZE-tblen+len);i++)
3364 BEGIN
3365 tmp[tmppr]=buf[i];
3366 tmppr++;
3367 END
3368 i=bf_ptr+tblen;
3369 tmppr=0;
3370 for (tmppr=0;tmppr<=(BUF_SIZE-bf_ptr-tblen);tmppr++)
3371 BEGIN
3372 buf[i]=tmp[tmppr];
3373 i++;
3374 END
3375 END
3376 for (i = 0; i <= (tblen - 1); i++)
3377 BEGIN
3378
3379 buf[i+bf_ptr]=dest[i];
3380
3381 END
3382 END
3383
3384 return tblen;
3385 END
3386
3387
3388 /*
3389 This function is for transform UTF-8 to Unicode with ICU libs. 23/sep/2009
3390 */
3391 int32_t icu_toUChars(BufType_T buf, BufPointer_T bf_ptr,BufPointer_T len,UChar * target, int32_t tarcap)
3392 BEGIN
3393 UErrorCode err1 = U_ZERO_ERROR;
3394 int32_t tulen;
3395
3396 u_strFromUTF8WithSub(target, tarcap, &tulen, (char *)&buf[bf_ptr], len, 0xfffd, NULL, &err1);
3397 if (!U_SUCCESS(err1))
3398 BEGIN
3399 printf("Error in icu_toUChars.\n");
3400 #ifdef TRACE
3401 if (Flag_trace)
3402 TRACE_PR_LN ("Error in icu_toUChars");
3403 #endif /* TRACE */
3404 END
3405
3406 return tulen;
3407 END
3408
3409 /*
3410 This function is for transform Unicode string to low case. 23/sep/2009
3411 */
3412 int32_t icu_strToLower(UChar * tarlow, int32_t tlcap, UChar * target, int32_t tarlen)
3413 BEGIN
3414 int32_t tllen;
3415 UErrorCode err1 = U_ZERO_ERROR;
3416 if (Flag_language)
3417 {
3418 tllen=u_strToLower(tarlow,tlcap, target,tarlen,Str_language,&err1);
3419 }
3420 else
3421 {
3422 tllen=u_strToLower(tarlow,tlcap, target,tarlen,NULL,&err1);
3423 }
3424 if (!U_SUCCESS(err1))
3425 BEGIN
3426 int16_t i=0;
3427 printf("Error in icu_strToLower.\n");
3428 #ifdef TRACE
3429 if (Flag_trace)
3430 TRACE_PR_LN ("Error in icu_strToLower");
3431 #endif /* TRACE */
3432 for (i=0;i<tarlen;i++)
3433 BEGIN
3434 printf("%X", target[i]);
3435 END
3436 printf("\n");
3437 for (i=0;i<tllen;i++)
3438 BEGIN
3439 printf("%X", tarlow[i]);
3440 END
3441 printf("\n");
3442 END
3443
3444 return tllen;
3445 END
3446
3447
3448 /*
3449 This function is for transform Unicode to UTF-8. 23/sep/2009
3450 */
3451 int32_t icu_fromUChars(unsigned char * dest, int32_t destcap, const UChar * src, int32_t srclen)
3452 BEGIN
3453 UErrorCode err2 = U_ZERO_ERROR;
3454 int32_t tblen;
3455
3456 u_strToUTF8WithSub((char *)dest, destcap, &tblen, src, srclen, 0xfffd, NULL, &err2);
3457 if (!U_SUCCESS(err2))
3458 BEGIN
3459 printf("Error in icu_fromUChars.\n");
3460 #ifdef TRACE
3461 if (Flag_trace)
3462 TRACE_PR_LN ("Error in icu_fromUChars");
3463 #endif /* TRACE */
3464 END
3465
3466 return tblen;
3467 END
3468
3469 int32_t icu_toUChar32s(BufType_T buf, BufPointer_T bf_ptr,BufPointer_T len,UChar32 * target, int32_t tarcap, UChar * buf16)
3470 BEGIN
3471 UErrorCode err1 = U_ZERO_ERROR;
3472 int32_t tulen;
3473
3474 u_strFromUTF8WithSub(buf16, tarcap, &tulen, (char *)&buf[bf_ptr], len, 0xfffd, NULL, &err1);
3475 if (!U_SUCCESS(err1))
3476 BEGIN
3477 printf("Error in icu_toUChar32s.\n");
3478 #ifdef TRACE
3479 if (Flag_trace)
3480 TRACE_PR_LN ("Error in icu_toUChar32s");
3481 #endif /* TRACE */
3482 END
3483 err1 = U_ZERO_ERROR;
3484 u_strToUTF32WithSub(target, tarcap, &tulen, buf16, -1, 0xfffd, NULL, &err1);
3485 if (!U_SUCCESS(err1))
3486 BEGIN
3487 printf("Error in icu_toUChar32s.\n");
3488 #ifdef TRACE
3489 if (Flag_trace)
3490 TRACE_PR_LN ("Error in icu_toUChar32s");
3491 #endif /* TRACE */
3492 END
3493 return tulen;
3494 END
3495
3496 int32_t icu_fromUChar32s(unsigned char * dest, int32_t destcap, const UChar32 * src, int32_t srclen, UChar * buf16)
3497 BEGIN
3498 UErrorCode err2 = U_ZERO_ERROR;
3499 int32_t tblen;
3500
3501 u_strFromUTF32WithSub(buf16, destcap, &tblen, src, srclen, 0xfffd, NULL, &err2);
3502 if (!U_SUCCESS(err2))
3503 BEGIN
3504 printf("Error in icu_fromUChar32s.\n");
3505 #ifdef TRACE
3506 if (Flag_trace)
3507 TRACE_PR_LN ("Error in icu_fromUChar32s");
3508 #endif /* TRACE */
3509 END
3510 err2 = U_ZERO_ERROR;
3511 u_strToUTF8WithSub((char *)dest, destcap, &tblen, buf16, -1, 0xfffd, NULL, &err2);
3512 if (!U_SUCCESS(err2))
3513 BEGIN
3514 printf("Error in icu_fromUChar32s.\n");
3515 #ifdef TRACE
3516 if (Flag_trace)
3517 TRACE_PR_LN ("Error in icu_fromUChar32s");
3518 #endif /* TRACE */
3519 END
3520 return tblen;
3521 END
3522 #endif
3523 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3524
3525
3526
3527 /***************************************************************************
3528 * WEB section number: 234
3529 * ~~~~~~~~~~~~~~~~~~~
3530 * This one is just a warning, not an error. It's for when something
3531 * isn't (or might not be) quite right with a macro name.
3532 ***************************************************************************/
3533 void macro_warn_print (void)
3534 BEGIN
3535 PRINT ("Warning--string name \"");
3536 PRINT_TOKEN;
3537 PRINT ("\" is ");
3538 END
3539 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 234 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3540
3541
3542
3543
3544 /***************************************************************************
3545 * WEB section number: 54
3546 * ~~~~~~~~~~~~~~~~~~~
3547 * Once a sequence of characters has been appended to |str_pool|, it
3548 * officially becomes a string when the function |make_string| is called.
3549 * It returns the string number of the string it just made.
3550 ***************************************************************************/
3551 StrNumber_T make_string (void)
3552 BEGIN
3553 if (str_ptr == Max_Strings)
3554 BEGIN
3555 BIBTEX_OVERFLOW ("number of strings ", Max_Strings);
3556 END
3557 INCR (str_ptr);
3558 str_start[str_ptr] = pool_ptr;
3559 return (str_ptr - 1);
3560 END
3561 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 54 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3562
3563
3564
3565
3566 /***************************************************************************
3567 * WEB section number: 18
3568 * ~~~~~~~~~~~~~~~~~~~
3569 *
3570 ***************************************************************************/
3571 void mark_error (void)
3572 BEGIN
3573 if (history < ERROR_MESSAGE)
3574 BEGIN
3575 history = ERROR_MESSAGE;
3576 err_count = 1;
3577 END
3578 else
3579 BEGIN
3580 INCR (err_count);
3581 END
3582 END
3583
3584
3585 void mark_fatal (void)
3586 BEGIN
3587 history = FATAL_MESSAGE;
3588 END
3589
3590
3591 void mark_warning (void)
3592 BEGIN
3593 if (history == WARNING_MESSAGE)
3594 BEGIN
3595 INCR (err_count);
3596 END
3597 else if (history == SPOTLESS)
3598 BEGIN
3599 history = WARNING_MESSAGE;
3600 err_count = 1;
3601 END
3602 END
3603 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 18 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3604
3605
3606
3607
3608 /***************************************************************************
3609 * WEB section number: 384
3610 * ~~~~~~~~~~~~~~~~~~~
3611 * This module, starting at |ex_buf_ptr|, looks in |ex_buf| for an
3612 * ``and'' surrounded by nonnull |white_space|. It stops either at
3613 * |ex_buf_length| or just past the ``and'', whichever comes first,
3614 * setting |ex_buf_ptr| accordingly. Its parameter |pop_lit_var| is
3615 * either |pop_lit3| or |pop_lit1|, depending on whether
3616 * format.name$ or num.names$ calls it.
3617 ***************************************************************************/
3618 void name_scan_for_and (StrNumber_T pop_lit_var)
3619 BEGIN
3620 brace_level = 0;
3621 preceding_white = FALSE;
3622 and_found = FALSE;
3623 while (( ! and_found) && (ex_buf_ptr < ex_buf_length))
3624 BEGIN
3625 #ifdef UTF_8
3626 UChar32 ch;
3627 U8_GET(&ex_buf[ex_buf_ptr], 0, 0, -1, ch);
3628 if (ch<0)
3629 BEGIN
3630 INCR (ex_buf_ptr);
3631 preceding_white = FALSE;
3632 continue;
3633 END
3634 switch (ch)
3635 #else
3636 switch (ex_buf[ex_buf_ptr])
3637 #endif
3638 BEGIN
3639 case 'a':
3640 case 'A':
3641 INCR (ex_buf_ptr);
3642 if (preceding_white)
3643
3644 /***************************************************************************
3645 * WEB section number: 386
3646 * ~~~~~~~~~~~~~~~~~~~
3647 * When we come here |ex_buf_ptr| is just past the ``a'' or ``A'', and when
3648 * we leave it's either at the same place or, if we found an ``and'', at
3649 * the following |white_space| character.
3650 ***************************************************************************/
3651 BEGIN
3652 if (ex_buf_ptr <= (ex_buf_length - 3))
3653 BEGIN
3654 if ((ex_buf[ex_buf_ptr] == 'n') || (ex_buf[ex_buf_ptr] == 'N'))
3655 BEGIN
3656 if ((ex_buf[ex_buf_ptr + 1] == 'd')
3657 || (ex_buf[ex_buf_ptr + 1] == 'D'))
3658 BEGIN
3659 if (lex_class[ex_buf[ex_buf_ptr + 2]] == WHITE_SPACE)
3660 BEGIN
3661 ex_buf_ptr = ex_buf_ptr + 2;
3662 and_found = TRUE;
3663 END
3664 END
3665 END
3666 END
3667 END
3668 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 386 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3669
3670 preceding_white = FALSE;
3671 break;
3672 #ifdef UTF_8
3673 case 0x3001: /* "、" Ideographic Comma */
3674 case 0xFF0C: /* "," Fullwidth Comma */
3675 ex_buf_ptr = ex_buf_ptr + 3;
3676 preceding_white = FALSE;
3677 and_found = TRUE;
3678 break;
3679 case 0x3000: /* " " Ideographic Space */
3680 ex_buf[ex_buf_ptr ] = SPACE;
3681 ex_buf[ex_buf_ptr+1] = SPACE;
3682 ex_buf[ex_buf_ptr+2] = SPACE;
3683 ex_buf_ptr = ex_buf_ptr + 3;
3684 preceding_white = TRUE;
3685 break;
3686 #endif
3687 case LEFT_BRACE:
3688 INCR (brace_level);
3689 INCR (ex_buf_ptr);
3690
3691 /***************************************************************************
3692 * WEB section number: 385
3693 * ~~~~~~~~~~~~~~~~~~~
3694 * When we come here |ex_buf_ptr| is just past the |left_brace|, and when
3695 * we leave it's either at |ex_buf_length| or just past the matching
3696 * |right_brace|.
3697 ***************************************************************************/
3698 BEGIN
3699 while ((brace_level > 0) && (ex_buf_ptr < ex_buf_length))
3700 BEGIN
3701 if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
3702 BEGIN
3703 DECR (brace_level);
3704 END
3705 else if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
3706 BEGIN
3707 INCR (brace_level);
3708 END
3709 INCR (ex_buf_ptr);
3710 END
3711 END
3712 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 385 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3713
3714 preceding_white = FALSE;
3715 break;
3716 case RIGHT_BRACE:
3717 decr_brace_level (pop_lit_var);
3718 INCR (ex_buf_ptr);
3719 preceding_white = FALSE;
3720 break;
3721 default:
3722 if (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE)
3723 BEGIN
3724 INCR (ex_buf_ptr);
3725 preceding_white = TRUE;
3726 END
3727 else
3728 BEGIN
3729 #ifdef UTF_8
3730 if (utf8len(ex_buf[ex_buf_ptr])>0)
3731 ex_buf_ptr = ex_buf_ptr + utf8len(ex_buf[ex_buf_ptr]);
3732 else
3733 #endif
3734 INCR (ex_buf_ptr);
3735 preceding_white = FALSE;
3736 END
3737 break;
3738 END
3739 END
3740 check_brace_level (pop_lit_var);
3741 END
3742 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 384 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3743
3744
3745
3746
3747 /***************************************************************************
3748 * WEB section number: 281
3749 * ~~~~~~~~~~~~~~~~~~~
3750 * When an entry being cross referenced doesn't exist on |cite_list|, we
3751 * complain.
3752 ***************************************************************************/
3753 void non_existent_cross_reference_er (void)
3754 BEGIN
3755 PRINT ("A bad cross reference-");
3756 bad_cross_reference_print (field_info[field_ptr]);
3757 PRINT_LN ("\", which doesn't exist");
3758 mark_error ();
3759 END
3760 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 281 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3761
3762
3763 /***************************************************************************
3764 * WEB section number: 51
3765 * ~~~~~~~~~~~~~~~~~~~
3766 * And here are the associated procedures. Note: The |TERM_OUT| file is
3767 * system dependent.
3768 ***************************************************************************/
3769 void out_pool_str (AlphaFile_T f, StrNumber_T s)
3770 BEGIN
3771 PoolPointer_T i;
3772
3773 if ((s < 0) || (s >= (str_ptr + MAX_POP)) || (s >= Max_Strings))
3774 BEGIN
3775 CONFUSION2 ("Illegal string number:%ld", (long) s);
3776 END
3777
3778 if (f != NULL)
3779 BEGIN
3780 #if defined(WIN32) && defined(KPATHSEA)
3781 #define MAX_STR 780
3782 unsigned char tmpstr[MAX_STR];
3783 int j=0;
3784 for (i=str_start[s]; i<=(str_start[s+1] - 1) && j<MAX_STR-1; i++, j++)
3785 BEGIN
3786 tmpstr[j] = xchr[str_pool[i]];
3787 END
3788 tmpstr[j] = '\0';
3789 FPUTS (tmpstr, f);
3790 #else
3791 for (i=str_start[s]; i<=(str_start[s+1] - 1); i++)
3792 BEGIN
3793 FPUTC (xchr[str_pool[i]], f);
3794 END
3795 #endif
3796 END
3797 END
3798 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 51 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3799
3800
3801
3802 /***************************************************************************
3803 * WEB section number: 321
3804 * ~~~~~~~~~~~~~~~~~~~
3805 * This procedure actually writes onto the .bbl file a line of output
3806 * (the characters from |out_buf[0]| to |out_buf[out_buf_length-1]|,
3807 * after removing trailing |white_space| characters). It also updates
3808 * |bbl_line_num|, the line counter. It writes a blank line if and only
3809 * if |out_buf| is empty. The program uses this procedure in such a way
3810 * that |out_buf| will be nonempty if there have been characters put in
3811 * it since the most recent newline$.
3812 ***************************************************************************/
3813 void output_bbl_line (void)
3814 BEGIN
3815 if (out_buf_length != 0)
3816 BEGIN
3817 while (out_buf_length > 0)
3818 BEGIN
3819 if (lex_class[out_buf[out_buf_length - 1]] == WHITE_SPACE)
3820 BEGIN
3821 DECR (out_buf_length);
3822 END
3823 else
3824 BEGIN
3825 goto Loop_Exit_Label;
3826 END
3827 END
3828 Loop_Exit_Label: if (out_buf_length == 0)
3829 BEGIN
3830 goto Exit_Label;
3831 END
3832 out_buf_ptr = 0;
3833 while (out_buf_ptr < out_buf_length)
3834 BEGIN
3835 FPUTC (xchr[out_buf[out_buf_ptr]], bbl_file);
3836 INCR (out_buf_ptr);
3837 END
3838 END
3839 FPUTC ('\n', bbl_file);
3840 INCR (bbl_line_num);
3841 out_buf_length = 0;
3842 Exit_Label: DO_NOTHING;
3843 END
3844 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 321 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3845
3846
3847
3848 /***************************************************************************
3849 * WEB section number: 82
3850 * ~~~~~~~~~~~~~~~~~~~
3851 * And here are the associated procedures. Note: The |term_out| file is
3852 * system dependent.
3853 ***************************************************************************/
3854 void out_token (AlphaFile_T f)
3855 BEGIN
3856 BufPointer_T i;
3857
3858 if (f != NULL)
3859 BEGIN
3860 i = buf_ptr1;
3861 while (i < buf_ptr2)
3862 BEGIN
3863 FPUTC (xchr[buffer[i]], f);
3864 INCR (i);
3865 END
3866 END
3867 END
3868 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 82 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3869
3870
3871
3872
3873 /***************************************************************************
3874 * WEB section number: 53
3875 * ~~~~~~~~~~~~~~~~~~~
3876 * To test if there is room to append |l| more characters to |str_pool|,
3877 * we shall write |str_room(l)|, which aborts \BibTeX\ and gives an
3878 * error message if there isn't enough room.
3879 ***************************************************************************/
3880 void pool_overflow (void)
3881 BEGIN
3882 BIB_XRETALLOC ("str_pool", str_pool, ASCIICode_T,
3883 Pool_Size, Pool_Size + POOL_SIZE);
3884 END
3885 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 53 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3886
3887
3888
3889
3890 /***************************************************************************
3891 * WEB section number: 309
3892 * ~~~~~~~~~~~~~~~~~~~
3893 * This procedure pops the stack, checking for, and trying to recover
3894 * from, stack underflow. (Actually, this procedure is really a
3895 * function, since it returns the two values through its |var|
3896 * parameters.) Also, if the literal being popped is a |stk_str| that's
3897 * been created during the execution of the current .bst command, pop
3898 * it from |str_pool| as well (it will be the string corresponding to
3899 * |str_ptr-1|). Note that when this happens, the string is no longer
3900 * `officially' available so that it must be used before anything else is
3901 * added to |str_pool|.
3902 ***************************************************************************/
3903 void pop_lit_stk (Integer_T *poplit, StkType_T *poptype)
3904 BEGIN
3905 if (lit_stk_ptr == 0)
3906 BEGIN
3907 BST_EX_WARN ("You can't pop an empty literal stack");
3908 *poptype = STK_EMPTY;
3909 END
3910 else
3911 BEGIN
3912 DECR (lit_stk_ptr);
3913 *poplit = lit_stack[lit_stk_ptr];
3914 *poptype = lit_stk_type[lit_stk_ptr];
3915 if (*poptype == STK_STR)
3916 BEGIN
3917 if (*poplit >= cmd_str_ptr)
3918 BEGIN
3919 if (*poplit != (str_ptr - 1))
3920 BEGIN
3921 CONFUSION ("Nontop top of string stack");
3922 END
3923 FLUSH_STRING;
3924 END
3925 END
3926 END
3927 END
3928 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 309 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3929
3930
3931
3932
3933 /***************************************************************************
3934 * WEB section number: 142
3935 * ~~~~~~~~~~~~~~~~~~~
3936 * Here we close the current-level .aux file and go back up a level,
3937 * if possible, by DECRing |aux_ptr|.
3938 ***************************************************************************/
3939 void pop_the_aux_stack (void)
3940 BEGIN
3941 a_close (CUR_AUX_FILE);
3942 if (aux_ptr == 0)
3943 BEGIN
3944 debug_msg (DBG_MISC, "calling longjmp (Aux_Done_Flag) ... ");
3945 longjmp (Aux_Done_Flag, 1);
3946 return;
3947 END
3948 else
3949 BEGIN
3950 DECR (aux_ptr);
3951 END
3952 END
3953 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 142 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3954
3955
3956
3957
3958 /***************************************************************************
3959 * WEB section number: 314
3960 * ~~~~~~~~~~~~~~~~~~~
3961 * This procedure pops and prints the top of the stack; when the stack is
3962 * empty the procedure |pop_lit_stk| complains.
3963 ***************************************************************************/
3964 void pop_top_and_print (void)
3965 BEGIN
3966 Integer_T stk_lt;
3967 StkType_T stk_tp;
3968
3969 pop_lit_stk (&stk_lt, &stk_tp);
3970 if (stk_tp == STK_EMPTY)
3971 BEGIN
3972 PRINT_LN ("Empty literal");
3973 END
3974 else
3975 BEGIN
3976 print_lit (stk_lt, stk_tp);
3977 END
3978 END
3979 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 314 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
3980
3981
3982
3983
3984 /***************************************************************************
3985 * WEB section number: 315
3986 * ~~~~~~~~~~~~~~~~~~~
3987 * This procedure pops and prints the whole stack.
3988 ***************************************************************************/
3989 void pop_whole_stack (void)
3990 BEGIN
3991 while (lit_stk_ptr > 0)
3992 BEGIN
3993 pop_top_and_print ();
3994 END
3995 END
3996 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 315 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/