| 1 |
/*- |
| 2 |
****************************************************************************** |
| 3 |
****************************************************************************** |
| 4 |
** |
| 5 |
** MODULE |
| 6 |
** |
| 7 |
** file: bibtex-1.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 first 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 |
** aux_err_stuff_after_right_brace |
| 30 |
** aux_err_white_space_in_argument |
| 31 |
** aux_input_command |
| 32 |
** bad_argument_token |
| 33 |
** bad_cross_reference_print |
| 34 |
** bib_cmd_confusion |
| 35 |
** bib_equals_sign_print |
| 36 |
** bib_err_print |
| 37 |
** bib_field_too_long_print |
| 38 |
** bib_id_print |
| 39 |
** bib_ln_num_print |
| 40 |
** bib_one_of_two_print |
| 41 |
** bib_unbalanced_braces_print |
| 42 |
** bib_warn_print |
| 43 |
** brace_lvl_one_letters_complaint |
| 44 |
** braces_unbalanced_complaint |
| 45 |
** bst_1print_string_size_exceeded |
| 46 |
** bst_2print_string_size_exceeded |
| 47 |
** bst_cant_mess_with_entries_prin |
| 48 |
** bst_entry_command |
| 49 |
** bst_err_print_and_look_for_blan |
| 50 |
** bst_execute_command |
| 51 |
** bst_ex_warn_print |
| 52 |
** bst_function_command |
| 53 |
** bst_id_print |
| 54 |
** bst_integers_command |
| 55 |
** build_in |
| 56 |
** case_conversion_confusion |
| 57 |
** check_brace_level |
| 58 |
** check_cite_overflow |
| 59 |
** check_command_execution |
| 60 |
** check_field_overflow |
| 61 |
** cite_key_disappeared_confusion |
| 62 |
** compress_bib_white |
| 63 |
** decr_brace_level |
| 64 |
** eat_bib_print |
| 65 |
** eat_bib_white_space |
| 66 |
** eat_bst_print |
| 67 |
** eat_bst_white_space |
| 68 |
** enough_text_chars |
| 69 |
** |
| 70 |
** AUTHORS |
| 71 |
** |
| 72 |
** Original WEB translation to C, conversion to "big" (32-bit) capacity, |
| 73 |
** addition of run-time selectable capacity and 8-bit support extensions |
| 74 |
** by: |
| 75 |
** |
| 76 |
** Niel Kempson |
| 77 |
** Snowy Owl Systems Limited, Cheltenham, England |
| 78 |
** E-mail: [email protected] |
| 79 |
** |
| 80 |
** 8-bit support extensions also by: |
| 81 |
** |
| 82 |
** Alejandro Aguilar-Sierra |
| 83 |
** Centro de Ciencias de la Atm\'osfera, |
| 84 |
** Universidad Nacional Aut\'onoma de M\'exico, M\'exico |
| 85 |
** E-mail: [email protected] |
| 86 |
** |
| 87 |
** COPYRIGHT |
| 88 |
** |
| 89 |
** This implementation copyright (c) 1991-1995 by Niel Kempson |
| 90 |
** and copyright (c) 1995 by Alejandro Aguilar-Sierra. |
| 91 |
** |
| 92 |
** This program is free software; you can redistribute it and/or |
| 93 |
** modify it under the terms of the GNU General Public License as |
| 94 |
** published by the Free Software Foundation; either version 1, or |
| 95 |
** (at your option) any later version. |
| 96 |
** |
| 97 |
** This program is distributed in the hope that it will be useful, |
| 98 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 99 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 100 |
** General Public License for more details. |
| 101 |
** |
| 102 |
** You should have received a copy of the GNU General Public License |
| 103 |
** along with this program; if not, write to the Free Software |
| 104 |
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 105 |
** |
| 106 |
** In other words, you are welcome to use, share and improve this |
| 107 |
** program. You are forbidden to forbid anyone else to use, share |
| 108 |
** and improve what you give them. Help stamp out software-hoarding! |
| 109 |
** |
| 110 |
** ACKNOWLEDGEMENT |
| 111 |
** |
| 112 |
** The original BibTeX was written by Oren Patashnik using Donald |
| 113 |
** Knuth's WEB system. This format produces a PASCAL program for |
| 114 |
** execution and a TeX documented version of the source code. This |
| 115 |
** program started as a (manual) translation of the WEB source into C. |
| 116 |
** |
| 117 |
** CHANGE LOG |
| 118 |
** |
| 119 |
** $Log: bibtex-1.c,v $ |
| 120 |
** Revision 3.71 1996/08/18 20:47:30 kempson |
| 121 |
** Official release 3.71 (see HISTORY file for details). |
| 122 |
** |
| 123 |
** Revision 3.70 1996/04/08 10:08:40 kempson |
| 124 |
** Final documentation & cosmetic changes for official release 3.70. |
| 125 |
** |
| 126 |
** Revision 3.5 1995/09/24 20:44:37 kempson |
| 127 |
** Many changes for final beta test version. |
| 128 |
** |
| 129 |
** Revision 3.4 1995/04/09 22:15:38 kempson |
| 130 |
** Placed under RCS control |
| 131 |
** |
| 132 |
****************************************************************************** |
| 133 |
****************************************************************************** |
| 134 |
*/ |
| 135 |
|
| 136 |
#ifdef HAVE_CONFIG_H |
| 137 |
#include <config.h> |
| 138 |
#endif |
| 139 |
|
| 140 |
#include "sysdep.h" |
| 141 |
#include "bibtex.h" |
| 142 |
#include "datatype.h" |
| 143 |
#include "gblprocs.h" |
| 144 |
#include "gblvars.h" |
| 145 |
#include "utils.h" |
| 146 |
#include "version.h" |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
/*************************************************************************** |
| 151 |
* WEB section number: 61 |
| 152 |
* ~~~~~~~~~~~~~~~~~~~ |
| 153 |
* This procedure copies the default logical area name |area| into the |
| 154 |
* array |name_of_file| starting at position 1, after shifting up the rest |
| 155 |
* of the filename. It also sets the global variable |name_length| to the |
| 156 |
* appropriate value. |
| 157 |
* |
| 158 |
* REMOVED: |add_area|. |
| 159 |
***************************************************************************/ |
| 160 |
|
| 161 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 61 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
/*************************************************************************** |
| 166 |
* WEB section number: 320 |
| 167 |
* ~~~~~~~~~~~~~~~~~~~ |
| 168 |
* This procedure adds to the execution buffer the given string in |
| 169 |
* |str_pool| if it will fit. It assumes the global variable |
| 170 |
* |ex_buf_length| gives the length of the current string in |ex_buf|, and |
| 171 |
* thus also gives the location of the next character. |
| 172 |
***************************************************************************/ |
| 173 |
void add_buf_pool (StrNumber_T p_str) |
| 174 |
BEGIN |
| 175 |
p_ptr1 = str_start[p_str]; |
| 176 |
p_ptr2 = str_start[p_str + 1]; |
| 177 |
if ((ex_buf_length + (p_ptr2 - p_ptr1)) > Buf_Size) |
| 178 |
BEGIN |
| 179 |
buffer_overflow (); |
| 180 |
END |
| 181 |
ex_buf_ptr = ex_buf_length; |
| 182 |
while (p_ptr1 < p_ptr2) |
| 183 |
BEGIN |
| 184 |
APPEND_EX_BUF_CHAR(str_pool[p_ptr1]); |
| 185 |
INCR (p_ptr1); |
| 186 |
END |
| 187 |
ex_buf_length = ex_buf_ptr; |
| 188 |
END |
| 189 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 320 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
/*************************************************************************** |
| 195 |
* WEB section number: 265 |
| 196 |
* ~~~~~~~~~~~~~~~~~~~ |
| 197 |
* This procedure adds (or restores) to |cite_list| a cite key; it is |
| 198 |
* called only when |all_entries| is |true| or when adding |
| 199 |
* cross references, and it assumes that |cite_loc| and |lc_cite_loc| are |
| 200 |
* set. It also INCRs its argument. |
| 201 |
***************************************************************************/ |
| 202 |
void add_database_cite (CiteNumber_T *new_cite) |
| 203 |
BEGIN |
| 204 |
check_cite_overflow (*new_cite); |
| 205 |
check_field_overflow (num_fields * (*new_cite + 1)); |
| 206 |
cite_list[*new_cite] = hash_text[cite_loc]; |
| 207 |
ilk_info[cite_loc] = *new_cite; |
| 208 |
ilk_info[lc_cite_loc] = cite_loc; |
| 209 |
INCR (*new_cite); |
| 210 |
END |
| 211 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 265 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
/*************************************************************************** |
| 217 |
* WEB section number: 60 |
| 218 |
* ~~~~~~~~~~~~~~~~~~~ |
| 219 |
* This procedure copies file extension |ext| into the array |
| 220 |
* |name_of_file| starting at position |name_length+1|. It also sets the |
| 221 |
* global variable |name_length| to the appropriate value. |
| 222 |
* |
| 223 |
* NOTE: because C arrays start at index 0, not 1, the subscripts of array |
| 224 |
* |name_of_file| are generally 1 less than those in the WEB source. |
| 225 |
***************************************************************************/ |
| 226 |
void add_extension (StrNumber_T ext) |
| 227 |
BEGIN |
| 228 |
PoolPointer_T p_ptr; |
| 229 |
|
| 230 |
name_ptr = name_length; |
| 231 |
p_ptr = str_start[ext]; |
| 232 |
while (p_ptr < str_start[ext + 1]) |
| 233 |
BEGIN |
| 234 |
name_of_file[name_ptr] = CHR (str_pool[p_ptr]); |
| 235 |
INCR (name_ptr); |
| 236 |
INCR (p_ptr); |
| 237 |
END |
| 238 |
name_length = name_length + LENGTH (ext); |
| 239 |
name_of_file[name_length] = 0; |
| 240 |
END |
| 241 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 60 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
/*************************************************************************** |
| 247 |
* WEB section number: 322 |
| 248 |
* ~~~~~~~~~~~~~~~~~~~ |
| 249 |
* This procedure adds to the output buffer the given string in |
| 250 |
* |str_pool|. It assumes the global variable |out_buf_length| gives the |
| 251 |
* length of the current string in |out_buf|, and thus also gives the |
| 252 |
* location for the next character. If there are enough characters |
| 253 |
* present in the output buffer, it writes one or more lines out to the |
| 254 |
* .bbl file. It breaks a line only at a |white_space| character, |
| 255 |
* and when it does, it adds two |space|s to the next output line. |
| 256 |
***************************************************************************/ |
| 257 |
void add_out_pool (StrNumber_T p_str) |
| 258 |
BEGIN |
| 259 |
BufPointer_T break_ptr; |
| 260 |
BufPointer_T end_ptr; |
| 261 |
Boolean_T break_pt_found; |
| 262 |
Boolean_T unbreakable_tail; |
| 263 |
|
| 264 |
p_ptr1 = str_start[p_str]; |
| 265 |
p_ptr2 = str_start[p_str + 1]; |
| 266 |
if ((out_buf_length + (p_ptr2 - p_ptr1)) > Buf_Size) |
| 267 |
BEGIN |
| 268 |
buffer_overflow (); |
| 269 |
END |
| 270 |
out_buf_ptr = out_buf_length; |
| 271 |
while (p_ptr1 < p_ptr2) |
| 272 |
BEGIN |
| 273 |
out_buf[out_buf_ptr] = str_pool[p_ptr1]; |
| 274 |
INCR (p_ptr1); |
| 275 |
INCR (out_buf_ptr); |
| 276 |
END |
| 277 |
out_buf_length = out_buf_ptr; |
| 278 |
unbreakable_tail = FALSE; |
| 279 |
while ((out_buf_length > Max_Print_Line) && ! unbreakable_tail) |
| 280 |
|
| 281 |
/*************************************************************************** |
| 282 |
* WEB section number: 323 |
| 283 |
* ~~~~~~~~~~~~~~~~~~~ |
| 284 |
* Here we break the line by looking for a |white_space| character, |
| 285 |
* backwards from |out_buf[max_print_line]| until |
| 286 |
* |out_buf[min_print_line]|; we break at the |white_space| and indent |
| 287 |
* the next line two |space|s. The next module handles things when |
| 288 |
* there's no |white_space| character to break at. (It seems that the |
| 289 |
* annoyances to the average user of a warning message when there's an |
| 290 |
* output line longer than |max_print_line| outweigh the benefits, so we |
| 291 |
* don't issue such warnings in the current code.) |
| 292 |
***************************************************************************/ |
| 293 |
BEGIN |
| 294 |
end_ptr = out_buf_length; |
| 295 |
out_buf_ptr = Max_Print_Line; |
| 296 |
break_pt_found = FALSE; |
| 297 |
while ((lex_class[out_buf[out_buf_ptr]] != WHITE_SPACE) |
| 298 |
&& (out_buf_ptr >= MIN_PRINT_LINE)) |
| 299 |
BEGIN |
| 300 |
DECR (out_buf_ptr); |
| 301 |
END |
| 302 |
if (out_buf_ptr == (MIN_PRINT_LINE - 1)) |
| 303 |
|
| 304 |
/*************************************************************************** |
| 305 |
* WEB section number: 324 |
| 306 |
* ~~~~~~~~~~~~~~~~~~~ |
| 307 |
* If there's no |white_space| character up through |
| 308 |
* |out_buf[max_print_line]|, we instead break the line at the first |
| 309 |
* following |white_space| character, if one exists. And if, starting |
| 310 |
* with that |white_space| character, there are multiple consecutive |
| 311 |
* |white_space| characters, |out_buf_ptr| points to the last of them. |
| 312 |
* If no |white_space| character exists, we haven't found a viable break |
| 313 |
* point, so we don't break the line (yet). |
| 314 |
***************************************************************************/ |
| 315 |
BEGIN |
| 316 |
out_buf_ptr = Max_Print_Line + 1; |
| 317 |
while (out_buf_ptr < end_ptr) |
| 318 |
BEGIN |
| 319 |
#ifdef UTF_8 |
| 320 |
if (lex_class[out_buf[out_buf_ptr]] == WHITE_SPACE) |
| 321 |
BEGIN |
| 322 |
UChar32 ch; |
| 323 |
U8_GET_OR_FFFD(out_buf, out_buf_ptr-4, out_buf_ptr-1, -1, ch); |
| 324 |
switch ( ublock_getCode(ch) ) |
| 325 |
BEGIN |
| 326 |
case UBLOCK_BASIC_LATIN: |
| 327 |
case UBLOCK_LATIN_1_SUPPLEMENT: |
| 328 |
case UBLOCK_LATIN_EXTENDED_A: |
| 329 |
case UBLOCK_LATIN_EXTENDED_B: |
| 330 |
case UBLOCK_LATIN_EXTENDED_C: |
| 331 |
case UBLOCK_LATIN_EXTENDED_D: |
| 332 |
case UBLOCK_LATIN_EXTENDED_E: |
| 333 |
#if defined(U_ICU_VERSION_MAJOR_NUM) && (U_ICU_VERSION_MAJOR_NUM > 69) |
| 334 |
case UBLOCK_LATIN_EXTENDED_F: |
| 335 |
case UBLOCK_LATIN_EXTENDED_G: |
| 336 |
#endif |
| 337 |
case UBLOCK_LATIN_EXTENDED_ADDITIONAL: |
| 338 |
case UBLOCK_GREEK: |
| 339 |
case UBLOCK_GREEK_EXTENDED: |
| 340 |
case UBLOCK_CYRILLIC: |
| 341 |
case UBLOCK_CYRILLIC_SUPPLEMENT: |
| 342 |
case UBLOCK_CYRILLIC_EXTENDED_A: |
| 343 |
case UBLOCK_CYRILLIC_EXTENDED_B: |
| 344 |
case UBLOCK_CYRILLIC_EXTENDED_C: |
| 345 |
#if defined(U_ICU_VERSION_MAJOR_NUM) && (U_ICU_VERSION_MAJOR_NUM > 71) |
| 346 |
case UBLOCK_CYRILLIC_EXTENDED_D: |
| 347 |
#endif |
| 348 |
case UBLOCK_HANGUL_SYLLABLES: |
| 349 |
goto Loop1_Exit; /* break line */ |
| 350 |
break; |
| 351 |
END |
| 352 |
END |
| 353 |
INCR (out_buf_ptr); /* do not break line */ |
| 354 |
#else |
| 355 |
if (lex_class[out_buf[out_buf_ptr]] != WHITE_SPACE) |
| 356 |
BEGIN |
| 357 |
INCR (out_buf_ptr); |
| 358 |
END |
| 359 |
else |
| 360 |
BEGIN |
| 361 |
goto Loop1_Exit; |
| 362 |
END |
| 363 |
#endif |
| 364 |
END |
| 365 |
Loop1_Exit: |
| 366 |
if (out_buf_ptr == end_ptr) |
| 367 |
BEGIN |
| 368 |
unbreakable_tail = TRUE; |
| 369 |
END |
| 370 |
else |
| 371 |
BEGIN |
| 372 |
break_pt_found = TRUE; |
| 373 |
while (out_buf_ptr + 1 < end_ptr) |
| 374 |
BEGIN |
| 375 |
if (lex_class[out_buf[out_buf_ptr + 1]] == WHITE_SPACE) |
| 376 |
BEGIN |
| 377 |
INCR (out_buf_ptr); |
| 378 |
END |
| 379 |
else |
| 380 |
BEGIN |
| 381 |
goto Loop2_Exit; |
| 382 |
END |
| 383 |
END |
| 384 |
Loop2_Exit: DO_NOTHING; |
| 385 |
END |
| 386 |
END |
| 387 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 324 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 388 |
|
| 389 |
else |
| 390 |
BEGIN |
| 391 |
break_pt_found = TRUE; |
| 392 |
END |
| 393 |
if (break_pt_found) |
| 394 |
BEGIN |
| 395 |
out_buf_length = out_buf_ptr; |
| 396 |
break_ptr = out_buf_length + 1; |
| 397 |
output_bbl_line (); |
| 398 |
out_buf[0] = SPACE; |
| 399 |
out_buf[1] = SPACE; |
| 400 |
out_buf_ptr = 2; |
| 401 |
tmp_ptr = break_ptr; |
| 402 |
while (tmp_ptr < end_ptr) |
| 403 |
BEGIN |
| 404 |
out_buf[out_buf_ptr] = out_buf[tmp_ptr]; |
| 405 |
INCR (out_buf_ptr); |
| 406 |
INCR (tmp_ptr); |
| 407 |
END |
| 408 |
out_buf_length = end_ptr - break_ptr + 2; |
| 409 |
END |
| 410 |
END |
| 411 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 323 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 412 |
|
| 413 |
END |
| 414 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 322 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
/*************************************************************************** |
| 420 |
* WEB section number: 318 |
| 421 |
* ~~~~~~~~~~~~~~~~~~~ |
| 422 |
* This procedure adds to |str_pool| the string from |ex_buf[0]| through |
| 423 |
* |ex_buf[ex_buf_length-1]| if it will fit. It assumes the global |
| 424 |
* variable |ex_buf_length| gives the length of the current string in |
| 425 |
* |ex_buf|. It then pushes this string onto the literal stack. |
| 426 |
***************************************************************************/ |
| 427 |
void add_pool_buf_and_push (void) |
| 428 |
BEGIN |
| 429 |
STR_ROOM (ex_buf_length); |
| 430 |
ex_buf_ptr = 0; |
| 431 |
while (ex_buf_ptr < ex_buf_length) |
| 432 |
BEGIN |
| 433 |
APPEND_CHAR (ex_buf[ex_buf_ptr]); |
| 434 |
INCR (ex_buf_ptr); |
| 435 |
END |
| 436 |
push_lit_stk (make_string (), STK_STR); |
| 437 |
END |
| 438 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 318 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
/*************************************************************************** |
| 444 |
* WEB section number: 169 |
| 445 |
* ~~~~~~~~~~~~~~~~~~~ |
| 446 |
* This macro complains if we've already encountered a function to be |
| 447 |
* inserted into the hash table. |
| 448 |
***************************************************************************/ |
| 449 |
void already_seen_function_print (HashLoc_T seen_fn_loc) |
| 450 |
BEGIN |
| 451 |
PRINT_POOL_STR (hash_text[seen_fn_loc]); |
| 452 |
PRINT (" is already a type \""); |
| 453 |
print_fn_class (seen_fn_loc); |
| 454 |
PRINT_LN ("\" function name"); |
| 455 |
BST_ERR_PRINT_AND_LOOK_FOR_BLAN; |
| 456 |
Exit_Label: DO_NOTHING; |
| 457 |
END |
| 458 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
/*************************************************************************** |
| 464 |
* WEB section number: 120 |
| 465 |
* ~~~~~~~~~~~~~~~~~~~ |
| 466 |
* A \bibdata command will have its arguments between braces and |
| 467 |
* separated by commas. There must be exactly one such command in the |
| 468 |
* .aux file(s). All upper-case letters are converted to lower case. |
| 469 |
***************************************************************************/ |
| 470 |
void aux_bib_data_command (void) |
| 471 |
BEGIN |
| 472 |
if (bib_seen) |
| 473 |
BEGIN |
| 474 |
AUX_ERR_ILLEGAL_ANOTHER (N_AUX_BIBDATA); |
| 475 |
END |
| 476 |
bib_seen = TRUE; |
| 477 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 478 |
BEGIN |
| 479 |
INCR (buf_ptr2); |
| 480 |
if ( ! scan2_white (RIGHT_BRACE, COMMA)) |
| 481 |
BEGIN |
| 482 |
AUX_ERR_NO_RIGHT_BRACE; |
| 483 |
END |
| 484 |
if (lex_class[SCAN_CHAR] == WHITE_SPACE) |
| 485 |
BEGIN |
| 486 |
AUX_ERR_WHITE_SPACE_IN_ARGUMENT; |
| 487 |
END |
| 488 |
if ((last > (buf_ptr2 + 1)) && (SCAN_CHAR == RIGHT_BRACE)) |
| 489 |
BEGIN |
| 490 |
AUX_ERR_STUFF_AFTER_RIGHT_BRACE; |
| 491 |
END |
| 492 |
|
| 493 |
/*************************************************************************** |
| 494 |
* WEB section number: 123 |
| 495 |
* ~~~~~~~~~~~~~~~~~~~ |
| 496 |
* Now we add the just-found argument to |bib_list| if it hasn't already |
| 497 |
* been encountered as a \bibdata argument and if, after appending |
| 498 |
* the |s_bib_extension| string, the resulting file name can be opened. |
| 499 |
***************************************************************************/ |
| 500 |
BEGIN |
| 501 |
if (bib_ptr == Max_Bib_Files) |
| 502 |
BEGIN |
| 503 |
BIB_XRETALLOC_NOSET ("bib_file", bib_file, AlphaFile_T, |
| 504 |
Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES); |
| 505 |
BIB_XRETALLOC_NOSET ("bib_list", bib_list, StrNumber_T, |
| 506 |
Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES); |
| 507 |
BIB_XRETALLOC ("s_preamble", s_preamble, StrNumber_T, |
| 508 |
Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES); |
| 509 |
END |
| 510 |
CUR_BIB_STR = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 511 |
BIB_FILE_ILK, DO_INSERT)]; |
| 512 |
if (hash_found) |
| 513 |
BEGIN |
| 514 |
OPEN_BIBDATA_AUX_ERR ("This database file appears more than once: "); |
| 515 |
END |
| 516 |
start_name (CUR_BIB_STR); |
| 517 |
add_extension (s_bib_extension); |
| 518 |
if ( ! a_open_in (&CUR_BIB_FILE, BIB_FILE_SEARCH_PATH)) |
| 519 |
BEGIN |
| 520 |
BEGIN |
| 521 |
OPEN_BIBDATA_AUX_ERR ("I couldn't open database file "); |
| 522 |
perror ("\nReason"); |
| 523 |
END |
| 524 |
END |
| 525 |
|
| 526 |
#ifdef TRACE |
| 527 |
if (Flag_trace) { |
| 528 |
TRACE_PR_POOL_STR (CUR_BIB_STR); |
| 529 |
TRACE_PR_POOL_STR (s_bib_extension); |
| 530 |
TRACE_PR_LN (" is a bibdata file"); |
| 531 |
} |
| 532 |
#endif /* TRACE */ |
| 533 |
|
| 534 |
INCR (bib_ptr); |
| 535 |
END |
| 536 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 123 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 537 |
|
| 538 |
END |
| 539 |
Exit_Label: DO_NOTHING; |
| 540 |
END |
| 541 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 120 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
/*************************************************************************** |
| 547 |
* WEB section number: 126 |
| 548 |
* ~~~~~~~~~~~~~~~~~~~ |
| 549 |
* A \bibstyle command will have exactly one argument, and it will be |
| 550 |
* between braces. There must be exactly one such command in the .aux |
| 551 |
* file(s). All upper-case letters are converted to lower case. |
| 552 |
***************************************************************************/ |
| 553 |
void aux_bib_style_command (void) |
| 554 |
BEGIN |
| 555 |
if (bst_seen) |
| 556 |
BEGIN |
| 557 |
AUX_ERR_ILLEGAL_ANOTHER (N_AUX_BIBSTYLE); |
| 558 |
END |
| 559 |
bst_seen = TRUE; |
| 560 |
INCR (buf_ptr2); |
| 561 |
if ( ! scan1_white (RIGHT_BRACE)) |
| 562 |
BEGIN |
| 563 |
AUX_ERR_NO_RIGHT_BRACE; |
| 564 |
END |
| 565 |
if (lex_class[SCAN_CHAR] == WHITE_SPACE) |
| 566 |
BEGIN |
| 567 |
AUX_ERR_WHITE_SPACE_IN_ARGUMENT; |
| 568 |
END |
| 569 |
if (last > (buf_ptr2 + 1)) |
| 570 |
BEGIN |
| 571 |
AUX_ERR_STUFF_AFTER_RIGHT_BRACE; |
| 572 |
END |
| 573 |
|
| 574 |
/*************************************************************************** |
| 575 |
* WEB section number: 127 |
| 576 |
* ~~~~~~~~~~~~~~~~~~~ |
| 577 |
* Now we open the file whose name is the just-found argument appended |
| 578 |
* with the |s_bst_extension| string, if possible. |
| 579 |
***************************************************************************/ |
| 580 |
BEGIN |
| 581 |
bst_str = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 582 |
BST_FILE_ILK, DO_INSERT)]; |
| 583 |
if (hash_found) |
| 584 |
BEGIN |
| 585 |
|
| 586 |
#ifdef TRACE |
| 587 |
if (Flag_trace) |
| 588 |
print_bst_name (); |
| 589 |
#endif /* TRACE */ |
| 590 |
|
| 591 |
CONFUSION ("Already encountered style file"); |
| 592 |
END |
| 593 |
start_name (bst_str); |
| 594 |
add_extension (s_bst_extension); |
| 595 |
if ( ! a_open_in (&bst_file, BST_FILE_SEARCH_PATH)) |
| 596 |
BEGIN |
| 597 |
BEGIN |
| 598 |
PRINT ("I couldn't open style file "); |
| 599 |
print_bst_name (); |
| 600 |
perror ("\nReason"); |
| 601 |
bst_str = 0; |
| 602 |
AUX_ERR_RETURN; |
| 603 |
END |
| 604 |
END |
| 605 |
PRINT ("The style file: "); |
| 606 |
print_bst_name (); |
| 607 |
END |
| 608 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 127 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 609 |
|
| 610 |
Exit_Label: DO_NOTHING; |
| 611 |
END |
| 612 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 126 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
/*************************************************************************** |
| 619 |
* WEB section number: 132 |
| 620 |
* ~~~~~~~~~~~~~~~~~~~ |
| 621 |
* A \citation command will have its arguments between braces and |
| 622 |
* separated by commas. Upper/lower cases are considered to be different |
| 623 |
* for \citation arguments, which is the same as the rest of \LaTeX\ |
| 624 |
* but different from the rest of \BibTeX. A cite key needn't exactly |
| 625 |
* case-match its corresponding database key to work, although two cite |
| 626 |
* keys that are case-mismatched will produce an error message. (A BEGIN\sl |
| 627 |
* case mismatch\/END is a mismatch, but only because of a case difference.) |
| 628 |
* |
| 629 |
* A \citation command having * as an argument indicates that the |
| 630 |
* entire database will be included (almost as if a \nocite command |
| 631 |
* that listed every cite key in the database, in order, had been given at |
| 632 |
* the corresponding spot in the .tex file). |
| 633 |
***************************************************************************/ |
| 634 |
void aux_citation_command (void) |
| 635 |
BEGIN |
| 636 |
citation_seen = TRUE; |
| 637 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 638 |
BEGIN |
| 639 |
INCR (buf_ptr2); |
| 640 |
if ( ! scan2_white (RIGHT_BRACE, COMMA)) |
| 641 |
BEGIN |
| 642 |
AUX_ERR_NO_RIGHT_BRACE; |
| 643 |
END |
| 644 |
if (lex_class[SCAN_CHAR] == WHITE_SPACE) |
| 645 |
BEGIN |
| 646 |
AUX_ERR_WHITE_SPACE_IN_ARGUMENT; |
| 647 |
END |
| 648 |
if ((last > (buf_ptr2 + 1)) && (SCAN_CHAR == RIGHT_BRACE)) |
| 649 |
BEGIN |
| 650 |
AUX_ERR_STUFF_AFTER_RIGHT_BRACE; |
| 651 |
END |
| 652 |
|
| 653 |
/*************************************************************************** |
| 654 |
* WEB section number: 133 |
| 655 |
* ~~~~~~~~~~~~~~~~~~~ |
| 656 |
* We must check if (the lower-case version of) this cite key has been |
| 657 |
* previously encountered, and proceed accordingly. The alias kludge |
| 658 |
* helps make the stack space not overflow on some machines. |
| 659 |
***************************************************************************/ |
| 660 |
BEGIN |
| 661 |
|
| 662 |
#ifdef TRACE |
| 663 |
if (Flag_trace) { |
| 664 |
TRACE_PR_TOKEN; |
| 665 |
TRACE_PR (" cite key encountered"); |
| 666 |
} |
| 667 |
#endif /* TRACE */ |
| 668 |
|
| 669 |
/*************************************************************************** |
| 670 |
* WEB section number: 134 |
| 671 |
* ~~~~~~~~~~~~~~~~~~~ |
| 672 |
* Here we check for a \citation command having * as an |
| 673 |
* argument, indicating that the entire database will be included. |
| 674 |
***************************************************************************/ |
| 675 |
BEGIN |
| 676 |
if (TOKEN_LEN == 1) |
| 677 |
BEGIN |
| 678 |
if (buffer[buf_ptr1] == STAR) |
| 679 |
BEGIN |
| 680 |
|
| 681 |
#ifdef TRACE |
| 682 |
if (Flag_trace) |
| 683 |
TRACE_PR_LN ("---entire database to be included"); |
| 684 |
#endif /* TRACE */ |
| 685 |
|
| 686 |
if (all_entries) |
| 687 |
BEGIN |
| 688 |
PRINT_LN ("Multiple inclusions of entire database"); |
| 689 |
AUX_ERR_RETURN; |
| 690 |
END |
| 691 |
else |
| 692 |
BEGIN |
| 693 |
all_entries = TRUE; |
| 694 |
all_marker = cite_ptr; |
| 695 |
goto Next_Cite_Label; |
| 696 |
END |
| 697 |
END |
| 698 |
END |
| 699 |
END |
| 700 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 134 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 701 |
|
| 702 |
tmp_ptr = buf_ptr1; |
| 703 |
while (tmp_ptr < buf_ptr2) |
| 704 |
BEGIN |
| 705 |
ex_buf[tmp_ptr] = buffer[tmp_ptr]; |
| 706 |
INCR (tmp_ptr); |
| 707 |
END |
| 708 |
lower_case (ex_buf, buf_ptr1, TOKEN_LEN); |
| 709 |
lc_cite_loc = str_lookup (ex_buf, buf_ptr1, TOKEN_LEN, LC_CITE_ILK, |
| 710 |
DO_INSERT); |
| 711 |
if (hash_found) |
| 712 |
|
| 713 |
/*************************************************************************** |
| 714 |
* WEB section number: 135 |
| 715 |
* ~~~~~~~~~~~~~~~~~~~ |
| 716 |
* We've previously encountered the lower-case version, so we check that |
| 717 |
* the actual version exactly matches the actual version of the |
| 718 |
* previously-encountered cite key(s). |
| 719 |
***************************************************************************/ |
| 720 |
BEGIN |
| 721 |
|
| 722 |
#ifdef TRACE |
| 723 |
if (Flag_trace) |
| 724 |
TRACE_PR_LN (" previously"); |
| 725 |
#endif /* TRACE */ |
| 726 |
|
| 727 |
dummy_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, CITE_ILK, |
| 728 |
DONT_INSERT); |
| 729 |
if ( ! hash_found) |
| 730 |
BEGIN |
| 731 |
PRINT ("Case mismatch error between cite keys "); |
| 732 |
PRINT_TOKEN; |
| 733 |
PRINT (" and "); |
| 734 |
PRINT_POOL_STR (cite_list[ilk_info[ilk_info[lc_cite_loc]]]); |
| 735 |
PRINT_NEWLINE; |
| 736 |
AUX_ERR_RETURN; |
| 737 |
END |
| 738 |
END |
| 739 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 135 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 740 |
|
| 741 |
else |
| 742 |
|
| 743 |
/*************************************************************************** |
| 744 |
* WEB section number: 136 |
| 745 |
* ~~~~~~~~~~~~~~~~~~~ |
| 746 |
* Now we add the just-found argument to |cite_list| if there isn't |
| 747 |
* anything funny happening. |
| 748 |
***************************************************************************/ |
| 749 |
BEGIN |
| 750 |
|
| 751 |
#ifdef TRACE |
| 752 |
if (Flag_trace) |
| 753 |
TRACE_PR_NEWLINE; |
| 754 |
#endif /* TRACE */ |
| 755 |
|
| 756 |
cite_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, CITE_ILK, |
| 757 |
DO_INSERT); |
| 758 |
if (hash_found) |
| 759 |
BEGIN |
| 760 |
hash_cite_confusion (); |
| 761 |
END |
| 762 |
check_cite_overflow (cite_ptr); |
| 763 |
CUR_CITE_STR = hash_text[cite_loc]; |
| 764 |
ilk_info[cite_loc] = cite_ptr; |
| 765 |
ilk_info[lc_cite_loc] = cite_loc; |
| 766 |
INCR (cite_ptr); |
| 767 |
END |
| 768 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 136 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 769 |
END |
| 770 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 133 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 771 |
|
| 772 |
|
| 773 |
Next_Cite_Label: DO_NOTHING |
| 774 |
END |
| 775 |
Exit_Label: DO_NOTHING; |
| 776 |
END |
| 777 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 132 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
/*************************************************************************** |
| 783 |
* WEB section number: 144 |
| 784 |
* ~~~~~~~~~~~~~~~~~~~ |
| 785 |
* We must complain if anything's amiss. |
| 786 |
***************************************************************************/ |
| 787 |
void aux_end1_err_print (void) |
| 788 |
BEGIN |
| 789 |
PRINT ("I found no "); |
| 790 |
END |
| 791 |
|
| 792 |
|
| 793 |
void aux_end2_err_print (void) |
| 794 |
BEGIN |
| 795 |
PRINT ("---while reading file "); |
| 796 |
print_aux_name (); |
| 797 |
mark_error (); |
| 798 |
END |
| 799 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 144 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
/*************************************************************************** |
| 805 |
* WEB section number: 112 |
| 806 |
* ~~~~~~~~~~~~~~~~~~~ |
| 807 |
* Here are a bunch of macros whose print statements are used at least |
| 808 |
* twice. Thus we save space by making the statements procedures. This |
| 809 |
* macro complains when there's a repeated command that's to be used just |
| 810 |
* once. |
| 811 |
***************************************************************************/ |
| 812 |
void aux_err_illegal_another_print (Integer_T cmd_num) |
| 813 |
BEGIN |
| 814 |
PRINT ("Illegal, another \\bib"); |
| 815 |
switch (cmd_num) |
| 816 |
BEGIN |
| 817 |
case N_AUX_BIBDATA: |
| 818 |
PRINT ("data"); |
| 819 |
break; |
| 820 |
case N_AUX_BIBSTYLE: |
| 821 |
PRINT ("style"); |
| 822 |
break; |
| 823 |
default: |
| 824 |
CONFUSION ("Illegal auxiliary-file command"); |
| 825 |
END |
| 826 |
PRINT (" command"); |
| 827 |
END |
| 828 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 112 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
/*************************************************************************** |
| 834 |
* WEB section number: 113 |
| 835 |
* ~~~~~~~~~~~~~~~~~~~ |
| 836 |
* This one complains when a command is missing its |right_brace|. |
| 837 |
***************************************************************************/ |
| 838 |
void aux_err_no_right_brace_print (void) |
| 839 |
BEGIN |
| 840 |
PRINT2 ("No \"%c\"", xchr[RIGHT_BRACE]); |
| 841 |
END |
| 842 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 113 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
/*************************************************************************** |
| 848 |
* WEB section number: 111 |
| 849 |
* ~~~~~~~~~~~~~~~~~~~ |
| 850 |
* When we find a bug, we print a message and flush the rest of the line. |
| 851 |
* This macro must be called from within a procedure that has an |exit| |
| 852 |
* label. |
| 853 |
***************************************************************************/ |
| 854 |
void aux_err_print (void) |
| 855 |
BEGIN |
| 856 |
PRINT2 ("---line %ld of file ", (long) CUR_AUX_LINE); |
| 857 |
print_aux_name (); |
| 858 |
print_bad_input_line (); |
| 859 |
print_skipping_whatever_remains (); |
| 860 |
PRINT_LN ("command"); |
| 861 |
END |
| 862 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 111 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
/*************************************************************************** |
| 868 |
* WEB section number: 114 |
| 869 |
* ~~~~~~~~~~~~~~~~~~~ |
| 870 |
* This one complains when a command has stuff after its |right_brace|. |
| 871 |
***************************************************************************/ |
| 872 |
void aux_err_stuff_after_right_brace (void) |
| 873 |
BEGIN |
| 874 |
PRINT2 ("Stuff after \"%c\"", xchr[RIGHT_BRACE]); |
| 875 |
END |
| 876 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 114 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
/*************************************************************************** |
| 882 |
* WEB section number: 115 |
| 883 |
* ~~~~~~~~~~~~~~~~~~~ |
| 884 |
* And this one complains when a command has |white_space| in its |
| 885 |
* argument. |
| 886 |
***************************************************************************/ |
| 887 |
void aux_err_white_space_in_argument (void) |
| 888 |
BEGIN |
| 889 |
PRINT ("White space in argument"); |
| 890 |
END |
| 891 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 115 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
/*************************************************************************** |
| 897 |
* WEB section number: 139 |
| 898 |
* ~~~~~~~~~~~~~~~~~~~ |
| 899 |
* An \@input command will have exactly one argument, it will be |
| 900 |
* between braces, and it must have the |s_aux_extension|. All upper-case |
| 901 |
* letters are converted to lower case. |
| 902 |
***************************************************************************/ |
| 903 |
void aux_input_command (void) |
| 904 |
BEGIN |
| 905 |
Boolean_T aux_extension_ok; |
| 906 |
|
| 907 |
INCR (buf_ptr2); |
| 908 |
if ( ! scan1_white (RIGHT_BRACE)) |
| 909 |
BEGIN |
| 910 |
AUX_ERR_NO_RIGHT_BRACE; |
| 911 |
END |
| 912 |
if (lex_class[SCAN_CHAR] == WHITE_SPACE) |
| 913 |
BEGIN |
| 914 |
AUX_ERR_WHITE_SPACE_IN_ARGUMENT; |
| 915 |
END |
| 916 |
if (last > (buf_ptr2 + 1)) |
| 917 |
BEGIN |
| 918 |
AUX_ERR_STUFF_AFTER_RIGHT_BRACE; |
| 919 |
END |
| 920 |
|
| 921 |
/*************************************************************************** |
| 922 |
* WEB section number: 140 |
| 923 |
* ~~~~~~~~~~~~~~~~~~~ |
| 924 |
* We must check that this potential .aux file won't overflow the |
| 925 |
* stack, that it has the correct extension, that we haven't encountered |
| 926 |
* it before (to prevent, among other things, an infinite loop). |
| 927 |
***************************************************************************/ |
| 928 |
BEGIN |
| 929 |
INCR (aux_ptr); |
| 930 |
if (aux_ptr == AUX_STACK_SIZE) |
| 931 |
BEGIN |
| 932 |
PRINT_TOKEN; |
| 933 |
PRINT (": "); |
| 934 |
BIBTEX_OVERFLOW ("auxiliary file depth ", AUX_STACK_SIZE); |
| 935 |
END |
| 936 |
aux_extension_ok = TRUE; |
| 937 |
if (TOKEN_LEN < LENGTH (s_aux_extension)) |
| 938 |
BEGIN |
| 939 |
aux_extension_ok = FALSE; |
| 940 |
END |
| 941 |
else if ( ! str_eq_buf (s_aux_extension, buffer, |
| 942 |
(buf_ptr2 - LENGTH (s_aux_extension)), |
| 943 |
LENGTH (s_aux_extension))) |
| 944 |
BEGIN |
| 945 |
aux_extension_ok = FALSE; |
| 946 |
END |
| 947 |
if ( ! aux_extension_ok) |
| 948 |
BEGIN |
| 949 |
PRINT_TOKEN; |
| 950 |
PRINT (" has a wrong extension"); |
| 951 |
DECR (aux_ptr); |
| 952 |
AUX_ERR_RETURN; |
| 953 |
END |
| 954 |
CUR_AUX_STR = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 955 |
AUX_FILE_ILK, DO_INSERT)]; |
| 956 |
if (hash_found) |
| 957 |
BEGIN |
| 958 |
PRINT ("Already encountered file "); |
| 959 |
print_aux_name (); |
| 960 |
DECR (aux_ptr); |
| 961 |
AUX_ERR_RETURN; |
| 962 |
END |
| 963 |
|
| 964 |
/*************************************************************************** |
| 965 |
* WEB section number: 141 |
| 966 |
* ~~~~~~~~~~~~~~~~~~~ |
| 967 |
* We check that this .aux file can actually be opened, and then open it. |
| 968 |
* |
| 969 |
* NOTE: because C arrays start at index 0, not 1, the subscripts of array |
| 970 |
* |name_of_file| are generally 1 less than those in the WEB source. |
| 971 |
***************************************************************************/ |
| 972 |
BEGIN |
| 973 |
start_name (CUR_AUX_STR); |
| 974 |
name_of_file[name_length] = 0; |
| 975 |
if ( ! a_open_in (&CUR_AUX_FILE, AUX_FILE_SEARCH_PATH)) |
| 976 |
BEGIN |
| 977 |
PRINT ("I couldn't open auxiliary file "); |
| 978 |
print_aux_name (); |
| 979 |
perror ("\nReason"); |
| 980 |
DECR (aux_ptr); |
| 981 |
AUX_ERR_RETURN; |
| 982 |
END |
| 983 |
PRINT2 ("A level-%ld auxilliary file: ", (long) aux_ptr); |
| 984 |
print_aux_name (); |
| 985 |
CUR_AUX_LINE = 0; |
| 986 |
END |
| 987 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 141 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 988 |
END |
| 989 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 140 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 990 |
|
| 991 |
Exit_Label: DO_NOTHING; |
| 992 |
END |
| 993 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 139 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
/*************************************************************************** |
| 999 |
* WEB section number: 177 |
| 1000 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1001 |
* A legal argument for an execute, iterate, or reverse |
| 1002 |
* command must exist and be |built_in| or |wiz_defined|. Here's where we |
| 1003 |
* check, returning |true| if the argument is illegal. |
| 1004 |
***************************************************************************/ |
| 1005 |
Boolean_T bad_argument_token (void) |
| 1006 |
BEGIN |
| 1007 |
Boolean_T bad_argument_token; |
| 1008 |
|
| 1009 |
bad_argument_token= TRUE; |
| 1010 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1011 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK, DONT_INSERT); |
| 1012 |
if ( ! hash_found) |
| 1013 |
BEGIN |
| 1014 |
PRINT_TOKEN; |
| 1015 |
BST_ERR (" is an unknown function"); |
| 1016 |
END |
| 1017 |
else if ((fn_type[fn_loc] != BUILT_IN) && (fn_type[fn_loc] != WIZ_DEFINED)) |
| 1018 |
BEGIN |
| 1019 |
PRINT_TOKEN; |
| 1020 |
PRINT (" has bad function type "); |
| 1021 |
print_fn_class (fn_loc); |
| 1022 |
BST_ERR_PRINT_AND_LOOK_FOR_BLAN; |
| 1023 |
END |
| 1024 |
bad_argument_token= FALSE; |
| 1025 |
|
| 1026 |
Exit_Label: |
| 1027 |
return (bad_argument_token); |
| 1028 |
END |
| 1029 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 177 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
/*************************************************************************** |
| 1035 |
* WEB section number: 280 |
| 1036 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1037 |
* This procedure exists to save space, since it's used twice---once for |
| 1038 |
* each of the two succeeding modules. |
| 1039 |
***************************************************************************/ |
| 1040 |
void bad_cross_reference_print (StrNumber_T s) |
| 1041 |
BEGIN |
| 1042 |
PRINT ("--entry \""); |
| 1043 |
PRINT_POOL_STR (CUR_CITE_STR); |
| 1044 |
PRINT_LN ("\""); |
| 1045 |
PRINT ("refers to entry \""); |
| 1046 |
PRINT_POOL_STR (s); |
| 1047 |
END |
| 1048 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 280 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
/*************************************************************************** |
| 1054 |
* WEB section number: 240 |
| 1055 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1056 |
* Here's another bug. |
| 1057 |
***************************************************************************/ |
| 1058 |
void bib_cmd_confusion (void) |
| 1059 |
BEGIN |
| 1060 |
CONFUSION ("Unknown database-file command"); |
| 1061 |
END |
| 1062 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 240 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
/*************************************************************************** |
| 1068 |
* WEB section number: 231 |
| 1069 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1070 |
* This one's for an expected |equals_sign|. |
| 1071 |
***************************************************************************/ |
| 1072 |
void bib_equals_sign_print (void) |
| 1073 |
BEGIN |
| 1074 |
BIB_ERR2 ("I was expecting an \"%c\"", xchr[EQUALS_SIGN]); |
| 1075 |
|
| 1076 |
Exit_Label: DO_NOTHING; |
| 1077 |
END |
| 1078 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 231 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
/*************************************************************************** |
| 1084 |
* WEB section number: 221 |
| 1085 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1086 |
* When there's a serious error parsing a .bib file, we flush |
| 1087 |
* everything up to the beginning of the next entry. |
| 1088 |
***************************************************************************/ |
| 1089 |
void bib_err_print (void) |
| 1090 |
BEGIN |
| 1091 |
PRINT ("-"); |
| 1092 |
bib_ln_num_print (); |
| 1093 |
print_bad_input_line (); |
| 1094 |
print_skipping_whatever_remains (); |
| 1095 |
if (at_bib_command) |
| 1096 |
BEGIN |
| 1097 |
PRINT_LN ("command"); |
| 1098 |
END |
| 1099 |
else |
| 1100 |
BEGIN |
| 1101 |
PRINT_LN ("entry"); |
| 1102 |
END |
| 1103 |
END |
| 1104 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 221 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
/*************************************************************************** |
| 1110 |
* WEB section number: 233 |
| 1111 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1112 |
* And this one about an overly exuberant field. |
| 1113 |
***************************************************************************/ |
| 1114 |
void bib_field_too_long_print (void) |
| 1115 |
BEGIN |
| 1116 |
BIB_ERR2 ("Your field is more than %ld characters", (long) Buf_Size); |
| 1117 |
|
| 1118 |
Exit_Label: DO_NOTHING; |
| 1119 |
END |
| 1120 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 233 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
/*************************************************************************** |
| 1126 |
* WEB section number: 235 |
| 1127 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1128 |
* This macro is used to scan all .bib identifiers. The argument |
| 1129 |
* tells what was happening at the time. The associated procedure simply |
| 1130 |
* prints an error message. |
| 1131 |
***************************************************************************/ |
| 1132 |
void bib_id_print (void) |
| 1133 |
BEGIN |
| 1134 |
if (scan_result == ID_NULL) |
| 1135 |
BEGIN |
| 1136 |
PRINT ("You're missing "); |
| 1137 |
END |
| 1138 |
else if (scan_result == OTHER_CHAR_ADJACENT) |
| 1139 |
BEGIN |
| 1140 |
PRINT2 ("\"%c\" immediately follows ", xchr[SCAN_CHAR]); |
| 1141 |
END |
| 1142 |
else |
| 1143 |
BEGIN |
| 1144 |
id_scanning_confusion (); |
| 1145 |
END |
| 1146 |
END |
| 1147 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 235 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
/*************************************************************************** |
| 1153 |
* WEB section number: 220 |
| 1154 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1155 |
* This little procedure exists because it's used by at least two other |
| 1156 |
* procedures and thus saves some space. |
| 1157 |
***************************************************************************/ |
| 1158 |
void bib_ln_num_print (void) |
| 1159 |
BEGIN |
| 1160 |
PRINT2 ("--line %ld of file ", (long) bib_line_num); |
| 1161 |
print_bib_name (); |
| 1162 |
END |
| 1163 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 220 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
/*************************************************************************** |
| 1169 |
* WEB section number: 230 |
| 1170 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1171 |
* And here are a bunch of error-message macros, each called more than |
| 1172 |
* once, that thus save space as implemented. This one is for when one of |
| 1173 |
* two possible characters is expected while scanning. |
| 1174 |
***************************************************************************/ |
| 1175 |
void bib_one_of_two_print (ASCIICode_T char1, ASCIICode_T char2) |
| 1176 |
BEGIN |
| 1177 |
BIB_ERR3 ("I was expecting a `%c' or a `%c'", xchr[char1], xchr[char2]); |
| 1178 |
Exit_Label: DO_NOTHING |
| 1179 |
END |
| 1180 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 230 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
/*************************************************************************** |
| 1186 |
* WEB section number: 232 |
| 1187 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1188 |
* This complains about unbalanced braces. |
| 1189 |
***************************************************************************/ |
| 1190 |
void bib_unbalanced_braces_print (void) |
| 1191 |
BEGIN |
| 1192 |
BIB_ERR ("Unbalanced braces"); |
| 1193 |
Exit_Label: DO_NOTHING; |
| 1194 |
END |
| 1195 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 232 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
/*************************************************************************** |
| 1201 |
* WEB section number: 222 |
| 1202 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1203 |
* When there's a harmless error parsing a .bib file, we just give a |
| 1204 |
* warning message. This is always called after other stuff has been |
| 1205 |
* printed out. |
| 1206 |
***************************************************************************/ |
| 1207 |
void bib_warn_print (void) |
| 1208 |
BEGIN |
| 1209 |
bib_ln_num_print (); |
| 1210 |
mark_warning (); |
| 1211 |
END |
| 1212 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 222 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
/*************************************************************************** |
| 1218 |
* WEB section number: 406 |
| 1219 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1220 |
* At most one of the important letters, perhaps doubled, may appear at |
| 1221 |
* |sp_brace_level = 1|. |
| 1222 |
***************************************************************************/ |
| 1223 |
void brace_lvl_one_letters_complaint (void) |
| 1224 |
BEGIN |
| 1225 |
PRINT ("The format string \""); |
| 1226 |
PRINT_POOL_STR (pop_lit1); |
| 1227 |
BST_EX_WARN ("\" has an illegal brace-level-1 letter"); |
| 1228 |
END |
| 1229 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 406 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
/*************************************************************************** |
| 1235 |
* WEB section number: 368 |
| 1236 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1237 |
* This complaint often arises because the style designer has to type lots |
| 1238 |
* of braces. |
| 1239 |
***************************************************************************/ |
| 1240 |
void braces_unbalanced_complaint (StrNumber_T pop_lit_var) |
| 1241 |
BEGIN |
| 1242 |
PRINT ("Warning--\""); |
| 1243 |
PRINT_POOL_STR (pop_lit_var); |
| 1244 |
BST_MILD_EX_WARN ("\" isn't a brace-balanced string"); |
| 1245 |
END |
| 1246 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 368 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
/*************************************************************************** |
| 1252 |
* WEB section number: 356 |
| 1253 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1254 |
* It's time for a complaint if either of the two (entry or global) string |
| 1255 |
* lengths is exceeded. |
| 1256 |
***************************************************************************/ |
| 1257 |
void bst_1print_string_size_exceeded (void) |
| 1258 |
BEGIN |
| 1259 |
PRINT ("Warning--you've exceeded "); |
| 1260 |
END |
| 1261 |
|
| 1262 |
void bst_2print_string_size_exceeded (void) |
| 1263 |
BEGIN |
| 1264 |
PRINT ("-string-size,"); |
| 1265 |
bst_mild_ex_warn_print (); |
| 1266 |
PRINT_LN ("*Please notify the bibstyle designer*"); |
| 1267 |
END |
| 1268 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 356 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
/*************************************************************************** |
| 1274 |
* WEB section number: 295 |
| 1275 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1276 |
* It's illegal to mess with the entry information at certain times; |
| 1277 |
* here's a complaint for these times. |
| 1278 |
***************************************************************************/ |
| 1279 |
void bst_cant_mess_with_entries_prin (void) |
| 1280 |
BEGIN |
| 1281 |
BST_EX_WARN ("You can't mess with entries here"); |
| 1282 |
END |
| 1283 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 295 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
/*************************************************************************** |
| 1289 |
* WEB section number: 170 |
| 1290 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1291 |
* An entry command has three arguments, each a (possibly empty) list |
| 1292 |
* of function names between braces (the names are separated by one or |
| 1293 |
* more |white_space| characters). All function names in this and other |
| 1294 |
* commands must be legal .bst identifiers. Upper/lower cases are |
| 1295 |
* considered to be the same for function names in these lists---all |
| 1296 |
* upper-case letters are converted to lower case. These arguments give |
| 1297 |
* lists of |field|s, |int_entry_var|s, and |str_entry_var|s. |
| 1298 |
***************************************************************************/ |
| 1299 |
void bst_entry_command (void) |
| 1300 |
BEGIN |
| 1301 |
if (entry_seen) |
| 1302 |
BEGIN |
| 1303 |
BST_ERR ("Illegal, another entry command"); |
| 1304 |
END |
| 1305 |
entry_seen = TRUE; |
| 1306 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1307 |
|
| 1308 |
/*************************************************************************** |
| 1309 |
* WEB section number: 171 |
| 1310 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1311 |
* This module reads a |left_brace|, the list of |field|s, and a |
| 1312 |
* |right_brace|. The |field|s are those like `author' and `title.' |
| 1313 |
***************************************************************************/ |
| 1314 |
BEGIN |
| 1315 |
BST_GET_AND_CHECK_LEFT_BRACE ("entry"); |
| 1316 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1317 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 1318 |
BEGIN |
| 1319 |
BST_IDENTIFIER_SCAN ("entry"); |
| 1320 |
|
| 1321 |
/*************************************************************************** |
| 1322 |
* WEB section number: 172 |
| 1323 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1324 |
* Here we insert the just found field name into the hash table, record |
| 1325 |
* it as a |field|, and assign it a number to be used in indexing into |
| 1326 |
* the |field_info| array. |
| 1327 |
***************************************************************************/ |
| 1328 |
BEGIN |
| 1329 |
|
| 1330 |
#ifdef TRACE |
| 1331 |
if (Flag_trace) { |
| 1332 |
TRACE_PR_TOKEN; |
| 1333 |
TRACE_PR_LN (" is a field"); |
| 1334 |
} |
| 1335 |
#endif /* TRACE */ |
| 1336 |
|
| 1337 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1338 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 1339 |
BST_FN_ILK, DO_INSERT); |
| 1340 |
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc); |
| 1341 |
fn_type[fn_loc] = FIELD; |
| 1342 |
ilk_info[fn_loc] = num_fields; |
| 1343 |
INCR (num_fields); |
| 1344 |
END |
| 1345 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 172 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1346 |
|
| 1347 |
|
| 1348 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1349 |
END |
| 1350 |
INCR (buf_ptr2); |
| 1351 |
END |
| 1352 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 171 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1353 |
|
| 1354 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1355 |
if (num_fields == num_pre_defined_fields) |
| 1356 |
BEGIN |
| 1357 |
BST_WARN ("Warning--I didn't find any fields"); |
| 1358 |
END |
| 1359 |
|
| 1360 |
/*************************************************************************** |
| 1361 |
* WEB section number: 173 |
| 1362 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1363 |
* This module reads a |left_brace|, the list of |int_entry_var|s, |
| 1364 |
* and a |right_brace|. |
| 1365 |
***************************************************************************/ |
| 1366 |
BEGIN |
| 1367 |
BST_GET_AND_CHECK_LEFT_BRACE ("entry"); |
| 1368 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1369 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 1370 |
BEGIN |
| 1371 |
BST_IDENTIFIER_SCAN ("entry"); |
| 1372 |
|
| 1373 |
/*************************************************************************** |
| 1374 |
* WEB section number: 174 |
| 1375 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1376 |
* Here we insert the just found |int_entry_var| name into the hash table |
| 1377 |
* and record it as an |int_entry_var|. An |int_entry_var| is one that |
| 1378 |
* the style designer wants a separate copy of for each entry. |
| 1379 |
***************************************************************************/ |
| 1380 |
BEGIN |
| 1381 |
|
| 1382 |
#ifdef TRACE |
| 1383 |
if (Flag_trace) { |
| 1384 |
TRACE_PR_TOKEN; |
| 1385 |
TRACE_PR_LN (" is an integer entry-variable"); |
| 1386 |
} |
| 1387 |
#endif /* TRACE */ |
| 1388 |
|
| 1389 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1390 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 1391 |
BST_FN_ILK, DO_INSERT); |
| 1392 |
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc); |
| 1393 |
fn_type[fn_loc] = INT_ENTRY_VAR; |
| 1394 |
FN_INFO[fn_loc] = num_ent_ints; |
| 1395 |
INCR (num_ent_ints); |
| 1396 |
END |
| 1397 |
|
| 1398 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 174 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1399 |
|
| 1400 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1401 |
END |
| 1402 |
INCR (buf_ptr2); |
| 1403 |
END |
| 1404 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 173 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1405 |
|
| 1406 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1407 |
|
| 1408 |
/*************************************************************************** |
| 1409 |
* WEB section number: 175 |
| 1410 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1411 |
* This module reads a |left_brace|, the list of |str_entry_var|s, and a |
| 1412 |
* |right_brace|. A |str_entry_var| is one that the style designer wants |
| 1413 |
* a separate copy of for each entry. |
| 1414 |
***************************************************************************/ |
| 1415 |
BEGIN |
| 1416 |
BST_GET_AND_CHECK_LEFT_BRACE ("entry"); |
| 1417 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1418 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 1419 |
BEGIN |
| 1420 |
BST_IDENTIFIER_SCAN ("entry"); |
| 1421 |
|
| 1422 |
/*************************************************************************** |
| 1423 |
* WEB section number: 176 |
| 1424 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1425 |
* Here we insert the just found |str_entry_var| name into the hash |
| 1426 |
* table, record it as a |str_entry_var|, and set its pointer into |
| 1427 |
* |entry_strs|. |
| 1428 |
***************************************************************************/ |
| 1429 |
BEGIN |
| 1430 |
#ifdef TRACE |
| 1431 |
if (Flag_trace) { |
| 1432 |
TRACE_PR_TOKEN; |
| 1433 |
TRACE_PR_LN (" is a string entry-variable"); |
| 1434 |
} |
| 1435 |
#endif /* TRACE */ |
| 1436 |
|
| 1437 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1438 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 1439 |
BST_FN_ILK, DO_INSERT); |
| 1440 |
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc); |
| 1441 |
fn_type[fn_loc] = STR_ENTRY_VAR; |
| 1442 |
FN_INFO[fn_loc] = num_ent_strs; |
| 1443 |
INCR (num_ent_strs); |
| 1444 |
END |
| 1445 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 176 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1446 |
|
| 1447 |
EAT_BST_WHITE_AND_EOF_CHECK ("entry"); |
| 1448 |
END |
| 1449 |
INCR (buf_ptr2); |
| 1450 |
END |
| 1451 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 175 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1452 |
|
| 1453 |
Exit_Label: DO_NOTHING; |
| 1454 |
END |
| 1455 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 170 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
/*************************************************************************** |
| 1461 |
* WEB section number: 149 |
| 1462 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1463 |
* When there's a serious error parsing the .bst file, we flush the |
| 1464 |
* rest of the current command; a blank line is assumed to mark the end of |
| 1465 |
* a command (but for the purposes of error recovery only). Thus, error |
| 1466 |
* recovery will be better if style designers leave blank lines between |
| 1467 |
* .bst commands. This macro must be called from within a procedure |
| 1468 |
* that has an |exit| label. |
| 1469 |
***************************************************************************/ |
| 1470 |
void bst_err_print_and_look_for_blan (void) |
| 1471 |
BEGIN |
| 1472 |
PRINT ("-"); |
| 1473 |
bst_ln_num_print (); |
| 1474 |
print_bad_input_line (); |
| 1475 |
while (last != 0) |
| 1476 |
if ( ! input_ln (bst_file)) |
| 1477 |
BEGIN |
| 1478 |
longjmp (Bst_Done_Flag, 1); |
| 1479 |
END |
| 1480 |
else |
| 1481 |
BEGIN |
| 1482 |
INCR (bst_line_num); |
| 1483 |
END |
| 1484 |
buf_ptr2 = last; |
| 1485 |
END |
| 1486 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 149 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
/*************************************************************************** |
| 1492 |
* WEB section number: 178 |
| 1493 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1494 |
* An execute command has one argument, a single |built_in| or |
| 1495 |
* |wiz_defined| function name between braces. Upper/lower cases are |
| 1496 |
* considered to be the same---all upper-case letters are converted to |
| 1497 |
* lower case. Also, we must make sure we've already seen a read |
| 1498 |
* command. |
| 1499 |
* |
| 1500 |
* This module reads a |left_brace|, a single function to be executed, and |
| 1501 |
* a |right_brace|. |
| 1502 |
***************************************************************************/ |
| 1503 |
void bst_execute_command (void) |
| 1504 |
BEGIN |
| 1505 |
if ( ! read_seen) |
| 1506 |
BEGIN |
| 1507 |
BST_ERR ("Illegal, execute command before read command"); |
| 1508 |
END |
| 1509 |
EAT_BST_WHITE_AND_EOF_CHECK ("execute"); |
| 1510 |
BST_GET_AND_CHECK_LEFT_BRACE ("execute"); |
| 1511 |
EAT_BST_WHITE_AND_EOF_CHECK ("execute"); |
| 1512 |
BST_IDENTIFIER_SCAN ("execute"); |
| 1513 |
|
| 1514 |
|
| 1515 |
/*************************************************************************** |
| 1516 |
* WEB section number: 179 |
| 1517 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1518 |
* Before executing the function, we must make sure it's a legal one. It |
| 1519 |
* must exist and be |built_in| or |wiz_defined|. |
| 1520 |
***************************************************************************/ |
| 1521 |
BEGIN |
| 1522 |
|
| 1523 |
#ifdef TRACE |
| 1524 |
if (Flag_trace) { |
| 1525 |
TRACE_PR_TOKEN; |
| 1526 |
TRACE_PR_LN (" is a to be executed function"); |
| 1527 |
} |
| 1528 |
#endif /* TRACE */ |
| 1529 |
|
| 1530 |
if (bad_argument_token ()) |
| 1531 |
BEGIN |
| 1532 |
goto Exit_Label; |
| 1533 |
END |
| 1534 |
END |
| 1535 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 179 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1536 |
|
| 1537 |
EAT_BST_WHITE_AND_EOF_CHECK ("execute"); |
| 1538 |
BST_GET_AND_CHECK_RIGHT_BRACE ("execute"); |
| 1539 |
|
| 1540 |
/*************************************************************************** |
| 1541 |
* WEB section number: 296 |
| 1542 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1543 |
* This module executes a single specified function once. It can't do |
| 1544 |
* anything with the entries. |
| 1545 |
***************************************************************************/ |
| 1546 |
BEGIN |
| 1547 |
init_command_execution (); |
| 1548 |
mess_with_entries = FALSE; |
| 1549 |
execute_fn (fn_loc); |
| 1550 |
check_command_execution (); |
| 1551 |
END |
| 1552 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 296 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1553 |
|
| 1554 |
Exit_Label: DO_NOTHING; |
| 1555 |
END |
| 1556 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 178 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
/*************************************************************************** |
| 1562 |
* WEB section number: 293 |
| 1563 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1564 |
* When there's an error while executing .bst functions, what we do |
| 1565 |
* depends on whether the function is messing with the entries. |
| 1566 |
* Furthermore this error is serious enough to classify as an |
| 1567 |
* |error_message| instead of a |warning_message|. These messages (that |
| 1568 |
* is, from |bst_ex_warn|) are meant both for the user and for the style |
| 1569 |
* designer while debugging. |
| 1570 |
***************************************************************************/ |
| 1571 |
void bst_ex_warn_print (void) |
| 1572 |
BEGIN |
| 1573 |
if (mess_with_entries) |
| 1574 |
BEGIN |
| 1575 |
PRINT (" for entry "); |
| 1576 |
PRINT_POOL_STR (CUR_CITE_STR); |
| 1577 |
END |
| 1578 |
PRINT_NEWLINE; |
| 1579 |
PRINT ("while executing-"); |
| 1580 |
bst_ln_num_print (); |
| 1581 |
mark_error (); |
| 1582 |
END |
| 1583 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 293 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
|
| 1588 |
/*************************************************************************** |
| 1589 |
* WEB section number: 180 |
| 1590 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1591 |
* A function command has two arguments; the first is a |wiz_defined| |
| 1592 |
* function name between braces. Upper/lower cases are considered to be |
| 1593 |
* the same---all upper-case letters are converted to lower case. The |
| 1594 |
* second argument defines this function. It consists of a sequence of |
| 1595 |
* functions, between braces, separated by |white_space| characters. |
| 1596 |
* Upper/lower cases are considered to be the same for function names but |
| 1597 |
* not for |str_literal|s. |
| 1598 |
***************************************************************************/ |
| 1599 |
void bst_function_command (void) |
| 1600 |
BEGIN |
| 1601 |
EAT_BST_WHITE_AND_EOF_CHECK ("function"); |
| 1602 |
|
| 1603 |
/*************************************************************************** |
| 1604 |
* WEB section number: 181 |
| 1605 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1606 |
* This module reads a |left_brace|, a |wiz_defined| function name, and |
| 1607 |
* a |right_brace|. |
| 1608 |
***************************************************************************/ |
| 1609 |
BEGIN |
| 1610 |
BST_GET_AND_CHECK_LEFT_BRACE ("function"); |
| 1611 |
EAT_BST_WHITE_AND_EOF_CHECK ("function"); |
| 1612 |
BST_IDENTIFIER_SCAN ("function"); |
| 1613 |
|
| 1614 |
/*************************************************************************** |
| 1615 |
* WEB section number: 182 |
| 1616 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1617 |
* The function name must exist and be a new one; we mark it as |
| 1618 |
* |wiz_defined|. Also, see if it's the default entry-type function. |
| 1619 |
***************************************************************************/ |
| 1620 |
BEGIN |
| 1621 |
#ifdef TRACE |
| 1622 |
if (Flag_trace) { |
| 1623 |
TRACE_PR_TOKEN; |
| 1624 |
TRACE_PR_LN (" is a wizard-defined function"); |
| 1625 |
} |
| 1626 |
#endif /* TRACE */ |
| 1627 |
|
| 1628 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1629 |
wiz_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK, |
| 1630 |
DO_INSERT); |
| 1631 |
CHECK_FOR_ALREADY_SEEN_FUNCTION (wiz_loc); |
| 1632 |
fn_type[wiz_loc] = WIZ_DEFINED; |
| 1633 |
if (hash_text[wiz_loc] == s_default) |
| 1634 |
BEGIN |
| 1635 |
b_default = wiz_loc; |
| 1636 |
END |
| 1637 |
END |
| 1638 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 182 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1639 |
|
| 1640 |
EAT_BST_WHITE_AND_EOF_CHECK ("function"); |
| 1641 |
BST_GET_AND_CHECK_RIGHT_BRACE ("function"); |
| 1642 |
END |
| 1643 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 181 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1644 |
|
| 1645 |
EAT_BST_WHITE_AND_EOF_CHECK ("function"); |
| 1646 |
BST_GET_AND_CHECK_LEFT_BRACE ("function"); |
| 1647 |
scan_fn_def (wiz_loc); |
| 1648 |
Exit_Label: DO_NOTHING; |
| 1649 |
END |
| 1650 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 180 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
/*************************************************************************** |
| 1656 |
* WEB section number: 166 |
| 1657 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1658 |
* This macro is used to scan all .bst identifiers. The argument |
| 1659 |
* supplies the .bst command name. The associated procedure simply |
| 1660 |
* prints an error message. |
| 1661 |
***************************************************************************/ |
| 1662 |
void bst_id_print (void) |
| 1663 |
BEGIN |
| 1664 |
if (scan_result == ID_NULL) |
| 1665 |
BEGIN |
| 1666 |
PRINT2 ("\"%c\" begins identifier, command: ", xchr[SCAN_CHAR]); |
| 1667 |
END |
| 1668 |
else if (scan_result == OTHER_CHAR_ADJACENT) |
| 1669 |
BEGIN |
| 1670 |
PRINT2 ("\"%c\" immediately follows identifier, command: ", |
| 1671 |
xchr[SCAN_CHAR]); |
| 1672 |
END |
| 1673 |
else |
| 1674 |
BEGIN |
| 1675 |
id_scanning_confusion (); |
| 1676 |
END |
| 1677 |
END |
| 1678 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 166 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
/*************************************************************************** |
| 1684 |
* WEB section number: 201 |
| 1685 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1686 |
* An integers command has one argument, a list of function names |
| 1687 |
* between braces (the names are separated by one or more |white_space| |
| 1688 |
* characters). Upper/lower cases are considered to be the same for |
| 1689 |
* function names in these lists---all upper-case letters are converted to |
| 1690 |
* lower case. Each name in this list specifies an |int_global_var|. |
| 1691 |
* There may be several integers commands in the .bst file. |
| 1692 |
* |
| 1693 |
* This module reads a |left_brace|, a list of |int_global_var|s, and a |
| 1694 |
* |right_brace|. |
| 1695 |
***************************************************************************/ |
| 1696 |
void bst_integers_command (void) |
| 1697 |
BEGIN |
| 1698 |
EAT_BST_WHITE_AND_EOF_CHECK ("integers"); |
| 1699 |
BST_GET_AND_CHECK_LEFT_BRACE ("integers"); |
| 1700 |
EAT_BST_WHITE_AND_EOF_CHECK ("integers"); |
| 1701 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 1702 |
BEGIN |
| 1703 |
BST_IDENTIFIER_SCAN ("integers"); |
| 1704 |
|
| 1705 |
/*************************************************************************** |
| 1706 |
* WEB section number: 202 |
| 1707 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1708 |
* Here we insert the just found |int_global_var| name into the hash |
| 1709 |
* table and record it as an |int_global_var|. Also, we initialize it by |
| 1710 |
* setting |FN_INFO[fn_loc]| to 0. |
| 1711 |
***************************************************************************/ |
| 1712 |
BEGIN |
| 1713 |
|
| 1714 |
#ifdef TRACE |
| 1715 |
if (Flag_trace) { |
| 1716 |
TRACE_PR_TOKEN; |
| 1717 |
TRACE_PR_LN (" is an integer global-variable"); |
| 1718 |
} |
| 1719 |
#endif /* TRACE */ |
| 1720 |
|
| 1721 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1722 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, |
| 1723 |
BST_FN_ILK, DO_INSERT); |
| 1724 |
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc); |
| 1725 |
fn_type[fn_loc] = INT_GLOBAL_VAR; |
| 1726 |
FN_INFO[fn_loc] = 0; |
| 1727 |
END |
| 1728 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 202 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1729 |
|
| 1730 |
EAT_BST_WHITE_AND_EOF_CHECK ("integers"); |
| 1731 |
END |
| 1732 |
INCR (buf_ptr2); |
| 1733 |
Exit_Label: DO_NOTHING; |
| 1734 |
END |
| 1735 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 201 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1736 |
|
| 1737 |
|
| 1738 |
/*************************************************************************** |
| 1739 |
* WEB section number: 203 |
| 1740 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1741 |
* An iterate command has one argument, a single |built_in| or |
| 1742 |
* |wiz_defined| function name between braces. Upper/lower cases are |
| 1743 |
* considered to be the same---all upper-case letters are converted to |
| 1744 |
* lower case. Also, we must make sure we've already seen a read |
| 1745 |
* command. |
| 1746 |
* |
| 1747 |
* This module reads a |left_brace|, a single function to be iterated, and |
| 1748 |
* a |right_brace|. |
| 1749 |
***************************************************************************/ |
| 1750 |
void bst_iterate_command (void) |
| 1751 |
BEGIN |
| 1752 |
if ( ! read_seen) |
| 1753 |
BEGIN |
| 1754 |
BST_ERR ("Illegal, iterate command before read command"); |
| 1755 |
END |
| 1756 |
EAT_BST_WHITE_AND_EOF_CHECK ("iterate"); |
| 1757 |
BST_GET_AND_CHECK_LEFT_BRACE ("iterate"); |
| 1758 |
EAT_BST_WHITE_AND_EOF_CHECK ("iterate"); |
| 1759 |
BST_IDENTIFIER_SCAN ("iterate"); |
| 1760 |
|
| 1761 |
/*************************************************************************** |
| 1762 |
* WEB section number: 204 |
| 1763 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1764 |
* Before iterating the function, we must make sure it's a legal one. It |
| 1765 |
* must exist and be |built_in| or |wiz_defined|. |
| 1766 |
***************************************************************************/ |
| 1767 |
BEGIN |
| 1768 |
|
| 1769 |
#ifdef TRACE |
| 1770 |
if (Flag_trace) { |
| 1771 |
TRACE_PR_TOKEN; |
| 1772 |
TRACE_PR_LN (" is a to be iterated function"); |
| 1773 |
} |
| 1774 |
#endif /* TRACE */ |
| 1775 |
|
| 1776 |
if (bad_argument_token ()) |
| 1777 |
BEGIN |
| 1778 |
goto Exit_Label; |
| 1779 |
END |
| 1780 |
END |
| 1781 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 204 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1782 |
|
| 1783 |
EAT_BST_WHITE_AND_EOF_CHECK ("iterate"); |
| 1784 |
BST_GET_AND_CHECK_RIGHT_BRACE ("iterate"); |
| 1785 |
|
| 1786 |
/*************************************************************************** |
| 1787 |
* WEB section number: 297 |
| 1788 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1789 |
* This module iterates a single specified function for all entries |
| 1790 |
* specified by |cite_list|. |
| 1791 |
***************************************************************************/ |
| 1792 |
BEGIN |
| 1793 |
init_command_execution (); |
| 1794 |
mess_with_entries = TRUE; |
| 1795 |
sort_cite_ptr = 0; |
| 1796 |
while (sort_cite_ptr < num_cites) |
| 1797 |
BEGIN |
| 1798 |
cite_ptr = SORTED_CITES[sort_cite_ptr]; |
| 1799 |
|
| 1800 |
#ifdef TRACE |
| 1801 |
if (Flag_trace) { |
| 1802 |
TRACE_PR_POOL_STR (hash_text[fn_loc]); |
| 1803 |
TRACE_PR (" to be iterated on "); |
| 1804 |
TRACE_PR_POOL_STR (CUR_CITE_STR); |
| 1805 |
TRACE_PR_NEWLINE; |
| 1806 |
} |
| 1807 |
#endif /* TRACE */ |
| 1808 |
|
| 1809 |
execute_fn (fn_loc); |
| 1810 |
check_command_execution (); |
| 1811 |
INCR (sort_cite_ptr); |
| 1812 |
END |
| 1813 |
END |
| 1814 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 297 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1815 |
|
| 1816 |
Exit_Label: DO_NOTHING; |
| 1817 |
END |
| 1818 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 203 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
/*************************************************************************** |
| 1824 |
* WEB section number: 167 |
| 1825 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1826 |
* This macro just makes sure we're at a |left_brace|. |
| 1827 |
***************************************************************************/ |
| 1828 |
void bst_left_brace_print (void) |
| 1829 |
BEGIN |
| 1830 |
PRINT2 ("\"%c\" is missing in command: ", xchr[LEFT_BRACE]); |
| 1831 |
END |
| 1832 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 167 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
/*************************************************************************** |
| 1838 |
* WEB section number: 148 |
| 1839 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1840 |
* This little procedure exists because it's used by at least two other |
| 1841 |
* procedures and thus saves some space. |
| 1842 |
***************************************************************************/ |
| 1843 |
void bst_ln_num_print (void) |
| 1844 |
BEGIN |
| 1845 |
PRINT2 ("--line %ld of file ", (long) bst_line_num); |
| 1846 |
print_bst_name (); |
| 1847 |
END |
| 1848 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 148 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
|
| 1853 |
/*************************************************************************** |
| 1854 |
* WEB section number: 205 |
| 1855 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1856 |
* A macro command, like a function command, has two arguments; |
| 1857 |
* the first is a macro name between braces. The name must be a legal |
| 1858 |
* .bst identifier. Upper/lower cases are considered to be the |
| 1859 |
* same---all upper-case letters are converted to lower case. The second |
| 1860 |
* argument defines this macro. It consists of a |double_quote|-delimited |
| 1861 |
* string (which must be on a single line) between braces, with optional |
| 1862 |
* |white_space| characters between the braces and the |double_quote|s. |
| 1863 |
* This |double_quote|-delimited string is parsed exactly as a |
| 1864 |
* |str_literal| is for the function command. |
| 1865 |
***************************************************************************/ |
| 1866 |
void bst_macro_command (void) |
| 1867 |
BEGIN |
| 1868 |
if (read_seen) |
| 1869 |
BEGIN |
| 1870 |
BST_ERR ("Illegal, macro command after read command"); |
| 1871 |
END |
| 1872 |
EAT_BST_WHITE_AND_EOF_CHECK ("macro"); |
| 1873 |
|
| 1874 |
/*************************************************************************** |
| 1875 |
* WEB section number: 206 |
| 1876 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1877 |
* This module reads a |left_brace|, a macro name, and a |right_brace|. |
| 1878 |
***************************************************************************/ |
| 1879 |
BEGIN |
| 1880 |
BST_GET_AND_CHECK_LEFT_BRACE ("macro"); |
| 1881 |
EAT_BST_WHITE_AND_EOF_CHECK ("macro"); |
| 1882 |
BST_IDENTIFIER_SCAN ("macro"); |
| 1883 |
|
| 1884 |
/*************************************************************************** |
| 1885 |
* WEB section number: 207 |
| 1886 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1887 |
* The macro name must be a new one; we mark it as |macro_ilk|. |
| 1888 |
***************************************************************************/ |
| 1889 |
BEGIN |
| 1890 |
|
| 1891 |
#ifdef TRACE |
| 1892 |
if (Flag_trace) { |
| 1893 |
TRACE_PR_TOKEN; |
| 1894 |
TRACE_PR_LN (" is a macro"); |
| 1895 |
} |
| 1896 |
#endif /* TRACE */ |
| 1897 |
|
| 1898 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1899 |
macro_name_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, MACRO_ILK, |
| 1900 |
DO_INSERT); |
| 1901 |
if (hash_found) |
| 1902 |
BEGIN |
| 1903 |
PRINT_TOKEN; |
| 1904 |
BST_ERR (" is already defined as a macro"); |
| 1905 |
END |
| 1906 |
ilk_info[macro_name_loc] = hash_text[macro_name_loc]; |
| 1907 |
END |
| 1908 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 207 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1909 |
|
| 1910 |
EAT_BST_WHITE_AND_EOF_CHECK ("macro"); |
| 1911 |
BST_GET_AND_CHECK_RIGHT_BRACE ("macro"); |
| 1912 |
END |
| 1913 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 206 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1914 |
|
| 1915 |
EAT_BST_WHITE_AND_EOF_CHECK ("macro"); |
| 1916 |
|
| 1917 |
/*************************************************************************** |
| 1918 |
* WEB section number: 208 |
| 1919 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1920 |
* This module reads a |left_brace|, the |double_quote|-delimited string |
| 1921 |
* that defines this macro, and a |right_brace|. |
| 1922 |
***************************************************************************/ |
| 1923 |
BEGIN |
| 1924 |
BST_GET_AND_CHECK_LEFT_BRACE ("macro"); |
| 1925 |
EAT_BST_WHITE_AND_EOF_CHECK ("macro"); |
| 1926 |
if (SCAN_CHAR != DOUBLE_QUOTE) |
| 1927 |
BEGIN |
| 1928 |
BST_ERR2 ("A macro definition must be %c-delimited", |
| 1929 |
xchr[DOUBLE_QUOTE]); |
| 1930 |
END |
| 1931 |
|
| 1932 |
/*************************************************************************** |
| 1933 |
* WEB section number: 209 |
| 1934 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1935 |
* A macro definition-string is preceded by a |double_quote| and consists |
| 1936 |
* of all characters on this line up to the next |double_quote|. The |
| 1937 |
* array |ilk_info| contains a pointer to this string for the macro name. |
| 1938 |
***************************************************************************/ |
| 1939 |
BEGIN |
| 1940 |
INCR (buf_ptr2); |
| 1941 |
if ( ! scan1 (DOUBLE_QUOTE)) |
| 1942 |
BEGIN |
| 1943 |
BST_ERR2 ("There's no `%c' to end macro definition", |
| 1944 |
xchr[DOUBLE_QUOTE]); |
| 1945 |
END |
| 1946 |
|
| 1947 |
#ifdef TRACE |
| 1948 |
if (Flag_trace) { |
| 1949 |
TRACE_PR ("\""); |
| 1950 |
TRACE_PR_TOKEN; |
| 1951 |
TRACE_PR ("\""); |
| 1952 |
TRACE_PR_LN (" is a macro string"); |
| 1953 |
} |
| 1954 |
#endif /* TRACE */ |
| 1955 |
|
| 1956 |
macro_def_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, TEXT_ILK, |
| 1957 |
DO_INSERT); |
| 1958 |
fn_type[macro_def_loc] = STR_LITERAL; |
| 1959 |
ilk_info[macro_name_loc] = hash_text[macro_def_loc]; |
| 1960 |
INCR (buf_ptr2); |
| 1961 |
END |
| 1962 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 209 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1963 |
|
| 1964 |
EAT_BST_WHITE_AND_EOF_CHECK ("macro"); |
| 1965 |
BST_GET_AND_CHECK_RIGHT_BRACE ("macro"); |
| 1966 |
END |
| 1967 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 208 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1968 |
|
| 1969 |
Exit_Label: DO_NOTHING; |
| 1970 |
END |
| 1971 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 205 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
/*************************************************************************** |
| 1977 |
* WEB section number: 294 |
| 1978 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1979 |
* When an error is so harmless, we print a |warning_message| instead of |
| 1980 |
* an |error_message|. |
| 1981 |
***************************************************************************/ |
| 1982 |
void bst_mild_ex_warn_print (void) |
| 1983 |
BEGIN |
| 1984 |
if (mess_with_entries) |
| 1985 |
BEGIN |
| 1986 |
PRINT (" for entry "); |
| 1987 |
PRINT_POOL_STR (CUR_CITE_STR); |
| 1988 |
END |
| 1989 |
PRINT_NEWLINE; |
| 1990 |
BST_WARN ("while executing"); |
| 1991 |
END |
| 1992 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 294 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1993 |
|
| 1994 |
|
| 1995 |
|
| 1996 |
|
| 1997 |
/*************************************************************************** |
| 1998 |
* WEB section number: 211 |
| 1999 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2000 |
* The read command has no arguments so there's no more parsing to do. |
| 2001 |
* We must make sure we haven't seen a read command before and we've |
| 2002 |
* already seen an entry command. |
| 2003 |
***************************************************************************/ |
| 2004 |
void bst_read_command (void) |
| 2005 |
BEGIN |
| 2006 |
if (read_seen) |
| 2007 |
BEGIN |
| 2008 |
BST_ERR ("Illegal, another read command"); |
| 2009 |
END |
| 2010 |
read_seen = TRUE; |
| 2011 |
if ( ! entry_seen) |
| 2012 |
BEGIN |
| 2013 |
BST_ERR ("Illegal, read command before entry command"); |
| 2014 |
END |
| 2015 |
sv_ptr1 = buf_ptr2; |
| 2016 |
sv_ptr2 = last; |
| 2017 |
tmp_ptr = sv_ptr1; |
| 2018 |
while (tmp_ptr < sv_ptr2) |
| 2019 |
BEGIN |
| 2020 |
sv_buffer[tmp_ptr] = buffer[tmp_ptr]; |
| 2021 |
INCR (tmp_ptr); |
| 2022 |
END |
| 2023 |
|
| 2024 |
/*************************************************************************** |
| 2025 |
* WEB section number: 223 |
| 2026 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2027 |
* For all |num_bib_files| database files, we keep reading and processing |
| 2028 |
* .bib entries until none left. |
| 2029 |
***************************************************************************/ |
| 2030 |
BEGIN |
| 2031 |
|
| 2032 |
/*************************************************************************** |
| 2033 |
* WEB section number: 224 |
| 2034 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2035 |
* We need to initialize the |field_info| array, and also various things |
| 2036 |
* associated with the |cite_list| array (but not |cite_list| itself). |
| 2037 |
***************************************************************************/ |
| 2038 |
BEGIN |
| 2039 |
|
| 2040 |
/*************************************************************************** |
| 2041 |
* WEB section number: 225 |
| 2042 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2043 |
* This module initializes all fields of all entries to |missing|, the |
| 2044 |
* value to which all fields are initialized. |
| 2045 |
***************************************************************************/ |
| 2046 |
BEGIN |
| 2047 |
check_field_overflow (num_fields * num_cites); |
| 2048 |
field_ptr = 0; |
| 2049 |
while (field_ptr < Max_Fields) |
| 2050 |
BEGIN |
| 2051 |
field_info[field_ptr] = MISSING; |
| 2052 |
INCR (field_ptr); |
| 2053 |
END |
| 2054 |
END |
| 2055 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 225 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2056 |
|
| 2057 |
/*************************************************************************** |
| 2058 |
* WEB section number: 227 |
| 2059 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2060 |
* We must initialize the |type_list| array so that we can detect |
| 2061 |
* duplicate (or missing) entries for cite keys on |cite_list|. Also, |
| 2062 |
* when we're to include the entire database, we use the array |
| 2063 |
* |entry_exists| to detect those missing entries whose |cite_list| info |
| 2064 |
* will (or to be more precise, might) be overwritten; and we use the |
| 2065 |
* array |cite_info| to save the part of |cite_list| that will (might) be |
| 2066 |
* overwritten. We also use |cite_info| for counting cross~references |
| 2067 |
* when it's appropriate---when an entry isn't otherwise to be included |
| 2068 |
* on |cite_list| (that is, the entry isn't \cited or |
| 2069 |
* \nocited). Such an entry is included on the final |cite_list| if |
| 2070 |
* it's cross~referenced at least |min_crossrefs| times. |
| 2071 |
***************************************************************************/ |
| 2072 |
BEGIN |
| 2073 |
cite_ptr = 0; |
| 2074 |
while (cite_ptr < Max_Cites) |
| 2075 |
BEGIN |
| 2076 |
type_list[cite_ptr] = EMPTY; |
| 2077 |
cite_info[cite_ptr] = ANY_VALUE; |
| 2078 |
INCR (cite_ptr); |
| 2079 |
END |
| 2080 |
old_num_cites = num_cites; |
| 2081 |
if (all_entries) |
| 2082 |
BEGIN |
| 2083 |
cite_ptr = all_marker; |
| 2084 |
while (cite_ptr < old_num_cites) |
| 2085 |
BEGIN |
| 2086 |
cite_info[cite_ptr] = cite_list[cite_ptr]; |
| 2087 |
entry_exists[cite_ptr] = FALSE; |
| 2088 |
INCR (cite_ptr); |
| 2089 |
END |
| 2090 |
cite_ptr = all_marker; |
| 2091 |
END |
| 2092 |
else |
| 2093 |
BEGIN |
| 2094 |
cite_ptr = num_cites; |
| 2095 |
all_marker = ANY_VALUE; |
| 2096 |
END |
| 2097 |
END |
| 2098 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 227 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2099 |
END |
| 2100 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 224 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2101 |
|
| 2102 |
read_performed = TRUE; |
| 2103 |
bib_ptr = 0; |
| 2104 |
while (bib_ptr < num_bib_files) |
| 2105 |
BEGIN |
| 2106 |
PRINT2 ("Database file #%ld: ", (long) bib_ptr + 1); |
| 2107 |
print_bib_name (); |
| 2108 |
bib_line_num = 0; |
| 2109 |
buf_ptr2 = last; |
| 2110 |
while ( ! feof (CUR_BIB_FILE)) |
| 2111 |
BEGIN |
| 2112 |
get_bib_command_or_entry_and_pr (); |
| 2113 |
END |
| 2114 |
a_close (CUR_BIB_FILE); |
| 2115 |
INCR (bib_ptr); |
| 2116 |
END |
| 2117 |
reading_completed = TRUE; |
| 2118 |
|
| 2119 |
#ifdef TRACE |
| 2120 |
if (Flag_trace) |
| 2121 |
TRACE_PR_LN ("Finished reading the database file(s)"); |
| 2122 |
#endif /* TRACE */ |
| 2123 |
|
| 2124 |
/*************************************************************************** |
| 2125 |
* WEB section number: 276 |
| 2126 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2127 |
* This gets things ready for further .bst processing. |
| 2128 |
***************************************************************************/ |
| 2129 |
BEGIN |
| 2130 |
num_cites = cite_ptr; |
| 2131 |
num_preamble_strings = preamble_ptr; |
| 2132 |
|
| 2133 |
/*************************************************************************** |
| 2134 |
* WEB section number: 277 |
| 2135 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2136 |
* Now we update any entry (here called a child entry) that |
| 2137 |
* cross referenced another (here called a parent entry); this |
| 2138 |
* cross referencing occurs when the child's crossref field (value) |
| 2139 |
* consists of the parent's database key. To do the update, we replace |
| 2140 |
* the child's |missing| fields by the corresponding fields of the |
| 2141 |
* parent. Also, we make sure the crossref field contains the |
| 2142 |
* case-correct version. Finally, although it is technically illegal to |
| 2143 |
* nest cross references, and although we give a warning (a few modules |
| 2144 |
* hence) when someone tries, we do what we can to accommodate the |
| 2145 |
* attempt. |
| 2146 |
***************************************************************************/ |
| 2147 |
BEGIN |
| 2148 |
cite_ptr = 0; |
| 2149 |
while (cite_ptr < num_cites) |
| 2150 |
BEGIN |
| 2151 |
field_ptr = (cite_ptr * num_fields) + crossref_num; |
| 2152 |
if (field_info[field_ptr] != MISSING) |
| 2153 |
BEGIN |
| 2154 |
if (find_cite_locs_for_this_cite_ke (field_info[field_ptr])) |
| 2155 |
BEGIN |
| 2156 |
cite_loc = ilk_info[lc_cite_loc]; |
| 2157 |
field_info[field_ptr] = hash_text[cite_loc]; |
| 2158 |
cite_parent_ptr = ilk_info[cite_loc]; |
| 2159 |
field_ptr = (cite_ptr * num_fields) + num_pre_defined_fields; |
| 2160 |
field_end_ptr = field_ptr - num_pre_defined_fields + num_fields; |
| 2161 |
field_parent_ptr = (cite_parent_ptr * num_fields) |
| 2162 |
+ num_pre_defined_fields; |
| 2163 |
while (field_ptr < field_end_ptr) |
| 2164 |
BEGIN |
| 2165 |
if (field_info[field_ptr] == MISSING) |
| 2166 |
BEGIN |
| 2167 |
field_info[field_ptr] = field_info[field_parent_ptr]; |
| 2168 |
END |
| 2169 |
INCR (field_ptr); |
| 2170 |
INCR (field_parent_ptr); |
| 2171 |
END |
| 2172 |
END |
| 2173 |
END |
| 2174 |
INCR (cite_ptr); |
| 2175 |
END |
| 2176 |
END |
| 2177 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 277 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2178 |
|
| 2179 |
/*************************************************************************** |
| 2180 |
* WEB section number: 279 |
| 2181 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2182 |
* Here we remove the crossref field value for each child whose |
| 2183 |
* parent was cross referenced too few times. We also issue any |
| 2184 |
* necessary warnings arising from a bad cross reference. |
| 2185 |
***************************************************************************/ |
| 2186 |
BEGIN |
| 2187 |
cite_ptr = 0; |
| 2188 |
while (cite_ptr < num_cites) |
| 2189 |
BEGIN |
| 2190 |
field_ptr = (cite_ptr * num_fields) + crossref_num; |
| 2191 |
if (field_info[field_ptr] != MISSING) |
| 2192 |
BEGIN |
| 2193 |
if ( ! find_cite_locs_for_this_cite_ke (field_info[field_ptr])) |
| 2194 |
BEGIN |
| 2195 |
if (cite_hash_found) |
| 2196 |
BEGIN |
| 2197 |
hash_cite_confusion (); |
| 2198 |
END |
| 2199 |
non_existent_cross_reference_er (); |
| 2200 |
field_info[field_ptr] = MISSING; |
| 2201 |
END |
| 2202 |
else |
| 2203 |
BEGIN |
| 2204 |
if (cite_loc != ilk_info[lc_cite_loc]) |
| 2205 |
BEGIN |
| 2206 |
hash_cite_confusion (); |
| 2207 |
END |
| 2208 |
cite_parent_ptr = ilk_info[cite_loc]; |
| 2209 |
if (type_list[cite_parent_ptr] == EMPTY) |
| 2210 |
BEGIN |
| 2211 |
non_existent_cross_reference_er (); |
| 2212 |
field_info[field_ptr] = MISSING; |
| 2213 |
END |
| 2214 |
else |
| 2215 |
BEGIN |
| 2216 |
field_parent_ptr = (cite_parent_ptr * num_fields) |
| 2217 |
+ crossref_num; |
| 2218 |
if (field_info[field_parent_ptr] != MISSING) |
| 2219 |
|
| 2220 |
/*************************************************************************** |
| 2221 |
* WEB section number: 282 |
| 2222 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2223 |
* We also complain when an entry being cross referenced has a |
| 2224 |
* non|missing| crossref field itself, but this one is just a |
| 2225 |
* warning, not a full-blown error. |
| 2226 |
***************************************************************************/ |
| 2227 |
BEGIN |
| 2228 |
PRINT ("Warning--you've nested cross references"); |
| 2229 |
bad_cross_reference_print (cite_list[cite_parent_ptr]); |
| 2230 |
PRINT_LN ("\", which also refers to something"); |
| 2231 |
mark_warning (); |
| 2232 |
END |
| 2233 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 282 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2234 |
|
| 2235 |
if (( ! all_entries) && (cite_parent_ptr >= old_num_cites) |
| 2236 |
&& (cite_info[cite_parent_ptr] < Min_Crossrefs)) |
| 2237 |
BEGIN |
| 2238 |
field_info[field_ptr] = MISSING; |
| 2239 |
END |
| 2240 |
END |
| 2241 |
END |
| 2242 |
END |
| 2243 |
INCR (cite_ptr); |
| 2244 |
END |
| 2245 |
END |
| 2246 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 279 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2247 |
|
| 2248 |
/*************************************************************************** |
| 2249 |
* WEB section number: 283 |
| 2250 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2251 |
* We remove (and give a warning for) each cite key on the original |
| 2252 |
* |cite_list| without a corresponding database entry. And we remove any |
| 2253 |
* entry that was included on |cite_list| only because it was |
| 2254 |
* cross~referenced, yet was cross~referenced fewer than |min_crossrefs| |
| 2255 |
* times. Throughout this module, |cite_ptr| points to the next cite key |
| 2256 |
* to be checked and |cite_xptr| points to the next permanent spot on |
| 2257 |
* |cite_list|. |
| 2258 |
***************************************************************************/ |
| 2259 |
BEGIN |
| 2260 |
cite_ptr = 0; |
| 2261 |
while (cite_ptr < num_cites) |
| 2262 |
BEGIN |
| 2263 |
if (type_list[cite_ptr] == EMPTY) |
| 2264 |
BEGIN |
| 2265 |
print_missing_entry (CUR_CITE_STR); |
| 2266 |
END |
| 2267 |
else if ((all_entries) || (cite_ptr < old_num_cites) |
| 2268 |
|| (cite_info[cite_ptr] >= Min_Crossrefs)) |
| 2269 |
BEGIN |
| 2270 |
if (cite_ptr > cite_xptr) |
| 2271 |
|
| 2272 |
/*************************************************************************** |
| 2273 |
* WEB section number: 285 |
| 2274 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2275 |
* We have to move to its final resting place all the entry information |
| 2276 |
* associated with the exact location in |cite_list| of this cite key. |
| 2277 |
***************************************************************************/ |
| 2278 |
BEGIN |
| 2279 |
cite_list[cite_xptr] = cite_list[cite_ptr]; |
| 2280 |
type_list[cite_xptr] = type_list[cite_ptr]; |
| 2281 |
if ( ! find_cite_locs_for_this_cite_ke (cite_list[cite_ptr])) |
| 2282 |
BEGIN |
| 2283 |
cite_key_disappeared_confusion (); |
| 2284 |
END |
| 2285 |
if (( ! cite_hash_found) || (cite_loc != ilk_info[lc_cite_loc])) |
| 2286 |
BEGIN |
| 2287 |
hash_cite_confusion (); |
| 2288 |
END |
| 2289 |
ilk_info[cite_loc] = cite_xptr; |
| 2290 |
field_ptr = cite_xptr * num_fields; |
| 2291 |
field_end_ptr = field_ptr + num_fields; |
| 2292 |
tmp_ptr = cite_ptr * num_fields; |
| 2293 |
while (field_ptr < field_end_ptr) |
| 2294 |
BEGIN |
| 2295 |
field_info[field_ptr] = field_info[tmp_ptr]; |
| 2296 |
INCR (field_ptr); |
| 2297 |
INCR (tmp_ptr); |
| 2298 |
END |
| 2299 |
END |
| 2300 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 285 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2301 |
|
| 2302 |
INCR (cite_xptr); |
| 2303 |
END |
| 2304 |
INCR (cite_ptr); |
| 2305 |
END |
| 2306 |
num_cites = cite_xptr; |
| 2307 |
if (all_entries) |
| 2308 |
|
| 2309 |
/*************************************************************************** |
| 2310 |
* WEB section number: 286 |
| 2311 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2312 |
* We need this module only when we're including the whole database. |
| 2313 |
* It's for missing entries whose cite key originally resided in |
| 2314 |
* |cite_list| at a spot that another cite key (might have) claimed. |
| 2315 |
***************************************************************************/ |
| 2316 |
BEGIN |
| 2317 |
cite_ptr = all_marker; |
| 2318 |
while (cite_ptr < old_num_cites) |
| 2319 |
BEGIN |
| 2320 |
if ( ! entry_exists[cite_ptr]) |
| 2321 |
BEGIN |
| 2322 |
print_missing_entry (cite_info[cite_ptr]); |
| 2323 |
END |
| 2324 |
INCR (cite_ptr); |
| 2325 |
END |
| 2326 |
END |
| 2327 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 286 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2328 |
|
| 2329 |
END |
| 2330 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 283 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2331 |
|
| 2332 |
/*************************************************************************** |
| 2333 |
* WEB section number: 287 |
| 2334 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2335 |
* This module initializes all |int_entry_var|s of all entries to 0, the |
| 2336 |
* value to which all integers are initialized. |
| 2337 |
***************************************************************************/ |
| 2338 |
BEGIN |
| 2339 |
int_ent_ptr = (num_ent_ints + 1) * (num_cites + 1); |
| 2340 |
entry_ints = (Integer_T *) mymalloc ((unsigned long) sizeof (Integer_T) |
| 2341 |
* (unsigned long) int_ent_ptr, "entry_ints"); |
| 2342 |
while (int_ent_ptr > 0) |
| 2343 |
BEGIN |
| 2344 |
DECR (int_ent_ptr); |
| 2345 |
entry_ints[int_ent_ptr] = 0; |
| 2346 |
END |
| 2347 |
END |
| 2348 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 287 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2349 |
|
| 2350 |
/*************************************************************************** |
| 2351 |
* WEB section number: 288 |
| 2352 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2353 |
* This module initializes all |str_entry_var|s of all entries to the |
| 2354 |
* null string, the value to which all strings are initialized. |
| 2355 |
***************************************************************************/ |
| 2356 |
BEGIN |
| 2357 |
str_ent_ptr = (num_ent_strs + 1) * (num_cites + 1); |
| 2358 |
entry_strs = (ASCIICode_T *) mymalloc ((unsigned long) sizeof (ASCIICode_T) |
| 2359 |
* (unsigned long) (Ent_Str_Size + 1) |
| 2360 |
* (unsigned long) str_ent_ptr, "entry_strs"); |
| 2361 |
while (str_ent_ptr > 0) |
| 2362 |
BEGIN |
| 2363 |
DECR (str_ent_ptr); |
| 2364 |
ENTRY_STRS(str_ent_ptr,0) = END_OF_STRING; |
| 2365 |
END |
| 2366 |
END |
| 2367 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 288 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2368 |
|
| 2369 |
/*************************************************************************** |
| 2370 |
* WEB section number: 289 |
| 2371 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2372 |
* The array |sorted_cites| initially specifies that the entries are to |
| 2373 |
* be processed in order of cite-key occurrence. The sort command |
| 2374 |
* may change this to whatever it likes (which, we hope, is whatever the |
| 2375 |
* style-designer instructs it to like). We make |sorted_cites| an alias |
| 2376 |
* to save space; this works fine because we're done with |cite_info|. |
| 2377 |
***************************************************************************/ |
| 2378 |
BEGIN |
| 2379 |
cite_ptr = 0; |
| 2380 |
while (cite_ptr < num_cites) |
| 2381 |
BEGIN |
| 2382 |
SORTED_CITES[cite_ptr] = cite_ptr; |
| 2383 |
INCR (cite_ptr); |
| 2384 |
END |
| 2385 |
END |
| 2386 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 289 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2387 |
|
| 2388 |
END |
| 2389 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 276 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2390 |
|
| 2391 |
read_completed = TRUE; |
| 2392 |
END |
| 2393 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 223 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2394 |
|
| 2395 |
buf_ptr2 = sv_ptr1; |
| 2396 |
last = sv_ptr2; |
| 2397 |
tmp_ptr = buf_ptr2; |
| 2398 |
while (tmp_ptr < last) |
| 2399 |
BEGIN |
| 2400 |
buffer[tmp_ptr] = sv_buffer[tmp_ptr]; |
| 2401 |
INCR (tmp_ptr); |
| 2402 |
END |
| 2403 |
Exit_Label: DO_NOTHING; |
| 2404 |
END |
| 2405 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 211 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2406 |
|
| 2407 |
|
| 2408 |
|
| 2409 |
|
| 2410 |
/*************************************************************************** |
| 2411 |
* WEB section number: 212 |
| 2412 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2413 |
* A reverse command has one argument, a single |built_in| or |
| 2414 |
* |wiz_defined| function name between braces. Upper/lower cases are |
| 2415 |
* considered to be the same---all upper-case letters are converted to |
| 2416 |
* lower case. Also, we must make sure we've already seen a read |
| 2417 |
* command. |
| 2418 |
* |
| 2419 |
* This module reads a |left_brace|, a single function to be iterated in |
| 2420 |
* reverse, and a |right_brace|. |
| 2421 |
***************************************************************************/ |
| 2422 |
void bst_reverse_command (void) |
| 2423 |
BEGIN |
| 2424 |
if ( ! read_seen) |
| 2425 |
BEGIN |
| 2426 |
BST_ERR ("Illegal, reverse command before read command"); |
| 2427 |
END |
| 2428 |
EAT_BST_WHITE_AND_EOF_CHECK ("reverse"); |
| 2429 |
BST_GET_AND_CHECK_LEFT_BRACE ("reverse"); |
| 2430 |
EAT_BST_WHITE_AND_EOF_CHECK ("reverse"); |
| 2431 |
BST_IDENTIFIER_SCAN ("reverse"); |
| 2432 |
|
| 2433 |
/*************************************************************************** |
| 2434 |
* WEB section number: 213 |
| 2435 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2436 |
* Before iterating the function, we must make sure it's a legal one. It |
| 2437 |
* must exist and be |built_in| or |wiz_defined|. |
| 2438 |
***************************************************************************/ |
| 2439 |
BEGIN |
| 2440 |
|
| 2441 |
#ifdef TRACE |
| 2442 |
if (Flag_trace) { |
| 2443 |
TRACE_PR_TOKEN; |
| 2444 |
TRACE_PR_LN (" is a to be iterated in reverse function"); |
| 2445 |
} |
| 2446 |
#endif /* TRACE */ |
| 2447 |
|
| 2448 |
if (bad_argument_token ()) |
| 2449 |
BEGIN |
| 2450 |
goto Exit_Label; |
| 2451 |
END |
| 2452 |
END |
| 2453 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 213 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2454 |
|
| 2455 |
EAT_BST_WHITE_AND_EOF_CHECK ("reverse"); |
| 2456 |
BST_GET_AND_CHECK_RIGHT_BRACE ("reverse"); |
| 2457 |
|
| 2458 |
/*************************************************************************** |
| 2459 |
* WEB section number: 298 |
| 2460 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2461 |
* This module iterates a single specified function for all entries |
| 2462 |
* specified by |cite_list|, but does it in reverse order. |
| 2463 |
***************************************************************************/ |
| 2464 |
BEGIN |
| 2465 |
init_command_execution (); |
| 2466 |
mess_with_entries = TRUE; |
| 2467 |
if (num_cites > 0) |
| 2468 |
BEGIN |
| 2469 |
sort_cite_ptr = num_cites; |
| 2470 |
REPEAT |
| 2471 |
BEGIN |
| 2472 |
DECR (sort_cite_ptr); |
| 2473 |
cite_ptr = SORTED_CITES[sort_cite_ptr]; |
| 2474 |
|
| 2475 |
#ifdef TRACE |
| 2476 |
if (Flag_trace) { |
| 2477 |
TRACE_PR_POOL_STR (hash_text[fn_loc]); |
| 2478 |
TRACE_PR (" to be iterated in reverse on "); |
| 2479 |
TRACE_PR_POOL_STR (CUR_CITE_STR); |
| 2480 |
TRACE_PR_NEWLINE; |
| 2481 |
} |
| 2482 |
#endif /* TRACE */ |
| 2483 |
|
| 2484 |
execute_fn (fn_loc); |
| 2485 |
check_command_execution (); |
| 2486 |
END UNTIL (sort_cite_ptr == 0); |
| 2487 |
END |
| 2488 |
END |
| 2489 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 298 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2490 |
|
| 2491 |
Exit_Label: DO_NOTHING; |
| 2492 |
END |
| 2493 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 212 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
/*************************************************************************** |
| 2498 |
* WEB section number: 168 |
| 2499 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2500 |
* And this one, a |right_brace|. |
| 2501 |
***************************************************************************/ |
| 2502 |
void bst_right_brace_print (void) |
| 2503 |
BEGIN |
| 2504 |
PRINT2 ("\"%c\" is missing in command: ", xchr[RIGHT_BRACE]); |
| 2505 |
END |
| 2506 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 168 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2507 |
|
| 2508 |
|
| 2509 |
|
| 2510 |
/*************************************************************************** |
| 2511 |
* WEB section number: 214 |
| 2512 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2513 |
* The sort command has no arguments so there's no more parsing to do, |
| 2514 |
* but we must make sure we've already seen a read command. |
| 2515 |
***************************************************************************/ |
| 2516 |
void bst_sort_command (void) |
| 2517 |
BEGIN |
| 2518 |
if ( ! read_seen) |
| 2519 |
BEGIN |
| 2520 |
BST_ERR ("Illegal, sort command before read command"); |
| 2521 |
END |
| 2522 |
|
| 2523 |
/*************************************************************************** |
| 2524 |
* WEB section number: 299 |
| 2525 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2526 |
* This module sorts the entries based on sort.key$; it is a stable |
| 2527 |
* sort. |
| 2528 |
***************************************************************************/ |
| 2529 |
BEGIN |
| 2530 |
|
| 2531 |
#ifdef TRACE |
| 2532 |
if (Flag_trace) |
| 2533 |
TRACE_PR_LN ("Sorting the entries"); |
| 2534 |
#endif /* TRACE */ |
| 2535 |
|
| 2536 |
if (num_cites > 1) |
| 2537 |
BEGIN |
| 2538 |
quick_sort (0, num_cites - 1); |
| 2539 |
END |
| 2540 |
|
| 2541 |
#ifdef TRACE |
| 2542 |
if (Flag_trace) |
| 2543 |
TRACE_PR_LN ("Done sorting"); |
| 2544 |
#endif /* TRACE */ |
| 2545 |
|
| 2546 |
END |
| 2547 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2548 |
|
| 2549 |
Exit_Label: DO_NOTHING; |
| 2550 |
END |
| 2551 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 214 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2552 |
|
| 2553 |
|
| 2554 |
|
| 2555 |
/*************************************************************************** |
| 2556 |
* WEB section number: 215 |
| 2557 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2558 |
* A strings command has one argument, a list of function names |
| 2559 |
* between braces (the names are separated by one or more |white_space| |
| 2560 |
* characters). Upper/lower cases are considered to be the same for |
| 2561 |
* function names in these lists---all upper-case letters are converted to |
| 2562 |
* lower case. Each name in this list specifies a |str_global_var|. |
| 2563 |
* There may be several strings commands in the .bst file. |
| 2564 |
* |
| 2565 |
* This module reads a |left_brace|, a list of |str_global_var|s, and a |
| 2566 |
* |right_brace|. |
| 2567 |
***************************************************************************/ |
| 2568 |
void bst_strings_command (void) |
| 2569 |
BEGIN |
| 2570 |
EAT_BST_WHITE_AND_EOF_CHECK ("strings"); |
| 2571 |
BST_GET_AND_CHECK_LEFT_BRACE ("strings"); |
| 2572 |
EAT_BST_WHITE_AND_EOF_CHECK ("strings"); |
| 2573 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 2574 |
BEGIN |
| 2575 |
BST_IDENTIFIER_SCAN ("strings"); |
| 2576 |
|
| 2577 |
/*************************************************************************** |
| 2578 |
* WEB section number: 216 |
| 2579 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2580 |
* Here we insert the just found |str_global_var| name into the hash |
| 2581 |
* table, record it as a |str_global_var|, set its pointer into |
| 2582 |
* |global_strs|, and initialize its value there to the null string. |
| 2583 |
***************************************************************************/ |
| 2584 |
BEGIN |
| 2585 |
|
| 2586 |
#ifdef TRACE |
| 2587 |
if (Flag_trace) { |
| 2588 |
TRACE_PR_TOKEN; |
| 2589 |
TRACE_PR_LN (" is a string global-variable"); |
| 2590 |
} |
| 2591 |
#endif /* TRACE */ |
| 2592 |
|
| 2593 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 2594 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK, |
| 2595 |
DO_INSERT); |
| 2596 |
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc); |
| 2597 |
fn_type[fn_loc] = STR_GLOBAL_VAR; |
| 2598 |
FN_INFO[fn_loc] = num_glb_strs; |
| 2599 |
if (num_glb_strs == Max_Glob_Strs) |
| 2600 |
BEGIN |
| 2601 |
BIB_XRETALLOC_NOSET ("glb_str_ptr", glb_str_ptr, StrNumber_T, |
| 2602 |
Max_Glob_Strs, Max_Glob_Strs + MAX_GLOB_STRS); |
| 2603 |
BIB_XRETALLOC_STRING ("global_strs", global_strs, Glob_Str_Size, |
| 2604 |
Max_Glob_Strs, Max_Glob_Strs + MAX_GLOB_STRS); |
| 2605 |
BIB_XRETALLOC ("glb_str_end", glb_str_end, Integer_T, |
| 2606 |
Max_Glob_Strs, Max_Glob_Strs + MAX_GLOB_STRS); |
| 2607 |
str_glb_ptr = num_glb_strs; |
| 2608 |
while (str_glb_ptr < Max_Glob_Strs) |
| 2609 |
BEGIN |
| 2610 |
glb_str_ptr[str_glb_ptr] = 0; |
| 2611 |
glb_str_end[str_glb_ptr] = 0; |
| 2612 |
INCR (str_glb_ptr); |
| 2613 |
END |
| 2614 |
END |
| 2615 |
INCR (num_glb_strs); |
| 2616 |
END |
| 2617 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 216 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2618 |
|
| 2619 |
EAT_BST_WHITE_AND_EOF_CHECK ("strings"); |
| 2620 |
|
| 2621 |
END |
| 2622 |
INCR (buf_ptr2); |
| 2623 |
Exit_Label: DO_NOTHING; |
| 2624 |
END |
| 2625 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 215 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2626 |
|
| 2627 |
|
| 2628 |
|
| 2629 |
|
| 2630 |
/*************************************************************************** |
| 2631 |
* WEB section number: 150 |
| 2632 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2633 |
* When there's a harmless error parsing the .bst file (harmless |
| 2634 |
* syntactically, at least) we give just a |warning_message|. |
| 2635 |
***************************************************************************/ |
| 2636 |
void bst_warn_print (void) |
| 2637 |
BEGIN |
| 2638 |
bst_ln_num_print (); |
| 2639 |
mark_warning (); |
| 2640 |
END |
| 2641 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 150 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
/*************************************************************************** |
| 2647 |
* WEB section number: 46 |
| 2648 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2649 |
* When a buffer overflows, it's time to complain (and then quit). |
| 2650 |
***************************************************************************/ |
| 2651 |
void buffer_overflow (void) |
| 2652 |
BEGIN |
| 2653 |
BIB_XRETALLOC_NOSET ("buffer", buffer, ASCIICode_T, |
| 2654 |
Buf_Size, Buf_Size + BUF_SIZE); |
| 2655 |
BIB_XRETALLOC_NOSET ("ex_buf", ex_buf, ASCIICode_T, |
| 2656 |
Buf_Size, Buf_Size + BUF_SIZE); |
| 2657 |
BIB_XRETALLOC_NOSET ("name_sep_char", name_sep_char, ASCIICode_T, |
| 2658 |
Buf_Size, Buf_Size + BUF_SIZE); |
| 2659 |
BIB_XRETALLOC_NOSET ("name_tok", name_tok, BufPointer_T, |
| 2660 |
Buf_Size, Buf_Size + BUF_SIZE); |
| 2661 |
BIB_XRETALLOC_NOSET ("out_buf", out_buf, ASCIICode_T, |
| 2662 |
Buf_Size, Buf_Size + BUF_SIZE); |
| 2663 |
BIB_XRETALLOC ("sv_buffer", sv_buffer, ASCIICode_T, |
| 2664 |
Buf_Size, Buf_Size + BUF_SIZE); |
| 2665 |
END |
| 2666 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 46 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
/*************************************************************************** |
| 2672 |
* WEB section number: 335 |
| 2673 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2674 |
* This procedure inserts a |built_in| function into the hash table and |
| 2675 |
* initializes the corresponding pre-defined string (of length at most |
| 2676 |
* |longest_pds|). The array |FN_INFO| contains a number from 0 through |
| 2677 |
* the number of |built_in| functions minus 1 (i.e., |num_blt_in_fns - 1| |
| 2678 |
* if we're keeping statistics); this number is used by a |case| statement |
| 2679 |
* to execute this function and is used for keeping execution counts when |
| 2680 |
* keeping statistics. |
| 2681 |
***************************************************************************/ |
| 2682 |
void build_in (PdsType_T pds, PdsLen_T len, |
| 2683 |
HashLoc_T *fn_hash_loc, BltInRange_T blt_in_num) |
| 2684 |
BEGIN |
| 2685 |
pre_define (pds, len, BST_FN_ILK); |
| 2686 |
*fn_hash_loc = pre_def_loc; |
| 2687 |
fn_type[*fn_hash_loc] = BUILT_IN; |
| 2688 |
FN_INFO[*fn_hash_loc] = blt_in_num; |
| 2689 |
|
| 2690 |
#ifdef STAT |
| 2691 |
if (Flag_stats) { |
| 2692 |
blt_in_loc[blt_in_num] = *fn_hash_loc; |
| 2693 |
execution_count[blt_in_num] = 0; |
| 2694 |
} |
| 2695 |
#endif /* STAT */ |
| 2696 |
|
| 2697 |
END |
| 2698 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 335 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2699 |
|
| 2700 |
|
| 2701 |
|
| 2702 |
|
| 2703 |
/*************************************************************************** |
| 2704 |
* WEB section number: 373 |
| 2705 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2706 |
* Another bug complaint. |
| 2707 |
***************************************************************************/ |
| 2708 |
void case_conversion_confusion (void) |
| 2709 |
BEGIN |
| 2710 |
CONFUSION ("Unknown type of case conversion"); |
| 2711 |
END |
| 2712 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 373 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2713 |
|
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
/*************************************************************************** |
| 2718 |
* WEB section number: 369 |
| 2719 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2720 |
* This one makes sure that |brace_level=0| (it's called at a point in a |
| 2721 |
* string where braces must be balanced). |
| 2722 |
***************************************************************************/ |
| 2723 |
void check_brace_level (StrNumber_T pop_lit_var) |
| 2724 |
BEGIN |
| 2725 |
if (brace_level > 0) |
| 2726 |
BEGIN |
| 2727 |
braces_unbalanced_complaint (pop_lit_var); |
| 2728 |
END |
| 2729 |
END |
| 2730 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 369 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
/*************************************************************************** |
| 2736 |
* WEB section number: 138 |
| 2737 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2738 |
* Complain if somebody's got a cite fetish. This procedure is called |
| 2739 |
* when were about to add another cite key to |cite_list|. It assumes |
| 2740 |
* that |cite_loc| gives the potential cite key's hash table location. |
| 2741 |
***************************************************************************/ |
| 2742 |
void check_cite_overflow (CiteNumber_T last_cite) |
| 2743 |
BEGIN |
| 2744 |
if (last_cite == Max_Cites) |
| 2745 |
BEGIN |
| 2746 |
BIB_XRETALLOC_NOSET ("cite_info", cite_info, StrNumber_T, |
| 2747 |
Max_Cites, Max_Cites + MAX_CITES); |
| 2748 |
BIB_XRETALLOC_NOSET ("cite_list", cite_list, StrNumber_T, |
| 2749 |
Max_Cites, Max_Cites + MAX_CITES); |
| 2750 |
BIB_XRETALLOC_NOSET ("entry_exists", entry_exists, Boolean_T, |
| 2751 |
Max_Cites, Max_Cites + MAX_CITES); |
| 2752 |
BIB_XRETALLOC ("type_list", type_list, HashPtr2_T, |
| 2753 |
Max_Cites, Max_Cites + MAX_CITES); |
| 2754 |
while (last_cite < Max_Cites) |
| 2755 |
BEGIN |
| 2756 |
type_list[last_cite] = EMPTY; |
| 2757 |
cite_info[last_cite] = ANY_VALUE; |
| 2758 |
INCR (last_cite); |
| 2759 |
END |
| 2760 |
END |
| 2761 |
END |
| 2762 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 138 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2763 |
|
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
/*************************************************************************** |
| 2768 |
* WEB section number: 317 |
| 2769 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2770 |
* At the end of a .bst command-execution we check that the stack and |
| 2771 |
* |str_pool| are still in good shape. |
| 2772 |
***************************************************************************/ |
| 2773 |
void check_command_execution (void) |
| 2774 |
BEGIN |
| 2775 |
if (lit_stk_ptr != 0) |
| 2776 |
BEGIN |
| 2777 |
PRINT_LN2 ("ptr=%ld, stack=", (long) lit_stk_ptr); |
| 2778 |
pop_whole_stack (); |
| 2779 |
PRINT ("---the literal stack isn't empty"); |
| 2780 |
bst_ex_warn_print (); |
| 2781 |
END |
| 2782 |
if (cmd_str_ptr != str_ptr) |
| 2783 |
BEGIN |
| 2784 |
|
| 2785 |
#ifdef TRACE |
| 2786 |
if (Flag_trace) |
| 2787 |
TRACE_PR_LN3 ("Pointer is %ld but should be %ld", (long) str_ptr, |
| 2788 |
(long) cmd_str_ptr); |
| 2789 |
#endif /* TRACE */ |
| 2790 |
|
| 2791 |
CONFUSION ("Nonempty empty string stack"); |
| 2792 |
END |
| 2793 |
END |
| 2794 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 317 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2795 |
|
| 2796 |
|
| 2797 |
|
| 2798 |
|
| 2799 |
/*************************************************************************** |
| 2800 |
* WEB section number: 226 |
| 2801 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2802 |
* Complain if somebody's got a field fetish. |
| 2803 |
***************************************************************************/ |
| 2804 |
void check_field_overflow (Integer_T total_fields) |
| 2805 |
BEGIN |
| 2806 |
if (total_fields > Max_Fields) |
| 2807 |
BEGIN |
| 2808 |
field_ptr = Max_Fields; |
| 2809 |
BIB_XRETALLOC ("field_info", field_info, StrNumber_T, |
| 2810 |
Max_Fields, total_fields + MAX_FIELDS); |
| 2811 |
/* Initialize to |missing|. */ |
| 2812 |
while (field_ptr < Max_Fields) |
| 2813 |
BEGIN |
| 2814 |
field_info[field_ptr] = MISSING; |
| 2815 |
INCR (field_ptr); |
| 2816 |
END |
| 2817 |
END |
| 2818 |
END |
| 2819 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 226 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2820 |
|
| 2821 |
|
| 2822 |
|
| 2823 |
/*************************************************************************** |
| 2824 |
* WEB section number: 271 |
| 2825 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2826 |
* Here's another bug complaint. |
| 2827 |
***************************************************************************/ |
| 2828 |
void cite_key_disappeared_confusion (void) |
| 2829 |
BEGIN |
| 2830 |
CONFUSION ("A cite key disappeared"); |
| 2831 |
END |
| 2832 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2833 |
|
| 2834 |
|
| 2835 |
|
| 2836 |
|
| 2837 |
/*************************************************************************** |
| 2838 |
* WEB section number: 252 |
| 2839 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2840 |
* The .bib-specific scanning function |compress_bib_white| skips over |
| 2841 |
* |white_space| characters within a string until hitting a nonwhite |
| 2842 |
* character; in fact, it does everything |eat_bib_white_space| does, but |
| 2843 |
* it also adds a |space| to |field_vl_str|. This function is never |
| 2844 |
* called if there are no |white_space| characters (or ends-of-line) to be |
| 2845 |
* scanned (though the associated macro might be). The function returns |
| 2846 |
* |false| if there is a serious syntax error. |
| 2847 |
***************************************************************************/ |
| 2848 |
Boolean_T compress_bib_white (void) |
| 2849 |
BEGIN |
| 2850 |
Boolean_T compress_bib_white; |
| 2851 |
|
| 2852 |
compress_bib_white = FALSE; |
| 2853 |
COPY_CHAR (SPACE); |
| 2854 |
while ( ! scan_white_space ()) |
| 2855 |
BEGIN |
| 2856 |
if ( ! input_ln (CUR_BIB_FILE)) |
| 2857 |
BEGIN |
| 2858 |
eat_bib_print (); |
| 2859 |
goto Exit_Label; |
| 2860 |
END |
| 2861 |
INCR (bib_line_num); |
| 2862 |
buf_ptr2 = 0; |
| 2863 |
END |
| 2864 |
compress_bib_white = TRUE; |
| 2865 |
Exit_Label: DO_NOTHING; |
| 2866 |
return (compress_bib_white); |
| 2867 |
END |
| 2868 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 252 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2869 |
|
| 2870 |
|
| 2871 |
|
| 2872 |
|
| 2873 |
/*************************************************************************** |
| 2874 |
* WEB section number: 367 |
| 2875 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2876 |
* This procedure complains if the just-encountered |right_brace| would |
| 2877 |
* make |brace_level| negative. |
| 2878 |
***************************************************************************/ |
| 2879 |
void decr_brace_level (StrNumber_T pop_lit_var) |
| 2880 |
BEGIN |
| 2881 |
if (brace_level == 0) |
| 2882 |
BEGIN |
| 2883 |
braces_unbalanced_complaint (pop_lit_var); |
| 2884 |
END |
| 2885 |
else |
| 2886 |
BEGIN |
| 2887 |
DECR (brace_level); |
| 2888 |
END |
| 2889 |
END |
| 2890 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 367 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
|
| 2895 |
/*************************************************************************** |
| 2896 |
* WEB section number: 229 |
| 2897 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2898 |
* It's often illegal to end a .bib command in certain places, and |
| 2899 |
* this is where we come to check. |
| 2900 |
***************************************************************************/ |
| 2901 |
void eat_bib_print (void) |
| 2902 |
BEGIN |
| 2903 |
BIB_ERR (" Illegal end of database file"); |
| 2904 |
Exit_Label: DO_NOTHING; |
| 2905 |
END |
| 2906 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 229 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2907 |
|
| 2908 |
|
| 2909 |
|
| 2910 |
|
| 2911 |
/*************************************************************************** |
| 2912 |
* WEB section number: 228 |
| 2913 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2914 |
* Before we actually start the code for reading a database file, we must |
| 2915 |
* define this .bib-specific scanning function. It skips over |
| 2916 |
* |white_space| characters until hitting a nonwhite character or the end |
| 2917 |
* of the file, respectively returning |true| or |false|. It also updates |
| 2918 |
* |bib_line_num|, the line counter. |
| 2919 |
***************************************************************************/ |
| 2920 |
Boolean_T eat_bib_white_space (void) |
| 2921 |
BEGIN |
| 2922 |
Boolean_T eat_bib_white_space; |
| 2923 |
|
| 2924 |
while ( ! scan_white_space ()) |
| 2925 |
BEGIN |
| 2926 |
if ( ! input_ln (CUR_BIB_FILE)) |
| 2927 |
BEGIN |
| 2928 |
eat_bib_white_space = FALSE; |
| 2929 |
goto Exit_Label; |
| 2930 |
END |
| 2931 |
INCR (bib_line_num); |
| 2932 |
buf_ptr2 = 0; |
| 2933 |
END |
| 2934 |
eat_bib_white_space = TRUE; |
| 2935 |
Exit_Label: |
| 2936 |
return (eat_bib_white_space); |
| 2937 |
END |
| 2938 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 228 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2939 |
|
| 2940 |
|
| 2941 |
|
| 2942 |
|
| 2943 |
/*************************************************************************** |
| 2944 |
* WEB section number: 153 |
| 2945 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2946 |
* It's often illegal to end a .bst command in certain places, and |
| 2947 |
* this is where we come to check. |
| 2948 |
***************************************************************************/ |
| 2949 |
void eat_bst_print (void) |
| 2950 |
BEGIN |
| 2951 |
PRINT ("Illegal end of style file in command: "); |
| 2952 |
END |
| 2953 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 153 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2954 |
|
| 2955 |
|
| 2956 |
|
| 2957 |
|
| 2958 |
/*************************************************************************** |
| 2959 |
* WEB section number: 152 |
| 2960 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2961 |
* This .bst-specific scanning function skips over |white_space| |
| 2962 |
* characters (and comments) until hitting a nonwhite character or the end |
| 2963 |
* of the file, respectively returning |true| or |false|. It also updates |
| 2964 |
* |bst_line_num|, the line counter. |
| 2965 |
***************************************************************************/ |
| 2966 |
Boolean_T eat_bst_white_space (void) |
| 2967 |
BEGIN |
| 2968 |
Boolean_T eat_bst_white_space; |
| 2969 |
|
| 2970 |
LOOP |
| 2971 |
BEGIN |
| 2972 |
if (scan_white_space ()) |
| 2973 |
BEGIN |
| 2974 |
if (SCAN_CHAR != COMMENT) |
| 2975 |
BEGIN |
| 2976 |
eat_bst_white_space = TRUE; |
| 2977 |
goto Exit_Label; |
| 2978 |
END |
| 2979 |
END |
| 2980 |
if ( ! input_ln (bst_file)) |
| 2981 |
BEGIN |
| 2982 |
eat_bst_white_space = FALSE; |
| 2983 |
goto Exit_Label; |
| 2984 |
END |
| 2985 |
INCR (bst_line_num); |
| 2986 |
buf_ptr2 = 0; |
| 2987 |
END |
| 2988 |
Exit_Label: |
| 2989 |
return (eat_bst_white_space); |
| 2990 |
END |
| 2991 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 152 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2992 |
|
| 2993 |
|
| 2994 |
|
| 2995 |
|
| 2996 |
/*************************************************************************** |
| 2997 |
* WEB section number: 418 |
| 2998 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2999 |
* This function looks at the string in |ex_buf|, starting at |
| 3000 |
* |ex_buf_xptr| and ending just before |ex_buf_ptr|, and it returns |
| 3001 |
* |true| if there are |enough_chars|, where a special character (even if |
| 3002 |
* it's missing its matching |right_brace|) counts as a single charcter. |
| 3003 |
* This procedure is called only for strings that don't have too many |
| 3004 |
* |right_brace|s. |
| 3005 |
***************************************************************************/ |
| 3006 |
Boolean_T enough_text_chars (BufPointer_T enough_chars) |
| 3007 |
BEGIN |
| 3008 |
Boolean_T enough_text_chars; |
| 3009 |
num_text_chars = 0; |
| 3010 |
ex_buf_yptr = ex_buf_xptr; |
| 3011 |
while ((ex_buf_yptr < ex_buf_ptr) && (num_text_chars < enough_chars)) |
| 3012 |
BEGIN |
| 3013 |
INCR (ex_buf_yptr); |
| 3014 |
if (ex_buf[ex_buf_yptr - 1] == LEFT_BRACE) |
| 3015 |
BEGIN |
| 3016 |
INCR (brace_level); |
| 3017 |
if ((brace_level == 1) && (ex_buf_yptr < ex_buf_ptr)) |
| 3018 |
BEGIN |
| 3019 |
if (ex_buf[ex_buf_yptr] == BACKSLASH) |
| 3020 |
BEGIN |
| 3021 |
INCR (ex_buf_yptr); |
| 3022 |
while ((ex_buf_yptr < ex_buf_ptr) && (brace_level > 0)) |
| 3023 |
BEGIN |
| 3024 |
if (ex_buf[ex_buf_yptr] == RIGHT_BRACE) |
| 3025 |
BEGIN |
| 3026 |
DECR (brace_level); |
| 3027 |
END |
| 3028 |
else if (ex_buf[ex_buf_yptr] == LEFT_BRACE) |
| 3029 |
BEGIN |
| 3030 |
INCR (brace_level); |
| 3031 |
END |
| 3032 |
INCR (ex_buf_yptr); |
| 3033 |
END |
| 3034 |
END |
| 3035 |
END |
| 3036 |
END |
| 3037 |
else if (ex_buf[ex_buf_yptr - 1] == RIGHT_BRACE) |
| 3038 |
BEGIN |
| 3039 |
DECR (brace_level); |
| 3040 |
END |
| 3041 |
INCR (num_text_chars); |
| 3042 |
END |
| 3043 |
if (num_text_chars < enough_chars) |
| 3044 |
BEGIN |
| 3045 |
enough_text_chars = FALSE; |
| 3046 |
END |
| 3047 |
else |
| 3048 |
BEGIN |
| 3049 |
enough_text_chars = TRUE; |
| 3050 |
END |
| 3051 |
return (enough_text_chars); |
| 3052 |
END |
| 3053 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 418 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |