| 1 |
/*- |
| 2 |
****************************************************************************** |
| 3 |
****************************************************************************** |
| 4 |
** |
| 5 |
** MODULE |
| 6 |
** |
| 7 |
** file: bibtex-3.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 third 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 |
** pre_def_certain_strings |
| 30 |
** pre_define |
| 31 |
** print_lit |
| 32 |
** print_missing_entry |
| 33 |
** print_overflow |
| 34 |
** print_recursion_illegal |
| 35 |
** print_skipping_whatever_remains |
| 36 |
** print_stk_lit |
| 37 |
** print_wrong_stk_lit |
| 38 |
** push_lit_stk |
| 39 |
** quick_sort |
| 40 |
** sam_too_long_file_name_print |
| 41 |
** sam_wrong_file_name_print |
| 42 |
** scan1 |
| 43 |
** scan1_white |
| 44 |
** scan2 |
| 45 |
** scan2_white |
| 46 |
** scan3 |
| 47 |
** scan_a_field_token_and_eat_whit |
| 48 |
** scan_alpha |
| 49 |
** scan_and_store_the_field_value |
| 50 |
** scan_balanced_braces |
| 51 |
** str_eq_buf |
| 52 |
** str_eq_str |
| 53 |
** str_lookup |
| 54 |
** swap |
| 55 |
** trace_and_stat_printing |
| 56 |
** trace_pr_fn_class |
| 57 |
** unknwn_function_class_confusion |
| 58 |
** unknwn_literal_confusion |
| 59 |
** upper_case |
| 60 |
** von_name_ends_and_last_name_sta |
| 61 |
** von_token_found |
| 62 |
** x_add_period |
| 63 |
** |
| 64 |
** AUTHORS |
| 65 |
** |
| 66 |
** Original WEB translation to C, conversion to "big" (32-bit) capacity, |
| 67 |
** addition of run-time selectable capacity and 8-bit support extensions |
| 68 |
** by: |
| 69 |
** |
| 70 |
** Niel Kempson |
| 71 |
** Snowy Owl Systems Limited, Cheltenham, England |
| 72 |
** E-mail: [email protected] |
| 73 |
** |
| 74 |
** 8-bit support extensions also by: |
| 75 |
** |
| 76 |
** Alejandro Aguilar-Sierra |
| 77 |
** Centro de Ciencias de la Atm\'osfera, |
| 78 |
** Universidad Nacional Aut\'onoma de M\'exico, M\'exico |
| 79 |
** E-mail: [email protected] |
| 80 |
** |
| 81 |
** COPYRIGHT |
| 82 |
** |
| 83 |
** This implementation copyright (c) 1991-1995 by Niel Kempson |
| 84 |
** and copyright (c) 1995 by Alejandro Aguilar-Sierra. |
| 85 |
** |
| 86 |
** This program is free software; you can redistribute it and/or |
| 87 |
** modify it under the terms of the GNU General Public License as |
| 88 |
** published by the Free Software Foundation; either version 1, or |
| 89 |
** (at your option) any later version. |
| 90 |
** |
| 91 |
** This program is distributed in the hope that it will be useful, |
| 92 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 93 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 94 |
** General Public License for more details. |
| 95 |
** |
| 96 |
** You should have received a copy of the GNU General Public License |
| 97 |
** along with this program; if not, write to the Free Software |
| 98 |
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 99 |
** |
| 100 |
** In other words, you are welcome to use, share and improve this |
| 101 |
** program. You are forbidden to forbid anyone else to use, share |
| 102 |
** and improve what you give them. Help stamp out software-hoarding! |
| 103 |
** |
| 104 |
** ACKNOWLEDGEMENT |
| 105 |
** |
| 106 |
** The original BibTeX was written by Oren Patashnik using Donald |
| 107 |
** Knuth's WEB system. This format produces a PASCAL program for |
| 108 |
** execution and a TeX documented version of the source code. This |
| 109 |
** program started as a (manual) translation of the WEB source into C. |
| 110 |
** |
| 111 |
** CHANGE LOG |
| 112 |
** |
| 113 |
** $Log: bibtex-3.c,v $ |
| 114 |
** Revision 3.71 1996/08/18 20:37:06 kempson |
| 115 |
** Official release 3.71 (see HISTORY file for details). |
| 116 |
** |
| 117 |
** Revision 3.70 1996/04/08 10:08:40 kempson |
| 118 |
** Final documentation & cosmetic changes for official release 3.70. |
| 119 |
** |
| 120 |
** Revision 3.6 1995/10/21 22:19:33 kempson |
| 121 |
** Removed previous WEB-imposed limit on the maximum value of Hash_Prime. |
| 122 |
** |
| 123 |
** Revision 3.5 1995/09/24 20:44:37 kempson |
| 124 |
** Many changes for final beta test version. |
| 125 |
** |
| 126 |
** Revision 3.4 1995/04/09 22:15:40 kempson |
| 127 |
** Placed under RCS control |
| 128 |
** |
| 129 |
****************************************************************************** |
| 130 |
****************************************************************************** |
| 131 |
*/ |
| 132 |
|
| 133 |
#ifdef HAVE_CONFIG_H |
| 134 |
#include <config.h> |
| 135 |
#endif |
| 136 |
|
| 137 |
#include "sysdep.h" |
| 138 |
#include "bibtex.h" |
| 139 |
#include "datatype.h" |
| 140 |
#include "gblprocs.h" |
| 141 |
#include "gblvars.h" |
| 142 |
#include "utils.h" |
| 143 |
#include "version.h" |
| 144 |
|
| 145 |
|
| 146 |
/*************************************************************************** |
| 147 |
* WEB section number: 336 |
| 148 |
* ~~~~~~~~~~~~~~~~~~~ |
| 149 |
* This is a procedure so that |initialize| is smaller. |
| 150 |
***************************************************************************/ |
| 151 |
void pre_def_certain_strings (void) |
| 152 |
BEGIN |
| 153 |
|
| 154 |
/*************************************************************************** |
| 155 |
* WEB section number: 75 |
| 156 |
* ~~~~~~~~~~~~~~~~~~~ |
| 157 |
* It's time to insert some of the pre-defined strings into |str_pool| |
| 158 |
* (and thus the hash table). These system-dependent strings should |
| 159 |
* contain no upper-case letters, and they must all be exactly |
| 160 |
* |longest_pds| characters long (even if fewer characters are actually |
| 161 |
* stored). The |pre_define| routine appears shortly. |
| 162 |
* |
| 163 |
* Important notes: These pre-definitions must not have any glitches or |
| 164 |
* the program may bomb because the |log_file| hasn't been opened yet, |
| 165 |
* and |text_ilk|s should be pre-defined later, for |
| 166 |
* .bst-function-execution purposes. |
| 167 |
***************************************************************************/ |
| 168 |
pre_define (".aux ", 4, FILE_EXT_ILK); |
| 169 |
s_aux_extension = hash_text[pre_def_loc]; |
| 170 |
pre_define (".bbl ", 4, FILE_EXT_ILK); |
| 171 |
s_bbl_extension = hash_text[pre_def_loc]; |
| 172 |
pre_define (".blg ", 4, FILE_EXT_ILK); |
| 173 |
s_log_extension = hash_text[pre_def_loc]; |
| 174 |
pre_define (".bst ", 4, FILE_EXT_ILK); |
| 175 |
s_bst_extension = hash_text[pre_def_loc]; |
| 176 |
pre_define (".bib ", 4, FILE_EXT_ILK); |
| 177 |
s_bib_extension = hash_text[pre_def_loc]; |
| 178 |
|
| 179 |
/*************************************************************************** |
| 180 |
* WEB section number: 79 |
| 181 |
* ~~~~~~~~~~~~~~~~~~~ |
| 182 |
* Now we pre-define the command strings; they must all be exactly |
| 183 |
* |longest_pds| characters long. |
| 184 |
* |
| 185 |
* Important note: These pre-definitions must not have any glitches or |
| 186 |
* the program may bomb because the |log_file| hasn't been opened yet. |
| 187 |
***************************************************************************/ |
| 188 |
pre_define ("\\citation ", 9, AUX_COMMAND_ILK); |
| 189 |
ilk_info[pre_def_loc] = N_AUX_CITATION; |
| 190 |
pre_define ("\\bibdata ", 8, AUX_COMMAND_ILK); |
| 191 |
ilk_info[pre_def_loc] = N_AUX_BIBDATA; |
| 192 |
pre_define ("\\bibstyle ", 9, AUX_COMMAND_ILK); |
| 193 |
ilk_info[pre_def_loc] = N_AUX_BIBSTYLE; |
| 194 |
pre_define ("\\@input ", 7, AUX_COMMAND_ILK); |
| 195 |
ilk_info[pre_def_loc] = N_AUX_INPUT; |
| 196 |
pre_define ("entry ", 5, BST_COMMAND_ILK); |
| 197 |
ilk_info[pre_def_loc] = N_BST_ENTRY; |
| 198 |
pre_define ("execute ", 7, BST_COMMAND_ILK); |
| 199 |
ilk_info[pre_def_loc] = N_BST_EXECUTE; |
| 200 |
pre_define ("function ", 8, BST_COMMAND_ILK); |
| 201 |
ilk_info[pre_def_loc] = N_BST_FUNCTION; |
| 202 |
pre_define ("integers ", 8, BST_COMMAND_ILK); |
| 203 |
ilk_info[pre_def_loc] = N_BST_INTEGERS; |
| 204 |
pre_define ("iterate ", 7, BST_COMMAND_ILK); |
| 205 |
ilk_info[pre_def_loc] = N_BST_ITERATE; |
| 206 |
pre_define ("macro ", 5, BST_COMMAND_ILK); |
| 207 |
ilk_info[pre_def_loc] = N_BST_MACRO; |
| 208 |
pre_define ("read ", 4, BST_COMMAND_ILK); |
| 209 |
ilk_info[pre_def_loc] = N_BST_READ; |
| 210 |
pre_define ("reverse ", 7, BST_COMMAND_ILK); |
| 211 |
ilk_info[pre_def_loc] = N_BST_REVERSE; |
| 212 |
pre_define ("sort ", 4, BST_COMMAND_ILK); |
| 213 |
ilk_info[pre_def_loc] = N_BST_SORT; |
| 214 |
pre_define ("strings ", 7, BST_COMMAND_ILK); |
| 215 |
ilk_info[pre_def_loc] = N_BST_STRINGS; |
| 216 |
pre_define ("comment ", 7, BIB_COMMAND_ILK); |
| 217 |
ilk_info[pre_def_loc] = N_BIB_COMMENT; |
| 218 |
pre_define ("preamble ", 8, BIB_COMMAND_ILK); |
| 219 |
ilk_info[pre_def_loc] = N_BIB_PREAMBLE; |
| 220 |
pre_define ("string ", 6, BIB_COMMAND_ILK); |
| 221 |
ilk_info[pre_def_loc] = N_BIB_STRING; |
| 222 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 79 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 223 |
|
| 224 |
/*************************************************************************** |
| 225 |
* WEB section number: 334 |
| 226 |
* ~~~~~~~~~~~~~~~~~~~ |
| 227 |
* It's time for us to insert more pre-defined strings into |str_pool| |
| 228 |
* (and thus the hash table) and to insert the |built_in| functions into |
| 229 |
* the hash table. The strings corresponding to these functions should |
| 230 |
* contain no upper-case letters, and they must all be exactly |
| 231 |
* |longest_pds| characters long. The |build_in| routine (to appear |
| 232 |
* shortly) does the work. |
| 233 |
* |
| 234 |
* Important note: These pre-definitions must not have any glitches or the |
| 235 |
* program may bomb because the |log_file| hasn't been opened yet. |
| 236 |
***************************************************************************/ |
| 237 |
build_in ("= ", 1, &b_equals, N_EQUALS); |
| 238 |
build_in ("> ", 1, &b_greater_than, N_GREATER_THAN); |
| 239 |
build_in ("< ", 1, &b_less_than, N_LESS_THAN); |
| 240 |
build_in ("+ ", 1, &b_plus, N_PLUS); |
| 241 |
build_in ("- ", 1, &b_minus, N_MINUS); |
| 242 |
build_in ("& ", 1, &b_bit_and, N_BIT_AND); |
| 243 |
build_in ("| ", 1, &b_bit_or, N_BIT_OR); |
| 244 |
build_in ("* ", 1, &b_concatenate, N_CONCATENATE); |
| 245 |
build_in (":= ", 2, &b_gets, N_GETS); |
| 246 |
build_in ("add.period$ ", 11, &b_add_period, N_ADD_PERIOD); |
| 247 |
build_in ("call.type$ ", 10, &b_call_type, N_CALL_TYPE); |
| 248 |
build_in ("change.case$", 12, &b_change_case, N_CHANGE_CASE); |
| 249 |
build_in ("chr.to.int$ ", 11, &b_chr_to_int, N_CHR_TO_INT); |
| 250 |
build_in ("cite$ ", 5, &b_cite, N_CITE); |
| 251 |
build_in ("duplicate$ ", 10, &b_duplicate, N_DUPLICATE); |
| 252 |
build_in ("empty$ ", 6, &b_empty, N_EMPTY); |
| 253 |
build_in ("format.name$", 12, &b_format_name, N_FORMAT_NAME); |
| 254 |
build_in ("if$ ", 3, &b_if, N_IF); |
| 255 |
build_in ("int.to.chr$ ", 11, &b_int_to_chr, N_INT_TO_CHR); |
| 256 |
build_in ("int.to.str$ ", 11, &b_int_to_str, N_INT_TO_STR); |
| 257 |
build_in ("missing$ ", 8, &b_missing, N_MISSING); |
| 258 |
build_in ("newline$ ", 8, &b_newline, N_NEWLINE); |
| 259 |
build_in ("num.names$ ", 10, &b_num_names, N_NUM_NAMES); |
| 260 |
build_in ("pop$ ", 4, &b_pop, N_POP); |
| 261 |
build_in ("preamble$ ", 9, &b_preamble, N_PREAMBLE); |
| 262 |
build_in ("purify$ ", 7, &b_purify, N_PURIFY); |
| 263 |
build_in ("quote$ ", 6, &b_quote, N_QUOTE); |
| 264 |
build_in ("skip$ ", 5, &b_skip, N_SKIP); |
| 265 |
build_in ("stack$ ", 6, &b_stack, N_STACK); |
| 266 |
build_in ("substring$ ", 10, &b_substring, N_SUBSTRING); |
| 267 |
build_in ("swap$ ", 5, &b_swap, N_SWAP); |
| 268 |
build_in ("text.length$", 12, &b_text_length, N_TEXT_LENGTH); |
| 269 |
build_in ("text.prefix$", 12, &b_text_prefix, N_TEXT_PREFIX); |
| 270 |
build_in ("top$ ", 4, &b_top_stack, N_TOP_STACK); |
| 271 |
build_in ("type$ ", 5, &b_type, N_TYPE); |
| 272 |
build_in ("warning$ ", 8, &b_warning, N_WARNING); |
| 273 |
build_in ("width$ ", 6, &b_width, N_WIDTH); |
| 274 |
build_in ("while$ ", 6, &b_while, N_WHILE); |
| 275 |
build_in ("write$ ", 6, &b_write, N_WRITE); |
| 276 |
#ifdef UTF_8 |
| 277 |
build_in ("is.cjk.str$ ", 11, &b_cjk_string, N_IS_CJK_STRING); |
| 278 |
build_in ("is.kanji.str$", 13, &b_cjk_string, N_IS_CJK_STRING); |
| 279 |
#endif |
| 280 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 334 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 281 |
|
| 282 |
/*************************************************************************** |
| 283 |
* WEB section number: 339 |
| 284 |
* ~~~~~~~~~~~~~~~~~~~ |
| 285 |
* Here we pre-define a few strings used in executing the .bst file: |
| 286 |
* the null string, which is sometimes pushed onto the stack; a string |
| 287 |
* used for default entry types; and some control sequences used to spot |
| 288 |
* foreign characters. We also initialize the |s_preamble| array to |
| 289 |
* empty. These pre-defined strings must all be exactly |longest_pds| |
| 290 |
* characters long. |
| 291 |
* |
| 292 |
* Important note: These pre-definitions must not have any glitches or |
| 293 |
* the program may bomb because the |log_file| hasn't been opened yet, |
| 294 |
* and |text_ilk|s should be pre-defined here, not earlier, for |
| 295 |
* .bst-function-execution purposes. |
| 296 |
***************************************************************************/ |
| 297 |
pre_define (" ", 0, TEXT_ILK); |
| 298 |
s_null = hash_text[pre_def_loc]; |
| 299 |
fn_type[pre_def_loc] = STR_LITERAL; |
| 300 |
pre_define ("default.type", 12, TEXT_ILK); |
| 301 |
s_default = hash_text[pre_def_loc]; |
| 302 |
fn_type[pre_def_loc] = STR_LITERAL; |
| 303 |
b_default = b_skip; |
| 304 |
preamble_ptr = 0; |
| 305 |
pre_define ("i ", 1, CONTROL_SEQ_ILK); |
| 306 |
ilk_info[pre_def_loc] = N_I; |
| 307 |
pre_define ("j ", 1, CONTROL_SEQ_ILK); |
| 308 |
ilk_info[pre_def_loc] = N_J; |
| 309 |
pre_define ("oe ", 2, CONTROL_SEQ_ILK); |
| 310 |
ilk_info[pre_def_loc] = N_OE; |
| 311 |
pre_define ("OE ", 2, CONTROL_SEQ_ILK); |
| 312 |
ilk_info[pre_def_loc] = N_OE_UPPER; |
| 313 |
pre_define ("ae ", 2, CONTROL_SEQ_ILK); |
| 314 |
ilk_info[pre_def_loc] = N_AE; |
| 315 |
pre_define ("AE ", 2, CONTROL_SEQ_ILK); |
| 316 |
ilk_info[pre_def_loc] = N_AE_UPPER; |
| 317 |
pre_define ("aa ", 2, CONTROL_SEQ_ILK); |
| 318 |
ilk_info[pre_def_loc] = N_AA; |
| 319 |
pre_define ("AA ", 2, CONTROL_SEQ_ILK); |
| 320 |
ilk_info[pre_def_loc] = N_AA_UPPER; |
| 321 |
pre_define ("o ", 1, CONTROL_SEQ_ILK); |
| 322 |
ilk_info[pre_def_loc] = N_O; |
| 323 |
pre_define ("O ", 1, CONTROL_SEQ_ILK); |
| 324 |
ilk_info[pre_def_loc] = N_O_UPPER; |
| 325 |
pre_define ("l ", 1, CONTROL_SEQ_ILK); |
| 326 |
ilk_info[pre_def_loc] = N_L; |
| 327 |
pre_define ("L ", 1, CONTROL_SEQ_ILK); |
| 328 |
ilk_info[pre_def_loc] = N_L_UPPER; |
| 329 |
pre_define ("ss ", 2, CONTROL_SEQ_ILK); |
| 330 |
ilk_info[pre_def_loc] = N_SS; |
| 331 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 339 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 332 |
|
| 333 |
/*************************************************************************** |
| 334 |
* WEB section number: 340 |
| 335 |
* ~~~~~~~~~~~~~~~~~~~ |
| 336 |
* Now we pre-define any built-in |field|s, |str_entry_var|s, and |
| 337 |
* |int_global_var|s; these strings must all be exactly |longest_pds| |
| 338 |
* characters long. Note that although these are built-in functions, we |
| 339 |
* classify them (in the |fn_type| array) otherwise. |
| 340 |
* |
| 341 |
* Important note: These pre-definitions must not have any glitches or |
| 342 |
* the program may bomb because the |log_file| hasn't been opened yet. |
| 343 |
***************************************************************************/ |
| 344 |
pre_define ("crossref ", 8, BST_FN_ILK); |
| 345 |
fn_type[pre_def_loc] = FIELD; |
| 346 |
FN_INFO[pre_def_loc] = num_fields; |
| 347 |
crossref_num = num_fields; |
| 348 |
INCR (num_fields); |
| 349 |
num_pre_defined_fields = num_fields; |
| 350 |
pre_define ("sort.key$ ", 9, BST_FN_ILK); |
| 351 |
fn_type[pre_def_loc] = STR_ENTRY_VAR; |
| 352 |
FN_INFO[pre_def_loc] = num_ent_strs; |
| 353 |
sort_key_num = num_ent_strs; |
| 354 |
INCR (num_ent_strs); |
| 355 |
pre_define ("entry.max$ ", 10, BST_FN_ILK); |
| 356 |
fn_type[pre_def_loc] = INT_GLOBAL_VAR; |
| 357 |
FN_INFO[pre_def_loc] = Ent_Str_Size; |
| 358 |
pre_define ("global.max$ ", 11, BST_FN_ILK); |
| 359 |
fn_type[pre_def_loc] = INT_GLOBAL_VAR; |
| 360 |
FN_INFO[pre_def_loc] = Glob_Str_Size; |
| 361 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 340 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 362 |
|
| 363 |
END |
| 364 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 336 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
/*************************************************************************** |
| 370 |
* WEB section number: 77 |
| 371 |
* ~~~~~~~~~~~~~~~~~~~ |
| 372 |
* This procedure initializes a pre-defined string of length at most |
| 373 |
* |longest_pds|. |
| 374 |
***************************************************************************/ |
| 375 |
void pre_define (PdsType_T pds, PdsLen_T len, StrIlk_T ilk) |
| 376 |
BEGIN |
| 377 |
PdsLen_T i; |
| 378 |
|
| 379 |
for (i=1; i<=len; i++) |
| 380 |
BEGIN |
| 381 |
|
| 382 |
/*---------------------------------------------------------------------- |
| 383 |
* Unlike the WEB, the string in `pds' will occupy the positions |
| 384 |
* pds[0] ... pds[len-1], rather than pds[1] ... pds[len]. |
| 385 |
*----------------------------------------------------------------------*/ |
| 386 |
buffer[i] = xord[(UChar_T)pds[i-1]]; |
| 387 |
END |
| 388 |
pre_def_loc = str_lookup (buffer, 1, len, ilk, DO_INSERT); |
| 389 |
END |
| 390 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 77 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
/*************************************************************************** |
| 396 |
* WEB section number: 3 |
| 397 |
* ~~~~~~~~~~~~~~~~~~~ |
| 398 |
***************************************************************************/ |
| 399 |
void print_a_newline (void) |
| 400 |
BEGIN |
| 401 |
if (log_file != NULL) |
| 402 |
FPUTC ('\n', log_file); |
| 403 |
FPUTC ('\n', TERM_OUT); |
| 404 |
END |
| 405 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
/*************************************************************************** |
| 411 |
* WEB section number: 51 |
| 412 |
* ~~~~~~~~~~~~~~~~~~~ |
| 413 |
* And here are the associated procedures. Note the |term_out| file is |
| 414 |
* system dependent. |
| 415 |
***************************************************************************/ |
| 416 |
void print_a_pool_str (StrNumber_T s) |
| 417 |
BEGIN |
| 418 |
out_pool_str (TERM_OUT, s); |
| 419 |
out_pool_str (log_file, s); |
| 420 |
END |
| 421 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 51 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
/*************************************************************************** |
| 427 |
* WEB section number: 82 |
| 428 |
* ~~~~~~~~~~~~~~~~~~~ |
| 429 |
* And here are the associated procedures. Note the |term_out| file is |
| 430 |
* system dependent. |
| 431 |
***************************************************************************/ |
| 432 |
void print_a_token (void) |
| 433 |
BEGIN |
| 434 |
out_token (TERM_OUT); |
| 435 |
out_token (log_file); |
| 436 |
END |
| 437 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 82 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
/*************************************************************************** |
| 443 |
* WEB section number: 108 |
| 444 |
* ~~~~~~~~~~~~~~~~~~~ |
| 445 |
* Print the name of the current .aux file, followed by a |newline|. |
| 446 |
***************************************************************************/ |
| 447 |
void print_aux_name (void) |
| 448 |
BEGIN |
| 449 |
PRINT_POOL_STR (CUR_AUX_STR); |
| 450 |
PRINT_NEWLINE; |
| 451 |
END |
| 452 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 108 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
/*************************************************************************** |
| 458 |
* WEB section number: 95 |
| 459 |
* ~~~~~~~~~~~~~~~~~~~ |
| 460 |
* The |print_bad_input_line| procedure prints the current input line, |
| 461 |
* splitting it at the character being scanned: It prints |buffer[0]|, |
| 462 |
* |buffer[1]|, \dots, |buffer[buf_ptr2-1]| on one line and |
| 463 |
* |SCAN_CHAR|, \dots, |buffer[last-1]| on the next (and both |
| 464 |
* lines start with a colon between two |space|s). Each |white_space| |
| 465 |
* character is printed as a |space|. |
| 466 |
***************************************************************************/ |
| 467 |
void print_bad_input_line (void) |
| 468 |
BEGIN |
| 469 |
BufPointer_T bf_ptr; |
| 470 |
|
| 471 |
PRINT (" : "); |
| 472 |
bf_ptr = 0; |
| 473 |
while (bf_ptr < buf_ptr2) |
| 474 |
BEGIN |
| 475 |
if (lex_class[buffer[bf_ptr]] == WHITE_SPACE) |
| 476 |
BEGIN |
| 477 |
PRINT2 ("%c", xchr[SPACE]); |
| 478 |
END |
| 479 |
else |
| 480 |
BEGIN |
| 481 |
PRINT2 ("%c", xchr[buffer[bf_ptr]]); |
| 482 |
END |
| 483 |
INCR (bf_ptr); |
| 484 |
END |
| 485 |
PRINT_NEWLINE; |
| 486 |
PRINT (" : "); |
| 487 |
bf_ptr = 0; |
| 488 |
while (bf_ptr < buf_ptr2) |
| 489 |
BEGIN |
| 490 |
PRINT2 ("%c", xchr[SPACE]); |
| 491 |
INCR (bf_ptr); |
| 492 |
END |
| 493 |
bf_ptr = buf_ptr2; |
| 494 |
while (bf_ptr < last) |
| 495 |
BEGIN |
| 496 |
if (lex_class[buffer[bf_ptr]] == WHITE_SPACE) |
| 497 |
BEGIN |
| 498 |
PRINT2 ("%c", xchr[SPACE]); |
| 499 |
END |
| 500 |
else |
| 501 |
BEGIN |
| 502 |
PRINT2 ("%c", xchr[buffer[bf_ptr]]); |
| 503 |
END |
| 504 |
INCR (bf_ptr); |
| 505 |
END |
| 506 |
PRINT_NEWLINE; |
| 507 |
bf_ptr = 0; |
| 508 |
while ((bf_ptr < buf_ptr2) && (lex_class[buffer[bf_ptr]] == WHITE_SPACE)) |
| 509 |
BEGIN |
| 510 |
INCR (bf_ptr); |
| 511 |
END |
| 512 |
if (bf_ptr == buf_ptr2) |
| 513 |
BEGIN |
| 514 |
PRINT_LN ("(Error may have been on previous line)"); |
| 515 |
END |
| 516 |
mark_error (); |
| 517 |
END |
| 518 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 95 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
/*************************************************************************** |
| 524 |
* WEB section number: 121 |
| 525 |
* ~~~~~~~~~~~~~~~~~~~ |
| 526 |
* Here's a procedure we'll need shortly. It prints the name of the |
| 527 |
* current .bib file, followed by a |newline|. |
| 528 |
***************************************************************************/ |
| 529 |
void print_bib_name (void) |
| 530 |
BEGIN |
| 531 |
PRINT_POOL_STR (CUR_BIB_STR); |
| 532 |
PRINT_POOL_STR (s_bib_extension); |
| 533 |
PRINT_NEWLINE; |
| 534 |
END |
| 535 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 121 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
/*************************************************************************** |
| 541 |
* WEB section number: 128 |
| 542 |
* ~~~~~~~~~~~~~~~~~~~ |
| 543 |
* Print the name of the .bst file, followed by a |newline|. |
| 544 |
***************************************************************************/ |
| 545 |
void print_bst_name (void) |
| 546 |
BEGIN |
| 547 |
PRINT_POOL_STR (bst_str); |
| 548 |
PRINT_POOL_STR (s_bst_extension); |
| 549 |
PRINT_NEWLINE; |
| 550 |
END |
| 551 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 128 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
/*************************************************************************** |
| 557 |
* WEB section number: 45 |
| 558 |
* ~~~~~~~~~~~~~~~~~~~ |
| 559 |
* When something happens that the program thinks is impossible, |
| 560 |
* call the maintainer. |
| 561 |
***************************************************************************/ |
| 562 |
void print_confusion (void) |
| 563 |
BEGIN |
| 564 |
PRINT_LN ("---this can't happen"); |
| 565 |
PRINT_LN ("*Please notify the BibTeX maintainer*"); |
| 566 |
mark_fatal (); |
| 567 |
END |
| 568 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 45 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
/*************************************************************************** |
| 574 |
* WEB section number: 158 |
| 575 |
* ~~~~~~~~~~~~~~~~~~~ |
| 576 |
* Occasionally we'll want to |print| the name of one of these function |
| 577 |
* classes. |
| 578 |
***************************************************************************/ |
| 579 |
void print_fn_class (HashLoc_T fn_loc) |
| 580 |
BEGIN |
| 581 |
switch (fn_type[fn_loc]) |
| 582 |
BEGIN |
| 583 |
case BUILT_IN: |
| 584 |
PRINT ("built-in"); |
| 585 |
break; |
| 586 |
case WIZ_DEFINED: |
| 587 |
PRINT ("wizard-defined"); |
| 588 |
break; |
| 589 |
case INT_LITERAL: |
| 590 |
PRINT ("integer-literal"); |
| 591 |
break; |
| 592 |
case STR_LITERAL: |
| 593 |
PRINT ("string-literal"); |
| 594 |
break; |
| 595 |
case FIELD: |
| 596 |
PRINT ("field"); |
| 597 |
break; |
| 598 |
case INT_ENTRY_VAR: |
| 599 |
PRINT ("integer-entry-variable"); |
| 600 |
break; |
| 601 |
case STR_ENTRY_VAR: |
| 602 |
PRINT ("string-entry-variable"); |
| 603 |
break; |
| 604 |
case INT_GLOBAL_VAR: |
| 605 |
PRINT ("integer-global-variable"); |
| 606 |
break; |
| 607 |
case STR_GLOBAL_VAR: |
| 608 |
PRINT ("string-global-variable"); |
| 609 |
break; |
| 610 |
default: |
| 611 |
unknwn_function_class_confusion (); |
| 612 |
break; |
| 613 |
END |
| 614 |
END |
| 615 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 158 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
/*************************************************************************** |
| 621 |
* WEB section number: 313 |
| 622 |
* ~~~~~~~~~~~~~~~~~~~ |
| 623 |
* This is similar to |print_stk_lit|, but here we don't give the |
| 624 |
* literal's type, and here we end with a new line. This procedure |
| 625 |
* should never be called after popping an empty stack. |
| 626 |
***************************************************************************/ |
| 627 |
void print_lit (Integer_T stk_lt, StkType_T stk_tp) |
| 628 |
BEGIN |
| 629 |
switch (stk_tp) |
| 630 |
BEGIN |
| 631 |
case STK_INT: |
| 632 |
PRINT_LN2 ("%ld", (long) stk_lt); |
| 633 |
break; |
| 634 |
case STK_STR: |
| 635 |
PRINT_POOL_STR (stk_lt); |
| 636 |
PRINT_NEWLINE; |
| 637 |
break; |
| 638 |
case STK_FN: |
| 639 |
PRINT_POOL_STR (hash_text[stk_lt]); |
| 640 |
PRINT_NEWLINE; |
| 641 |
break; |
| 642 |
case STK_FIELD_MISSING: |
| 643 |
PRINT_POOL_STR (stk_lt); |
| 644 |
PRINT_NEWLINE; |
| 645 |
break; |
| 646 |
case STK_EMPTY: |
| 647 |
illegl_literal_confusion (); |
| 648 |
break; |
| 649 |
default: |
| 650 |
unknwn_literal_confusion (); |
| 651 |
break; |
| 652 |
END |
| 653 |
END |
| 654 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 313 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
/************************************************************************** |
| 660 |
* WEB section number: 284 |
| 661 |
* ~~~~~~~~~~~~~~~~~~~ |
| 662 |
* When a cite key on the original |cite_list| (or added to |cite_list| |
| 663 |
* because of cross~referencing) didn't appear in the database, complain. |
| 664 |
***************************************************************************/ |
| 665 |
void print_missing_entry (StrNumber_T s) |
| 666 |
BEGIN |
| 667 |
PRINT ("Warning--I didn't find a database entry for \""); |
| 668 |
PRINT_POOL_STR (s); |
| 669 |
PRINT_LN ("\""); |
| 670 |
mark_warning (); |
| 671 |
END |
| 672 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 284 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
/*************************************************************************** |
| 677 |
* WEB section number: 44 |
| 678 |
* ~~~~~~~~~~~~~~~~~~~ |
| 679 |
* When something in the program wants to be bigger or something out |
| 680 |
* there wants to be smaller, it's time to call it a run. Here's the |
| 681 |
* first of several macros that have associated procedures so that they |
| 682 |
* produce less inline code. |
| 683 |
***************************************************************************/ |
| 684 |
void print_overflow (void) |
| 685 |
BEGIN |
| 686 |
PRINT ("Sorry---you've exceeded BibTeX's "); |
| 687 |
mark_fatal (); |
| 688 |
END |
| 689 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 44 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
/*************************************************************************** |
| 694 |
* WEB section number: 184 |
| 695 |
* ~~~~~~~~~~~~~~~~~~~ |
| 696 |
* This macro is similar to the last one but is specifically for |
| 697 |
* recursion in a |wiz_defined| function, which is illegal; it helps save |
| 698 |
* space. |
| 699 |
***************************************************************************/ |
| 700 |
void print_recursion_illegal (void) |
| 701 |
BEGIN |
| 702 |
|
| 703 |
#ifdef TRACE |
| 704 |
if (Flag_trace) |
| 705 |
TRACE_PR_NEWLINE; |
| 706 |
#endif /* TRACE */ |
| 707 |
|
| 708 |
PRINT_LN ("Curse you, wizard, before you recurse me:"); |
| 709 |
PRINT ("function "); |
| 710 |
PRINT_TOKEN; |
| 711 |
PRINT_LN (" is illegal in its own definition"); |
| 712 |
|
| 713 |
/*------------------------------------------------------------------------ |
| 714 |
* print_recursion_illegal(); |
| 715 |
*----------------------------------------------------------------------*/ |
| 716 |
skip_token_print (); |
| 717 |
END |
| 718 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 184 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
/*************************************************************************** |
| 723 |
* WEB section number: 96 |
| 724 |
* ~~~~~~~~~~~~~~~~~~~ |
| 725 |
* This little procedure exists because it's used by at least two other |
| 726 |
* procedures and thus saves some space. |
| 727 |
***************************************************************************/ |
| 728 |
void print_skipping_whatever_remains (void) |
| 729 |
BEGIN |
| 730 |
PRINT ("I'm skipping whatever remains of this "); |
| 731 |
END |
| 732 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 96 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
/*************************************************************************** |
| 737 |
* WEB section number: 311 |
| 738 |
* ~~~~~~~~~~~~~~~~~~~ |
| 739 |
* Occasionally we'll want to know what's on the literal stack. Here we |
| 740 |
* print out a stack literal, giving its type. This procedure should |
| 741 |
* never be called after popping an empty stack. |
| 742 |
***************************************************************************/ |
| 743 |
void print_stk_lit (Integer_T stk_lt, StkType_T stk_tp) |
| 744 |
BEGIN |
| 745 |
switch (stk_tp) |
| 746 |
BEGIN |
| 747 |
case STK_INT: |
| 748 |
PRINT2 ("%ld is an integer literal", (long) stk_lt); |
| 749 |
break; |
| 750 |
case STK_STR: |
| 751 |
PRINT ("\""); |
| 752 |
PRINT_POOL_STR (stk_lt); |
| 753 |
PRINT ("\" is a string literal"); |
| 754 |
break; |
| 755 |
case STK_FN: |
| 756 |
PRINT ("`"); |
| 757 |
PRINT_POOL_STR (hash_text[stk_lt]); |
| 758 |
PRINT ("' is a function literal"); |
| 759 |
break; |
| 760 |
case STK_FIELD_MISSING: |
| 761 |
PRINT ("`"); |
| 762 |
PRINT_POOL_STR (stk_lt); |
| 763 |
PRINT ("' is a missing field"); |
| 764 |
break; |
| 765 |
case STK_EMPTY: |
| 766 |
illegl_literal_confusion (); |
| 767 |
break; |
| 768 |
default: |
| 769 |
unknwn_literal_confusion (); |
| 770 |
break; |
| 771 |
END |
| 772 |
END |
| 773 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 311 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
/*************************************************************************** |
| 778 |
* WEB section number: 312 |
| 779 |
* ~~~~~~~~~~~~~~~~~~~ |
| 780 |
* This procedure appropriately chastises the style designer; however, if |
| 781 |
* the wrong literal came from popping an empty stack, the procedure |
| 782 |
* |pop_lit_stack| will have already done the chastising (because this |
| 783 |
* procedure is called only after popping the stack) so there's no need |
| 784 |
* for more. |
| 785 |
***************************************************************************/ |
| 786 |
void print_wrong_stk_lit (Integer_T stk_lt, StkType_T stk_tp1, |
| 787 |
StkType_T stk_tp2) |
| 788 |
BEGIN |
| 789 |
if (stk_tp1 != STK_EMPTY) |
| 790 |
BEGIN |
| 791 |
print_stk_lit (stk_lt, stk_tp1); |
| 792 |
switch (stk_tp2) |
| 793 |
BEGIN |
| 794 |
case STK_INT: |
| 795 |
PRINT (", not an integer,"); |
| 796 |
break; |
| 797 |
case STK_STR: |
| 798 |
PRINT (", not a string,"); |
| 799 |
break; |
| 800 |
case STK_FN: |
| 801 |
PRINT (", not a function,"); |
| 802 |
break; |
| 803 |
case STK_FIELD_MISSING: |
| 804 |
case STK_EMPTY: |
| 805 |
illegl_literal_confusion (); |
| 806 |
break; |
| 807 |
default: |
| 808 |
unknwn_literal_confusion (); |
| 809 |
break; |
| 810 |
END |
| 811 |
bst_ex_warn_print (); |
| 812 |
END |
| 813 |
END |
| 814 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 312 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
/*************************************************************************** |
| 819 |
* WEB section number: 307 |
| 820 |
* ~~~~~~~~~~~~~~~~~~~ |
| 821 |
* Ok, that's it for sorting; now we'll play with the literal stack. |
| 822 |
* This procedure pushes a literal onto the stack, checking for stack |
| 823 |
* overflow. |
| 824 |
***************************************************************************/ |
| 825 |
void push_lit_stk (Integer_T push_lt, StkType_T push_type) |
| 826 |
BEGIN |
| 827 |
|
| 828 |
#ifdef TRACE |
| 829 |
LitStkLoc_T dum_ptr; |
| 830 |
#endif /* TRACE */ |
| 831 |
|
| 832 |
lit_stack[lit_stk_ptr] = push_lt; |
| 833 |
lit_stk_type[lit_stk_ptr] = push_type; |
| 834 |
|
| 835 |
#ifdef TRACE |
| 836 |
if (Flag_trace) { |
| 837 |
for (dum_ptr=0; dum_ptr <= lit_stk_ptr; dum_ptr++) |
| 838 |
BEGIN |
| 839 |
TRACE_PR (" "); |
| 840 |
END |
| 841 |
TRACE_PR ("Pushing "); |
| 842 |
|
| 843 |
switch (lit_stk_type[lit_stk_ptr]) |
| 844 |
BEGIN |
| 845 |
case STK_INT: |
| 846 |
TRACE_PR_LN2 ("%ld", (long) lit_stack[lit_stk_ptr]); |
| 847 |
break; |
| 848 |
case STK_STR: |
| 849 |
TRACE_PR ("\""); |
| 850 |
TRACE_PR_POOL_STR (lit_stack[lit_stk_ptr]); |
| 851 |
TRACE_PR_LN ("\""); |
| 852 |
break; |
| 853 |
case STK_FN: |
| 854 |
TRACE_PR ("`"); |
| 855 |
TRACE_PR_POOL_STR (hash_text[lit_stack[lit_stk_ptr]]); |
| 856 |
TRACE_PR_LN ("'"); |
| 857 |
break; |
| 858 |
case STK_FIELD_MISSING: |
| 859 |
TRACE_PR ("missing field `"); |
| 860 |
out_pool_str (log_file, lit_stack[lit_stk_ptr]); |
| 861 |
TRACE_PR_LN ("'"); |
| 862 |
break; |
| 863 |
case STK_EMPTY: |
| 864 |
TRACE_PR_LN ("a bad literal--popped from an empty stack"); |
| 865 |
break; |
| 866 |
default: |
| 867 |
unknwn_literal_confusion (); |
| 868 |
break; |
| 869 |
END |
| 870 |
} /* end if (Flag_trace) */ |
| 871 |
#endif /* TRACE */ |
| 872 |
|
| 873 |
if (lit_stk_ptr == Lit_Stk_Size) |
| 874 |
BEGIN |
| 875 |
BIB_XRETALLOC_NOSET ("lit_stack", lit_stack, Integer_T, |
| 876 |
Lit_Stk_Size, Lit_Stk_Size + LIT_STK_SIZE); |
| 877 |
BIB_XRETALLOC ("lit_stk_type", lit_stk_type, StkType_T, |
| 878 |
Lit_Stk_Size, Lit_Stk_Size + LIT_STK_SIZE); |
| 879 |
END |
| 880 |
INCR (lit_stk_ptr); |
| 881 |
END |
| 882 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 307 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 883 |
|
| 884 |
|
| 885 |
/*************************************************************************** |
| 886 |
* WEB section number: 303 |
| 887 |
* ~~~~~~~~~~~~~~~~~~~ |
| 888 |
* These next two procedures (actually, one procedures and one function, |
| 889 |
* but who's counting) are subroutines for |quick_sort|, which follows. |
| 890 |
* The |swap| procedure exchanges the two elements its arguments point |
| 891 |
* to. |
| 892 |
***************************************************************************/ |
| 893 |
void quick_sort (CiteNumber_T left_end, CiteNumber_T right_end) |
| 894 |
BEGIN |
| 895 |
CiteNumber_T left, |
| 896 |
right; |
| 897 |
CiteNumber_T insert_ptr; |
| 898 |
CiteNumber_T middle; |
| 899 |
CiteNumber_T partition; |
| 900 |
|
| 901 |
#ifdef TRACE |
| 902 |
if (Flag_trace) |
| 903 |
TRACE_PR_LN3 ("Sorting %ld through %ld", (long) left_end, |
| 904 |
(long) right_end); |
| 905 |
#endif /* TRACE */ |
| 906 |
|
| 907 |
if ((right_end - left_end) < SHORT_LIST) |
| 908 |
BEGIN |
| 909 |
|
| 910 |
/*************************************************************************** |
| 911 |
* WEB section number: 304 |
| 912 |
* ~~~~~~~~~~~~~~~~~~~ |
| 913 |
* This code sorts the entries between |left_end| and |right_end| when |
| 914 |
* the difference is less than |short_list|. Each iteration of the outer |
| 915 |
* loop inserts the element indicated by |insert_ptr| into its proper |
| 916 |
* place among the (sorted) elements from |left_end| through |
| 917 |
* |insert_ptr-1|. |
| 918 |
***************************************************************************/ |
| 919 |
for (insert_ptr=(left_end+1); insert_ptr<=right_end; insert_ptr++) |
| 920 |
BEGIN |
| 921 |
for (right=insert_ptr; right >= (left_end+1); right--) |
| 922 |
BEGIN |
| 923 |
if (less_than (SORTED_CITES[right-1], SORTED_CITES[right])) |
| 924 |
BEGIN |
| 925 |
goto Next_Insert_Label; |
| 926 |
END |
| 927 |
swap (right - 1, right); |
| 928 |
END |
| 929 |
Next_Insert_Label: DO_NOTHING; |
| 930 |
END |
| 931 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 304 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 932 |
|
| 933 |
END |
| 934 |
else |
| 935 |
BEGIN |
| 936 |
|
| 937 |
/*************************************************************************** |
| 938 |
* WEB section number: 305 |
| 939 |
* ~~~~~~~~~~~~~~~~~~~ |
| 940 |
* Now we find the median of the three sort.key$s to which the three |
| 941 |
* elements |sorted_cites[left_end+end_offset]|, |
| 942 |
* |sorted_cites[right_end]-end_offset|, and |
| 943 |
* |sorted_cites[(left_end+right_end) div 2]| point (a nonzero |
| 944 |
* |end_offset| avoids using as the leftmost of the three elements the |
| 945 |
* one that was swapped there when the old partition element was swapped |
| 946 |
* into its final spot; this turns out to avoid $n^2$ behavior when the |
| 947 |
* list is nearly sorted to start with). This code determines which of |
| 948 |
* the six possible permutations we're dealing with and moves the median |
| 949 |
* element to |left_end|. The comments next to the |swap| actions give |
| 950 |
* the known orderings of the corresponding elements of |sorted_cites| |
| 951 |
* before the action. |
| 952 |
***************************************************************************/ |
| 953 |
left = left_end + END_OFFSET; |
| 954 |
middle = (left_end + right_end) / 2; |
| 955 |
right = right_end - END_OFFSET; |
| 956 |
if (less_than (SORTED_CITES[left], SORTED_CITES[middle])) |
| 957 |
BEGIN |
| 958 |
if (less_than (SORTED_CITES[middle], SORTED_CITES[right])) |
| 959 |
BEGIN |
| 960 |
swap (left_end, middle); |
| 961 |
END |
| 962 |
else if (less_than (SORTED_CITES[left], SORTED_CITES[right])) |
| 963 |
BEGIN |
| 964 |
swap (left_end, right); |
| 965 |
END |
| 966 |
else |
| 967 |
BEGIN |
| 968 |
swap (left_end, left); |
| 969 |
END |
| 970 |
END |
| 971 |
else if (less_than (SORTED_CITES[right], SORTED_CITES[middle])) |
| 972 |
BEGIN |
| 973 |
swap (left_end, middle); |
| 974 |
END |
| 975 |
else if (less_than (SORTED_CITES[right], SORTED_CITES[left])) |
| 976 |
BEGIN |
| 977 |
swap (left_end, right); |
| 978 |
END |
| 979 |
else |
| 980 |
BEGIN |
| 981 |
swap (left_end, left); |
| 982 |
END |
| 983 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 305 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 984 |
|
| 985 |
/*************************************************************************** |
| 986 |
* WEB section number: 306 |
| 987 |
* ~~~~~~~~~~~~~~~~~~~ |
| 988 |
* This module uses the median-of-three computed above to partition the |
| 989 |
* elements into those less than and those greater than the median. |
| 990 |
* Equal sort.key$s are sorted by order of occurrence (in |
| 991 |
* |cite_list|). |
| 992 |
***************************************************************************/ |
| 993 |
partition = SORTED_CITES[left_end]; |
| 994 |
left = left_end + 1; |
| 995 |
right = right_end; |
| 996 |
do |
| 997 |
BEGIN |
| 998 |
while (less_than (SORTED_CITES[left], partition)) |
| 999 |
BEGIN |
| 1000 |
INCR (left); |
| 1001 |
END |
| 1002 |
while (less_than (partition, SORTED_CITES[right])) |
| 1003 |
BEGIN |
| 1004 |
DECR (right); |
| 1005 |
END |
| 1006 |
if (left < right) |
| 1007 |
BEGIN |
| 1008 |
swap (left, right); |
| 1009 |
INCR (left); |
| 1010 |
DECR (right); |
| 1011 |
END |
| 1012 |
END while ( ! (left == (right + 1))); |
| 1013 |
swap (left_end, right); |
| 1014 |
quick_sort (left_end, right - 1); |
| 1015 |
quick_sort (left, right_end); |
| 1016 |
END |
| 1017 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 306 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1018 |
|
| 1019 |
END |
| 1020 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 303 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
/*************************************************************************** |
| 1026 |
* WEB section number: 98 |
| 1027 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1028 |
* I mean, this is truly disgraceful. A user has to type something in to |
| 1029 |
* the terminal just once during the entire run. And it's not some |
| 1030 |
* complicated string where you have to get every last punctuation mark |
| 1031 |
* just right, and it's not some fancy list where you get nervous because |
| 1032 |
* if you forget one item you have to type the whole thing again; it's |
| 1033 |
* just a simple, ordinary, file name. Now you'd think a five-year-old |
| 1034 |
* could do it; you'd think it's so simple a user should be able to do it |
| 1035 |
* in his sleep. But noooooooooo. He had to sit there droning on and on |
| 1036 |
* about who knows what until he exceeded the bounds of common sense, and |
| 1037 |
* he probably didn't even realize it. Just pitiful. What's this world |
| 1038 |
* coming to? We should probably just delete all his files and be done |
| 1039 |
* with him. Note: The |TERM_OUT| file is system dependent. |
| 1040 |
* |
| 1041 |
* NOTE: because C arrays start at index 0, not 1, the subscripts of array |
| 1042 |
* |name_of_file| are generally 1 less than those in the WEB source. |
| 1043 |
***************************************************************************/ |
| 1044 |
void sam_too_long_file_name_print (void) |
| 1045 |
BEGIN |
| 1046 |
FPRINTF (TERM_OUT, "File name `"); |
| 1047 |
name_ptr = 0; |
| 1048 |
while (name_ptr < aux_name_length) |
| 1049 |
BEGIN |
| 1050 |
FPUTC (name_of_file[name_ptr], TERM_OUT); |
| 1051 |
INCR (name_ptr); |
| 1052 |
END |
| 1053 |
FPRINTF (TERM_OUT, "' is too long\n"); |
| 1054 |
END |
| 1055 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 98 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
/*************************************************************************** |
| 1060 |
* WEB section number: 99 |
| 1061 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1062 |
* We've abused the user enough for one section; suffice it to |
| 1063 |
* say here that most of what we said last module still applies. |
| 1064 |
* Note: The |TERM_OUT| file is system dependent. |
| 1065 |
* |
| 1066 |
* NOTE: because C arrays start at index 0, not 1, the subscripts of array |
| 1067 |
* |name_of_file| are generally 1 less than those in the WEB source. |
| 1068 |
***************************************************************************/ |
| 1069 |
void sam_wrong_file_name_print (void) |
| 1070 |
BEGIN |
| 1071 |
FPRINTF (TERM_OUT, "I couldn't open file name `"); |
| 1072 |
FPUTS (name_of_file, TERM_OUT); |
| 1073 |
FPRINTF (TERM_OUT, "'\n"); |
| 1074 |
END |
| 1075 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 99 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
/*************************************************************************** |
| 1080 |
* WEB section number: 83 |
| 1081 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1082 |
* This function scans the |buffer| for the next token, starting at the |
| 1083 |
* global variable |buf_ptr2| and ending just before either the single |
| 1084 |
* specified stop-character or the end of the current line, whichever |
| 1085 |
* comes first, respectively returning |true| or |false|; afterward, |
| 1086 |
* |scan_char| is the first character following this token. |
| 1087 |
***************************************************************************/ |
| 1088 |
Boolean_T scan1 (ASCIICode_T char1) |
| 1089 |
BEGIN |
| 1090 |
Boolean_T scan1; |
| 1091 |
|
| 1092 |
buf_ptr1 = buf_ptr2; |
| 1093 |
while ((SCAN_CHAR != char1) && (buf_ptr2 < last)) |
| 1094 |
BEGIN |
| 1095 |
INCR (buf_ptr2); |
| 1096 |
END |
| 1097 |
if (buf_ptr2 < last) |
| 1098 |
BEGIN |
| 1099 |
scan1 = TRUE; |
| 1100 |
END |
| 1101 |
else |
| 1102 |
BEGIN |
| 1103 |
scan1 = FALSE; |
| 1104 |
END |
| 1105 |
return (scan1); |
| 1106 |
END |
| 1107 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 83 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
/*************************************************************************** |
| 1112 |
* WEB section number: 84 |
| 1113 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1114 |
* This function is the same but stops at |white_space| characters as well. |
| 1115 |
***************************************************************************/ |
| 1116 |
Boolean_T scan1_white (ASCIICode_T char1) |
| 1117 |
BEGIN |
| 1118 |
Boolean_T scan1_white; |
| 1119 |
|
| 1120 |
buf_ptr1 = buf_ptr2; |
| 1121 |
while ((lex_class[SCAN_CHAR] != WHITE_SPACE) |
| 1122 |
&& (SCAN_CHAR != char1) && (buf_ptr2 < last)) |
| 1123 |
BEGIN |
| 1124 |
INCR (buf_ptr2); |
| 1125 |
END |
| 1126 |
if (buf_ptr2 < last) |
| 1127 |
BEGIN |
| 1128 |
scan1_white = TRUE; |
| 1129 |
END |
| 1130 |
else |
| 1131 |
BEGIN |
| 1132 |
scan1_white = FALSE; |
| 1133 |
END |
| 1134 |
return (scan1_white); |
| 1135 |
END |
| 1136 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 84 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
/*************************************************************************** |
| 1142 |
* WEB section number: 85 |
| 1143 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1144 |
* This function is similar to |scan1|, but stops at either of two |
| 1145 |
* stop-characters as well as the end of the current line. |
| 1146 |
***************************************************************************/ |
| 1147 |
Boolean_T scan2 (ASCIICode_T char1, ASCIICode_T char2) |
| 1148 |
BEGIN |
| 1149 |
Boolean_T scan2; |
| 1150 |
|
| 1151 |
buf_ptr1 = buf_ptr2; |
| 1152 |
while ((SCAN_CHAR != char1) && (SCAN_CHAR != char2) |
| 1153 |
&& (buf_ptr2 < last)) |
| 1154 |
BEGIN |
| 1155 |
INCR (buf_ptr2); |
| 1156 |
END |
| 1157 |
if (buf_ptr2 < last) |
| 1158 |
BEGIN |
| 1159 |
scan2 = TRUE; |
| 1160 |
END |
| 1161 |
else |
| 1162 |
BEGIN |
| 1163 |
scan2 = FALSE; |
| 1164 |
END |
| 1165 |
return (scan2); |
| 1166 |
END |
| 1167 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 85 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
/*************************************************************************** |
| 1172 |
* WEB section number: 86 |
| 1173 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1174 |
* This function is the same but stops at |white_space| characters as well. |
| 1175 |
***************************************************************************/ |
| 1176 |
Boolean_T scan2_white (ASCIICode_T char1, ASCIICode_T char2) |
| 1177 |
BEGIN |
| 1178 |
Boolean_T scan2_white; |
| 1179 |
|
| 1180 |
buf_ptr1 = buf_ptr2; |
| 1181 |
while ((SCAN_CHAR != char1) && (SCAN_CHAR != char2) |
| 1182 |
&& (lex_class[SCAN_CHAR] != WHITE_SPACE) && (buf_ptr2 < last)) |
| 1183 |
BEGIN |
| 1184 |
INCR (buf_ptr2); |
| 1185 |
END |
| 1186 |
if (buf_ptr2 < last) |
| 1187 |
BEGIN |
| 1188 |
scan2_white = TRUE; |
| 1189 |
END |
| 1190 |
else |
| 1191 |
BEGIN |
| 1192 |
scan2_white = FALSE; |
| 1193 |
END |
| 1194 |
return (scan2_white); |
| 1195 |
END |
| 1196 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 86 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
/*************************************************************************** |
| 1202 |
* WEB section number: 87 |
| 1203 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1204 |
* This function is similar to |scan2|, but stops at either of three |
| 1205 |
* stop-characters as well as the end of the current line. |
| 1206 |
***************************************************************************/ |
| 1207 |
Boolean_T scan3 (ASCIICode_T char1, ASCIICode_T char2, |
| 1208 |
ASCIICode_T char3) |
| 1209 |
BEGIN |
| 1210 |
Boolean_T scan3; |
| 1211 |
|
| 1212 |
buf_ptr1 = buf_ptr2; |
| 1213 |
while ((SCAN_CHAR != char1) && (SCAN_CHAR != char2) |
| 1214 |
&& (SCAN_CHAR != char3) && (buf_ptr2 < last)) |
| 1215 |
BEGIN |
| 1216 |
INCR (buf_ptr2); |
| 1217 |
END |
| 1218 |
if (buf_ptr2 < last) |
| 1219 |
BEGIN |
| 1220 |
scan3 = TRUE; |
| 1221 |
END |
| 1222 |
else |
| 1223 |
BEGIN |
| 1224 |
scan3 = FALSE; |
| 1225 |
END |
| 1226 |
return (scan3); |
| 1227 |
END |
| 1228 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 87 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
/*************************************************************************** |
| 1234 |
* WEB section number: 250 |
| 1235 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1236 |
* Each field token is either a nonnegative number, a macro name (like |
| 1237 |
* `jan'), or a brace-balanced string delimited by either |double_quote|s |
| 1238 |
* or braces. Thus there are four possibilities for the first character |
| 1239 |
* of the field token: If it's a |left_brace| or a |double_quote|, the |
| 1240 |
* token (with balanced braces, up to the matching |right_str_delim|) is |
| 1241 |
* a string; if it's |numeric|, the token is a number; if it's anything |
| 1242 |
* else, the token is a macro name (and should thus have been defined by |
| 1243 |
* either the .bst-file's macro command or the .bib-file's |
| 1244 |
* string command). This function returns |false| if there was a |
| 1245 |
* serious syntax error. |
| 1246 |
***************************************************************************/ |
| 1247 |
Boolean_T scan_a_field_token_and_eat_whit (void) |
| 1248 |
BEGIN |
| 1249 |
Boolean_T scan_a_field_token_And_eat_whit; |
| 1250 |
|
| 1251 |
scan_a_field_token_And_eat_whit = FALSE; |
| 1252 |
switch (SCAN_CHAR) |
| 1253 |
BEGIN |
| 1254 |
case LEFT_BRACE: |
| 1255 |
right_str_delim = RIGHT_BRACE; |
| 1256 |
if ( ! scan_balanced_braces ()) |
| 1257 |
goto Exit_Label; |
| 1258 |
break; |
| 1259 |
case DOUBLE_QUOTE: |
| 1260 |
right_str_delim = DOUBLE_QUOTE; |
| 1261 |
if ( ! scan_balanced_braces ()) |
| 1262 |
goto Exit_Label; |
| 1263 |
break; |
| 1264 |
case '0': |
| 1265 |
case '1': |
| 1266 |
case '2': |
| 1267 |
case '3': |
| 1268 |
case '4': |
| 1269 |
case '5': |
| 1270 |
case '6': |
| 1271 |
case '7': |
| 1272 |
case '8': |
| 1273 |
case '9': |
| 1274 |
|
| 1275 |
/*************************************************************************** |
| 1276 |
* WEB section number: 258 |
| 1277 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1278 |
* This module scans a nonnegative number and copies it to |field_vl_str| |
| 1279 |
* if it's to store the field. |
| 1280 |
***************************************************************************/ |
| 1281 |
if ( ! scan_nonneg_integer ()) |
| 1282 |
BEGIN |
| 1283 |
CONFUSION ("A digit disappeared"); |
| 1284 |
END |
| 1285 |
if (store_field) |
| 1286 |
BEGIN |
| 1287 |
tmp_ptr = buf_ptr1; |
| 1288 |
while (tmp_ptr < buf_ptr2) |
| 1289 |
BEGIN |
| 1290 |
COPY_CHAR (buffer[tmp_ptr]); |
| 1291 |
INCR (tmp_ptr); |
| 1292 |
END |
| 1293 |
END |
| 1294 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 258 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1295 |
|
| 1296 |
break; |
| 1297 |
default: |
| 1298 |
|
| 1299 |
/*************************************************************************** |
| 1300 |
* WEB section number: 259 |
| 1301 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1302 |
* This module scans a macro name and copies its string to |field_vl_str| |
| 1303 |
* if it's to store the field, complaining if the macro is recursive or |
| 1304 |
* undefined. |
| 1305 |
***************************************************************************/ |
| 1306 |
scan_identifier (COMMA, right_outer_delim, CONCAT_CHAR); |
| 1307 |
BIB_IDENTIFIER_SCAN_CHECK ("a field part"); |
| 1308 |
if (store_field) |
| 1309 |
BEGIN |
| 1310 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1311 |
macro_name_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, MACRO_ILK, |
| 1312 |
DONT_INSERT); |
| 1313 |
store_token = TRUE; |
| 1314 |
if (at_bib_command) |
| 1315 |
BEGIN |
| 1316 |
if (command_num == N_BIB_STRING) |
| 1317 |
BEGIN |
| 1318 |
if (macro_name_loc == cur_macro_loc) |
| 1319 |
BEGIN |
| 1320 |
store_token = FALSE; |
| 1321 |
MACRO_NAME_WARNING ("used in its own definition"); |
| 1322 |
END |
| 1323 |
END |
| 1324 |
END |
| 1325 |
if ( ! hash_found) |
| 1326 |
BEGIN |
| 1327 |
store_token = FALSE; |
| 1328 |
MACRO_NAME_WARNING ("undefined"); |
| 1329 |
END |
| 1330 |
if (store_token) |
| 1331 |
BEGIN |
| 1332 |
|
| 1333 |
/*************************************************************************** |
| 1334 |
* WEB section number: 260 |
| 1335 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1336 |
* The macro definition may have |white_space| that needs compressing, |
| 1337 |
* because it may have been defined in the .bst file. |
| 1338 |
***************************************************************************/ |
| 1339 |
tmp_ptr = str_start[ilk_info[macro_name_loc]]; |
| 1340 |
tmp_end_ptr = str_start[ilk_info[macro_name_loc] + 1]; |
| 1341 |
if (FIELD_END == 0) |
| 1342 |
BEGIN |
| 1343 |
if ((lex_class[str_pool[tmp_ptr]] == WHITE_SPACE) |
| 1344 |
&& (tmp_ptr < tmp_end_ptr)) |
| 1345 |
BEGIN |
| 1346 |
COPY_CHAR (SPACE); |
| 1347 |
INCR (tmp_ptr); |
| 1348 |
while ((lex_class[str_pool[tmp_ptr]] == WHITE_SPACE) |
| 1349 |
&& (tmp_ptr < tmp_end_ptr)) |
| 1350 |
BEGIN |
| 1351 |
INCR (tmp_ptr); |
| 1352 |
END |
| 1353 |
END |
| 1354 |
END |
| 1355 |
while (tmp_ptr < tmp_end_ptr) |
| 1356 |
BEGIN |
| 1357 |
if (lex_class[str_pool[tmp_ptr]] != WHITE_SPACE) |
| 1358 |
BEGIN |
| 1359 |
COPY_CHAR (str_pool[tmp_ptr]); |
| 1360 |
END |
| 1361 |
else if (FIELD_VL_STR[FIELD_END - 1] != SPACE) |
| 1362 |
BEGIN |
| 1363 |
COPY_CHAR (SPACE); |
| 1364 |
END |
| 1365 |
INCR (tmp_ptr); |
| 1366 |
END |
| 1367 |
END |
| 1368 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 260 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1369 |
|
| 1370 |
END |
| 1371 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 259 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1372 |
|
| 1373 |
break; |
| 1374 |
END |
| 1375 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1376 |
scan_a_field_token_And_eat_whit = TRUE; |
| 1377 |
Exit_Label: DO_NOTHING; |
| 1378 |
return (scan_a_field_token_And_eat_whit); |
| 1379 |
END |
| 1380 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 250 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
/*************************************************************************** |
| 1385 |
* WEB section number: 88 |
| 1386 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1387 |
* This function scans for letters, stopping at the first nonletter; it |
| 1388 |
* returns |true| if there is at least one letter. |
| 1389 |
***************************************************************************/ |
| 1390 |
Boolean_T scan_alpha (void) |
| 1391 |
BEGIN |
| 1392 |
Boolean_T scan_alpha; |
| 1393 |
|
| 1394 |
buf_ptr1 = buf_ptr2; |
| 1395 |
while ((lex_class[SCAN_CHAR] == ALPHA) && (buf_ptr2 < last)) |
| 1396 |
BEGIN |
| 1397 |
INCR (buf_ptr2); |
| 1398 |
END |
| 1399 |
if (TOKEN_LEN == 0) |
| 1400 |
BEGIN |
| 1401 |
scan_alpha = FALSE; |
| 1402 |
END |
| 1403 |
else |
| 1404 |
BEGIN |
| 1405 |
scan_alpha = TRUE; |
| 1406 |
END |
| 1407 |
return (scan_alpha); |
| 1408 |
END |
| 1409 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 88 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
/*************************************************************************** |
| 1414 |
* WEB section number: 249 |
| 1415 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1416 |
* This function scans the list of field tokens that define the field |
| 1417 |
* value string. If |store_field| is |true| it accumulates (indirectly) |
| 1418 |
* in |field_vl_str| the concatenation of all the field tokens, |
| 1419 |
* compressing nonnull |white_space| to a single |space| and, if the |
| 1420 |
* field value is for a field (rather than a string definition), removing |
| 1421 |
* any leading or trailing |white_space|; when it's finished it puts the |
| 1422 |
* string into the hash table. It returns |false| if there was a serious |
| 1423 |
* syntax error. |
| 1424 |
***************************************************************************/ |
| 1425 |
Boolean_T scan_and_store_the_field_value (void) |
| 1426 |
BEGIN |
| 1427 |
Boolean_T scan_and_store_the_field_value; |
| 1428 |
|
| 1429 |
scan_and_store_the_field_value = FALSE; |
| 1430 |
FIELD_END = 0; |
| 1431 |
if ( ! scan_a_field_token_and_eat_whit ()) |
| 1432 |
BEGIN |
| 1433 |
goto Exit_Label; |
| 1434 |
END |
| 1435 |
while (SCAN_CHAR == CONCAT_CHAR) |
| 1436 |
BEGIN |
| 1437 |
INCR (buf_ptr2); |
| 1438 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1439 |
if ( ! scan_a_field_token_and_eat_whit ()) |
| 1440 |
BEGIN |
| 1441 |
goto Exit_Label; |
| 1442 |
END |
| 1443 |
END |
| 1444 |
if (store_field) |
| 1445 |
BEGIN |
| 1446 |
|
| 1447 |
/*************************************************************************** |
| 1448 |
* WEB section number: 261 |
| 1449 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1450 |
* Now it's time to store the field value in the hash table, and store an |
| 1451 |
* appropriate pointer to it (depending on whether it's for a database |
| 1452 |
* entry or command). But first, if necessary, we remove a trailing |
| 1453 |
* |space| and a leading |space| if these exist. (Hey, if we had some |
| 1454 |
* ham we could make ham-and-eggs if we had some eggs.) |
| 1455 |
***************************************************************************/ |
| 1456 |
if ( ! at_bib_command) |
| 1457 |
BEGIN |
| 1458 |
if (FIELD_END > 0) |
| 1459 |
BEGIN |
| 1460 |
if (FIELD_VL_STR[FIELD_END - 1] == SPACE) |
| 1461 |
BEGIN |
| 1462 |
DECR (FIELD_END); |
| 1463 |
END |
| 1464 |
END |
| 1465 |
END |
| 1466 |
if (( ! at_bib_command) && (FIELD_VL_STR[0] == SPACE) && (FIELD_END > 0)) |
| 1467 |
BEGIN |
| 1468 |
FIELD_START = 1; |
| 1469 |
END |
| 1470 |
else |
| 1471 |
BEGIN |
| 1472 |
FIELD_START = 0; |
| 1473 |
END |
| 1474 |
field_val_loc = str_lookup (FIELD_VL_STR, FIELD_START, |
| 1475 |
FIELD_END - FIELD_START, TEXT_ILK, |
| 1476 |
DO_INSERT); |
| 1477 |
fn_type[field_val_loc] = STR_LITERAL; |
| 1478 |
|
| 1479 |
#ifdef TRACE |
| 1480 |
if (Flag_trace) { |
| 1481 |
TRACE_PR ("\""); |
| 1482 |
TRACE_PR_POOL_STR (hash_text[field_val_loc]); |
| 1483 |
TRACE_PR_LN ("\" is a field value"); |
| 1484 |
} |
| 1485 |
#endif /* TRACE */ |
| 1486 |
|
| 1487 |
if (at_bib_command) |
| 1488 |
BEGIN |
| 1489 |
|
| 1490 |
/*************************************************************************** |
| 1491 |
* WEB section number: 262 |
| 1492 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1493 |
* Here's where we store the goods when we're dealing with a command |
| 1494 |
* rather than an entry. |
| 1495 |
***************************************************************************/ |
| 1496 |
switch (command_num) |
| 1497 |
BEGIN |
| 1498 |
case N_BIB_PREAMBLE: |
| 1499 |
s_preamble[preamble_ptr] = hash_text[field_val_loc]; |
| 1500 |
INCR (preamble_ptr); |
| 1501 |
break; |
| 1502 |
case N_BIB_STRING: |
| 1503 |
ilk_info[cur_macro_loc] = hash_text[field_val_loc]; |
| 1504 |
break; |
| 1505 |
default: |
| 1506 |
bib_cmd_confusion (); |
| 1507 |
break; |
| 1508 |
END |
| 1509 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 262 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1510 |
|
| 1511 |
END |
| 1512 |
else |
| 1513 |
BEGIN |
| 1514 |
|
| 1515 |
/*************************************************************************** |
| 1516 |
* WEB section number: 263 |
| 1517 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1518 |
* And here, an entry. |
| 1519 |
***************************************************************************/ |
| 1520 |
field_ptr = (entry_cite_ptr * num_fields) + FN_INFO[field_name_loc]; |
| 1521 |
if (field_info[field_ptr] != MISSING) |
| 1522 |
BEGIN |
| 1523 |
PRINT ("Warning--I'm ignoring "); |
| 1524 |
PRINT_POOL_STR (cite_list[entry_cite_ptr]); |
| 1525 |
PRINT ("'s extra \""); |
| 1526 |
PRINT_POOL_STR (hash_text[field_name_loc]); |
| 1527 |
BIB_WARN_NEWLINE ("\" field"); |
| 1528 |
END |
| 1529 |
else |
| 1530 |
BEGIN |
| 1531 |
field_info[field_ptr] = hash_text[field_val_loc]; |
| 1532 |
if ((ilk_info[field_name_loc] == crossref_num) |
| 1533 |
&& ( ! all_entries)) |
| 1534 |
BEGIN |
| 1535 |
|
| 1536 |
/*************************************************************************** |
| 1537 |
* WEB section number: 264 |
| 1538 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1539 |
* If the cross-referenced entry isn't already on |cite_list| we add it |
| 1540 |
* (at least temporarily); if it is already on |cite_list| we update the |
| 1541 |
* cross-reference count, if necessary. Note that |all_entries| is |
| 1542 |
* |false| here. The alias kludge helps make the stack space not |
| 1543 |
* overflow on some machines. |
| 1544 |
***************************************************************************/ |
| 1545 |
tmp_ptr = FIELD_START; |
| 1546 |
while (tmp_ptr < FIELD_END) |
| 1547 |
BEGIN |
| 1548 |
EXTRA_BUF[tmp_ptr] = FIELD_VL_STR[tmp_ptr]; |
| 1549 |
INCR (tmp_ptr); |
| 1550 |
END |
| 1551 |
lower_case (EXTRA_BUF, FIELD_START, FIELD_END - FIELD_START); |
| 1552 |
lc_cite_loc = str_lookup (EXTRA_BUF, FIELD_START, |
| 1553 |
FIELD_END - FIELD_START, LC_CITE_ILK, |
| 1554 |
DO_INSERT); |
| 1555 |
if (hash_found) |
| 1556 |
BEGIN |
| 1557 |
cite_loc = ilk_info[lc_cite_loc]; |
| 1558 |
if (ilk_info[cite_loc] >= old_num_cites) |
| 1559 |
BEGIN |
| 1560 |
INCR (cite_info[ilk_info[cite_loc]]); |
| 1561 |
END |
| 1562 |
END |
| 1563 |
else |
| 1564 |
BEGIN |
| 1565 |
cite_loc = str_lookup (FIELD_VL_STR, FIELD_START, |
| 1566 |
FIELD_END - FIELD_START, CITE_ILK, |
| 1567 |
DO_INSERT); |
| 1568 |
if (hash_found) |
| 1569 |
BEGIN |
| 1570 |
hash_cite_confusion (); |
| 1571 |
END |
| 1572 |
add_database_cite (&cite_ptr); |
| 1573 |
cite_info[ilk_info[cite_loc]] = 1; |
| 1574 |
END |
| 1575 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 264 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1576 |
|
| 1577 |
END |
| 1578 |
END |
| 1579 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 263 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1580 |
|
| 1581 |
END |
| 1582 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 261 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1583 |
|
| 1584 |
END |
| 1585 |
scan_and_store_the_field_value = TRUE; |
| 1586 |
Exit_Label: DO_NOTHING; |
| 1587 |
return (scan_and_store_the_field_value); |
| 1588 |
END |
| 1589 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 249 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
/*************************************************************************** |
| 1594 |
* WEB section number: 253 |
| 1595 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1596 |
* This .bib-specific function scans a string with balanced braces, |
| 1597 |
* stopping just past the matching |right_str_delim|. How much work it |
| 1598 |
* does depends on whether |store_field = true|. It returns |false| if |
| 1599 |
* there was a serious syntax error. |
| 1600 |
***************************************************************************/ |
| 1601 |
Boolean_T scan_balanced_braces (void) |
| 1602 |
BEGIN |
| 1603 |
Boolean_T scan_balanced_braces; |
| 1604 |
|
| 1605 |
scan_balanced_braces = FALSE; |
| 1606 |
INCR (buf_ptr2); |
| 1607 |
CHECK_FOR_AND_COMPRESS_BIB_WHIT; |
| 1608 |
if (FIELD_END > 1) |
| 1609 |
BEGIN |
| 1610 |
if (FIELD_VL_STR[FIELD_END- 1] == SPACE) |
| 1611 |
BEGIN |
| 1612 |
if (ex_buf[FIELD_END- 2] == SPACE) |
| 1613 |
BEGIN |
| 1614 |
DECR (FIELD_END); |
| 1615 |
END |
| 1616 |
END |
| 1617 |
END |
| 1618 |
bib_brace_level = 0; |
| 1619 |
if (store_field) |
| 1620 |
BEGIN |
| 1621 |
|
| 1622 |
/*************************************************************************** |
| 1623 |
* WEB section number: 256 |
| 1624 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1625 |
* This module scans over a brace-balanced string, compressing multiple |
| 1626 |
* |white_space| characters into a single |space|. It starts with |
| 1627 |
* |bib_brace_level = 0| and starts at a non|white_space| character. |
| 1628 |
***************************************************************************/ |
| 1629 |
while (SCAN_CHAR != right_str_delim) |
| 1630 |
BEGIN |
| 1631 |
switch (SCAN_CHAR) |
| 1632 |
BEGIN |
| 1633 |
case LEFT_BRACE: |
| 1634 |
INCR (bib_brace_level); |
| 1635 |
COPY_CHAR (LEFT_BRACE); |
| 1636 |
INCR (buf_ptr2); |
| 1637 |
CHECK_FOR_AND_COMPRESS_BIB_WHIT; |
| 1638 |
|
| 1639 |
/*************************************************************************** |
| 1640 |
* WEB section number: 257 |
| 1641 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1642 |
* This module is similar to the last but starts with |bib_brace_level > 0| |
| 1643 |
* (and, like the last, it starts at a non|white_space| character). |
| 1644 |
***************************************************************************/ |
| 1645 |
LOOP |
| 1646 |
BEGIN |
| 1647 |
switch (SCAN_CHAR) |
| 1648 |
BEGIN |
| 1649 |
case RIGHT_BRACE: |
| 1650 |
DECR (bib_brace_level); |
| 1651 |
COPY_CHAR (RIGHT_BRACE); |
| 1652 |
INCR (buf_ptr2); |
| 1653 |
CHECK_FOR_AND_COMPRESS_BIB_WHIT; |
| 1654 |
if (bib_brace_level == 0) |
| 1655 |
BEGIN |
| 1656 |
goto Loop_Exit_Label; |
| 1657 |
END |
| 1658 |
break; |
| 1659 |
case LEFT_BRACE: |
| 1660 |
INCR (bib_brace_level); |
| 1661 |
COPY_CHAR (LEFT_BRACE); |
| 1662 |
INCR (buf_ptr2); |
| 1663 |
CHECK_FOR_AND_COMPRESS_BIB_WHIT; |
| 1664 |
break; |
| 1665 |
default: |
| 1666 |
COPY_CHAR (SCAN_CHAR); |
| 1667 |
INCR (buf_ptr2); |
| 1668 |
CHECK_FOR_AND_COMPRESS_BIB_WHIT; |
| 1669 |
break; |
| 1670 |
END |
| 1671 |
END |
| 1672 |
Loop_Exit_Label: DO_NOTHING |
| 1673 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1674 |
|
| 1675 |
break; |
| 1676 |
case RIGHT_BRACE: |
| 1677 |
BIB_UNBALANCED_BRACES_ERR; |
| 1678 |
default: |
| 1679 |
COPY_CHAR (SCAN_CHAR); |
| 1680 |
INCR (buf_ptr2); |
| 1681 |
CHECK_FOR_AND_COMPRESS_BIB_WHIT; |
| 1682 |
break; |
| 1683 |
END |
| 1684 |
END |
| 1685 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 256 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1686 |
|
| 1687 |
END |
| 1688 |
else |
| 1689 |
BEGIN |
| 1690 |
|
| 1691 |
/*************************************************************************** |
| 1692 |
* WEB section number: 254 |
| 1693 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1694 |
* This module scans over a brace-balanced string without keeping track |
| 1695 |
* of anything but the brace level. It starts with |bib_brace_level = 0| |
| 1696 |
* and at a non|white_space| character. |
| 1697 |
***************************************************************************/ |
| 1698 |
while (SCAN_CHAR != right_str_delim) |
| 1699 |
BEGIN |
| 1700 |
if (SCAN_CHAR == LEFT_BRACE) |
| 1701 |
BEGIN |
| 1702 |
INCR (bib_brace_level); |
| 1703 |
INCR (buf_ptr2); |
| 1704 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1705 |
while (bib_brace_level > 0) |
| 1706 |
BEGIN |
| 1707 |
|
| 1708 |
/*************************************************************************** |
| 1709 |
* WEB section number: 255 |
| 1710 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1711 |
* This module does the same as above but, because |bib_brace_level > 0|, it |
| 1712 |
* doesn't have to look for a |right_str_delim|. |
| 1713 |
***************************************************************************/ |
| 1714 |
if (SCAN_CHAR == RIGHT_BRACE) |
| 1715 |
BEGIN |
| 1716 |
DECR (bib_brace_level); |
| 1717 |
INCR (buf_ptr2); |
| 1718 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1719 |
END |
| 1720 |
else if (SCAN_CHAR == LEFT_BRACE) |
| 1721 |
BEGIN |
| 1722 |
INCR (bib_brace_level); |
| 1723 |
INCR (buf_ptr2); |
| 1724 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1725 |
END |
| 1726 |
else |
| 1727 |
BEGIN |
| 1728 |
INCR (buf_ptr2); |
| 1729 |
if ( ! scan2 (RIGHT_BRACE, LEFT_BRACE)) |
| 1730 |
BEGIN |
| 1731 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1732 |
END |
| 1733 |
END |
| 1734 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 255 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1735 |
|
| 1736 |
END |
| 1737 |
END |
| 1738 |
else if (SCAN_CHAR == RIGHT_BRACE) |
| 1739 |
BEGIN |
| 1740 |
BIB_UNBALANCED_BRACES_ERR; |
| 1741 |
END |
| 1742 |
else |
| 1743 |
BEGIN |
| 1744 |
INCR (buf_ptr2); |
| 1745 |
if ( ! scan3 (right_str_delim, LEFT_BRACE, RIGHT_BRACE)) |
| 1746 |
BEGIN |
| 1747 |
EAT_BIB_WHITE_AND_EOF_CHECK; |
| 1748 |
END |
| 1749 |
END |
| 1750 |
END |
| 1751 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 254 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1752 |
|
| 1753 |
END |
| 1754 |
INCR (buf_ptr2); |
| 1755 |
scan_balanced_braces = TRUE; |
| 1756 |
Exit_Label: DO_NOTHING; |
| 1757 |
return (scan_balanced_braces); |
| 1758 |
END |
| 1759 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1760 |
|
| 1761 |
|
| 1762 |
/*************************************************************************** |
| 1763 |
* WEB section number: 188 |
| 1764 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1765 |
* This macro inserts a hash-table location (or one of the two |
| 1766 |
* special markers |quote_next_fn| and |end_of_def|) into the |
| 1767 |
* |singl_function| array, which will later be copied into the |
| 1768 |
* |wiz_functions| array. |
| 1769 |
***************************************************************************/ |
| 1770 |
#define INSERT_FN_LOC(X) {\ |
| 1771 |
singl_function[single_ptr] = (X);\ |
| 1772 |
if (single_ptr == Single_Fn_Space)\ |
| 1773 |
{BIB_XRETALLOC ("singl_function", singl_function, HashPtr2_T,\ |
| 1774 |
Single_Fn_Space, Single_Fn_Space + Single_Fn_Space);}\ |
| 1775 |
INCR (single_ptr);} |
| 1776 |
|
| 1777 |
|
| 1778 |
/*************************************************************************** |
| 1779 |
* WEB section number: 187 |
| 1780 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1781 |
* This recursive function reads and stores the list of functions |
| 1782 |
* (separated by |white_space| characters or ends-of-line) that define |
| 1783 |
* this new function, and reads a |right_brace|. |
| 1784 |
***************************************************************************/ |
| 1785 |
void scan_fn_def (HashLoc_T fn_hash_loc) |
| 1786 |
BEGIN |
| 1787 |
typedef Integer_T FnDefLoc_T; |
| 1788 |
HashPtr2_T *singl_function; |
| 1789 |
FnDefLoc_T single_ptr; |
| 1790 |
FnDefLoc_T copy_ptr; |
| 1791 |
BufPointer_T end_of_num; |
| 1792 |
HashLoc_T impl_fn_loc; |
| 1793 |
Integer_T Single_Fn_Space; |
| 1794 |
|
| 1795 |
Single_Fn_Space = SINGLE_FN_SPACE; |
| 1796 |
singl_function = (HashPtr2_T *) mymalloc ((Single_Fn_Space + 1) |
| 1797 |
* (unsigned long) sizeof (HashPtr2_T), "singl_function"); |
| 1798 |
EAT_BST_WHITE_AND_EOF_CHECK ("function"); |
| 1799 |
single_ptr = 0; |
| 1800 |
while (SCAN_CHAR != RIGHT_BRACE) |
| 1801 |
BEGIN |
| 1802 |
|
| 1803 |
/*************************************************************************** |
| 1804 |
* WEB section number: 189 |
| 1805 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1806 |
* There are five possibilities for the first character of the token |
| 1807 |
* representing the next function of the definition: If it's a |
| 1808 |
* |number_sign|, the token is an |int_literal|; if it's a |
| 1809 |
* |double_quote|, the token is a |str_literal|; if it's a |
| 1810 |
* |single_quote|, the token is a quoted function; if it's a |
| 1811 |
* |left_brace|, the token isn't really a token, but rather the start of |
| 1812 |
* another function definition (which will result in a recursive call to |
| 1813 |
* |scan_fn_def|); if it's anything else, the token is the name of an |
| 1814 |
* already-defined function. Note: To prevent the wizard from using |
| 1815 |
* recursion, we have to check that neither a quoted function nor an |
| 1816 |
* already-defined-function is actually the currently-being-defined |
| 1817 |
* function (which is stored at |wiz_loc|). |
| 1818 |
***************************************************************************/ |
| 1819 |
switch (SCAN_CHAR) |
| 1820 |
BEGIN |
| 1821 |
case NUMBER_SIGN: |
| 1822 |
|
| 1823 |
/*************************************************************************** |
| 1824 |
* WEB section number: 190 |
| 1825 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1826 |
* An |int_literal| is preceded by a |number_sign|, consists of an |
| 1827 |
* integer (i.e., an optional |minus_sign| followed by one or more |
| 1828 |
* |numeric| characters), and is followed either by a |white_space| |
| 1829 |
* character, an end-of-line, or a |right_brace|. The array |fn_info| |
| 1830 |
* contains the value of the integer for |int_literal|s. |
| 1831 |
***************************************************************************/ |
| 1832 |
BEGIN |
| 1833 |
INCR (buf_ptr2); |
| 1834 |
if ( ! scan_integer ()) |
| 1835 |
BEGIN |
| 1836 |
SKIP_TOKEN ("Illegal integer in integer literal"); |
| 1837 |
END |
| 1838 |
|
| 1839 |
#ifdef TRACE |
| 1840 |
if (Flag_trace) { |
| 1841 |
TRACE_PR ("#"); |
| 1842 |
TRACE_PR_TOKEN; |
| 1843 |
TRACE_PR_LN2 (" is an integer literal with value %ld", |
| 1844 |
(long) token_value); |
| 1845 |
} |
| 1846 |
#endif /* TRACE */ |
| 1847 |
|
| 1848 |
literal_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, INTEGER_ILK, |
| 1849 |
DO_INSERT); |
| 1850 |
if ( ! hash_found) |
| 1851 |
BEGIN |
| 1852 |
fn_type[literal_loc] = INT_LITERAL; |
| 1853 |
FN_INFO[literal_loc] = token_value; |
| 1854 |
END |
| 1855 |
if ((lex_class[SCAN_CHAR] != WHITE_SPACE) && (buf_ptr2 < last) |
| 1856 |
&& (SCAN_CHAR != RIGHT_BRACE) && (SCAN_CHAR != COMMENT)) |
| 1857 |
BEGIN |
| 1858 |
SKIP_TOKEN_ILLEGAL_STUFF_AFTER; |
| 1859 |
END |
| 1860 |
INSERT_FN_LOC (literal_loc); |
| 1861 |
END |
| 1862 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 190 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1863 |
|
| 1864 |
break; |
| 1865 |
case DOUBLE_QUOTE: |
| 1866 |
|
| 1867 |
/*************************************************************************** |
| 1868 |
* WEB section number: 191 |
| 1869 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1870 |
* A |str_literal| is preceded by a |double_quote| and consists of all |
| 1871 |
* characters on this line up to the next |double_quote|. Also, there |
| 1872 |
* must be either a |white_space| character, an end-of-line, a |
| 1873 |
* |right_brace|, or a |comment| following (since functions in the |
| 1874 |
* definition must be separated by |white_space|). The array |fn_info| |
| 1875 |
* contains nothing for |str_literal|s. |
| 1876 |
***************************************************************************/ |
| 1877 |
BEGIN |
| 1878 |
INCR (buf_ptr2); |
| 1879 |
if ( ! scan1 (DOUBLE_QUOTE)) |
| 1880 |
BEGIN |
| 1881 |
SKIP_TOKEN2 ("No `%c' to end string literal", xchr[DOUBLE_QUOTE]); |
| 1882 |
END |
| 1883 |
|
| 1884 |
#ifdef TRACE |
| 1885 |
if (Flag_trace) { |
| 1886 |
TRACE_PR ("\""); |
| 1887 |
TRACE_PR_TOKEN; |
| 1888 |
TRACE_PR ("\""); |
| 1889 |
TRACE_PR_LN (" is a string literal"); |
| 1890 |
} |
| 1891 |
#endif /* TRACE */ |
| 1892 |
|
| 1893 |
literal_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, TEXT_ILK, |
| 1894 |
DO_INSERT); |
| 1895 |
fn_type[literal_loc] = STR_LITERAL; |
| 1896 |
INCR (buf_ptr2); |
| 1897 |
if ((lex_class[SCAN_CHAR] != WHITE_SPACE) && (buf_ptr2 < last) |
| 1898 |
&& (SCAN_CHAR != RIGHT_BRACE) && (SCAN_CHAR != COMMENT)) |
| 1899 |
BEGIN |
| 1900 |
SKIP_TOKEN_ILLEGAL_STUFF_AFTER; |
| 1901 |
END |
| 1902 |
INSERT_FN_LOC (literal_loc); |
| 1903 |
END |
| 1904 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 191 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1905 |
|
| 1906 |
break; |
| 1907 |
case SINGLE_QUOTE: |
| 1908 |
|
| 1909 |
/*************************************************************************** |
| 1910 |
* WEB section number: 192 |
| 1911 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1912 |
* A quoted function is preceded by a |single_quote| and consists of all |
| 1913 |
* characters up to the next |white_space| character, end-of-line, |
| 1914 |
* |right_brace|, or |comment|. |
| 1915 |
***************************************************************************/ |
| 1916 |
BEGIN |
| 1917 |
INCR (buf_ptr2); |
| 1918 |
if (scan2_white (RIGHT_BRACE, COMMENT)) |
| 1919 |
BEGIN |
| 1920 |
DO_NOTHING; |
| 1921 |
END |
| 1922 |
|
| 1923 |
#ifdef TRACE |
| 1924 |
if (Flag_trace) { |
| 1925 |
TRACE_PR ("'"); |
| 1926 |
TRACE_PR_TOKEN; |
| 1927 |
TRACE_PR (" is a quoted function "); |
| 1928 |
} |
| 1929 |
#endif /* TRACE */ |
| 1930 |
|
| 1931 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 1932 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK, |
| 1933 |
DONT_INSERT); |
| 1934 |
if ( ! hash_found) |
| 1935 |
BEGIN |
| 1936 |
SKIP_TOKEN_UNKNOWN_FUNCTION; |
| 1937 |
END |
| 1938 |
else |
| 1939 |
|
| 1940 |
/*************************************************************************** |
| 1941 |
* WEB section number: 193 |
| 1942 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1943 |
* Here we check that this quoted function is a legal one---the function |
| 1944 |
* name must already exist, but it mustn't be the currently-being-defined |
| 1945 |
* function (which is stored at |wiz_loc|). |
| 1946 |
***************************************************************************/ |
| 1947 |
BEGIN |
| 1948 |
if (fn_loc == wiz_loc) |
| 1949 |
BEGIN |
| 1950 |
SKIP_RECURSIVE_TOKEN; |
| 1951 |
END |
| 1952 |
else |
| 1953 |
BEGIN |
| 1954 |
|
| 1955 |
#ifdef TRACE |
| 1956 |
if (Flag_trace) { |
| 1957 |
TRACE_PR ("of type "); |
| 1958 |
trace_pr_fn_class (fn_loc); |
| 1959 |
TRACE_PR_NEWLINE; |
| 1960 |
} |
| 1961 |
#endif /* TRACE */ |
| 1962 |
|
| 1963 |
INSERT_FN_LOC (QUOTE_NEXT_FN); |
| 1964 |
INSERT_FN_LOC (fn_loc); |
| 1965 |
END |
| 1966 |
END |
| 1967 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 193 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1968 |
|
| 1969 |
END |
| 1970 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 192 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1971 |
|
| 1972 |
break; |
| 1973 |
case LEFT_BRACE: |
| 1974 |
|
| 1975 |
/*************************************************************************** |
| 1976 |
* WEB section number: 194 |
| 1977 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1978 |
* This module marks the implicit function as being quoted, generates a |
| 1979 |
* name, and stores it in the hash table. This name is strictly internal |
| 1980 |
* to this program, starts with a |single_quote| (since that will make |
| 1981 |
* this function name unique), and ends with the variable |impl_fn_num| |
| 1982 |
* converted to ASCII. The alias kludge helps make the stack space not |
| 1983 |
* overflow on some machines. |
| 1984 |
***************************************************************************/ |
| 1985 |
BEGIN |
| 1986 |
EX_BUF2[0] = SINGLE_QUOTE; |
| 1987 |
int_to_ASCII (impl_fn_num, EX_BUF2, 1, &end_of_num); |
| 1988 |
impl_fn_loc = str_lookup (EX_BUF2, 0, end_of_num, BST_FN_ILK, |
| 1989 |
DO_INSERT); |
| 1990 |
if (hash_found) |
| 1991 |
BEGIN |
| 1992 |
CONFUSION ("Already encountered implicit function"); |
| 1993 |
END |
| 1994 |
|
| 1995 |
#ifdef TRACE |
| 1996 |
if (Flag_trace) { |
| 1997 |
TRACE_PR_POOL_STR (hash_text[impl_fn_loc]); |
| 1998 |
TRACE_PR_LN (" is an implicit function"); |
| 1999 |
} |
| 2000 |
#endif /* TRACE */ |
| 2001 |
|
| 2002 |
INCR (impl_fn_num); |
| 2003 |
fn_type[impl_fn_loc] = WIZ_DEFINED; |
| 2004 |
INSERT_FN_LOC (QUOTE_NEXT_FN); |
| 2005 |
INSERT_FN_LOC (impl_fn_loc); |
| 2006 |
INCR (buf_ptr2); |
| 2007 |
scan_fn_def (impl_fn_loc); |
| 2008 |
END |
| 2009 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 194 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2010 |
|
| 2011 |
break; |
| 2012 |
default: |
| 2013 |
|
| 2014 |
/*************************************************************************** |
| 2015 |
* WEB section number: 199 |
| 2016 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2017 |
* An already-defined function consists of all characters up to the next |
| 2018 |
* |white_space| character, end-of-line, |right_brace|, or |comment|. |
| 2019 |
* This function name must already exist, but it mustn't be the |
| 2020 |
* currently-being-defined function (which is stored at |wiz_loc|). |
| 2021 |
***************************************************************************/ |
| 2022 |
BEGIN |
| 2023 |
if (scan2_white (RIGHT_BRACE, COMMENT)) |
| 2024 |
BEGIN |
| 2025 |
DO_NOTHING; |
| 2026 |
END |
| 2027 |
|
| 2028 |
#ifdef TRACE |
| 2029 |
if (Flag_trace) { |
| 2030 |
TRACE_PR_TOKEN; |
| 2031 |
TRACE_PR (" is a function "); |
| 2032 |
} |
| 2033 |
#endif /* TRACE */ |
| 2034 |
|
| 2035 |
lower_case (buffer, buf_ptr1, TOKEN_LEN); |
| 2036 |
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK, |
| 2037 |
DONT_INSERT); |
| 2038 |
if ( ! hash_found) |
| 2039 |
BEGIN |
| 2040 |
SKIP_TOKEN_UNKNOWN_FUNCTION; |
| 2041 |
END |
| 2042 |
else if (fn_loc == wiz_loc) |
| 2043 |
BEGIN |
| 2044 |
SKIP_RECURSIVE_TOKEN; |
| 2045 |
END |
| 2046 |
else |
| 2047 |
BEGIN |
| 2048 |
|
| 2049 |
#ifdef TRACE |
| 2050 |
if (Flag_trace) { |
| 2051 |
TRACE_PR ("of type "); |
| 2052 |
trace_pr_fn_class (fn_loc); |
| 2053 |
TRACE_PR_NEWLINE; |
| 2054 |
} |
| 2055 |
#endif /* TRACE */ |
| 2056 |
|
| 2057 |
INSERT_FN_LOC (fn_loc); |
| 2058 |
END |
| 2059 |
END |
| 2060 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 199 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2061 |
|
| 2062 |
break; |
| 2063 |
END |
| 2064 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 189 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2065 |
|
| 2066 |
Next_Token_Label: |
| 2067 |
EAT_BST_WHITE_AND_EOF_CHECK ("function"); |
| 2068 |
END |
| 2069 |
|
| 2070 |
/*************************************************************************** |
| 2071 |
* WEB section number: 200 |
| 2072 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2073 |
* Now we add the |end_of_def| special marker, make sure this function will |
| 2074 |
* fit into |wiz_functions|, and put it there. |
| 2075 |
***************************************************************************/ |
| 2076 |
BEGIN |
| 2077 |
INSERT_FN_LOC (END_OF_DEF); |
| 2078 |
while ((single_ptr + wiz_def_ptr) > Wiz_Fn_Space) |
| 2079 |
BEGIN |
| 2080 |
BIB_XRETALLOC ("wiz_functions", wiz_functions, HashPtr2_T, |
| 2081 |
Wiz_Fn_Space, Wiz_Fn_Space + WIZ_FN_SPACE); |
| 2082 |
END |
| 2083 |
FN_INFO[fn_hash_loc] = wiz_def_ptr; |
| 2084 |
copy_ptr = 0; |
| 2085 |
while (copy_ptr < single_ptr) |
| 2086 |
BEGIN |
| 2087 |
wiz_functions[wiz_def_ptr] = singl_function[copy_ptr]; |
| 2088 |
INCR (copy_ptr); |
| 2089 |
INCR (wiz_def_ptr); |
| 2090 |
END |
| 2091 |
END |
| 2092 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 200 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2093 |
|
| 2094 |
INCR (buf_ptr2); |
| 2095 |
Exit_Label: free (singl_function); |
| 2096 |
END |
| 2097 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 187 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
/*************************************************************************** |
| 2103 |
* WEB section number: 90 |
| 2104 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2105 |
* This procedure scans for an identifier, stopping at the first |
| 2106 |
* |illegal_id_char|, or stopping at the first character if it's |
| 2107 |
* |numeric|. It sets the global variable |scan_result| to |id_null| if |
| 2108 |
* the identifier is null, else to |white_adjacent| if it ended at a |
| 2109 |
* |white_space| character or an end-of-line, else to |
| 2110 |
* |specified_char_adjacent| if it ended at one of |char1| or |char2| or |
| 2111 |
* |char3|, else to |other_char_adjacent| if it ended at a nonspecified, |
| 2112 |
* non|white_space| |illegal_id_char|. By convention, when some calling |
| 2113 |
* code really wants just one or two ``specified'' characters, it merely |
| 2114 |
* repeats one of the characters. |
| 2115 |
***************************************************************************/ |
| 2116 |
void scan_identifier (ASCIICode_T char1, ASCIICode_T char2, |
| 2117 |
ASCIICode_T char3) |
| 2118 |
BEGIN |
| 2119 |
buf_ptr1 = buf_ptr2; |
| 2120 |
if (lex_class[SCAN_CHAR] != NUMERIC) |
| 2121 |
BEGIN |
| 2122 |
while ((id_class[SCAN_CHAR] == LEGAL_ID_CHAR) && (buf_ptr2 < last)) |
| 2123 |
BEGIN |
| 2124 |
INCR (buf_ptr2); |
| 2125 |
END |
| 2126 |
END |
| 2127 |
if (TOKEN_LEN == 0) |
| 2128 |
BEGIN |
| 2129 |
scan_result = ID_NULL; |
| 2130 |
END |
| 2131 |
else if ((lex_class[SCAN_CHAR] == WHITE_SPACE) || (buf_ptr2 == last)) |
| 2132 |
BEGIN |
| 2133 |
scan_result = SPECIFIED_CHAR_ADJACENT; |
| 2134 |
END |
| 2135 |
else if ((SCAN_CHAR == char1) || (SCAN_CHAR == char2) |
| 2136 |
|| (SCAN_CHAR == char3)) |
| 2137 |
BEGIN |
| 2138 |
scan_result = SPECIFIED_CHAR_ADJACENT; |
| 2139 |
END |
| 2140 |
else |
| 2141 |
BEGIN |
| 2142 |
scan_result = OTHER_CHAR_ADJACENT; |
| 2143 |
END |
| 2144 |
END |
| 2145 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 90 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
|
| 2150 |
/*************************************************************************** |
| 2151 |
* WEB section number: 93 |
| 2152 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2153 |
* This procedure scans for an integer, stopping at the first nondigit; |
| 2154 |
* it sets the value of |token_value| accordingly. It returns |true| if |
| 2155 |
* the token was a legal integer (i.e., consisted of an optional |
| 2156 |
* |minus_sign| followed by one or more digits). |
| 2157 |
***************************************************************************/ |
| 2158 |
Boolean_T scan_integer (void) |
| 2159 |
BEGIN |
| 2160 |
Integer8_T sign_length; |
| 2161 |
Boolean_T scan_integer; |
| 2162 |
|
| 2163 |
buf_ptr1 = buf_ptr2; |
| 2164 |
if (SCAN_CHAR == MINUS_SIGN) |
| 2165 |
BEGIN |
| 2166 |
sign_length = 1; |
| 2167 |
INCR (buf_ptr2); |
| 2168 |
END |
| 2169 |
else |
| 2170 |
BEGIN |
| 2171 |
sign_length = 0; |
| 2172 |
END |
| 2173 |
token_value = 0; |
| 2174 |
while ((lex_class[SCAN_CHAR] == NUMERIC) && (buf_ptr2 < last)) |
| 2175 |
BEGIN |
| 2176 |
token_value = (token_value * 10) + CHAR_VALUE; |
| 2177 |
INCR (buf_ptr2); |
| 2178 |
END |
| 2179 |
if (NEGATIVE) |
| 2180 |
BEGIN |
| 2181 |
token_value = -token_value; |
| 2182 |
END |
| 2183 |
if (TOKEN_LEN == sign_length) |
| 2184 |
BEGIN |
| 2185 |
scan_integer = FALSE; |
| 2186 |
END |
| 2187 |
else |
| 2188 |
BEGIN |
| 2189 |
scan_integer = TRUE; |
| 2190 |
END |
| 2191 |
return(scan_integer); |
| 2192 |
END |
| 2193 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 93 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2194 |
|
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
/*************************************************************************** |
| 2199 |
* WEB section number: 92 |
| 2200 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2201 |
* This function scans for a nonnegative integer, stopping at the first |
| 2202 |
* nondigit; it sets the value of |token_value| accordingly. It returns |
| 2203 |
* |true| if the token was a legal nonnegative integer (i.e., consisted |
| 2204 |
* of one or more digits). |
| 2205 |
***************************************************************************/ |
| 2206 |
Boolean_T scan_nonneg_integer (void) |
| 2207 |
BEGIN |
| 2208 |
Boolean_T scan_nonneg_integer; |
| 2209 |
|
| 2210 |
buf_ptr1 = buf_ptr2; |
| 2211 |
token_value = 0; |
| 2212 |
while ((lex_class[SCAN_CHAR] == NUMERIC) && (buf_ptr2 < last)) |
| 2213 |
BEGIN |
| 2214 |
token_value = (token_value * 10) + CHAR_VALUE; |
| 2215 |
INCR (buf_ptr2); |
| 2216 |
END |
| 2217 |
if (TOKEN_LEN == 0) |
| 2218 |
BEGIN |
| 2219 |
scan_nonneg_integer = FALSE; |
| 2220 |
END |
| 2221 |
else |
| 2222 |
BEGIN |
| 2223 |
scan_nonneg_integer = TRUE; |
| 2224 |
END |
| 2225 |
return (scan_nonneg_integer); |
| 2226 |
END |
| 2227 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 92 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
/*************************************************************************** |
| 2233 |
* WEB section number: 94 |
| 2234 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2235 |
* This function scans over |white_space| characters, stopping either at |
| 2236 |
* the first nonwhite character or the end of the line, respectively |
| 2237 |
* returning |true| or |false|. |
| 2238 |
***************************************************************************/ |
| 2239 |
Boolean_T scan_white_space (void) |
| 2240 |
BEGIN |
| 2241 |
Boolean_T scan_white_space; |
| 2242 |
|
| 2243 |
while ((lex_class[SCAN_CHAR] == WHITE_SPACE) && (buf_ptr2 < last)) |
| 2244 |
BEGIN |
| 2245 |
INCR (buf_ptr2); |
| 2246 |
END |
| 2247 |
if (buf_ptr2 < last) |
| 2248 |
BEGIN |
| 2249 |
scan_white_space = TRUE; |
| 2250 |
END |
| 2251 |
else |
| 2252 |
BEGIN |
| 2253 |
scan_white_space = FALSE; |
| 2254 |
END |
| 2255 |
return (scan_white_space); |
| 2256 |
END |
| 2257 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 94 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2258 |
|
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
/*************************************************************************** |
| 2263 |
* WEB section number: 186 |
| 2264 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2265 |
* And another. |
| 2266 |
***************************************************************************/ |
| 2267 |
void skip_illegal_stuff_after_token (void) |
| 2268 |
BEGIN |
| 2269 |
PRINT2 ("\"%c\" can't follow a literal", xchr[SCAN_CHAR]); |
| 2270 |
skip_token_print (); |
| 2271 |
END |
| 2272 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 186 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
/*************************************************************************** |
| 2277 |
* WEB section number: 404 |
| 2278 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2279 |
* When we come here |sp_ptr| is just past the |left_brace|, and when we |
| 2280 |
* leave it's either at |sp_end| or just past the matching |right_brace|. |
| 2281 |
***************************************************************************/ |
| 2282 |
void skip_stuff_at_sp_brace_level_gr (void) |
| 2283 |
BEGIN |
| 2284 |
while ((sp_brace_level > 1) && (sp_ptr < sp_end)) |
| 2285 |
BEGIN |
| 2286 |
if (str_pool[sp_ptr] == RIGHT_BRACE) |
| 2287 |
BEGIN |
| 2288 |
DECR (sp_brace_level); |
| 2289 |
END |
| 2290 |
else if (str_pool[sp_ptr] == LEFT_BRACE) |
| 2291 |
BEGIN |
| 2292 |
INCR (sp_brace_level); |
| 2293 |
END |
| 2294 |
INCR (sp_ptr); |
| 2295 |
END |
| 2296 |
END |
| 2297 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 404 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2298 |
|
| 2299 |
|
| 2300 |
|
| 2301 |
|
| 2302 |
/*************************************************************************** |
| 2303 |
* WEB section number: 183 |
| 2304 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2305 |
* We're about to start scanning tokens in a function definition. When a |
| 2306 |
* function token is illegal, we skip until it ends; a |white_space| |
| 2307 |
* character, an end-of-line, a |right_brace|, or a |comment| marks the |
| 2308 |
* end of the current token. |
| 2309 |
***************************************************************************/ |
| 2310 |
void skip_token_print (void) |
| 2311 |
BEGIN |
| 2312 |
PRINT ("-"); |
| 2313 |
bst_ln_num_print (); |
| 2314 |
mark_error (); |
| 2315 |
if (scan2_white (RIGHT_BRACE, COMMENT)) |
| 2316 |
BEGIN |
| 2317 |
DO_NOTHING; |
| 2318 |
END |
| 2319 |
END |
| 2320 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 183 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2321 |
|
| 2322 |
|
| 2323 |
|
| 2324 |
|
| 2325 |
/*************************************************************************** |
| 2326 |
* WEB section number: 185 |
| 2327 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2328 |
* Here's another macro for saving some space when there's a problem with |
| 2329 |
* a token. |
| 2330 |
***************************************************************************/ |
| 2331 |
void skp_token_unknown_function_prin (void) |
| 2332 |
BEGIN |
| 2333 |
PRINT_TOKEN; |
| 2334 |
PRINT (" is an unknown function"); |
| 2335 |
skip_token_print (); |
| 2336 |
END |
| 2337 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 185 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2338 |
|
| 2339 |
|
| 2340 |
|
| 2341 |
|
| 2342 |
/*************************************************************************** |
| 2343 |
* WEB section number: 58 |
| 2344 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2345 |
* This procedure copies file name |file_name| into the beginning of |
| 2346 |
* |name_of_file|, if it will fit. It also sets the global variable |
| 2347 |
* |name_length| to the appropriate value. |
| 2348 |
* |
| 2349 |
* NOTE: because C arrays start at index 0, not 1, the subscripts of array |
| 2350 |
* |name_of_file| are generally 1 less than those in the WEB source. |
| 2351 |
***************************************************************************/ |
| 2352 |
void start_name (StrNumber_T file_name) |
| 2353 |
BEGIN |
| 2354 |
PoolPointer_T p_ptr; |
| 2355 |
|
| 2356 |
free (name_of_file); |
| 2357 |
name_of_file = (unsigned char *) mymalloc (LENGTH (file_name) + 5, "name_of_file"); |
| 2358 |
name_ptr = 0; |
| 2359 |
p_ptr = str_start[file_name]; |
| 2360 |
while (p_ptr < str_start[file_name + 1]) |
| 2361 |
BEGIN |
| 2362 |
name_of_file[name_ptr] = CHR (str_pool[p_ptr]); |
| 2363 |
INCR (name_ptr); |
| 2364 |
INCR (p_ptr); |
| 2365 |
END |
| 2366 |
name_length = LENGTH (file_name); |
| 2367 |
name_of_file[name_length] = 0; |
| 2368 |
END |
| 2369 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 58 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2370 |
|
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
/*************************************************************************** |
| 2375 |
* WEB section number: 56 |
| 2376 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2377 |
* This subroutine compares string |s| with another string that appears |
| 2378 |
* in the buffer |buf| between positions |bf_ptr| and |bf_ptr+len-1|; the |
| 2379 |
* result is |true| if and only if the strings are equal. |
| 2380 |
***************************************************************************/ |
| 2381 |
Boolean_T str_eq_buf (StrNumber_T s, BufType_T buf, |
| 2382 |
BufPointer_T bf_ptr, BufPointer_T len) |
| 2383 |
BEGIN |
| 2384 |
BufPointer_T i; |
| 2385 |
PoolPointer_T j; |
| 2386 |
Boolean_T str_eq_buf; |
| 2387 |
|
| 2388 |
if (LENGTH (s) != len) |
| 2389 |
BEGIN |
| 2390 |
str_eq_buf = FALSE; |
| 2391 |
goto Exit_Label; |
| 2392 |
END |
| 2393 |
i = bf_ptr; |
| 2394 |
j = str_start[s]; |
| 2395 |
while (j < str_start[s + 1]) |
| 2396 |
BEGIN |
| 2397 |
if (str_pool[j] != buf[i]) |
| 2398 |
BEGIN |
| 2399 |
str_eq_buf = FALSE; |
| 2400 |
goto Exit_Label; |
| 2401 |
END |
| 2402 |
INCR (i); |
| 2403 |
INCR (j); |
| 2404 |
END |
| 2405 |
str_eq_buf = TRUE; |
| 2406 |
Exit_Label: |
| 2407 |
return (str_eq_buf); |
| 2408 |
END |
| 2409 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 56 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2410 |
|
| 2411 |
|
| 2412 |
|
| 2413 |
|
| 2414 |
/*************************************************************************** |
| 2415 |
* WEB section number: 57 |
| 2416 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2417 |
* This subroutine compares two |str_pool| strings and returns true |
| 2418 |
* |true| if and only if the strings are equal. |
| 2419 |
***************************************************************************/ |
| 2420 |
Boolean_T str_eq_str (StrNumber_T s1, StrNumber_T s2) |
| 2421 |
BEGIN |
| 2422 |
Boolean_T str_eq_str; |
| 2423 |
|
| 2424 |
if (LENGTH (s1) != LENGTH (s2)) |
| 2425 |
BEGIN |
| 2426 |
str_eq_str = FALSE; |
| 2427 |
goto Exit_Label; |
| 2428 |
END |
| 2429 |
p_ptr1 = str_start[s1]; |
| 2430 |
p_ptr2 = str_start[s2]; |
| 2431 |
while (p_ptr1 < str_start[s1 + 1]) |
| 2432 |
BEGIN |
| 2433 |
if (str_pool[p_ptr1] != str_pool[p_ptr2]) |
| 2434 |
BEGIN |
| 2435 |
str_eq_str = FALSE; |
| 2436 |
goto Exit_Label; |
| 2437 |
END |
| 2438 |
INCR (p_ptr1); |
| 2439 |
INCR (p_ptr2); |
| 2440 |
END |
| 2441 |
str_eq_str = TRUE; |
| 2442 |
Exit_Label: |
| 2443 |
return (str_eq_str); |
| 2444 |
END |
| 2445 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 57 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
|
| 2450 |
/*************************************************************************** |
| 2451 |
* WEB section number: 68 |
| 2452 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2453 |
* Here is the subroutine that searches the hash table for a |
| 2454 |
* (string,~|str_ilk|) pair, where the string is of length |l>=0| and |
| 2455 |
* appears in |buffer[j..(j+l-1)]|. If it finds the pair, it returns the |
| 2456 |
* corresponding hash-table location and sets the global variable |
| 2457 |
* |hash_found| to |true|. Otherwise it sets |hash_found| to |false|, |
| 2458 |
* and if the parameter |insert_it| is |true|, it inserts the pair into |
| 2459 |
* the hash table, inserts the string into |str_pool| if not previously |
| 2460 |
* encountered, and returns its location. Note that two different pairs |
| 2461 |
* can have the same string but different |str_ilk|s, in which case the |
| 2462 |
* second pair encountered, if |insert_it| were |true|, would be inserted |
| 2463 |
* into the hash table though its string wouldn't be inserted into |
| 2464 |
* |str_pool| because it would already be there. |
| 2465 |
***************************************************************************/ |
| 2466 |
HashLoc_T str_lookup (BufType_T buf, BufPointer_T j, BufPointer_T l, |
| 2467 |
StrIlk_T ilk, Boolean_T insert_it) |
| 2468 |
BEGIN |
| 2469 |
HashLoc_T str_lookup; |
| 2470 |
long h; |
| 2471 |
HashLoc_T p; |
| 2472 |
BufPointer_T k; |
| 2473 |
Boolean_T old_string; |
| 2474 |
StrNumber_T str_num; |
| 2475 |
|
| 2476 |
/*************************************************************************** |
| 2477 |
* WEB section number: 69 |
| 2478 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2479 |
* The value of |Hash_Prime| should be roughly 85\% of |Hash_Size|, and |
| 2480 |
* it should be a prime number |
| 2481 |
* (it should also be less than $2^14 + 2^6 = 16320$ because of |
| 2482 |
* WEB's simple-macro bound). The theory of hashing tells us to expect |
| 2483 |
* fewer than two table probes, on the average, when the search is |
| 2484 |
* successful. |
| 2485 |
* |
| 2486 |
* NOTE: the limit imposed on the value of Hash_Prime no longer applies |
| 2487 |
* because we are using C #defines. |
| 2488 |
***************************************************************************/ |
| 2489 |
BEGIN |
| 2490 |
h = 0; |
| 2491 |
k = j; |
| 2492 |
while (k < (j + l)) |
| 2493 |
BEGIN |
| 2494 |
h = h + h + buf[k]; |
| 2495 |
while (h >= Hash_Prime) |
| 2496 |
h = h - Hash_Prime; |
| 2497 |
INCR (k); |
| 2498 |
END |
| 2499 |
END |
| 2500 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 69 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2501 |
|
| 2502 |
p = h + HASH_BASE; |
| 2503 |
hash_found = FALSE; |
| 2504 |
old_string = FALSE; |
| 2505 |
str_num = 0; /* avoid uninitialized warning */ |
| 2506 |
LOOP |
| 2507 |
BEGIN |
| 2508 |
|
| 2509 |
/*************************************************************************** |
| 2510 |
* WEB section number: 70 |
| 2511 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2512 |
* Here we handle the case in which we've already encountered this |
| 2513 |
* string; note that even if we have, we'll still have to insert the pair |
| 2514 |
* into the hash table if |str_ilk| doesn't match. |
| 2515 |
***************************************************************************/ |
| 2516 |
BEGIN |
| 2517 |
if (hash_text[p] > 0) |
| 2518 |
BEGIN |
| 2519 |
if (str_eq_buf (hash_text[p], buf, j, l)) |
| 2520 |
BEGIN |
| 2521 |
if (hash_ilk[p] == ilk) |
| 2522 |
BEGIN |
| 2523 |
hash_found = TRUE; |
| 2524 |
goto Str_Found_Label; |
| 2525 |
END |
| 2526 |
else |
| 2527 |
BEGIN |
| 2528 |
old_string = TRUE; |
| 2529 |
str_num = hash_text[p]; |
| 2530 |
END |
| 2531 |
END |
| 2532 |
END |
| 2533 |
END |
| 2534 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 70 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2535 |
|
| 2536 |
if (hash_next[p] == EMPTY) |
| 2537 |
BEGIN |
| 2538 |
if ( ! insert_it) |
| 2539 |
BEGIN |
| 2540 |
goto Str_Not_Found_Label; |
| 2541 |
END |
| 2542 |
|
| 2543 |
/*************************************************************************** |
| 2544 |
* WEB section number: 71 |
| 2545 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2546 |
* This code inserts the pair in the appropriate unused location. |
| 2547 |
***************************************************************************/ |
| 2548 |
BEGIN |
| 2549 |
if (hash_text[p] > 0) |
| 2550 |
BEGIN |
| 2551 |
REPEAT |
| 2552 |
BEGIN |
| 2553 |
if (HASH_IS_FULL) |
| 2554 |
BEGIN |
| 2555 |
BIBTEX_OVERFLOW ("hash size ", Hash_Size); |
| 2556 |
END |
| 2557 |
DECR (hash_used); |
| 2558 |
END UNTIL (hash_text[hash_used] == 0); |
| 2559 |
hash_next[p] = hash_used; |
| 2560 |
p = hash_used; |
| 2561 |
END |
| 2562 |
if (old_string) |
| 2563 |
BEGIN |
| 2564 |
hash_text[p] = str_num; |
| 2565 |
END |
| 2566 |
else |
| 2567 |
BEGIN |
| 2568 |
STR_ROOM (l); |
| 2569 |
k = j; |
| 2570 |
while (k < (j + l)) |
| 2571 |
BEGIN |
| 2572 |
APPEND_CHAR (buf[k]); |
| 2573 |
INCR (k); |
| 2574 |
END |
| 2575 |
hash_text[p] = make_string (); |
| 2576 |
END |
| 2577 |
hash_ilk[p] = ilk; |
| 2578 |
END |
| 2579 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 71 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2580 |
|
| 2581 |
goto Str_Found_Label; |
| 2582 |
END |
| 2583 |
p = hash_next[p]; |
| 2584 |
END |
| 2585 |
Str_Not_Found_Label: DO_NOTHING; |
| 2586 |
Str_Found_Label: str_lookup = p; |
| 2587 |
return (str_lookup); |
| 2588 |
END |
| 2589 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 68 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
/*************************************************************************** |
| 2594 |
* WEB section number: 300 |
| 2595 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2596 |
* The |swap| procedure exchanges the two elements its arguments point |
| 2597 |
* to. |
| 2598 |
***************************************************************************/ |
| 2599 |
void swap (CiteNumber_T swap1, CiteNumber_T swap2) |
| 2600 |
BEGIN |
| 2601 |
CiteNumber_T innocent_bystander; |
| 2602 |
|
| 2603 |
innocent_bystander = SORTED_CITES[swap2]; |
| 2604 |
SORTED_CITES[swap2] = SORTED_CITES[swap1]; |
| 2605 |
SORTED_CITES[swap1] = innocent_bystander; |
| 2606 |
END |
| 2607 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 300 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
/*************************************************************************** |
| 2612 |
* WEB section number: 456 |
| 2613 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2614 |
* Here we print |trace| and/or |stat| information, if desired. |
| 2615 |
***************************************************************************/ |
| 2616 |
void trace_and_stat_printing (void) |
| 2617 |
BEGIN |
| 2618 |
|
| 2619 |
#ifdef TRACE |
| 2620 |
|
| 2621 |
if (Flag_trace) { |
| 2622 |
|
| 2623 |
/*************************************************************************** |
| 2624 |
* WEB section number: 457 |
| 2625 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2626 |
* This prints information obtained from the .aux file about the |
| 2627 |
* other files. |
| 2628 |
***************************************************************************/ |
| 2629 |
BEGIN |
| 2630 |
if (num_bib_files == 1) |
| 2631 |
BEGIN |
| 2632 |
TRACE_PR_LN ("The 1 database file is"); |
| 2633 |
END |
| 2634 |
else |
| 2635 |
BEGIN |
| 2636 |
TRACE_PR_LN2 ("The %ld database files are", (long) num_bib_files); |
| 2637 |
END |
| 2638 |
if (num_bib_files == 0) |
| 2639 |
BEGIN |
| 2640 |
TRACE_PR_LN (" undefined"); |
| 2641 |
END |
| 2642 |
else |
| 2643 |
BEGIN |
| 2644 |
bib_ptr = 0; |
| 2645 |
while (bib_ptr < num_bib_files) |
| 2646 |
BEGIN |
| 2647 |
TRACE_PR (" "); |
| 2648 |
TRACE_PR_POOL_STR (CUR_BIB_STR); |
| 2649 |
TRACE_PR_POOL_STR (s_bib_extension); |
| 2650 |
TRACE_PR_NEWLINE; |
| 2651 |
INCR (bib_ptr); |
| 2652 |
END |
| 2653 |
END |
| 2654 |
TRACE_PR ("The style file is "); |
| 2655 |
if (bst_str == 0) |
| 2656 |
BEGIN |
| 2657 |
TRACE_PR_LN ("undefined"); |
| 2658 |
END |
| 2659 |
else |
| 2660 |
BEGIN |
| 2661 |
TRACE_PR_POOL_STR (bst_str); |
| 2662 |
TRACE_PR_POOL_STR (s_bst_extension); |
| 2663 |
TRACE_PR_NEWLINE; |
| 2664 |
END |
| 2665 |
END |
| 2666 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 457 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2667 |
|
| 2668 |
/*************************************************************************** |
| 2669 |
* WEB section number: 458 |
| 2670 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2671 |
* In entry-sorted order, this prints an entry's |cite_list| string and, |
| 2672 |
* indirectly, its entry type and entry variables. |
| 2673 |
***************************************************************************/ |
| 2674 |
BEGIN |
| 2675 |
if (all_entries) |
| 2676 |
BEGIN |
| 2677 |
TRACE_PR2 ("all_marker=%ld, ", (long) all_marker); |
| 2678 |
END |
| 2679 |
if (read_performed) |
| 2680 |
BEGIN |
| 2681 |
TRACE_PR_LN2 ("old_num_cites=%ld", (long) old_num_cites); |
| 2682 |
END |
| 2683 |
else |
| 2684 |
BEGIN |
| 2685 |
TRACE_PR_NEWLINE; |
| 2686 |
END |
| 2687 |
TRACE_PR2 ("The %ld", (long) num_cites); |
| 2688 |
if (num_cites == 1) |
| 2689 |
BEGIN |
| 2690 |
TRACE_PR_LN (" entry:"); |
| 2691 |
END |
| 2692 |
else |
| 2693 |
BEGIN |
| 2694 |
TRACE_PR_LN (" entries:"); |
| 2695 |
END |
| 2696 |
if (num_cites == 0) |
| 2697 |
BEGIN |
| 2698 |
TRACE_PR_LN (" undefined"); |
| 2699 |
END |
| 2700 |
else |
| 2701 |
BEGIN |
| 2702 |
sort_cite_ptr = 0; |
| 2703 |
while (sort_cite_ptr < num_cites) |
| 2704 |
BEGIN |
| 2705 |
if ( ! read_completed) |
| 2706 |
BEGIN |
| 2707 |
cite_ptr = sort_cite_ptr; |
| 2708 |
END |
| 2709 |
else |
| 2710 |
BEGIN |
| 2711 |
cite_ptr = SORTED_CITES[sort_cite_ptr]; |
| 2712 |
END |
| 2713 |
TRACE_PR_POOL_STR (CUR_CITE_STR); |
| 2714 |
if (read_performed) |
| 2715 |
|
| 2716 |
/*************************************************************************** |
| 2717 |
* WEB section number: 458 |
| 2718 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2719 |
* This prints information gathered while reading the .bst and |
| 2720 |
* .bib files. |
| 2721 |
***************************************************************************/ |
| 2722 |
BEGIN |
| 2723 |
TRACE_PR (", entry-type "); |
| 2724 |
if (type_list[cite_ptr] == UNDEFINED) |
| 2725 |
BEGIN |
| 2726 |
TRACE_PR ("unknown"); |
| 2727 |
END |
| 2728 |
else if (type_list[cite_ptr] == EMPTY) |
| 2729 |
BEGIN |
| 2730 |
TRACE_PR ("--- no type found"); |
| 2731 |
END |
| 2732 |
else |
| 2733 |
BEGIN |
| 2734 |
TRACE_PR_POOL_STR (hash_text[type_list[cite_ptr]]); |
| 2735 |
END |
| 2736 |
TRACE_PR_LN (", has entry strings"); |
| 2737 |
|
| 2738 |
/*************************************************************************** |
| 2739 |
* WEB section number: 460 |
| 2740 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2741 |
* This prints, for the current entry, the strings declared by the |
| 2742 |
* entry command. |
| 2743 |
***************************************************************************/ |
| 2744 |
BEGIN |
| 2745 |
if (num_ent_strs == 0) |
| 2746 |
BEGIN |
| 2747 |
TRACE_PR_LN (" undefined"); |
| 2748 |
END |
| 2749 |
else if ( ! read_completed) |
| 2750 |
BEGIN |
| 2751 |
TRACE_PR_LN (" uninitialized"); |
| 2752 |
END |
| 2753 |
else |
| 2754 |
BEGIN |
| 2755 |
str_ent_ptr = cite_ptr * num_ent_strs; |
| 2756 |
while (str_ent_ptr < ((cite_ptr + 1) * num_ent_strs)) |
| 2757 |
BEGIN |
| 2758 |
ent_chr_ptr = 0; |
| 2759 |
TRACE_PR (" \""); |
| 2760 |
|
| 2761 |
while (ENTRY_STRS(str_ent_ptr, ent_chr_ptr) != END_OF_STRING) |
| 2762 |
BEGIN |
| 2763 |
TRACE_PR2 ("%c", |
| 2764 |
xchr[ENTRY_STRS(str_ent_ptr, ent_chr_ptr)]); |
| 2765 |
INCR (ent_chr_ptr); |
| 2766 |
END |
| 2767 |
TRACE_PR_LN ("\""); |
| 2768 |
INCR (str_ent_ptr); |
| 2769 |
END |
| 2770 |
END |
| 2771 |
END |
| 2772 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 460 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2773 |
|
| 2774 |
TRACE_PR (" has entry integers"); |
| 2775 |
|
| 2776 |
/*************************************************************************** |
| 2777 |
* WEB section number: 461 |
| 2778 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2779 |
* This prints, for the current entry, the integers declared by the |
| 2780 |
* entry command. |
| 2781 |
***************************************************************************/ |
| 2782 |
BEGIN |
| 2783 |
if (num_ent_ints == 0) |
| 2784 |
BEGIN |
| 2785 |
TRACE_PR (" undefined"); |
| 2786 |
END |
| 2787 |
else if ( ! read_completed) |
| 2788 |
BEGIN |
| 2789 |
TRACE_PR (" uninitialized"); |
| 2790 |
END |
| 2791 |
else |
| 2792 |
BEGIN |
| 2793 |
int_ent_ptr = cite_ptr * num_ent_ints; |
| 2794 |
while (int_ent_ptr < ((cite_ptr + 1) * num_ent_ints)) |
| 2795 |
BEGIN |
| 2796 |
TRACE_PR2 (" %ld", (long) entry_ints[int_ent_ptr]); |
| 2797 |
INCR (int_ent_ptr); |
| 2798 |
END |
| 2799 |
END |
| 2800 |
TRACE_PR_NEWLINE; |
| 2801 |
END |
| 2802 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 461 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2803 |
|
| 2804 |
TRACE_PR_LN (" and has fields"); |
| 2805 |
|
| 2806 |
/*************************************************************************** |
| 2807 |
* WEB section number: 462 |
| 2808 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2809 |
* This prints the fields stored for the current entry. |
| 2810 |
***************************************************************************/ |
| 2811 |
BEGIN |
| 2812 |
if ( ! read_performed) |
| 2813 |
BEGIN |
| 2814 |
TRACE_PR_LN (" uninitialized"); |
| 2815 |
END |
| 2816 |
else |
| 2817 |
BEGIN |
| 2818 |
field_ptr = cite_ptr * num_fields; |
| 2819 |
field_end_ptr = field_ptr + num_fields; |
| 2820 |
no_fields = TRUE; |
| 2821 |
while (field_ptr < field_end_ptr) |
| 2822 |
BEGIN |
| 2823 |
if (field_info[field_ptr] != MISSING) |
| 2824 |
BEGIN |
| 2825 |
TRACE_PR (" \""); |
| 2826 |
TRACE_PR_POOL_STR (field_info[field_ptr]); |
| 2827 |
TRACE_PR_LN ("\""); |
| 2828 |
no_fields = FALSE; |
| 2829 |
END |
| 2830 |
INCR (field_ptr); |
| 2831 |
END |
| 2832 |
if (no_fields) |
| 2833 |
BEGIN |
| 2834 |
TRACE_PR_LN (" missing"); |
| 2835 |
END |
| 2836 |
END |
| 2837 |
END |
| 2838 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 462 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2839 |
|
| 2840 |
END |
| 2841 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 459 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2842 |
|
| 2843 |
else |
| 2844 |
BEGIN |
| 2845 |
TRACE_PR_NEWLINE; |
| 2846 |
END |
| 2847 |
INCR (sort_cite_ptr); |
| 2848 |
END |
| 2849 |
END |
| 2850 |
END |
| 2851 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 458 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2852 |
|
| 2853 |
/*************************************************************************** |
| 2854 |
* WEB section number: 463 |
| 2855 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2856 |
* This gives all the |wiz_defined| functions that appeared in the |
| 2857 |
* .bst file. |
| 2858 |
***************************************************************************/ |
| 2859 |
BEGIN |
| 2860 |
TRACE_PR_LN ("The wiz-defined functions are"); |
| 2861 |
if (wiz_def_ptr == 0) |
| 2862 |
BEGIN |
| 2863 |
TRACE_PR_LN (" nonexistent"); |
| 2864 |
END |
| 2865 |
else |
| 2866 |
BEGIN |
| 2867 |
wiz_fn_ptr = 0; |
| 2868 |
|
| 2869 |
while (wiz_fn_ptr < wiz_def_ptr) |
| 2870 |
BEGIN |
| 2871 |
if (wiz_functions[wiz_fn_ptr] == END_OF_DEF) |
| 2872 |
BEGIN |
| 2873 |
TRACE_PR_LN2 ("%ld--end-of-def--", (long) wiz_fn_ptr); |
| 2874 |
END |
| 2875 |
else if (wiz_functions[wiz_fn_ptr] == QUOTE_NEXT_FN) |
| 2876 |
BEGIN |
| 2877 |
TRACE_PR2 ("%ld quote_next_function ", (long) wiz_fn_ptr); |
| 2878 |
END |
| 2879 |
else |
| 2880 |
BEGIN |
| 2881 |
TRACE_PR2 ("%ld `", (long) wiz_fn_ptr); |
| 2882 |
TRACE_PR_POOL_STR (hash_text[wiz_functions[wiz_fn_ptr]]); |
| 2883 |
TRACE_PR_LN ("'"); |
| 2884 |
END |
| 2885 |
INCR (wiz_fn_ptr); |
| 2886 |
END |
| 2887 |
END |
| 2888 |
END |
| 2889 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 463 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2890 |
|
| 2891 |
/*************************************************************************** |
| 2892 |
* WEB section number: 464 |
| 2893 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2894 |
* This includes all the `static' strings (that is, those that are also |
| 2895 |
* in the hash table), but none of the dynamic strings (that is, those |
| 2896 |
* put on the stack while executing .bst commands). |
| 2897 |
***************************************************************************/ |
| 2898 |
BEGIN |
| 2899 |
TRACE_PR_LN ("The string pool is"); |
| 2900 |
str_num = 1; |
| 2901 |
|
| 2902 |
while (str_num < str_ptr) |
| 2903 |
BEGIN |
| 2904 |
TRACE_PR3 ("%4ld%6ld \"", (long) str_num, (long) str_start[str_num]); |
| 2905 |
TRACE_PR_POOL_STR (str_num); |
| 2906 |
TRACE_PR_LN ("\""); |
| 2907 |
INCR (str_num); |
| 2908 |
END |
| 2909 |
END |
| 2910 |
} /* end if (Flag_trace) */ |
| 2911 |
|
| 2912 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 464 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2913 |
|
| 2914 |
#endif /* TRACE */ |
| 2915 |
|
| 2916 |
|
| 2917 |
#ifdef STAT |
| 2918 |
|
| 2919 |
/*************************************************************************** |
| 2920 |
* WEB section number: 465 |
| 2921 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2922 |
* These statistics can help determine how large some of the constants |
| 2923 |
* should be and can tell how useful certain |built_in| functions are. |
| 2924 |
* They are written to the same files as tracing information. |
| 2925 |
***************************************************************************/ |
| 2926 |
if (Flag_stats) { |
| 2927 |
BEGIN |
| 2928 |
STAT_PR2 ("You've used %ld", (long) num_cites); |
| 2929 |
if (num_cites == 1) |
| 2930 |
BEGIN |
| 2931 |
STAT_PR_LN (" entry,"); |
| 2932 |
END |
| 2933 |
else |
| 2934 |
BEGIN |
| 2935 |
STAT_PR_LN (" entries,"); |
| 2936 |
END |
| 2937 |
STAT_PR_LN2 (" %ld wiz_defined-function locations,", |
| 2938 |
(long) wiz_def_ptr); |
| 2939 |
STAT_PR_LN3 (" %ld strings with %ld characters,", |
| 2940 |
(long) str_ptr, (long) str_start[str_ptr]); |
| 2941 |
blt_in_ptr = 0; |
| 2942 |
total_ex_count = 0; |
| 2943 |
while (blt_in_ptr < NUM_BLT_IN_FNS) |
| 2944 |
BEGIN |
| 2945 |
total_ex_count = total_ex_count + execution_count[blt_in_ptr]; |
| 2946 |
INCR (blt_in_ptr); |
| 2947 |
END |
| 2948 |
STAT_PR_LN2 ("and the built_in function-call counts, %ld in all, are:", |
| 2949 |
(long) total_ex_count); |
| 2950 |
blt_in_ptr = 0; |
| 2951 |
while (blt_in_ptr < NUM_BLT_IN_FNS) |
| 2952 |
BEGIN |
| 2953 |
STAT_PR_POOL_STR (hash_text[blt_in_loc[blt_in_ptr]]); |
| 2954 |
STAT_PR_LN2 (" -- %ld", (long) execution_count[blt_in_ptr]); |
| 2955 |
INCR (blt_in_ptr); |
| 2956 |
END |
| 2957 |
END |
| 2958 |
} /* end if (Flag_stats) */ |
| 2959 |
|
| 2960 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 465 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2961 |
|
| 2962 |
#endif /* STAT */ |
| 2963 |
END |
| 2964 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 456 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2965 |
|
| 2966 |
|
| 2967 |
|
| 2968 |
|
| 2969 |
/*************************************************************************** |
| 2970 |
* WEB section number: 159 |
| 2971 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2972 |
* This version is for printing when in |trace| mode. |
| 2973 |
***************************************************************************/ |
| 2974 |
#ifdef TRACE |
| 2975 |
void trace_pr_fn_class (HashLoc_T fn_loc) |
| 2976 |
BEGIN |
| 2977 |
|
| 2978 |
if (!Flag_trace) |
| 2979 |
return; |
| 2980 |
|
| 2981 |
switch (fn_type[fn_loc]) |
| 2982 |
BEGIN |
| 2983 |
case BUILT_IN: |
| 2984 |
TRACE_PR ("built-in"); |
| 2985 |
break; |
| 2986 |
case WIZ_DEFINED: |
| 2987 |
TRACE_PR ("wizard-defined"); |
| 2988 |
break; |
| 2989 |
case INT_LITERAL: |
| 2990 |
TRACE_PR ("integer-literal"); |
| 2991 |
break; |
| 2992 |
case STR_LITERAL: |
| 2993 |
TRACE_PR ("string-literal"); |
| 2994 |
break; |
| 2995 |
case FIELD: |
| 2996 |
TRACE_PR ("field"); |
| 2997 |
break; |
| 2998 |
case INT_ENTRY_VAR: |
| 2999 |
TRACE_PR ("integer-entry-variable"); |
| 3000 |
break; |
| 3001 |
case STR_ENTRY_VAR: |
| 3002 |
TRACE_PR ("string-entry-variable"); |
| 3003 |
break; |
| 3004 |
case INT_GLOBAL_VAR: |
| 3005 |
TRACE_PR ("integer-global-variable"); |
| 3006 |
break; |
| 3007 |
case STR_GLOBAL_VAR: |
| 3008 |
TRACE_PR ("string-global-variable"); |
| 3009 |
break; |
| 3010 |
default: |
| 3011 |
unknwn_function_class_confusion (); |
| 3012 |
break; |
| 3013 |
END |
| 3014 |
END |
| 3015 |
#endif /* TRACE */ |
| 3016 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 159 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3017 |
|
| 3018 |
|
| 3019 |
|
| 3020 |
|
| 3021 |
|
| 3022 |
/*************************************************************************** |
| 3023 |
* WEB section number: 157 |
| 3024 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3025 |
* Here's another bug report. |
| 3026 |
***************************************************************************/ |
| 3027 |
void unknwn_function_class_confusion (void) |
| 3028 |
BEGIN |
| 3029 |
CONFUSION ("Unknown function class"); |
| 3030 |
END |
| 3031 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 157 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3032 |
|
| 3033 |
|
| 3034 |
|
| 3035 |
|
| 3036 |
/*************************************************************************** |
| 3037 |
* WEB section number: 310 |
| 3038 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3039 |
* More bug complaints, this time about bad literals. |
| 3040 |
***************************************************************************/ |
| 3041 |
void unknwn_literal_confusion (void) |
| 3042 |
BEGIN |
| 3043 |
CONFUSION ("Unknown literal type"); |
| 3044 |
END |
| 3045 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3046 |
|
| 3047 |
|
| 3048 |
|
| 3049 |
|
| 3050 |
/*************************************************************************** |
| 3051 |
* WEB section number: 63 |
| 3052 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3053 |
* This system-independent procedure is the same as the previous except |
| 3054 |
* that it converts lower- to upper-case letters. |
| 3055 |
***************************************************************************/ |
| 3056 |
#ifndef UTF_8 |
| 3057 |
void upper_case (BufType_T buf, BufPointer_T bf_ptr, |
| 3058 |
BufPointer_T len) |
| 3059 |
BEGIN |
| 3060 |
BufPointer_T i; |
| 3061 |
|
| 3062 |
if (len > 0) |
| 3063 |
BEGIN |
| 3064 |
for (i = bf_ptr; i <= (bf_ptr+len-1); i++) |
| 3065 |
BEGIN |
| 3066 |
|
| 3067 |
#ifdef SUPPORT_8BIT |
| 3068 |
if (IsLower (buf[i])) |
| 3069 |
BEGIN |
| 3070 |
buf[i] = ToUpper(buf[i]); |
| 3071 |
END |
| 3072 |
#else /* NOT SUPPORT_8BIT */ |
| 3073 |
if ((buf[i] >= 'a') && (buf[i] <= 'z')) |
| 3074 |
BEGIN |
| 3075 |
buf[i] = buf[i] - CASE_DIFFERENCE; |
| 3076 |
END |
| 3077 |
#endif /* SUPPORT_8BIT */ |
| 3078 |
|
| 3079 |
END |
| 3080 |
END |
| 3081 |
END |
| 3082 |
#else |
| 3083 |
/* |
| 3084 |
This foction "upper_case_uni" is for prcessing the character UTF-8. |
| 3085 |
It's like lower_case_uni. 23/sep/2009 |
| 3086 |
*/ |
| 3087 |
|
| 3088 |
BufPointer_T upper_case_uni (BufType_T buf, BufPointer_T bf_ptr, |
| 3089 |
BufPointer_T len) |
| 3090 |
BEGIN |
| 3091 |
// printf("O~ lala~~"); |
| 3092 |
UChar target[BUF_SIZE+1]; |
| 3093 |
int32_t tarcap=BUF_SIZE+1; |
| 3094 |
int32_t tarlen = icu_toUChars(buf, bf_ptr, len, target, tarcap); |
| 3095 |
|
| 3096 |
UChar tarup[BUF_SIZE+1]; |
| 3097 |
int32_t tucap=BUF_SIZE+1; |
| 3098 |
int32_t tulen=icu_strToUpper(tarup, tucap,target, tarlen); |
| 3099 |
|
| 3100 |
unsigned char dest[BUF_SIZE+1]; |
| 3101 |
int32_t destcap= BUF_SIZE-bf_ptr; |
| 3102 |
|
| 3103 |
int32_t tblen=icu_fromUChars(dest, destcap, (const UChar *) tarup, tulen); |
| 3104 |
|
| 3105 |
BufPointer_T i; |
| 3106 |
if (tblen > 0) |
| 3107 |
BEGIN |
| 3108 |
if (len!=tblen) |
| 3109 |
BEGIN |
| 3110 |
unsigned char tmp[BUF_SIZE+1]; |
| 3111 |
BufPointer_T tmppr=0; |
| 3112 |
for (i=bf_ptr+len;i<=(BUF_SIZE-tblen+len);i++) |
| 3113 |
BEGIN |
| 3114 |
tmp[tmppr]=buf[i]; |
| 3115 |
tmppr++; |
| 3116 |
END |
| 3117 |
i=bf_ptr+tblen; |
| 3118 |
tmppr=0; |
| 3119 |
for (tmppr=0;tmppr<=(BUF_SIZE-bf_ptr-tblen);tmppr++) |
| 3120 |
BEGIN |
| 3121 |
buf[i]=tmp[tmppr]; |
| 3122 |
i++; |
| 3123 |
END |
| 3124 |
END |
| 3125 |
for (i = 0; i <= (tblen - 1); i++) |
| 3126 |
BEGIN |
| 3127 |
|
| 3128 |
buf[i+bf_ptr]=dest[i]; |
| 3129 |
END |
| 3130 |
END |
| 3131 |
return tblen; |
| 3132 |
END |
| 3133 |
|
| 3134 |
/* |
| 3135 |
This function is for transform Unicode string to up case. 23/sep/2009 |
| 3136 |
*/ |
| 3137 |
|
| 3138 |
int32_t icu_strToUpper(UChar * tarup, int32_t tucap, UChar * target, int32_t tarlen) |
| 3139 |
BEGIN |
| 3140 |
int32_t tulen; |
| 3141 |
UErrorCode err1 = U_ZERO_ERROR; |
| 3142 |
if (!U_SUCCESS(err1)) |
| 3143 |
BEGIN |
| 3144 |
printf("Error in icu_strToUpper?\n"); |
| 3145 |
END |
| 3146 |
if (Flag_language) |
| 3147 |
{ |
| 3148 |
tulen=u_strToUpper(tarup,tucap, target,tarlen,Str_language,&err1); |
| 3149 |
} |
| 3150 |
else |
| 3151 |
{ |
| 3152 |
tulen=u_strToUpper(tarup,tucap, target,tarlen,NULL,&err1); |
| 3153 |
} |
| 3154 |
if (!U_SUCCESS(err1)) |
| 3155 |
BEGIN |
| 3156 |
printf("Error in icu_strToUpper.\n"); |
| 3157 |
#ifdef TRACE |
| 3158 |
if (Flag_trace) |
| 3159 |
TRACE_PR_LN ("Error in icu_strToUpper"); |
| 3160 |
#endif /* TRACE */ |
| 3161 |
END |
| 3162 |
|
| 3163 |
return tulen; |
| 3164 |
END |
| 3165 |
#endif |
| 3166 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 63 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3167 |
|
| 3168 |
|
| 3169 |
|
| 3170 |
|
| 3171 |
/*************************************************************************** |
| 3172 |
* WEB section number: 401 |
| 3173 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3174 |
* The last name starts just past the last token, before the first |
| 3175 |
* |comma| (if there is no |comma|, there is deemed to be one at the end |
| 3176 |
* of the string), for which there exists a first brace-level-0 letter |
| 3177 |
* (or brace-level-1 special character), and it's in lower case, unless |
| 3178 |
* this last token is also the last token before the |comma|, in which |
| 3179 |
* case the last name starts with this token (unless this last token is |
| 3180 |
* connected by a |sep_char| other than a |tie| to the previous token, in |
| 3181 |
* which case the last name starts with as many tokens earlier as are |
| 3182 |
* connected by non|tie|s to this last one (except on Tuesdays |
| 3183 |
* $\ldots\,$), although this module never sees such a case). Note that |
| 3184 |
* if there are any tokens in either the von or last names, then the last |
| 3185 |
* name has at least one, even if it starts with a lower-case letter. |
| 3186 |
***************************************************************************/ |
| 3187 |
void von_name_ends_and_last_name_sta (void) |
| 3188 |
BEGIN |
| 3189 |
von_end = last_end - 1; |
| 3190 |
while (von_end > von_start) |
| 3191 |
BEGIN |
| 3192 |
name_bf_ptr = name_tok[von_end - 1]; |
| 3193 |
name_bf_xptr = name_tok[von_end]; |
| 3194 |
if (von_token_found ()) |
| 3195 |
BEGIN |
| 3196 |
goto Exit_Label; |
| 3197 |
END |
| 3198 |
DECR (von_end); |
| 3199 |
END |
| 3200 |
Exit_Label: DO_NOTHING; |
| 3201 |
END |
| 3202 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3203 |
|
| 3204 |
|
| 3205 |
|
| 3206 |
|
| 3207 |
/*************************************************************************** |
| 3208 |
* WEB section number: 397 |
| 3209 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3210 |
* It's a von token if there exists a first brace-level-0 letter (or |
| 3211 |
* brace-level-1 special character), and it's in lower case; in this case |
| 3212 |
* we return |true|. The token is in |name_buf|, starting at |
| 3213 |
* |name_bf_ptr| and ending just before |name_bf_xptr|. |
| 3214 |
***************************************************************************/ |
| 3215 |
Boolean_T von_token_found (void) |
| 3216 |
BEGIN |
| 3217 |
Boolean_T von_token_found; |
| 3218 |
|
| 3219 |
nm_brace_level = 0; |
| 3220 |
von_token_found = FALSE; |
| 3221 |
while (name_bf_ptr < name_bf_xptr) |
| 3222 |
BEGIN |
| 3223 |
|
| 3224 |
#ifdef SUPPORT_8BIT |
| 3225 |
if IsUpper(NAME_BUF[name_bf_ptr]) |
| 3226 |
BEGIN |
| 3227 |
goto Exit_Label; |
| 3228 |
END |
| 3229 |
else if IsLower(NAME_BUF[name_bf_ptr]) |
| 3230 |
BEGIN |
| 3231 |
RETURN_VON_FOUND; |
| 3232 |
END |
| 3233 |
#else /* NOT SUPPORT_8BIT */ |
| 3234 |
if ((NAME_BUF[name_bf_ptr] >= 'A') && (NAME_BUF[name_bf_ptr] <= 'Z')) |
| 3235 |
BEGIN |
| 3236 |
goto Exit_Label; |
| 3237 |
END |
| 3238 |
else if ((NAME_BUF[name_bf_ptr] >= 'a') && (NAME_BUF[name_bf_ptr] <= 'z')) |
| 3239 |
BEGIN |
| 3240 |
RETURN_VON_FOUND; |
| 3241 |
END |
| 3242 |
#endif /* SUPPORT_8BIT */ |
| 3243 |
|
| 3244 |
else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE) |
| 3245 |
BEGIN |
| 3246 |
INCR (nm_brace_level); |
| 3247 |
INCR (name_bf_ptr); |
| 3248 |
if (((name_bf_ptr + 2) < name_bf_xptr) |
| 3249 |
&& (NAME_BUF[name_bf_ptr] == BACKSLASH)) |
| 3250 |
|
| 3251 |
/*************************************************************************** |
| 3252 |
* WEB section number: 398 |
| 3253 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3254 |
* When we come here |name_bf_ptr| is just past the |left_brace|, |
| 3255 |
* but we always leave by |return|ing. |
| 3256 |
***************************************************************************/ |
| 3257 |
BEGIN |
| 3258 |
INCR (name_bf_ptr); |
| 3259 |
name_bf_yptr = name_bf_ptr; |
| 3260 |
while ((name_bf_ptr < name_bf_xptr) |
| 3261 |
&& (lex_class[NAME_BUF[name_bf_ptr]] == ALPHA)) |
| 3262 |
BEGIN |
| 3263 |
INCR (name_bf_ptr); |
| 3264 |
END |
| 3265 |
control_seq_loc = str_lookup (NAME_BUF, name_bf_yptr, |
| 3266 |
name_bf_ptr - name_bf_yptr, |
| 3267 |
CONTROL_SEQ_ILK, DONT_INSERT); |
| 3268 |
if (hash_found) |
| 3269 |
|
| 3270 |
/*************************************************************************** |
| 3271 |
* WEB section number: 399 |
| 3272 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3273 |
* The accented or foreign character is either `\i' or `\j' or |
| 3274 |
* one of the eleven alphabetic foreign characters in Table~3.2 of the |
| 3275 |
* \LaTeX\ manual. |
| 3276 |
***************************************************************************/ |
| 3277 |
BEGIN |
| 3278 |
switch (ilk_info[control_seq_loc]) |
| 3279 |
BEGIN |
| 3280 |
case N_OE_UPPER: |
| 3281 |
case N_AE_UPPER: |
| 3282 |
case N_AA_UPPER: |
| 3283 |
case N_O_UPPER: |
| 3284 |
case N_L_UPPER: |
| 3285 |
goto Exit_Label; |
| 3286 |
case N_I: |
| 3287 |
case N_J: |
| 3288 |
case N_OE: |
| 3289 |
case N_AE: |
| 3290 |
case N_AA: |
| 3291 |
case N_O: |
| 3292 |
case N_L: |
| 3293 |
case N_SS: |
| 3294 |
RETURN_VON_FOUND; |
| 3295 |
default: |
| 3296 |
CONFUSION ("Control-sequence hash error"); |
| 3297 |
END |
| 3298 |
END |
| 3299 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 399 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3300 |
|
| 3301 |
while ((name_bf_ptr < name_bf_xptr) && (nm_brace_level > 0)) |
| 3302 |
BEGIN |
| 3303 |
|
| 3304 |
#ifdef SUPPORT_8BIT |
| 3305 |
if IsUpper(NAME_BUF[name_bf_ptr]) |
| 3306 |
BEGIN |
| 3307 |
goto Exit_Label; |
| 3308 |
END |
| 3309 |
else if IsLower(NAME_BUF[name_bf_ptr]) |
| 3310 |
BEGIN |
| 3311 |
RETURN_VON_FOUND; |
| 3312 |
END |
| 3313 |
#else /* NOT SUPPORT_8BIT */ |
| 3314 |
if ((NAME_BUF[name_bf_ptr] >= 'A') && (NAME_BUF[name_bf_ptr] <= 'Z')) |
| 3315 |
BEGIN |
| 3316 |
goto Exit_Label; |
| 3317 |
END |
| 3318 |
else if ((NAME_BUF[name_bf_ptr] >= 'a') |
| 3319 |
&& (NAME_BUF[name_bf_ptr] <= 'z')) |
| 3320 |
BEGIN |
| 3321 |
RETURN_VON_FOUND; |
| 3322 |
END |
| 3323 |
#endif /* SUPPORT_8BIT */ |
| 3324 |
|
| 3325 |
else if (NAME_BUF[name_bf_ptr] == RIGHT_BRACE) |
| 3326 |
BEGIN |
| 3327 |
DECR (nm_brace_level); |
| 3328 |
END |
| 3329 |
else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE) |
| 3330 |
BEGIN |
| 3331 |
INCR (nm_brace_level); |
| 3332 |
END |
| 3333 |
INCR (name_bf_ptr); |
| 3334 |
END |
| 3335 |
goto Exit_Label; |
| 3336 |
END |
| 3337 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 398 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3338 |
|
| 3339 |
else |
| 3340 |
|
| 3341 |
/*************************************************************************** |
| 3342 |
* WEB section number: 400 |
| 3343 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3344 |
* When we come here |name_bf_ptr| is just past the |left_brace|; when we |
| 3345 |
* leave it's either at |name_bf_xptr| or just past the matching |
| 3346 |
* |right_brace|. |
| 3347 |
***************************************************************************/ |
| 3348 |
BEGIN |
| 3349 |
while ((nm_brace_level > 0) && (name_bf_ptr < name_bf_xptr)) |
| 3350 |
BEGIN |
| 3351 |
if (NAME_BUF[name_bf_ptr] == RIGHT_BRACE) |
| 3352 |
BEGIN |
| 3353 |
DECR (nm_brace_level); |
| 3354 |
END |
| 3355 |
else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE) |
| 3356 |
BEGIN |
| 3357 |
INCR (nm_brace_level); |
| 3358 |
END |
| 3359 |
INCR (name_bf_ptr); |
| 3360 |
END |
| 3361 |
END |
| 3362 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 400 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3363 |
|
| 3364 |
END |
| 3365 |
else |
| 3366 |
BEGIN |
| 3367 |
INCR (name_bf_ptr); |
| 3368 |
END |
| 3369 |
END |
| 3370 |
Exit_Label: DO_NOTHING; |
| 3371 |
return (von_token_found); |
| 3372 |
END |
| 3373 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 397 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3374 |
|
| 3375 |
|
| 3376 |
|
| 3377 |
|
| 3378 |
/*************************************************************************** |
| 3379 |
* WEB section number: 360 |
| 3380 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3381 |
* The |built_in| function add.period$ pops the top (string) |
| 3382 |
* literal, adds a |period| to a nonnull string if its last |
| 3383 |
* non|right_brace| character isn't a |period|, |question_mark|, or |
| 3384 |
* |exclamation_mark|, and pushes this resulting string back onto the |
| 3385 |
* stack. If the literal isn't a string, it complains and pushes the |
| 3386 |
* null string. |
| 3387 |
***************************************************************************/ |
| 3388 |
void x_add_period (void) |
| 3389 |
BEGIN |
| 3390 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 3391 |
if (pop_typ1 != STK_STR) |
| 3392 |
BEGIN |
| 3393 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 3394 |
push_lit_stk (s_null, STK_STR); |
| 3395 |
END |
| 3396 |
else if (LENGTH (pop_lit1) == 0) |
| 3397 |
BEGIN |
| 3398 |
push_lit_stk (s_null, STK_STR); |
| 3399 |
END |
| 3400 |
else |
| 3401 |
|
| 3402 |
/*************************************************************************** |
| 3403 |
* WEB section number: 361 |
| 3404 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3405 |
* Here we scan backwards from the end of the string, skipping |
| 3406 |
* non|right_brace| characters, to see if we have to add the |period|. |
| 3407 |
***************************************************************************/ |
| 3408 |
BEGIN |
| 3409 |
#ifdef UTF_8 |
| 3410 |
UChar ch; |
| 3411 |
#endif |
| 3412 |
sp_ptr = str_start[pop_lit1 + 1]; |
| 3413 |
sp_end = str_start[pop_lit1]; |
| 3414 |
while (sp_ptr > sp_end) |
| 3415 |
BEGIN |
| 3416 |
DECR (sp_ptr); |
| 3417 |
if (str_pool[sp_ptr] != RIGHT_BRACE) |
| 3418 |
BEGIN |
| 3419 |
goto Loop_Exit_Label; |
| 3420 |
END |
| 3421 |
END |
| 3422 |
Loop_Exit_Label: |
| 3423 |
#ifdef UTF_8 |
| 3424 |
ch = str_pool[sp_ptr]; |
| 3425 |
if (utf8len(str_pool[sp_ptr]) != 1 && utf8len(str_pool[sp_ptr-1]) != 2 && utf8len(str_pool[sp_ptr-2]) == 3) |
| 3426 |
ch = ((str_pool[sp_ptr-2]&0x0f) <<12) | ((str_pool[sp_ptr-1]&0x3f) << 6) | (str_pool[sp_ptr]&0x3f); |
| 3427 |
switch (ch) |
| 3428 |
#else |
| 3429 |
switch (str_pool[sp_ptr]) |
| 3430 |
#endif |
| 3431 |
BEGIN |
| 3432 |
case PERIOD: |
| 3433 |
case QUESTION_MARK: |
| 3434 |
case EXCLAMATION_MARK: |
| 3435 |
#ifdef UTF_8 |
| 3436 |
case 0x203C: case 0x203D: case 0x2047: /* ‼ ‽ ⁇ */ |
| 3437 |
case 0x2048: case 0x2049: case 0x3002: /* ⁈ ⁉ 。 */ |
| 3438 |
case 0xFF01: case 0xFF0E: case 0xFF1F: /* ! . ? */ |
| 3439 |
#endif |
| 3440 |
REPUSH_STRING; |
| 3441 |
break; |
| 3442 |
default: |
| 3443 |
|
| 3444 |
/*************************************************************************** |
| 3445 |
* WEB section number: 362 |
| 3446 |
* ~~~~~~~~~~~~~~~~~~~ |
| 3447 |
* Ok guys, we really have to do it. |
| 3448 |
***************************************************************************/ |
| 3449 |
BEGIN |
| 3450 |
if (pop_lit1 < cmd_str_ptr) |
| 3451 |
BEGIN |
| 3452 |
STR_ROOM (LENGTH (pop_lit1) + 1); |
| 3453 |
sp_ptr = str_start[pop_lit1]; |
| 3454 |
sp_end = str_start[pop_lit1 + 1]; |
| 3455 |
while (sp_ptr < sp_end) |
| 3456 |
BEGIN |
| 3457 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 3458 |
INCR (sp_ptr); |
| 3459 |
END |
| 3460 |
END |
| 3461 |
else |
| 3462 |
BEGIN |
| 3463 |
pool_ptr = str_start[pop_lit1 + 1]; |
| 3464 |
STR_ROOM (1); |
| 3465 |
END |
| 3466 |
APPEND_CHAR (PERIOD); |
| 3467 |
push_lit_stk (make_string (), STK_STR); |
| 3468 |
break; |
| 3469 |
END |
| 3470 |
END |
| 3471 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 362 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3472 |
|
| 3473 |
END |
| 3474 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 361 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 3475 |
|
| 3476 |
END |
| 3477 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 360 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |