| 1 |
/*- |
| 2 |
****************************************************************************** |
| 3 |
****************************************************************************** |
| 4 |
** |
| 5 |
** MODULE |
| 6 |
** |
| 7 |
** file: bibtex.h |
| 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 module defines the macros used in the BibTeX WEB source. |
| 22 |
** This file also contains the definitions that determine BibTeX's |
| 23 |
** processing capacity. |
| 24 |
** |
| 25 |
** AUTHORS |
| 26 |
** |
| 27 |
** Original WEB translation to C, conversion to "big" (32-bit) capacity, |
| 28 |
** addition of run-time selectable capacity and 8-bit support extensions |
| 29 |
** by: |
| 30 |
** |
| 31 |
** Niel Kempson |
| 32 |
** Snowy Owl Systems Limited, Cheltenham, England |
| 33 |
** E-mail: [email protected] |
| 34 |
** |
| 35 |
** 8-bit support extensions also by: |
| 36 |
** |
| 37 |
** Alejandro Aguilar-Sierra |
| 38 |
** Centro de Ciencias de la Atm\'osfera, |
| 39 |
** Universidad Nacional Aut\'onoma de M\'exico, M\'exico |
| 40 |
** E-mail: [email protected] |
| 41 |
** |
| 42 |
** COPYRIGHT |
| 43 |
** |
| 44 |
** This implementation copyright (c) 1991-1995 by Niel Kempson |
| 45 |
** and copyright (c) 1995 by Alejandro Aguilar-Sierra. |
| 46 |
** |
| 47 |
** This program is free software; you can redistribute it and/or |
| 48 |
** modify it under the terms of the GNU General Public License as |
| 49 |
** published by the Free Software Foundation; either version 1, or |
| 50 |
** (at your option) any later version. |
| 51 |
** |
| 52 |
** This program is distributed in the hope that it will be useful, |
| 53 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 54 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 55 |
** General Public License for more details. |
| 56 |
** |
| 57 |
** You should have received a copy of the GNU General Public License |
| 58 |
** along with this program; if not, write to the Free Software |
| 59 |
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 60 |
** |
| 61 |
** In other words, you are welcome to use, share and improve this |
| 62 |
** program. You are forbidden to forbid anyone else to use, share |
| 63 |
** and improve what you give them. Help stamp out software-hoarding! |
| 64 |
** |
| 65 |
** ACKNOWLEDGEMENT |
| 66 |
** |
| 67 |
** The original BibTeX was written by Oren Patashnik using Donald |
| 68 |
** Knuth's WEB system. This format produces a PASCAL program for |
| 69 |
** execution and a TeX documented version of the source code. This |
| 70 |
** program started as a (manual) translation of the WEB source into C. |
| 71 |
** |
| 72 |
** CHANGE LOG |
| 73 |
** |
| 74 |
** $Log: bibtex.h,v $ |
| 75 |
** Revision 3.71 1996/08/18 20:47:30 kempson |
| 76 |
** Official release 3.71 (see HISTORY file for details). |
| 77 |
** |
| 78 |
** Revision 3.70 1996/04/08 10:08:40 kempson |
| 79 |
** Final documentation & cosmetic changes for official release 3.70. |
| 80 |
** |
| 81 |
** Revision 3.5 1995/09/24 20:44:37 kempson |
| 82 |
** Many changes for final beta test version. |
| 83 |
** |
| 84 |
** Revision 3.4 1995/04/09 22:15:43 kempson |
| 85 |
** Placed under RCS control |
| 86 |
** |
| 87 |
****************************************************************************** |
| 88 |
****************************************************************************** |
| 89 |
*/ |
| 90 |
#ifndef __BIBTEX_H__ |
| 91 |
#define __BIBTEX_H__ 1 |
| 92 |
|
| 93 |
|
| 94 |
/*************************************************************************** |
| 95 |
* WEB section number: 1 |
| 96 |
* ~~~~~~~~~~~~~~~~~~~ |
| 97 |
* The BANNER string is defined here and should be changed whenever BibTeX |
| 98 |
* is modified. |
| 99 |
***************************************************************************/ |
| 100 |
#ifdef UTF_8 |
| 101 |
# define BANNER "This is BibTeXu: a UTF-8 Big BibTeX version 0.99d" |
| 102 |
# define PROGNAME "bibtexu" |
| 103 |
# define SUPPORT_8BIT |
| 104 |
#else |
| 105 |
# ifdef SUPPORT_8BIT |
| 106 |
# define BANNER "This is 8-bit Big BibTeX version 0.99d" |
| 107 |
# else |
| 108 |
# define BANNER "This is Big BibTeX version 0.99d" |
| 109 |
# endif |
| 110 |
# define PROGNAME "bibtex8" |
| 111 |
#endif |
| 112 |
|
| 113 |
|
| 114 |
/*************************************************************************** |
| 115 |
* WEB section number: 2 |
| 116 |
* ~~~~~~~~~~~~~~~~~~~ |
| 117 |
* Terminal output goes to the file |TERM_OUT|, while terminal input comes |
| 118 |
* from |TERM_IN|. On our system, these (system-dependent) files are |
| 119 |
* already opened at the beginning of the program. |
| 120 |
***************************************************************************/ |
| 121 |
#define TERM_OUT stdout |
| 122 |
#define TERM_IN stdin |
| 123 |
|
| 124 |
/*************************************************************************** |
| 125 |
* WEB section number: 3 |
| 126 |
* ~~~~~~~~~~~~~~~~~~~ |
| 127 |
* This program uses the term |print| instead of |write| when writing on |
| 128 |
* both the |log_file| and (system-dependent) |term_out| file, and it |
| 129 |
* uses |trace_pr| when in |trace| mode, for which it writes on just the |
| 130 |
* |log_file|. If you want to change where either set of macros writes |
| 131 |
* to, you should also change the other macros in this program for that |
| 132 |
* set; each such macro begins with |print_| or |trace_pr_|. |
| 133 |
***************************************************************************/ |
| 134 |
#define PRINT_NEWLINE print_a_newline () |
| 135 |
|
| 136 |
#define PRINT(X) \ |
| 137 |
{\ |
| 138 |
if (log_file != NULL)\ |
| 139 |
FPRINTF (log_file, X);\ |
| 140 |
FPRINTF (TERM_OUT, X);\ |
| 141 |
} |
| 142 |
|
| 143 |
#define PRINT2(X, Y) \ |
| 144 |
{\ |
| 145 |
if (log_file != NULL)\ |
| 146 |
FPRINTF (log_file, X, Y);\ |
| 147 |
FPRINTF (TERM_OUT, X, Y);\ |
| 148 |
} |
| 149 |
|
| 150 |
#define PRINT3(X, Y, Z) \ |
| 151 |
{\ |
| 152 |
if (log_file != NULL)\ |
| 153 |
FPRINTF (log_file, X, Y, Z);\ |
| 154 |
FPRINTF (TERM_OUT, X, Y, Z);\ |
| 155 |
} |
| 156 |
|
| 157 |
#define PRINT4(W, X, Y, Z) \ |
| 158 |
{\ |
| 159 |
if (log_file != NULL)\ |
| 160 |
FPRINTF (log_file, W, X, Y, Z);\ |
| 161 |
FPRINTF (TERM_OUT, W, X, Y, Z);\ |
| 162 |
} |
| 163 |
|
| 164 |
#define PRINT_LN(X) \ |
| 165 |
{\ |
| 166 |
if (log_file != NULL) {\ |
| 167 |
FPRINTF (log_file, X); FPUTC ('\n', log_file);\ |
| 168 |
}\ |
| 169 |
FPRINTF (TERM_OUT, X); FPUTC('\n', TERM_OUT);\ |
| 170 |
} |
| 171 |
|
| 172 |
#define PRINT_LN2(X, Y) \ |
| 173 |
{\ |
| 174 |
if (log_file != NULL) {\ |
| 175 |
FPRINTF (log_file, X, Y); FPUTC ('\n', log_file);\ |
| 176 |
}\ |
| 177 |
FPRINTF (TERM_OUT, X, Y); FPUTC('\n', TERM_OUT);\ |
| 178 |
} |
| 179 |
|
| 180 |
#define PRINT_LN3(X, Y, Z) \ |
| 181 |
{\ |
| 182 |
if (log_file != NULL) {\ |
| 183 |
FPRINTF (log_file, X, Y, Z); FPUTC ('\n', log_file);\ |
| 184 |
}\ |
| 185 |
FPRINTF (TERM_OUT, X, Y, Z); FPUTC('\n', TERM_OUT);\ |
| 186 |
} |
| 187 |
|
| 188 |
#define PRINT_LN4(W, X, Y, Z) \ |
| 189 |
{\ |
| 190 |
if (log_file != NULL) {\ |
| 191 |
FPRINTF (log_file, W, X, Y, Z); FPUTC ('\n', log_file);\ |
| 192 |
}\ |
| 193 |
FPRINTF (TERM_OUT, W, X, Y, Z); FPUTC('\n', TERM_OUT);\ |
| 194 |
} |
| 195 |
|
| 196 |
#define TRACE_PR(X) \ |
| 197 |
if (log_file != NULL) FPRINTF (log_file, X); |
| 198 |
|
| 199 |
#define TRACE_PR2(X, Y) \ |
| 200 |
if (log_file != NULL) FPRINTF (log_file, X, Y); |
| 201 |
|
| 202 |
#define TRACE_PR3(X, Y, Z) \ |
| 203 |
if (log_file != NULL) FPRINTF (log_file, X, Y, Z); |
| 204 |
|
| 205 |
#define TRACE_PR_LN(X) \ |
| 206 |
{\ |
| 207 |
if (log_file != NULL) {\ |
| 208 |
FPRINTF (log_file, X); FPUTC ('\n', log_file);\ |
| 209 |
}\ |
| 210 |
} |
| 211 |
|
| 212 |
#define TRACE_PR_LN2(X, Y) \ |
| 213 |
{\ |
| 214 |
if (log_file != NULL) {\ |
| 215 |
FPRINTF (log_file, X, Y); FPUTC ('\n', log_file);\ |
| 216 |
}\ |
| 217 |
} |
| 218 |
|
| 219 |
#define TRACE_PR_LN3(X, Y, Z) \ |
| 220 |
{\ |
| 221 |
if (log_file != NULL) {\ |
| 222 |
FPRINTF (log_file, X, Y, Z); FPUTC ('\n', log_file);\ |
| 223 |
}\ |
| 224 |
} |
| 225 |
|
| 226 |
#define TRACE_PR_NEWLINE \ |
| 227 |
{\ |
| 228 |
if (log_file != NULL)\ |
| 229 |
FPUTC ('\n', log_file);\ |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
/*************************************************************************** |
| 234 |
* WEB section number: 4 |
| 235 |
* ~~~~~~~~~~~~~~~~~~~ |
| 236 |
* Some of the code is intended to be used only when diagnosing the strange |
| 237 |
* behaviour that sometimes occurs when BibTeX is being installed or when |
| 238 |
* system wizards are fooling around with BibTeX without quite knowing what |
| 239 |
* they are doing. Such code will not normally be compiled; it is delimited |
| 240 |
* by the preprocessor conditionals `#ifdef DEBUG ... #endif'. Similarly, |
| 241 |
* there is some conditional code delimited by `#ifdef STAT ... #endif' |
| 242 |
* that is intended only for use when statistics are to be kept about |
| 243 |
* BibTeX's memory/CPU usage, and there is conditional code delimited by |
| 244 |
* `#ifdef TRACE ... #endif' that is intended to be a trace facility for |
| 245 |
* use mainly when debugging .BST files. |
| 246 |
***************************************************************************/ |
| 247 |
#define DEBUG 1 |
| 248 |
#define STAT 1 |
| 249 |
#define TRACE 1 |
| 250 |
|
| 251 |
/*************************************************************************** |
| 252 |
* WEB section number: 9 |
| 253 |
* ~~~~~~~~~~~~~~~~~~~ |
| 254 |
* Here are some macros for common programming idioms. |
| 255 |
***************************************************************************/ |
| 256 |
#define INCR(X) ++(X) |
| 257 |
#define DECR(X) --(X) |
| 258 |
#define LOOP while (TRUE) |
| 259 |
#define DO_NOTHING ; |
| 260 |
#define EMPTY 0 |
| 261 |
#define ANY_VALUE 0 |
| 262 |
|
| 263 |
/*************************************************************************** |
| 264 |
* WEB section number: 14 |
| 265 |
* ~~~~~~~~~~~~~~~~~~~ |
| 266 |
* These parameters may be changed at compile time to extend or reduce |
| 267 |
* BiBTeX's capacity. They are set to accommodate a maximum of about 750 |
| 268 |
* cites when used with the standard styles. |
| 269 |
***************************************************************************/ |
| 270 |
#define MIN_PRINT_LINE 3 |
| 271 |
#define MAX_PRINT_LINE 79 |
| 272 |
#define AUX_STACK_SIZE 20 |
| 273 |
#define MAX_BIB_FILES 20 |
| 274 |
|
| 275 |
#define BUF_SIZE 20000 |
| 276 |
#define MAX_CITES 750 |
| 277 |
#define MAX_FIELDS 5000 |
| 278 |
#define MAX_STRINGS 4000 |
| 279 |
#define POOL_SIZE 65000L |
| 280 |
|
| 281 |
#define MIN_CROSSREFS 2 |
| 282 |
#define WIZ_FN_SPACE 3000 |
| 283 |
#define SINGLE_FN_SPACE 50 |
| 284 |
#define ENT_STR_SIZE 100 |
| 285 |
#define GLOB_STR_SIZE 1000 |
| 286 |
#define LIT_STK_SIZE 50 |
| 287 |
|
| 288 |
|
| 289 |
/*************************************************************************** |
| 290 |
* WEB section number: 15 |
| 291 |
* ~~~~~~~~~~~~~~~~~~~ |
| 292 |
* These parameters can also be changed at compile time, but they're |
| 293 |
* needed to define some WEB numeric macros so they must be defined |
| 294 |
* themselves. |
| 295 |
***************************************************************************/ |
| 296 |
#define HASH_SIZE 5000 |
| 297 |
|
| 298 |
#ifdef MSDOS |
| 299 |
# define FILE_NAME_SIZE 64 |
| 300 |
#else /* NOT MSDOS */ |
| 301 |
# define FILE_NAME_SIZE 255 |
| 302 |
#endif /* MSDOS */ |
| 303 |
|
| 304 |
#define MAX_GLOB_STRS 10 |
| 305 |
|
| 306 |
/*************************************************************************** |
| 307 |
* WEB section number: 18 |
| 308 |
* ~~~~~~~~~~~~~~~~~~~ |
| 309 |
* A global variable called |history| will contain one of four values at |
| 310 |
* the end of every run: |spotless| means that no unusual messages were |
| 311 |
* printed; |warning_message| means that a message of possible interest |
| 312 |
* was printed but no serious errors were detected; |error_message| means |
| 313 |
* that at least one error was found; |fatal_message| means that the |
| 314 |
* program terminated abnormally. The value of |history| does not |
| 315 |
* influence the behavior of the program; it is simply computed for the |
| 316 |
* convenience of systems that might want to use such information. |
| 317 |
***************************************************************************/ |
| 318 |
#define SPOTLESS 0 |
| 319 |
#define WARNING_MESSAGE 1 |
| 320 |
#define ERROR_MESSAGE 2 |
| 321 |
#define FATAL_MESSAGE 3 |
| 322 |
|
| 323 |
/*************************************************************************** |
| 324 |
* WEB section number: 23 |
| 325 |
* ~~~~~~~~~~~~~~~~~~~ |
| 326 |
* We shall use the |text_char| to stand for the data type of the |
| 327 |
* characters that are converted to and from |ASCIICode_T| when they are |
| 328 |
* input and output. We shall also assume that |text_char| consists of the |
| 329 |
* elements |chr[FIRST_TEXT_CHAR]| through |chr[LAST_TEXT_CHAR]| inclusive. |
| 330 |
* The following definitions should be adjusted if necessary. |
| 331 |
***************************************************************************/ |
| 332 |
#define FIRST_TEXT_CHAR 0 |
| 333 |
#define LAST_TEXT_CHAR 255 |
| 334 |
|
| 335 |
#ifdef SUPPORT_8BIT |
| 336 |
#define LAST_ASCII_CHAR 255 |
| 337 |
#else |
| 338 |
#define LAST_ASCII_CHAR 127 |
| 339 |
#endif /* SUPPORT_8BIT */ |
| 340 |
#ifdef UTF_8 |
| 341 |
#define LAST_LATIN_CHAR 0x17F |
| 342 |
#define LAST_UCS_CHAR 0x10FFFF |
| 343 |
#else |
| 344 |
#define LAST_LATIN_CHAR LAST_ASCII_CHAR |
| 345 |
#endif |
| 346 |
|
| 347 |
|
| 348 |
/*************************************************************************** |
| 349 |
* WEB section number: 26 |
| 350 |
* ~~~~~~~~~~~~~~~~~~~ |
| 351 |
* Some of the ASCII codes without visible characters have been given |
| 352 |
* symbolic names in this program because they are used with a special |
| 353 |
* meaning. The |tab| character may be system dependent. |
| 354 |
***************************************************************************/ |
| 355 |
#define NULL_CODE 0 |
| 356 |
#define TAB 9 |
| 357 |
#define SPACE 32 |
| 358 |
#define INVALID_CODE 127 |
| 359 |
|
| 360 |
/*************************************************************************** |
| 361 |
* WEB section number: 29 |
| 362 |
* ~~~~~~~~~~~~~~~~~~~ |
| 363 |
* Also, various characters are given symbolic names; all the ones this |
| 364 |
* program uses are collected here. We use the sharp sign as the |
| 365 |
* |concat_char|, rather than something more natural (like an ampersand), |
| 366 |
* for uniformity of database syntax (ampersand is a valid character in |
| 367 |
* identifiers). |
| 368 |
***************************************************************************/ |
| 369 |
#define DOUBLE_QUOTE '"' |
| 370 |
#define NUMBER_SIGN '#' |
| 371 |
#define COMMENT '%' |
| 372 |
#define SINGLE_QUOTE '\'' |
| 373 |
#define LEFT_PAREN '(' |
| 374 |
#define RIGHT_PAREN ')' |
| 375 |
#define COMMA ',' |
| 376 |
#define MINUS_SIGN '-' |
| 377 |
#define EQUALS_SIGN '=' |
| 378 |
#define AT_SIGN '@' |
| 379 |
#define LEFT_BRACE '{' |
| 380 |
#define RIGHT_BRACE '}' |
| 381 |
#define PERIOD '.' |
| 382 |
#define QUESTION_MARK '?' |
| 383 |
#define EXCLAMATION_MARK '!' |
| 384 |
#define TIE '~' |
| 385 |
#define HYPHEN '-' |
| 386 |
#define STAR '*' |
| 387 |
#define CONCAT_CHAR '#' |
| 388 |
#define COLON ':' |
| 389 |
#define BACKSLASH '\\' |
| 390 |
|
| 391 |
/*************************************************************************** |
| 392 |
* WEB section number: 31 |
| 393 |
* ~~~~~~~~~~~~~~~~~~~~ |
| 394 |
* Every character has two types of the lexical classifications. The |
| 395 |
* first type is general, and the second type tells whether the character |
| 396 |
* is legal in identifiers. |
| 397 |
***************************************************************************/ |
| 398 |
#define ILLEGAL 0 |
| 399 |
#define WHITE_SPACE 1 |
| 400 |
#define ALPHA 2 |
| 401 |
#define NUMERIC 3 |
| 402 |
#define SEP_CHAR 4 |
| 403 |
#define OTHER_LEX 5 |
| 404 |
#define LAST_LEX 5 |
| 405 |
#define ILLEGAL_ID_CHAR 0 |
| 406 |
#define LEGAL_ID_CHAR 1 |
| 407 |
|
| 408 |
/*************************************************************************** |
| 409 |
* WEB section number: 35 |
| 410 |
* ~~~~~~~~~~~~~~~~~~~~ |
| 411 |
* Now we initialize the system-dependent |char_width| array, for which |
| 412 |
* |space| is the only |white_space| character given a nonzero printing |
| 413 |
* width. The widths here are taken from Stanford's June '87 cmr10 font |
| 414 |
* and represent hundredths of a point (rounded), but since they're used |
| 415 |
* only for relative comparisons, the units have no meaning. |
| 416 |
***************************************************************************/ |
| 417 |
#define SS_WIDTH 500 |
| 418 |
#define AE_WIDTH 722 |
| 419 |
#define OE_WIDTH 778 |
| 420 |
#define UPPER_AE_WIDTH 903 |
| 421 |
#define UPPER_OE_WIDTH 1014 |
| 422 |
|
| 423 |
/*************************************************************************** |
| 424 |
* WEB section number: 44 |
| 425 |
* ~~~~~~~~~~~~~~~~~~~~ |
| 426 |
* When something in the program wants to be bigger or something out |
| 427 |
* there wants to be smaller, it's time to call it a run. Here's the |
| 428 |
* first of several macros that have associated procedures so that they |
| 429 |
* produce less inline code. |
| 430 |
***************************************************************************/ |
| 431 |
#define BIBTEX_OVERFLOW(X, Y) {\ |
| 432 |
print_overflow ();\ |
| 433 |
PRINT_LN3 ("%s%ld\n", (X), (long) (Y));\ |
| 434 |
longjmp (Close_Up_Shop_Flag, 1);} |
| 435 |
|
| 436 |
/*************************************************************************** |
| 437 |
* WEB section number: 45 |
| 438 |
* ~~~~~~~~~~~~~~~~~~~~ |
| 439 |
* When something happens that the program thinks is impossible, call the |
| 440 |
* maintainer. |
| 441 |
***************************************************************************/ |
| 442 |
#define CONFUSION(X) {\ |
| 443 |
PRINT (X); print_confusion();\ |
| 444 |
longjmp (Close_Up_Shop_Flag, 1);} |
| 445 |
#define CONFUSION2(X, Y) {\ |
| 446 |
PRINT2 (X, Y); print_confusion();\ |
| 447 |
longjmp (Close_Up_Shop_Flag, 1);} |
| 448 |
|
| 449 |
/*************************************************************************** |
| 450 |
* WEB section number: 50 |
| 451 |
* ~~~~~~~~~~~~~~~~~~~~ |
| 452 |
* These macros send a string in |str_pool| to an output file. |
| 453 |
***************************************************************************/ |
| 454 |
#define MAX_POP 3 |
| 455 |
#define PRINT_POOL_STR(X) print_a_pool_str(X) |
| 456 |
#define TRACE_PR_POOL_STR(X) { out_pool_str(log_file, X);} |
| 457 |
|
| 458 |
/*************************************************************************** |
| 459 |
* WEB section number: 52 |
| 460 |
* ~~~~~~~~~~~~~~~~~~~ |
| 461 |
* Several of the elementary string operations are performed using WEB |
| 462 |
* macros instead of using PASCAL procedures, because many of the operations |
| 463 |
* are done quite frequently and we want to avoid the overhead of procedure |
| 464 |
* calls. For example, here's a simple macro that computes the length of a |
| 465 |
* string. |
| 466 |
***************************************************************************/ |
| 467 |
#define LENGTH(s) (str_start[(s)+1] - str_start[s]) |
| 468 |
|
| 469 |
/*************************************************************************** |
| 470 |
* WEB section number: 53 |
| 471 |
* ~~~~~~~~~~~~~~~~~~~ |
| 472 |
* Strings are created by appending character codes to |str_pool|. The macro |
| 473 |
* called |append_char|, defined here, does not check to see if the value |
| 474 |
* of |pool_ptr| is too high; this test is supposed to be made before |
| 475 |
* |append_char| is used. |
| 476 |
***************************************************************************/ |
| 477 |
#define APPEND_CHAR(X) {str_pool[pool_ptr] = (X);\ |
| 478 |
INCR(pool_ptr);} |
| 479 |
#define STR_ROOM(X) {while((pool_ptr+(X))>Pool_Size)\ |
| 480 |
pool_overflow();} |
| 481 |
|
| 482 |
/*************************************************************************** |
| 483 |
* WEB section number: 55 |
| 484 |
* ~~~~~~~~~~~~~~~~~~~ |
| 485 |
* These macros destroy an recreate the string at the end of the pool. |
| 486 |
***************************************************************************/ |
| 487 |
#define FLUSH_STRING {DECR(str_ptr);\ |
| 488 |
pool_ptr=str_start[str_ptr];} |
| 489 |
#define UNFLUSH_STRING {INCR(str_ptr);\ |
| 490 |
pool_ptr=str_start[str_ptr];} |
| 491 |
|
| 492 |
/*************************************************************************** |
| 493 |
* WEB section number: 62 |
| 494 |
* ~~~~~~~~~~~~~~~~~~~ |
| 495 |
* This system-independent procedure converts upper-case characters to |
| 496 |
* lower case for the specified part of |buf|. It is system independent |
| 497 |
* because it uses only the internal representation for characters. |
| 498 |
***************************************************************************/ |
| 499 |
#define CASE_DIFFERENCE ('a' - 'A') |
| 500 |
|
| 501 |
/*************************************************************************** |
| 502 |
* WEB section number: 64 |
| 503 |
* ~~~~~~~~~~~~~~~~~~~ |
| 504 |
* All static strings that BibTeX might have to search for, generally |
| 505 |
* identifiers, are stored and retrieved by means of a fairly standard |
| 506 |
* hash-table algorithm (but slightly altered here) called the method of |
| 507 |
* ``coalescing lists'' (cf.\ Algorithm 6.4C in The Art of Computer |
| 508 |
* Programming). Once a string enters the table, it is never removed. |
| 509 |
* The actual sequence of characters forming a string is stored in the |
| 510 |
* |str_pool| array. |
| 511 |
***************************************************************************/ |
| 512 |
#define HASH_BASE (EMPTY + 1) |
| 513 |
#define HASH_MAX (HASH_BASE + Hash_Size - 1) |
| 514 |
#define HASH_IS_FULL ((hash_used) == (HASH_BASE)) |
| 515 |
#define TEXT_ILK 0 |
| 516 |
#define INTEGER_ILK 1 |
| 517 |
#define AUX_COMMAND_ILK 2 |
| 518 |
#define AUX_FILE_ILK 3 |
| 519 |
#define BST_COMMAND_ILK 4 |
| 520 |
#define BST_FILE_ILK 5 |
| 521 |
#define BIB_FILE_ILK 6 |
| 522 |
#define FILE_EXT_ILK 7 |
| 523 |
#define FILE_AREA_ILK 8 |
| 524 |
#define CITE_ILK 9 |
| 525 |
#define LC_CITE_ILK 10 |
| 526 |
#define BST_FN_ILK 11 |
| 527 |
#define BIB_COMMAND_ILK 12 |
| 528 |
#define MACRO_ILK 13 |
| 529 |
#define CONTROL_SEQ_ILK 14 |
| 530 |
#define LAST_ILK 14 |
| 531 |
|
| 532 |
/*************************************************************************** |
| 533 |
* WEB section number: 68 |
| 534 |
* ~~~~~~~~~~~~~~~~~~~ |
| 535 |
* Here is the subroutine that searches the the hash table for a (string, |
| 536 |
* str_ilk) pair, where the string is of length l >= 0 and appears in |
| 537 |
* |buffer[j..(j+l-1)]|. If it finds the pair, it returns the corresponding |
| 538 |
* hash table location and sets the global variable |hash_found| to |TRUE|. |
| 539 |
* Otherwise is sets |hash_found| to |FALSE|, and if the parameter |
| 540 |
* |insert_it| is |TRUE|, it inserts the pair into the hash table, inserts |
| 541 |
* the string into |str_pool| if not previously encountered, and returns its |
| 542 |
* location. Note that two different pairs can have the same string but |
| 543 |
* different |str_ilks|, in which case the second pair encountered, if |
| 544 |
* |insert_it| were |TRUE|, would be inserted into the hash table though its |
| 545 |
* string wouldn't be inserted into |str_pool| because it would already be |
| 546 |
* there. |
| 547 |
***************************************************************************/ |
| 548 |
#define MAX_HASH_VALUE (Hash_Prime + Hash_Prime - 2 + 127) |
| 549 |
#define DO_INSERT TRUE |
| 550 |
#define DONT_INSERT FALSE |
| 551 |
|
| 552 |
/*************************************************************************** |
| 553 |
* WEB section number: 73 |
| 554 |
* ~~~~~~~~~~~~~~~~~~~ |
| 555 |
* The longest pre-defined string determines type definitions used to |
| 556 |
* insert the pre-defined strings into |str_pool|. |
| 557 |
* Set to accommodate the longest translations of the environment variables. |
| 558 |
***************************************************************************/ |
| 559 |
#define LONGEST_PDS MAX_FILE_NAME |
| 560 |
|
| 561 |
/*************************************************************************** |
| 562 |
* WEB section number: 78 |
| 563 |
* ~~~~~~~~~~~~~~~~~~~ |
| 564 |
* These constants all begin with |n_| and are used for the |case| |
| 565 |
* statement that determines which command to execute. The variable |
| 566 |
* |command_num| is set to one of these and is used to do the branching, |
| 567 |
* but it must have the full |integer| range because at times it can |
| 568 |
* assume an arbitrary |ilk_info| value (though it will be one of the |
| 569 |
* values here when we actually use it). |
| 570 |
***************************************************************************/ |
| 571 |
#define N_AUX_BIBDATA 0 |
| 572 |
#define N_AUX_BIBSTYLE 1 |
| 573 |
#define N_AUX_CITATION 2 |
| 574 |
#define N_AUX_INPUT 3 |
| 575 |
|
| 576 |
#define N_BST_ENTRY 0 |
| 577 |
#define N_BST_EXECUTE 1 |
| 578 |
#define N_BST_FUNCTION 2 |
| 579 |
#define N_BST_INTEGERS 3 |
| 580 |
#define N_BST_ITERATE 4 |
| 581 |
#define N_BST_MACRO 5 |
| 582 |
#define N_BST_READ 6 |
| 583 |
#define N_BST_REVERSE 7 |
| 584 |
#define N_BST_SORT 8 |
| 585 |
#define N_BST_STRINGS 9 |
| 586 |
|
| 587 |
#define N_BIB_COMMENT 0 |
| 588 |
#define N_BIB_PREAMBLE 1 |
| 589 |
#define N_BIB_STRING 2 |
| 590 |
|
| 591 |
/*************************************************************************** |
| 592 |
* WEB section number: 80 |
| 593 |
* ~~~~~~~~~~~~~~~~~~~ |
| 594 |
* This section describes the various |buffer| scanning routines. The |
| 595 |
* two global variables |buf_ptr1| and |buf_ptr2| are used in scanning an |
| 596 |
* input line. Between scans, |buf_ptr1| points to the first character |
| 597 |
* of the current token and |buf_ptr2| points to that of the next. The |
| 598 |
* global variable |last|, set by the function |input_ln|, marks the end |
| 599 |
* of the current line; it equals 0 at the end of the current file. All |
| 600 |
* the procedures and functions in this section will indicate an |
| 601 |
* end-of-line when it's the end of the file. |
| 602 |
***************************************************************************/ |
| 603 |
#define TOKEN_LEN (buf_ptr2 - buf_ptr1) |
| 604 |
#define SCAN_CHAR buffer[buf_ptr2] |
| 605 |
|
| 606 |
/*************************************************************************** |
| 607 |
* WEB section number: 81 |
| 608 |
* ~~~~~~~~~~~~~~~~~~~ |
| 609 |
* These macros send the current token, in |buffer[buf_ptr1]| to |
| 610 |
* |buffer[buf_ptr2-1]|, to an output file. |
| 611 |
***************************************************************************/ |
| 612 |
#define PRINT_TOKEN print_a_token (); |
| 613 |
#define TRACE_PR_TOKEN out_token (log_file); |
| 614 |
|
| 615 |
/*************************************************************************** |
| 616 |
* WEB section number: 89 |
| 617 |
* ~~~~~~~~~~~~~~~~~~~ |
| 618 |
* These are the possible values for |scan_result|; they're set by the |
| 619 |
* |scan_identifier| procedure and are described in the next section. |
| 620 |
***************************************************************************/ |
| 621 |
#define ID_NULL 0 |
| 622 |
#define SPECIFIED_CHAR_ADJACENT 1 |
| 623 |
#define OTHER_CHAR_ADJACENT 2 |
| 624 |
#define WHITE_ADJACENT 3 |
| 625 |
|
| 626 |
/*************************************************************************** |
| 627 |
* WEB section number: 91 |
| 628 |
* ~~~~~~~~~~~~~~~~~~~ |
| 629 |
* The next two procedures scan for an integer, setting the global |
| 630 |
* variable |token_value| to the corresponding integer. |
| 631 |
***************************************************************************/ |
| 632 |
#define CHAR_VALUE (SCAN_CHAR - '0') |
| 633 |
|
| 634 |
/*************************************************************************** |
| 635 |
* WEB section number: 93 |
| 636 |
* ~~~~~~~~~~~~~~~~~~~ |
| 637 |
* This procedure scans for an integer, stopping at the first nondigit; |
| 638 |
* it sets the value of |token_value| accordingly. It returns |true| if |
| 639 |
* the token was a legal integer (i.e., consisted of an optional |
| 640 |
* |minus_sign| followed by one or more digits). |
| 641 |
***************************************************************************/ |
| 642 |
#define NEGATIVE (sign_length == 1) |
| 643 |
|
| 644 |
/*************************************************************************** |
| 645 |
* WEB section number: 98 |
| 646 |
* ~~~~~~~~~~~~~~~~~~~ |
| 647 |
* I mean, this is truly disgraceful ... |
| 648 |
* |
| 649 |
* Note: The |term_out| file is system dependent. |
| 650 |
***************************************************************************/ |
| 651 |
#define SAM_YOU_MADE_THE_FILE_NAME_TOO {\ |
| 652 |
sam_too_long_file_name_print ();\ |
| 653 |
goto Aux_Not_Found_Label;} |
| 654 |
|
| 655 |
/*************************************************************************** |
| 656 |
* WEB section number: 99 |
| 657 |
* ~~~~~~~~~~~~~~~~~~~ |
| 658 |
* We've abused the user enough for one section; suffice it to |
| 659 |
* say here that most of what we said last module still applies. |
| 660 |
* Note: The |term_out| file is system dependent. |
| 661 |
***************************************************************************/ |
| 662 |
#define SAM_YOU_MADE_THE_FILE_NAME_WRON {\ |
| 663 |
sam_wrong_file_name_print ();\ |
| 664 |
goto Aux_Not_Found_Label;} |
| 665 |
|
| 666 |
/*************************************************************************** |
| 667 |
* WEB section number: 104 |
| 668 |
* ~~~~~~~~~~~~~~~~~~~ |
| 669 |
* Here we set up definitions and declarations for files opened in this |
| 670 |
* section. Each element in |aux_list| (except for |
| 671 |
* |aux_list[aux_stack_size]|, which is always unused) is a pointer to |
| 672 |
* the appropriate |str_pool| string representing the \.{.aux} file name. |
| 673 |
* The array |aux_file| contains the corresponding \PASCAL\ |file| |
| 674 |
* variables. |
| 675 |
***************************************************************************/ |
| 676 |
#define CUR_AUX_STR aux_list[aux_ptr] |
| 677 |
#define CUR_AUX_FILE aux_file[aux_ptr] |
| 678 |
#define CUR_AUX_LINE aux_ln_stack[aux_ptr] |
| 679 |
|
| 680 |
/*************************************************************************** |
| 681 |
* WEB section number: 111 |
| 682 |
* ~~~~~~~~~~~~~~~~~~~ |
| 683 |
* When we find a bug, we print a message and flush the rest of the line. |
| 684 |
* This macro must be called from within a procedure that has an |exit| |
| 685 |
* label. |
| 686 |
***************************************************************************/ |
| 687 |
#define AUX_ERR_RETURN {aux_err_print(); goto Exit_Label;} |
| 688 |
|
| 689 |
/*************************************************************************** |
| 690 |
* WEB section number: 112 |
| 691 |
* ~~~~~~~~~~~~~~~~~~~ |
| 692 |
* Here are a bunch of macros whose print statements are used at least |
| 693 |
* twice. Thus we save space by making the statements procedures. This |
| 694 |
* macro complains when there's a repeated command that's to be used just |
| 695 |
* once. |
| 696 |
***************************************************************************/ |
| 697 |
#define AUX_ERR_ILLEGAL_ANOTHER(X) {aux_err_illegal_another_print (X);\ |
| 698 |
AUX_ERR_RETURN;} |
| 699 |
|
| 700 |
/*************************************************************************** |
| 701 |
* WEB section number: 113 |
| 702 |
* ~~~~~~~~~~~~~~~~~~~ |
| 703 |
* This one complains when a command is missing its |right_brace|. |
| 704 |
***************************************************************************/ |
| 705 |
#define AUX_ERR_NO_RIGHT_BRACE {\ |
| 706 |
PRINT2 ("No \"%c\"", xchr[RIGHT_BRACE]);\ |
| 707 |
AUX_ERR_RETURN;} |
| 708 |
|
| 709 |
/*************************************************************************** |
| 710 |
* WEB section number: 114 |
| 711 |
* ~~~~~~~~~~~~~~~~~~~ |
| 712 |
* This one complains when a command has stuff after its |right_brace|. |
| 713 |
***************************************************************************/ |
| 714 |
#define AUX_ERR_STUFF_AFTER_RIGHT_BRACE {\ |
| 715 |
PRINT2 ("Stuff after \"%c\"", xchr[RIGHT_BRACE]);\ |
| 716 |
AUX_ERR_RETURN;} |
| 717 |
|
| 718 |
/*************************************************************************** |
| 719 |
* WEB section number: 115 |
| 720 |
* ~~~~~~~~~~~~~~~~~~~ |
| 721 |
* And this one complains when a command has white space in its argument. |
| 722 |
***************************************************************************/ |
| 723 |
#define AUX_ERR_WHITE_SPACE_IN_ARGUMENT {\ |
| 724 |
PRINT ("White space in argument");\ |
| 725 |
AUX_ERR_RETURN;} |
| 726 |
|
| 727 |
/*************************************************************************** |
| 728 |
* WEB section number: 117 |
| 729 |
* ~~~~~~~~~~~~~~~~~~~ |
| 730 |
* Here we introduce some variables for processing a \.{\\bibdata} |
| 731 |
* command. Each element in |bib_list| (except for |
| 732 |
* |bib_list[max_bib_files]|, which is always unused) is a pointer to the |
| 733 |
* appropriate |str_pool| string representing the \.{.bib} file name. |
| 734 |
* The array |bib_file| contains the corresponding \PASCAL\ |file| |
| 735 |
* variables. |
| 736 |
***************************************************************************/ |
| 737 |
#define CUR_BIB_STR bib_list[bib_ptr] |
| 738 |
#define CUR_BIB_FILE bib_file[bib_ptr] |
| 739 |
|
| 740 |
/*************************************************************************** |
| 741 |
* WEB section number: 122 |
| 742 |
* ~~~~~~~~~~~~~~~~~~~ |
| 743 |
* This macro is very similar to aux_err but it complains specifically about |
| 744 |
* opening a file for a \bibdata command. |
| 745 |
***************************************************************************/ |
| 746 |
#define OPEN_BIBDATA_AUX_ERR(X) {\ |
| 747 |
PRINT (X);\ |
| 748 |
print_bib_name();\ |
| 749 |
AUX_ERR_RETURN;} |
| 750 |
|
| 751 |
/*************************************************************************** |
| 752 |
* WEB section number: 129 |
| 753 |
* ~~~~~~~~~~~~~~~~~~~ |
| 754 |
* Here we introduce some variables for processing a \.{\\citation} |
| 755 |
* command. Each element in |cite_list| (except for |
| 756 |
* |cite_list[Max_Cites]|, which is always unused) is a pointer to the |
| 757 |
* appropriate |str_pool| string. The cite-key list is kept in order of |
| 758 |
* occurrence with duplicates removed. |
| 759 |
***************************************************************************/ |
| 760 |
#define CUR_CITE_STR cite_list[cite_ptr] |
| 761 |
|
| 762 |
/*************************************************************************** |
| 763 |
* WEB section number: 133 |
| 764 |
* ~~~~~~~~~~~~~~~~~~~ |
| 765 |
* We must check if (the lower-case version of) this cite key has been |
| 766 |
* previously encountered, and proceed accordingly. The alias kludge |
| 767 |
* helps make the stack space not overflow on some machines. |
| 768 |
***************************************************************************/ |
| 769 |
#define EX_BUF1 ex_buf |
| 770 |
|
| 771 |
/*************************************************************************** |
| 772 |
* WEB section number: 144 |
| 773 |
* ~~~~~~~~~~~~~~~~~~~ |
| 774 |
* We must complain if anything's amiss. |
| 775 |
***************************************************************************/ |
| 776 |
#define AUX_END_ERR(X) {\ |
| 777 |
aux_end1_err_print();\ |
| 778 |
PRINT (X);\ |
| 779 |
aux_end2_err_print();} |
| 780 |
|
| 781 |
/*************************************************************************** |
| 782 |
* WEB section number: 149 |
| 783 |
* ~~~~~~~~~~~~~~~~~~~ |
| 784 |
* When there's a serious error parsing the .bst file, we flush the rest of |
| 785 |
* the current command; a blank line is assumed to mark the end of a command |
| 786 |
* (but for the purposes of error recovery only). Thus, error recovery will |
| 787 |
* be better if style designers leave blank lines between .bst commands. |
| 788 |
* This macro must be called from within a procedure that has an 'exit' |
| 789 |
* label. |
| 790 |
***************************************************************************/ |
| 791 |
#define BST_ERR_PRINT_AND_LOOK_FOR_BLAN {\ |
| 792 |
bst_err_print_and_look_for_blan();\ |
| 793 |
goto Exit_Label;} |
| 794 |
|
| 795 |
#define BST_ERR(X) {\ |
| 796 |
PRINT (X);\ |
| 797 |
bst_err_print_and_look_for_blan ();\ |
| 798 |
goto Exit_Label;} |
| 799 |
|
| 800 |
#define BST_ERR2(X, Y) {\ |
| 801 |
PRINT2 (X, Y);\ |
| 802 |
bst_err_print_and_look_for_blan ();\ |
| 803 |
goto Exit_Label;} |
| 804 |
|
| 805 |
/*************************************************************************** |
| 806 |
* WEB section number: 150 |
| 807 |
* ~~~~~~~~~~~~~~~~~~~ |
| 808 |
* When there's a harmless error parsing the .bst file (harmless |
| 809 |
* syntactically, at least) we give just a warning message. |
| 810 |
***************************************************************************/ |
| 811 |
#define BST_WARN(X) {\ |
| 812 |
PRINT (X); bst_warn_print();} |
| 813 |
|
| 814 |
/*************************************************************************** |
| 815 |
* WEB section number: 153 |
| 816 |
* ~~~~~~~~~~~~~~~~~~~ |
| 817 |
* It's often illegal to end a .bst command in certain places, and this is |
| 818 |
* where we come to check. |
| 819 |
***************************************************************************/ |
| 820 |
#define EAT_BST_WHITE_AND_EOF_CHECK(X) {\ |
| 821 |
if (! eat_bst_white_space()) {\ |
| 822 |
PRINT (X); BST_ERR(X);}} |
| 823 |
|
| 824 |
/*************************************************************************** |
| 825 |
* WEB section number: 156 |
| 826 |
* ~~~~~~~~~~~~~~~~~~~ |
| 827 |
* We need data structures for the function definitions, the entry |
| 828 |
* variables, the global variables, and the actual entries corresponding |
| 829 |
* to the cite-key list. First we define the classes of `function's used. |
| 830 |
* Functions in all classes are of |bst_fn_ilk| except for |int_literal|s, |
| 831 |
* which are of |integer_ilk|; and |str_literal|s, which are of |
| 832 |
* |text_ilk|. |
| 833 |
***************************************************************************/ |
| 834 |
#define BUILT_IN 0 |
| 835 |
#define WIZ_DEFINED 1 |
| 836 |
#define INT_LITERAL 2 |
| 837 |
#define STR_LITERAL 3 |
| 838 |
#define FIELD 4 |
| 839 |
#define INT_ENTRY_VAR 5 |
| 840 |
#define STR_ENTRY_VAR 6 |
| 841 |
#define INT_GLOBAL_VAR 7 |
| 842 |
#define STR_GLOBAL_VAR 8 |
| 843 |
#define LAST_FN_CLASS 8 |
| 844 |
|
| 845 |
/*************************************************************************** |
| 846 |
* WEB section number: 160 |
| 847 |
* ~~~~~~~~~~~~~~~~~~~ |
| 848 |
* Besides the function classes, we have types based on \BibTeX's |
| 849 |
* capacity limitations and one based on what can go into the array |
| 850 |
* |wiz_functions| explained below. |
| 851 |
***************************************************************************/ |
| 852 |
#define QUOTE_NEXT_FN (HASH_BASE - 1) |
| 853 |
#define END_OF_DEF (HASH_MAX + 1) |
| 854 |
|
| 855 |
/*************************************************************************** |
| 856 |
* WEB section number: 161 |
| 857 |
* ~~~~~~~~~~~~~~~~~~~ |
| 858 |
* We store information about the \.{.bst} functions in arrays the same |
| 859 |
* size as the hash-table arrays and in locations corresponding to their |
| 860 |
* hash-table locations. The two arrays |fn_info| (an alias of |
| 861 |
* |ilk_info| described earlier) and |fn_type| accomplish this: |fn_type| |
| 862 |
* specifies one of the above classes, and |fn_info| gives information |
| 863 |
* dependent on the class. |
| 864 |
***************************************************************************/ |
| 865 |
#define FN_INFO ilk_info |
| 866 |
#define MISSING EMPTY |
| 867 |
|
| 868 |
/*************************************************************************** |
| 869 |
* WEB section number: 166 |
| 870 |
* ~~~~~~~~~~~~~~~~~~~ |
| 871 |
* This macro is used to scan all .bst identifiers. The argument supplies |
| 872 |
* .bst command name. The associated procedure simply prints an error |
| 873 |
* message. |
| 874 |
***************************************************************************/ |
| 875 |
#define BST_IDENTIFIER_SCAN(X) {\ |
| 876 |
scan_identifier (RIGHT_BRACE, COMMENT, COMMENT);\ |
| 877 |
if ((scan_result == WHITE_ADJACENT) \ |
| 878 |
|| (scan_result == SPECIFIED_CHAR_ADJACENT)) {DO_NOTHING;}\ |
| 879 |
else {bst_id_print(); BST_ERR(X)}} |
| 880 |
|
| 881 |
/*************************************************************************** |
| 882 |
* WEB section number: 167 |
| 883 |
* ~~~~~~~~~~~~~~~~~~~ |
| 884 |
* This macro just makes sure we're at a |left_brace|. |
| 885 |
***************************************************************************/ |
| 886 |
#define BST_GET_AND_CHECK_LEFT_BRACE(X) {\ |
| 887 |
if (SCAN_CHAR != LEFT_BRACE) \ |
| 888 |
{bst_left_brace_print(); BST_ERR(X);}\ |
| 889 |
INCR (buf_ptr2);} |
| 890 |
|
| 891 |
/*************************************************************************** |
| 892 |
* WEB section number: 168 |
| 893 |
* ~~~~~~~~~~~~~~~~~~~ |
| 894 |
* This macro just makes sure we're at a |right_brace|. |
| 895 |
***************************************************************************/ |
| 896 |
#define BST_GET_AND_CHECK_RIGHT_BRACE(X) {\ |
| 897 |
if (SCAN_CHAR != RIGHT_BRACE) \ |
| 898 |
{bst_right_brace_print(); BST_ERR(X);}\ |
| 899 |
INCR (buf_ptr2);} |
| 900 |
|
| 901 |
/*************************************************************************** |
| 902 |
* WEB section number: 169 |
| 903 |
* ~~~~~~~~~~~~~~~~~~~ |
| 904 |
* This macro complains if we've already encountered a function to be |
| 905 |
* inserted into the hash table. |
| 906 |
***************************************************************************/ |
| 907 |
#define CHECK_FOR_ALREADY_SEEN_FUNCTION(X) {\ |
| 908 |
if (hash_found) {\ |
| 909 |
already_seen_function_print(X);\ |
| 910 |
goto Exit_Label;}} |
| 911 |
|
| 912 |
/*************************************************************************** |
| 913 |
* WEB section number: 183 |
| 914 |
* ~~~~~~~~~~~~~~~~~~~ |
| 915 |
* We're about to start scanning tokens in a function definition. When a |
| 916 |
* function token is illegal, we skip until it ends; a |white_space| |
| 917 |
* character, an end-of-line, a |right_brace|, or a |comment| marks the |
| 918 |
* end of the current token. |
| 919 |
***************************************************************************/ |
| 920 |
#define SKIP_TOKEN(X) {\ |
| 921 |
PRINT (X);\ |
| 922 |
skip_token_print ();\ |
| 923 |
goto Next_Token_Label;} |
| 924 |
#define SKIP_TOKEN2(X, Y) {\ |
| 925 |
PRINT2 (X, Y);\ |
| 926 |
skip_token_print ();\ |
| 927 |
goto Next_Token_Label;} |
| 928 |
|
| 929 |
/*************************************************************************** |
| 930 |
* WEB section number: 184 |
| 931 |
* ~~~~~~~~~~~~~~~~~~~ |
| 932 |
* This macro is similar to the last one but is specifically for |
| 933 |
* recursion in a |wiz_defined| function, which is illegal; it helps save |
| 934 |
* space. |
| 935 |
***************************************************************************/ |
| 936 |
#define SKIP_RECURSIVE_TOKEN { print_recursion_illegal (); \ |
| 937 |
goto Next_Token_Label;} |
| 938 |
|
| 939 |
/*************************************************************************** |
| 940 |
* WEB section number: 185 |
| 941 |
* ~~~~~~~~~~~~~~~~~~~ |
| 942 |
* Here's another macro for saving some space when there's a problem with |
| 943 |
* a token. |
| 944 |
***************************************************************************/ |
| 945 |
#define SKIP_TOKEN_UNKNOWN_FUNCTION {skp_token_unknown_function_prin ();\ |
| 946 |
goto Next_Token_Label;} |
| 947 |
|
| 948 |
/*************************************************************************** |
| 949 |
* WEB section number: 186 |
| 950 |
* ~~~~~~~~~~~~~~~~~~~ |
| 951 |
* And another. |
| 952 |
***************************************************************************/ |
| 953 |
#define SKIP_TOKEN_ILLEGAL_STUFF_AFTER {\ |
| 954 |
skip_illegal_stuff_after_token ();\ |
| 955 |
goto Next_Token_Label;} |
| 956 |
|
| 957 |
/*************************************************************************** |
| 958 |
* WEB section number: 194 |
| 959 |
* ~~~~~~~~~~~~~~~~~~~ |
| 960 |
* This module marks the implicit function as being quoted, generates a |
| 961 |
* name, and stores it in the hash table. This name is strictly internal |
| 962 |
* to this program, starts with a |single_quote| (since that will make |
| 963 |
* this function name unique), and ends with the variable |impl_fn_num| |
| 964 |
* converted to ASCII. The alias kludge helps make the stack space not |
| 965 |
* overflow on some machines. |
| 966 |
***************************************************************************/ |
| 967 |
#define EX_BUF2 ex_buf |
| 968 |
|
| 969 |
/*************************************************************************** |
| 970 |
* WEB section number: 197 |
| 971 |
* ~~~~~~~~~~~~~~~~~~~ |
| 972 |
* This module appends a character to |int_buf| after checking to make |
| 973 |
* sure it will fit; for use in |int_to_ASCII|. |
| 974 |
***************************************************************************/ |
| 975 |
#define APPEND_INT_CHAR(X) {\ |
| 976 |
if (int_ptr == Buf_Size)\ |
| 977 |
{ buffer_overflow ();}\ |
| 978 |
int_buf[int_ptr] = (X);\ |
| 979 |
INCR (int_ptr); } |
| 980 |
|
| 981 |
/*************************************************************************** |
| 982 |
* WEB section number: 216 |
| 983 |
* ~~~~~~~~~~~~~~~~~~~ |
| 984 |
* Here we insert the just found |int_global_var| name into the hash |
| 985 |
* table and record it as an |int_global_var|. Also, we initialize it by |
| 986 |
* setting |fn_info[fn_loc]| to 0. |
| 987 |
***************************************************************************/ |
| 988 |
#define END_OF_STRING INVALID_CODE |
| 989 |
|
| 990 |
/*************************************************************************** |
| 991 |
* WEB section number: 219 |
| 992 |
* ~~~~~~~~~~~~~~~~~~~ |
| 993 |
* These global variables are used ... |
| 994 |
***************************************************************************/ |
| 995 |
#define UNDEFINED (HASH_MAX + 1) |
| 996 |
|
| 997 |
/*************************************************************************** |
| 998 |
* WEB section number: 221 |
| 999 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1000 |
* When there's a serious error parsing a \.{.bib} file, we flush |
| 1001 |
* everything up to the beginning of the next entry. |
| 1002 |
***************************************************************************/ |
| 1003 |
#define BIB_ERR(X) {\ |
| 1004 |
PRINT (X);\ |
| 1005 |
bib_err_print ();\ |
| 1006 |
goto Exit_Label;} |
| 1007 |
#define BIB_ERR2(X, Y) {\ |
| 1008 |
PRINT2 (X, Y);\ |
| 1009 |
bib_err_print ();\ |
| 1010 |
goto Exit_Label;} |
| 1011 |
#define BIB_ERR3(X, Y, Z) {\ |
| 1012 |
PRINT3 (X, Y, Z);\ |
| 1013 |
bib_err_print ();\ |
| 1014 |
goto Exit_Label;} |
| 1015 |
|
| 1016 |
/*************************************************************************** |
| 1017 |
* WEB section number: 222 |
| 1018 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1019 |
* When there's a harmless error parsing a \.{.bib} file, we just give a |
| 1020 |
* warning message. This is always called after other stuff has been |
| 1021 |
* printed out. |
| 1022 |
***************************************************************************/ |
| 1023 |
#define BIB_WARN(X) {\ |
| 1024 |
PRINT (X);\ |
| 1025 |
bib_warn_print ();} |
| 1026 |
#define BIB_WARN_NEWLINE(X) {\ |
| 1027 |
PRINT_LN (X);\ |
| 1028 |
bib_warn_print ();} |
| 1029 |
|
| 1030 |
/*************************************************************************** |
| 1031 |
* WEB section number: 229 |
| 1032 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1033 |
* It's often illegal to end a \.{.bib} command in certain places, and |
| 1034 |
* this is where we come to check. |
| 1035 |
***************************************************************************/ |
| 1036 |
#define EAT_BIB_WHITE_AND_EOF_CHECK {\ |
| 1037 |
if (! eat_bib_white_space())\ |
| 1038 |
{eat_bib_print();\ |
| 1039 |
goto Exit_Label;}} |
| 1040 |
|
| 1041 |
/*************************************************************************** |
| 1042 |
* WEB section number: 230 |
| 1043 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1044 |
* And here are a bunch of error-message macros, each called more than |
| 1045 |
* once, that thus save space as implemented. This one is for when one |
| 1046 |
* of two possible characters is expected while scanning. |
| 1047 |
***************************************************************************/ |
| 1048 |
#define BIB_ONE_OF_TWO_EXPECTED_ERR(X, Y) {\ |
| 1049 |
bib_one_of_two_print (X, Y);\ |
| 1050 |
goto Exit_Label;} |
| 1051 |
|
| 1052 |
/*************************************************************************** |
| 1053 |
* WEB section number: 231 |
| 1054 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1055 |
* This one's for an unexpected equals sign. |
| 1056 |
***************************************************************************/ |
| 1057 |
#define BIB_EQUALS_SIGN_EXPECTED_ERR {\ |
| 1058 |
bib_equals_sign_print ();\ |
| 1059 |
goto Exit_Label;} |
| 1060 |
|
| 1061 |
/*************************************************************************** |
| 1062 |
* WEB section number: 232 |
| 1063 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1064 |
* This complains about unbalanced braces. |
| 1065 |
***************************************************************************/ |
| 1066 |
#define BIB_UNBALANCED_BRACES_ERR {\ |
| 1067 |
bib_unbalanced_braces_print ();\ |
| 1068 |
goto Exit_Label;} |
| 1069 |
|
| 1070 |
/*************************************************************************** |
| 1071 |
* WEB section number: 233 |
| 1072 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1073 |
* And this one about an overly exuberant field. |
| 1074 |
***************************************************************************/ |
| 1075 |
#define BIB_FIELD_TOO_LONG_ERR {\ |
| 1076 |
bib_field_too_long_print ();\ |
| 1077 |
goto Exit_Label;} |
| 1078 |
|
| 1079 |
/*************************************************************************** |
| 1080 |
* WEB section number: 234 |
| 1081 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1082 |
* This one is just a warning, not an error. It's for when something |
| 1083 |
* isn't (or might not be) quite right with a macro name. |
| 1084 |
***************************************************************************/ |
| 1085 |
#define MACRO_NAME_WARNING(X) {\ |
| 1086 |
macro_warn_print ();\ |
| 1087 |
BIB_WARN_NEWLINE (X);} |
| 1088 |
|
| 1089 |
/*************************************************************************** |
| 1090 |
* WEB section number: 235 |
| 1091 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1092 |
* This macro is used to scan all \.{.bib} identifiers. The argument |
| 1093 |
* tells what was happening at the time. The associated procedure simply |
| 1094 |
* prints an error message. |
| 1095 |
***************************************************************************/ |
| 1096 |
#define BIB_IDENTIFIER_SCAN_CHECK(X) {\ |
| 1097 |
if ((scan_result == WHITE_ADJACENT) \ |
| 1098 |
|| (scan_result == SPECIFIED_CHAR_ADJACENT)) {DO_NOTHING;}\ |
| 1099 |
else {bib_id_print(); BIB_ERR (X);}} |
| 1100 |
|
| 1101 |
/*************************************************************************** |
| 1102 |
* WEB section number: 247 |
| 1103 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1104 |
* The variables for the function |
| 1105 |
* |scan_and_store_the_field_value_and_eat_white| must be global since |
| 1106 |
* the functions it calls use them too. The alias kludge helps make the |
| 1107 |
* stack space not overflow on some machines. |
| 1108 |
***************************************************************************/ |
| 1109 |
#define FIELD_VL_STR ex_buf |
| 1110 |
#define FIELD_END ex_buf_ptr |
| 1111 |
#define FIELD_START ex_buf_xptr |
| 1112 |
|
| 1113 |
/*************************************************************************** |
| 1114 |
* WEB section number: 251 |
| 1115 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1116 |
* Now we come to the stuff that actually accumulates the field value to |
| 1117 |
* be stored. This module copies a character into |field_vl_str| if it |
| 1118 |
* will fit; since it's so low level, it's implemented as a macro. |
| 1119 |
***************************************************************************/ |
| 1120 |
#define COPY_CHAR(X) {\ |
| 1121 |
if (FIELD_END == Buf_Size)\ |
| 1122 |
{ BIB_FIELD_TOO_LONG_ERR; }\ |
| 1123 |
else\ |
| 1124 |
{ FIELD_VL_STR[FIELD_END] = (X);\ |
| 1125 |
INCR (FIELD_END);}} |
| 1126 |
|
| 1127 |
/*************************************************************************** |
| 1128 |
* WEB section number: 252 |
| 1129 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1130 |
* The \.{.bib}-specific scanning function |compress_bib_white| skips |
| 1131 |
* over |white_space| characters within a string until hitting a nonwhite |
| 1132 |
* character; in fact, it does everything |eat_bib_white_space| does, but |
| 1133 |
* it also adds a |space| to |field_vl_str|. This function is never |
| 1134 |
* called if there are no |white_space| characters (or ends-of-line) to |
| 1135 |
* be scanned (though the associated macro might be). The function |
| 1136 |
* returns |false| if there is a serious syntax error. |
| 1137 |
***************************************************************************/ |
| 1138 |
#define CHECK_FOR_AND_COMPRESS_BIB_WHIT {\ |
| 1139 |
if ((lex_class[SCAN_CHAR] == WHITE_SPACE) || (buf_ptr2 == last)){\ |
| 1140 |
if (! compress_bib_white ()) { goto Exit_Label;}}} |
| 1141 |
|
| 1142 |
/*************************************************************************** |
| 1143 |
* WEB section number: 264 |
| 1144 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1145 |
* If the cross-referenced entry isn't already on |cite_list| we add it |
| 1146 |
* (at least temporarily); if it is already on |cite_list| we update the |
| 1147 |
* cross-reference count, if necessary. Note that |all_entries| is |
| 1148 |
* |false| here. The alias kludge helps make the stack space not |
| 1149 |
* overflow on some machines. |
| 1150 |
***************************************************************************/ |
| 1151 |
#define EXTRA_BUF out_buf |
| 1152 |
|
| 1153 |
/*************************************************************************** |
| 1154 |
* WEB section number: 267 |
| 1155 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1156 |
* The lower-case version of this database key must correspond to one in |
| 1157 |
* |cite_list|, or else |all_entries| must be |true|, if this entry is to |
| 1158 |
* be included in the reference list. Accordingly, this module sets |
| 1159 |
* |store_entry|, which determines whether the relevant information for |
| 1160 |
* this entry is stored. The alias kludge helps make the stack space not |
| 1161 |
* overflow on some machines. |
| 1162 |
***************************************************************************/ |
| 1163 |
#define EX_BUF3 ex_buf |
| 1164 |
|
| 1165 |
/*************************************************************************** |
| 1166 |
* WEB section number: 270 |
| 1167 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1168 |
* This module, a simpler version of the |
| 1169 |
* |find_cite_locs_for_this_cite_key| function, exists primarily to |
| 1170 |
* compute |lc_xcite_loc|. When this code is executed we have |
| 1171 |
* |(all_entries) and (entry_cite_ptr >= all_marker) and (not |
| 1172 |
* entry_exists[entry_cite_ptr])|. The alias kludge helps make the stack |
| 1173 |
* space not overflow on some machines. |
| 1174 |
***************************************************************************/ |
| 1175 |
#define EX_BUF4 ex_buf |
| 1176 |
#define EX_BUF4_PTR ex_buf_ptr |
| 1177 |
|
| 1178 |
/*************************************************************************** |
| 1179 |
* WEB section number: 277 |
| 1180 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1181 |
* Occasionally we need to figure out the hash-table location of a given |
| 1182 |
* cite-key string and its lower-case equivalent. This function does |
| 1183 |
* that. To perform the task it needs to borrow a buffer, a need that |
| 1184 |
* gives rise to the alias kludge---it helps make the stack space not |
| 1185 |
* overflow on some machines (and while it's at it, it'll borrow a |
| 1186 |
* pointer, too). Finally, the function returns |true| if the cite key |
| 1187 |
* exists on |cite_list|, and its sets |cite_hash_found| according to |
| 1188 |
* whether or not it found the actual version (before |lower_case|ing) of |
| 1189 |
* the cite key; however, its {\sl raison d'\^$\mkern-8mu$etre\/} |
| 1190 |
* (literally, ``to eat a raisin'') is to compute |cite_loc| and |
| 1191 |
* |lc_cite_loc|. |
| 1192 |
***************************************************************************/ |
| 1193 |
#define EX_BUF5 ex_buf |
| 1194 |
#define EX_BUF5_PTR ex_buf_ptr |
| 1195 |
|
| 1196 |
/*************************************************************************** |
| 1197 |
* WEB section number: 289 |
| 1198 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1199 |
* The array |sorted_cites| initially specifies that the entries are to |
| 1200 |
* be processed in order of cite-key occurrence. The \.{sort} command |
| 1201 |
* may change this to whatever it likes (which, we hope, is whatever the |
| 1202 |
* style-designer instructs it to like). We make |sorted_cites| an alias |
| 1203 |
* to save space; this works fine because we're done with |cite_info|. |
| 1204 |
***************************************************************************/ |
| 1205 |
#define SORTED_CITES cite_info |
| 1206 |
|
| 1207 |
/*************************************************************************** |
| 1208 |
* WEB section number: 291 |
| 1209 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1210 |
* Where |lit_stk_loc| is a stack location, and where |stk_type| gives |
| 1211 |
* one of the three types of literals (an integer, a string, or a |
| 1212 |
* function) or a special marker. If a |lit_stk_type| element is a |
| 1213 |
* |stk_int| then the corresponding |lit_stack| element is an integer; if |
| 1214 |
* a |stk_str|, then a pointer to a |str_pool| string; and if a |stk_fn|, |
| 1215 |
* then a pointer to the function's hash-table location. However, if the |
| 1216 |
* literal should have been a |stk_str| that was the value of a field |
| 1217 |
* that happened to be |missing|, then the special value |
| 1218 |
* |stk_field_missing| goes on the stack instead; its corresponding |
| 1219 |
* |lit_stack| element is a pointer to the field-name's string. Finally, |
| 1220 |
* |stk_empty| is the type of a literal popped from an empty stack. |
| 1221 |
***************************************************************************/ |
| 1222 |
#define STK_INT 0 |
| 1223 |
#define STK_STR 1 |
| 1224 |
#define STK_FN 2 |
| 1225 |
#define STK_FIELD_MISSING 3 |
| 1226 |
#define STK_EMPTY 4 |
| 1227 |
#define LAST_LIT_TYPE 4 |
| 1228 |
|
| 1229 |
/*************************************************************************** |
| 1230 |
* WEB section number: 293 |
| 1231 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1232 |
* When there's an error while executing \.{.bst} functions, what we do |
| 1233 |
* depends on whether the function is messing with the entries. |
| 1234 |
* Furthermore this error is serious enough to classify as an |
| 1235 |
* |error_message| instead of a |warning_message|. These messages (that |
| 1236 |
* is, from |bst_ex_warn|) are meant both for the user and for the style |
| 1237 |
* designer while debugging. |
| 1238 |
***************************************************************************/ |
| 1239 |
#define BST_EX_WARN(X) {\ |
| 1240 |
PRINT (X); bst_ex_warn_print ();} |
| 1241 |
#define BST_EX_WARN2(X, Y) {\ |
| 1242 |
PRINT2 (X, Y); bst_ex_warn_print ();} |
| 1243 |
|
| 1244 |
/*************************************************************************** |
| 1245 |
* WEB section number: 294 |
| 1246 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1247 |
* When an error is so harmless, we print a warning message instead of an |
| 1248 |
* error message. |
| 1249 |
***************************************************************************/ |
| 1250 |
#define BST_MILD_EX_WARN(X) {\ |
| 1251 |
PRINT (X); bst_mild_ex_warn_print ();} |
| 1252 |
|
| 1253 |
/*************************************************************************** |
| 1254 |
* WEB section number: 301 |
| 1255 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1256 |
* The function |less_than| compares the two \.{sort.key\$}s indirectly |
| 1257 |
* pointed to by its arguments and returns |true| if the first argument's |
| 1258 |
* \.{sort.key\$} is lexicographically less than the second's (that is, |
| 1259 |
* alphabetically earlier). In case of ties the function compares the |
| 1260 |
* indices |arg1| and |arg2|, which are assumed to be different, and |
| 1261 |
* returns |true| if the first is smaller. This function uses |
| 1262 |
* |ASCII_code|s to compare, so it might give ``interesting'' results |
| 1263 |
* when handling nonletters. |
| 1264 |
***************************************************************************/ |
| 1265 |
#define COMPARE_RETURN(X) {\ |
| 1266 |
less_than = (X);\ |
| 1267 |
goto Exit_Label;} |
| 1268 |
|
| 1269 |
/*************************************************************************** |
| 1270 |
* WEB section number: 302 |
| 1271 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1272 |
* The recursive procedure |quick_sort| sorts ... |
| 1273 |
***************************************************************************/ |
| 1274 |
#define SHORT_LIST 10 |
| 1275 |
#define END_OFFSET 4 |
| 1276 |
|
| 1277 |
/*************************************************************************** |
| 1278 |
* WEB section number: 308 |
| 1279 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1280 |
* This macro pushes the last thing, necessarily a string, that was |
| 1281 |
* popped. And this module, along with others that push the literal |
| 1282 |
* stack without explicitly calling |push_lit_stack|, have an index entry |
| 1283 |
* under ``push the literal stack''; these implicit pushes collectively |
| 1284 |
* speed up the program by about ten percent. |
| 1285 |
***************************************************************************/ |
| 1286 |
#define REPUSH_STRING {\ |
| 1287 |
if (lit_stack[lit_stk_ptr] >= cmd_str_ptr)\ |
| 1288 |
{ UNFLUSH_STRING; }\ |
| 1289 |
INCR (lit_stk_ptr);} |
| 1290 |
|
| 1291 |
/*************************************************************************** |
| 1292 |
* WEB section number: 319 |
| 1293 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1294 |
* These macros append a character to |ex_buf|. Which is called depends |
| 1295 |
* on whether the character is known to fit. |
| 1296 |
***************************************************************************/ |
| 1297 |
#define APPEND_EX_BUF_CHAR(X) {\ |
| 1298 |
ex_buf[ex_buf_ptr] = (X);\ |
| 1299 |
INCR(ex_buf_ptr);} |
| 1300 |
#define APPEND_EX_BUF_CHAR_AND_CHECK(X) {\ |
| 1301 |
if (ex_buf_ptr == Buf_Size) {buffer_overflow ();}; \ |
| 1302 |
APPEND_EX_BUF_CHAR(X)} |
| 1303 |
|
| 1304 |
/*************************************************************************** |
| 1305 |
* WEB section number: 333 |
| 1306 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1307 |
* These constants all begin with |n_| and are used for the |case| |
| 1308 |
* statement that determines which |built_in| function to execute. |
| 1309 |
***************************************************************************/ |
| 1310 |
#define N_EQUALS 0 |
| 1311 |
#define N_GREATER_THAN 1 |
| 1312 |
#define N_LESS_THAN 2 |
| 1313 |
#define N_PLUS 3 |
| 1314 |
#define N_MINUS 4 |
| 1315 |
#define N_CONCATENATE 5 |
| 1316 |
#define N_GETS 6 |
| 1317 |
#define N_ADD_PERIOD 7 |
| 1318 |
#define N_CALL_TYPE 8 |
| 1319 |
#define N_CHANGE_CASE 9 |
| 1320 |
#define N_CHR_TO_INT 10 |
| 1321 |
#define N_CITE 11 |
| 1322 |
#define N_DUPLICATE 12 |
| 1323 |
#define N_EMPTY 13 |
| 1324 |
#define N_FORMAT_NAME 14 |
| 1325 |
#define N_IF 15 |
| 1326 |
#define N_INT_TO_CHR 16 |
| 1327 |
#define N_INT_TO_STR 17 |
| 1328 |
#define N_MISSING 18 |
| 1329 |
#define N_NEWLINE 19 |
| 1330 |
#define N_NUM_NAMES 20 |
| 1331 |
#define N_POP 21 |
| 1332 |
#define N_PREAMBLE 22 |
| 1333 |
#define N_PURIFY 23 |
| 1334 |
#define N_QUOTE 24 |
| 1335 |
#define N_SKIP 25 |
| 1336 |
#define N_STACK 26 |
| 1337 |
#define N_SUBSTRING 27 |
| 1338 |
#define N_SWAP 28 |
| 1339 |
#define N_TEXT_LENGTH 29 |
| 1340 |
#define N_TEXT_PREFIX 30 |
| 1341 |
#define N_TOP_STACK 31 |
| 1342 |
#define N_TYPE 32 |
| 1343 |
#define N_WARNING 33 |
| 1344 |
#define N_WHILE 34 |
| 1345 |
#define N_WIDTH 35 |
| 1346 |
#define N_WRITE 36 |
| 1347 |
#define N_BIT_AND 37 |
| 1348 |
#define N_BIT_OR 38 |
| 1349 |
#ifdef UTF_8 |
| 1350 |
#define N_IS_CJK_STRING 39 |
| 1351 |
#define NUM_BLT_IN_FNS 40 |
| 1352 |
#else |
| 1353 |
#define NUM_BLT_IN_FNS 39 |
| 1354 |
#endif |
| 1355 |
|
| 1356 |
/*************************************************************************** |
| 1357 |
* WEB section number: 338 |
| 1358 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1359 |
* These constants all begin with |n_| and are used for the |case| |
| 1360 |
* statement that determines which, if any, control sequence we're |
| 1361 |
* dealing with; a control sequence of interest will be either one of the |
| 1362 |
* undotted characters `\.{\\i}' or `\.{\\j}' or one of the foreign |
| 1363 |
* characters in Table~3.2 of the \LaTeX\ manual. |
| 1364 |
***************************************************************************/ |
| 1365 |
#define N_I 0 |
| 1366 |
#define N_J 1 |
| 1367 |
#define N_OE 2 |
| 1368 |
#define N_OE_UPPER 3 |
| 1369 |
#define N_AE 4 |
| 1370 |
#define N_AE_UPPER 5 |
| 1371 |
#define N_AA 6 |
| 1372 |
#define N_AA_UPPER 7 |
| 1373 |
#define N_O 8 |
| 1374 |
#define N_O_UPPER 9 |
| 1375 |
#define N_L 10 |
| 1376 |
#define N_L_UPPER 11 |
| 1377 |
#define N_SS 12 |
| 1378 |
|
| 1379 |
/*************************************************************************** |
| 1380 |
* WEB section number: 344 |
| 1381 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1382 |
* These are nonrecursive variables that |execute_fn| uses. Declaring |
| 1383 |
* them here (instead of in the previous module) saves execution time and |
| 1384 |
* stack space on most machines. |
| 1385 |
***************************************************************************/ |
| 1386 |
#define NAME_BUF sv_buffer |
| 1387 |
|
| 1388 |
/*************************************************************************** |
| 1389 |
* WEB section number: 356 |
| 1390 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1391 |
* It's time for a complaint if either of the two (entry or global) string |
| 1392 |
* lengths is exceeded. |
| 1393 |
***************************************************************************/ |
| 1394 |
#define BST_STRING_SIZE_EXCEEDED(X, Y) {\ |
| 1395 |
bst_1print_string_size_exceeded ();\ |
| 1396 |
PRINT3 ("%ld%s", (long) (X), Y);\ |
| 1397 |
bst_2print_string_size_exceeded ();} |
| 1398 |
|
| 1399 |
/*************************************************************************** |
| 1400 |
* WEB section number: 365 |
| 1401 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1402 |
* First we define a few variables for case conversion. The constant |
| 1403 |
* definitions, to be used in |case| statements, are in order of probable |
| 1404 |
* frequency. |
| 1405 |
***************************************************************************/ |
| 1406 |
#define TITLE_LOWERS 0 |
| 1407 |
#define ALL_LOWERS 1 |
| 1408 |
#define ALL_UPPERS 2 |
| 1409 |
#define BAD_CONVERSION 3 |
| 1410 |
|
| 1411 |
/*************************************************************************** |
| 1412 |
* WEB section number: 397 |
| 1413 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1414 |
* It's a von token if there exists a first brace-level-0 letter (or |
| 1415 |
* brace-level-1 special character), and it's in lower case; in this case |
| 1416 |
* we return |true|. The token is in |name_buf|, starting at |
| 1417 |
* |name_bf_ptr| and ending just before |name_bf_xptr|. |
| 1418 |
***************************************************************************/ |
| 1419 |
#define RETURN_VON_FOUND {\ |
| 1420 |
von_token_found = TRUE;\ |
| 1421 |
goto Exit_Label;} |
| 1422 |
|
| 1423 |
/*************************************************************************** |
| 1424 |
* WEB section number: 417 |
| 1425 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1426 |
* Here we output either the \.{.bst} given string if it exists, or else |
| 1427 |
* the \.{.bib} |sep_char| if it exists, or else the default string. A |
| 1428 |
* |tie| is the default space character between the last two tokens of |
| 1429 |
* the name part, and between the first two tokens if the first token is |
| 1430 |
* short enough; otherwise, a |space| is the default. |
| 1431 |
***************************************************************************/ |
| 1432 |
#define LONG_TOKEN 3 |
| 1433 |
|
| 1434 |
/*************************************************************************** |
| 1435 |
* WEB section number: 419 |
| 1436 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1437 |
* If the last character output for this name part is a |tie| but the |
| 1438 |
* previous character it isn't, we're dealing with a discretionary |tie|; |
| 1439 |
* thus we replace it by a |space| if there are enough characters in the |
| 1440 |
* rest of the name part. |
| 1441 |
***************************************************************************/ |
| 1442 |
#define LONG_NAME 3 |
| 1443 |
|
| 1444 |
/*************************************************************************** |
| 1445 |
* WEB section number: 465 |
| 1446 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1447 |
* These statistics can help determine how large some of the constants |
| 1448 |
* should be and can tell how useful certain |built_in| functions are. |
| 1449 |
* They are written to the same files as tracing information. |
| 1450 |
***************************************************************************/ |
| 1451 |
#define STAT_PR TRACE_PR |
| 1452 |
#define STAT_PR2 TRACE_PR2 |
| 1453 |
#define STAT_PR3 TRACE_PR3 |
| 1454 |
|
| 1455 |
#define STAT_PR_LN TRACE_PR_LN |
| 1456 |
#define STAT_PR_LN2 TRACE_PR_LN2 |
| 1457 |
#define STAT_PR_LN3 TRACE_PR_LN3 |
| 1458 |
|
| 1459 |
#define STAT_PR_POOL_STR TRACE_PR_POOL_STR |
| 1460 |
|
| 1461 |
|
| 1462 |
/*************************************************************************** |
| 1463 |
* WEB section number: N/A |
| 1464 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1465 |
* C isn't very good at declaring two dimensional arrays whose sizes are |
| 1466 |
* determined at run time. Here we create a useful macro to simulate |
| 1467 |
* accessing a 2D array by converting the row/col into an offset from the |
| 1468 |
* beginning of a 1D array. |
| 1469 |
***************************************************************************/ |
| 1470 |
#define ENTRY_STRS(_r,_c) entry_strs[(_r * (Ent_Str_Size+1)) + _c] |
| 1471 |
#define GLOBAL_STRS(_r,_c) global_strs[(_r * (Glob_Str_Size+1)) + _c] |
| 1472 |
|
| 1473 |
|
| 1474 |
/*************************************************************************** |
| 1475 |
* WEB section number: N/A |
| 1476 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1477 |
* Define a macro to handle 1-, 2-, 3-, and 4-byte UTF-8 codes. |
| 1478 |
***************************************************************************/ |
| 1479 |
#define DO_UTF8(ch, do_1, do_2, do_3, do_4) \ |
| 1480 |
if (ch <= 0x7F) { do_1; } \ |
| 1481 |
else if ((ch >= 0xC2) && (ch <= 0xDF)) { do_2; } \ |
| 1482 |
else if ((ch >= 0xE0) && (ch <= 0xEF)) { do_3; } \ |
| 1483 |
else if ((ch >= 0xF0) && (ch <= 0xF4)) { do_4; } \ |
| 1484 |
else printf("this (%x) isn't a right UTF-8 char!\n", ch) |
| 1485 |
|
| 1486 |
|
| 1487 |
/*************************************************************************** |
| 1488 |
* WEB section number: N/A |
| 1489 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1490 |
* Macros adapted from Kpathsea (lib.h) and Web2C (cpascal.h) to dynamically |
| 1491 |
* resize arrays. |
| 1492 |
***************************************************************************/ |
| 1493 |
/* Reallocate N items of type T for ARRAY using myrealloc. */ |
| 1494 |
#define MYRETALLOC(array, addr, n, t) ((addr) = (t *) myrealloc(addr, (n) * sizeof(t), array)) |
| 1495 |
/* BibTeX needs this to dynamically reallocate arrays. Too bad we can't |
| 1496 |
rely on stringification, or we could avoid the ARRAY_NAME arg. |
| 1497 |
Actually allocate one more than requests, so we can index the last |
| 1498 |
entry, as Pascal wants to do. */ |
| 1499 |
#define BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size) \ |
| 1500 |
if (log_file != NULL)\ |
| 1501 |
fprintf (log_file, "Reallocated %s (elt_size=%d) to %ld items from %ld.\n", \ |
| 1502 |
array_name, (int) sizeof (type), new_size, size_var); \ |
| 1503 |
MYRETALLOC (array_name, array_var, new_size + 1, type) |
| 1504 |
/* Same as above, but also increase SIZE_VAR for the last (or only) array. */ |
| 1505 |
#define BIB_XRETALLOC(array_name, array_var, type, size_var, new_size) do { \ |
| 1506 |
BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size); \ |
| 1507 |
size_var = new_size; \ |
| 1508 |
} while (0) |
| 1509 |
/* Same as above, but for the pseudo-TYPE ASCIICode_T[LENGTH+1]. */ |
| 1510 |
#define BIB_XRETALLOC_STRING(array_name, array_var, length, size_var, new_size) \ |
| 1511 |
if (log_file != NULL)\ |
| 1512 |
fprintf (log_file, "Reallocated %s (elt_size=%d) to %ld items from %ld.\n", \ |
| 1513 |
array_name, (int) (length + 1), new_size, size_var); \ |
| 1514 |
MYRETALLOC (array_name, array_var, (new_size) * (length + 1), ASCIICode_T) |
| 1515 |
|
| 1516 |
#endif /* __BIBTEX_H__ */ |
| 1517 |
|