| 1 |
/*- |
| 2 |
****************************************************************************** |
| 3 |
****************************************************************************** |
| 4 |
** |
| 5 |
** MODULE |
| 6 |
** |
| 7 |
** file: bibtex-4.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 fourth 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 |
** x_change_case |
| 30 |
** x_chr_to_int |
| 31 |
** x_cite |
| 32 |
** x_concatenate |
| 33 |
** x_duplicate |
| 34 |
** x_empty |
| 35 |
** x_equals |
| 36 |
** x_format_name |
| 37 |
** x_gets |
| 38 |
** x_greater_than |
| 39 |
** x_int_to_chr |
| 40 |
** x_int_to_str |
| 41 |
** x_less_than |
| 42 |
** x_minus |
| 43 |
** x_missing |
| 44 |
** x_num_names |
| 45 |
** x_plus |
| 46 |
** x_preamble |
| 47 |
** x_purify |
| 48 |
** x_quote |
| 49 |
** x_substring |
| 50 |
** x_swap |
| 51 |
** x_text_length |
| 52 |
** x_text_prefix |
| 53 |
** x_type |
| 54 |
** x_warning |
| 55 |
** x_width |
| 56 |
** x_write |
| 57 |
** |
| 58 |
** AUTHORS |
| 59 |
** |
| 60 |
** Original WEB translation to C, conversion to "big" (32-bit) capacity, |
| 61 |
** addition of run-time selectable capacity and 8-bit support extensions |
| 62 |
** by: |
| 63 |
** |
| 64 |
** Niel Kempson |
| 65 |
** Snowy Owl Systems Limited, Cheltenham, England |
| 66 |
** E-mail: [email protected] |
| 67 |
** |
| 68 |
** 8-bit support extensions also by: |
| 69 |
** |
| 70 |
** Alejandro Aguilar-Sierra |
| 71 |
** Centro de Ciencias de la Atm\'osfera, |
| 72 |
** Universidad Nacional Aut\'onoma de M\'exico, M\'exico |
| 73 |
** E-mail: [email protected] |
| 74 |
** |
| 75 |
** COPYRIGHT |
| 76 |
** |
| 77 |
** This implementation copyright (c) 1991-1995 by Niel Kempson |
| 78 |
** and copyright (c) 1995 by Alejandro Aguilar-Sierra. |
| 79 |
** |
| 80 |
** This program is free software; you can redistribute it and/or |
| 81 |
** modify it under the terms of the GNU General Public License as |
| 82 |
** published by the Free Software Foundation; either version 1, or |
| 83 |
** (at your option) any later version. |
| 84 |
** |
| 85 |
** This program is distributed in the hope that it will be useful, |
| 86 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 87 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 88 |
** General Public License for more details. |
| 89 |
** |
| 90 |
** You should have received a copy of the GNU General Public License |
| 91 |
** along with this program; if not, write to the Free Software |
| 92 |
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 93 |
** |
| 94 |
** In other words, you are welcome to use, share and improve this |
| 95 |
** program. You are forbidden to forbid anyone else to use, share |
| 96 |
** and improve what you give them. Help stamp out software-hoarding! |
| 97 |
** |
| 98 |
** ACKNOWLEDGEMENT |
| 99 |
** |
| 100 |
** The original BibTeX was written by Oren Patashnik using Donald |
| 101 |
** Knuth's WEB system. This format produces a PASCAL program for |
| 102 |
** execution and a TeX documented version of the source code. This |
| 103 |
** program started as a (manual) translation of the WEB source into C. |
| 104 |
** |
| 105 |
** CHANGE LOG |
| 106 |
** |
| 107 |
** $Log: bibtex-4.c,v $ |
| 108 |
** Revision 3.71 1996/08/18 20:47:30 kempson |
| 109 |
** Official release 3.71 (see HISTORY file for details). |
| 110 |
** |
| 111 |
** Revision 3.70 1996/04/08 10:08:40 kempson |
| 112 |
** Final documentation & cosmetic changes for official release 3.70. |
| 113 |
** |
| 114 |
** Revision 3.5 1995/09/24 20:44:37 kempson |
| 115 |
** Many changes for final beta test version. |
| 116 |
** |
| 117 |
** Revision 3.4 1995/04/09 22:15:41 kempson |
| 118 |
** Placed under RCS control |
| 119 |
** |
| 120 |
****************************************************************************** |
| 121 |
****************************************************************************** |
| 122 |
*/ |
| 123 |
|
| 124 |
#ifdef HAVE_CONFIG_H |
| 125 |
#include <config.h> |
| 126 |
#endif |
| 127 |
|
| 128 |
#include "sysdep.h" |
| 129 |
#include "bibtex.h" |
| 130 |
#include "datatype.h" |
| 131 |
#include "gblprocs.h" |
| 132 |
#include "gblvars.h" |
| 133 |
#include "utils.h" |
| 134 |
#include "version.h" |
| 135 |
|
| 136 |
|
| 137 |
/*************************************************************************** |
| 138 |
* WEB section number: 364 |
| 139 |
* ~~~~~~~~~~~~~~~~~~~ |
| 140 |
* The |built_in| function change.case$ pops the top two (string) |
| 141 |
* literals; it changes the case of the second according to the |
| 142 |
* specifications of the first, as follows. (Note: The word `letters' in |
| 143 |
* the next sentence refers only to those at brace-level~0, the top-most |
| 144 |
* brace level; no other characters are changed, except perhaps for |
| 145 |
* special characters, described shortly.) If the first literal is the |
| 146 |
* string t, it converts to lower case all letters except the very |
| 147 |
* first character in the string, which it leaves alone, and except the |
| 148 |
* first character following any |colon| and then nonnull |white_space|, |
| 149 |
* which it also leaves alone; if it's the string l, it converts all |
| 150 |
* letters to lower case; if it's the string u, it converts all |
| 151 |
* letters to upper case; and if it's anything else, it complains and |
| 152 |
* does no conversion. It then pushes this resulting string. If either |
| 153 |
* type is incorrect, it complains and pushes the null string; however, |
| 154 |
* if both types are correct but the specification string (i.e., the |
| 155 |
* first string) isn't one of the legal ones, it merely pushes the second |
| 156 |
* back onto the stack, after complaining. (Another note: It ignores |
| 157 |
* case differences in the specification string; for example, the strings |
| 158 |
* t and T are equivalent for the purposes of this |built_in| |
| 159 |
* function.) |
| 160 |
***************************************************************************/ |
| 161 |
void x_change_case (void) |
| 162 |
BEGIN |
| 163 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 164 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 165 |
if (pop_typ1 != STK_STR) |
| 166 |
BEGIN |
| 167 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 168 |
push_lit_stk (s_null, STK_STR); |
| 169 |
END |
| 170 |
else if (pop_typ2 != STK_STR) |
| 171 |
BEGIN |
| 172 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); |
| 173 |
push_lit_stk (s_null, STK_STR); |
| 174 |
END |
| 175 |
else |
| 176 |
BEGIN |
| 177 |
|
| 178 |
/*************************************************************************** |
| 179 |
* WEB section number: 366 |
| 180 |
* ~~~~~~~~~~~~~~~~~~~ |
| 181 |
* First we define a few variables for case conversion. The constant |
| 182 |
* definitions, to be used in |case| statements, are in order of probable |
| 183 |
* frequency. |
| 184 |
***************************************************************************/ |
| 185 |
BEGIN |
| 186 |
switch (str_pool[str_start[pop_lit1]]) |
| 187 |
BEGIN |
| 188 |
case 't': |
| 189 |
case 'T': |
| 190 |
conversion_type = TITLE_LOWERS; |
| 191 |
break; |
| 192 |
case 'l': |
| 193 |
case 'L': |
| 194 |
conversion_type = ALL_LOWERS; |
| 195 |
break; |
| 196 |
case 'u': |
| 197 |
case 'U': |
| 198 |
conversion_type = ALL_UPPERS; |
| 199 |
break; |
| 200 |
default: |
| 201 |
conversion_type = BAD_CONVERSION; |
| 202 |
break; |
| 203 |
END |
| 204 |
if ((LENGTH (pop_lit1) != 1) || (conversion_type == BAD_CONVERSION)) |
| 205 |
BEGIN |
| 206 |
conversion_type = BAD_CONVERSION; |
| 207 |
PRINT_POOL_STR (pop_lit1); |
| 208 |
BST_EX_WARN (" is an illegal case-conversion string"); |
| 209 |
END |
| 210 |
END |
| 211 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 366 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 212 |
|
| 213 |
ex_buf_length = 0; |
| 214 |
add_buf_pool (pop_lit2); |
| 215 |
|
| 216 |
/*************************************************************************** |
| 217 |
* WEB section number: 370 |
| 218 |
* ~~~~~~~~~~~~~~~~~~~ |
| 219 |
* Here's where we actually go through the string and do the case |
| 220 |
* conversion. |
| 221 |
***************************************************************************/ |
| 222 |
BEGIN |
| 223 |
brace_level = 0; |
| 224 |
ex_buf_ptr = 0; |
| 225 |
while (ex_buf_ptr < ex_buf_length) |
| 226 |
BEGIN |
| 227 |
if (ex_buf[ex_buf_ptr] == LEFT_BRACE) |
| 228 |
BEGIN |
| 229 |
INCR (brace_level); |
| 230 |
if (brace_level != 1) |
| 231 |
BEGIN |
| 232 |
goto OK_Pascal_I_Give_Up_Label; |
| 233 |
END |
| 234 |
if ((ex_buf_ptr + 4) > ex_buf_length) |
| 235 |
BEGIN |
| 236 |
goto OK_Pascal_I_Give_Up_Label; |
| 237 |
END |
| 238 |
else if (ex_buf[ex_buf_ptr + 1] != BACKSLASH) |
| 239 |
BEGIN |
| 240 |
goto OK_Pascal_I_Give_Up_Label; |
| 241 |
END |
| 242 |
if (conversion_type == TITLE_LOWERS) |
| 243 |
BEGIN |
| 244 |
if (ex_buf_ptr == 0) |
| 245 |
BEGIN |
| 246 |
goto OK_Pascal_I_Give_Up_Label; |
| 247 |
END |
| 248 |
else if ((prev_colon) |
| 249 |
&& (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE)) |
| 250 |
BEGIN |
| 251 |
goto OK_Pascal_I_Give_Up_Label; |
| 252 |
END |
| 253 |
END |
| 254 |
|
| 255 |
/*************************************************************************** |
| 256 |
* WEB section number: 371 |
| 257 |
* ~~~~~~~~~~~~~~~~~~~ |
| 258 |
* We're dealing with a special character (usually either an undotted |
| 259 |
* `\i' or `\j', or an accent like one in Table~3.1 of the \LaTeX\ |
| 260 |
* manual, or a foreign character like one in Table~3.2) if the first |
| 261 |
* character after the |left_brace| is a |backslash|; the special |
| 262 |
* character ends with the matching |right_brace|. How we handle what's |
| 263 |
* in between depends on the special character. In general, this code |
| 264 |
* will do reasonably well if there is other stuff, too, between braces, |
| 265 |
* but it doesn't try to do anything special with |colon|s. |
| 266 |
***************************************************************************/ |
| 267 |
BEGIN |
| 268 |
INCR (ex_buf_ptr); |
| 269 |
while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)) |
| 270 |
BEGIN |
| 271 |
INCR (ex_buf_ptr); |
| 272 |
ex_buf_xptr = ex_buf_ptr; |
| 273 |
while ((ex_buf_ptr < ex_buf_length) |
| 274 |
&& (lex_class[ex_buf[ex_buf_ptr]] == ALPHA)) |
| 275 |
BEGIN |
| 276 |
INCR (ex_buf_ptr); |
| 277 |
END |
| 278 |
control_seq_loc = str_lookup (ex_buf, ex_buf_xptr, |
| 279 |
ex_buf_ptr - ex_buf_xptr, |
| 280 |
CONTROL_SEQ_ILK, DONT_INSERT); |
| 281 |
if (hash_found) |
| 282 |
|
| 283 |
/*************************************************************************** |
| 284 |
* WEB section number: 372 |
| 285 |
* ~~~~~~~~~~~~~~~~~~~ |
| 286 |
* A control sequence, for the purposes of this program, consists just of |
| 287 |
* the consecutive alphabetic characters following the |backslash|; it |
| 288 |
* might be empty (although ones in this section aren't). |
| 289 |
***************************************************************************/ |
| 290 |
BEGIN |
| 291 |
switch (conversion_type) |
| 292 |
BEGIN |
| 293 |
case TITLE_LOWERS: |
| 294 |
case ALL_LOWERS: |
| 295 |
switch (ilk_info[control_seq_loc]) |
| 296 |
BEGIN |
| 297 |
case N_L_UPPER: |
| 298 |
case N_O_UPPER: |
| 299 |
case N_OE_UPPER: |
| 300 |
case N_AE_UPPER: |
| 301 |
case N_AA_UPPER: |
| 302 |
Lower_case (ex_buf, ex_buf_xptr, |
| 303 |
ex_buf_ptr - ex_buf_xptr); |
| 304 |
break; |
| 305 |
default: |
| 306 |
DO_NOTHING; |
| 307 |
break; |
| 308 |
END |
| 309 |
break; |
| 310 |
case ALL_UPPERS: |
| 311 |
switch (ilk_info[control_seq_loc]) |
| 312 |
BEGIN |
| 313 |
case N_L: |
| 314 |
case N_O: |
| 315 |
case N_OE: |
| 316 |
case N_AE: |
| 317 |
case N_AA: |
| 318 |
upper_case (ex_buf, ex_buf_xptr, |
| 319 |
ex_buf_ptr - ex_buf_xptr); |
| 320 |
break; |
| 321 |
case N_I: |
| 322 |
case N_J: |
| 323 |
case N_SS: |
| 324 |
|
| 325 |
/*************************************************************************** |
| 326 |
* WEB section number: 374 |
| 327 |
* ~~~~~~~~~~~~~~~~~~~ |
| 328 |
* After converting the control sequence, we need to remove the preceding |
| 329 |
* |backslash| and any following |white_space|. |
| 330 |
***************************************************************************/ |
| 331 |
BEGIN |
| 332 |
upper_case (ex_buf, ex_buf_xptr, |
| 333 |
ex_buf_ptr - ex_buf_xptr); |
| 334 |
while (ex_buf_xptr < ex_buf_ptr) |
| 335 |
BEGIN |
| 336 |
ex_buf[ex_buf_xptr - 1] = ex_buf[ex_buf_xptr]; |
| 337 |
INCR (ex_buf_xptr); |
| 338 |
END |
| 339 |
DECR (ex_buf_xptr); |
| 340 |
while ((ex_buf_ptr < ex_buf_length) |
| 341 |
&& (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE)) |
| 342 |
BEGIN |
| 343 |
INCR (ex_buf_ptr); |
| 344 |
END |
| 345 |
tmp_ptr = ex_buf_ptr; |
| 346 |
while (tmp_ptr < ex_buf_length) |
| 347 |
BEGIN |
| 348 |
ex_buf[tmp_ptr - (ex_buf_ptr - ex_buf_xptr)] |
| 349 |
= ex_buf[tmp_ptr]; |
| 350 |
INCR (tmp_ptr); |
| 351 |
END |
| 352 |
ex_buf_length = tmp_ptr - (ex_buf_ptr - ex_buf_xptr); |
| 353 |
ex_buf_ptr = ex_buf_xptr; |
| 354 |
END |
| 355 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 374 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 356 |
|
| 357 |
break; |
| 358 |
default: |
| 359 |
DO_NOTHING; |
| 360 |
break; |
| 361 |
END |
| 362 |
break; |
| 363 |
case BAD_CONVERSION: |
| 364 |
DO_NOTHING; |
| 365 |
break; |
| 366 |
default: |
| 367 |
case_conversion_confusion (); |
| 368 |
break; |
| 369 |
END |
| 370 |
END |
| 371 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 372 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 372 |
|
| 373 |
ex_buf_xptr = ex_buf_ptr; |
| 374 |
while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0) |
| 375 |
&& (ex_buf[ex_buf_ptr] != BACKSLASH)) |
| 376 |
BEGIN |
| 377 |
if (ex_buf[ex_buf_ptr] == RIGHT_BRACE) |
| 378 |
BEGIN |
| 379 |
DECR (brace_level); |
| 380 |
END |
| 381 |
else if (ex_buf[ex_buf_ptr] == LEFT_BRACE) |
| 382 |
BEGIN |
| 383 |
INCR (brace_level); |
| 384 |
END |
| 385 |
INCR (ex_buf_ptr); |
| 386 |
END |
| 387 |
|
| 388 |
/*************************************************************************** |
| 389 |
* WEB section number: 375 |
| 390 |
* ~~~~~~~~~~~~~~~~~~~ |
| 391 |
* There are no control sequences in what we're about to convert, |
| 392 |
* so a straight conversion suffices. |
| 393 |
***************************************************************************/ |
| 394 |
switch (conversion_type) |
| 395 |
BEGIN |
| 396 |
case TITLE_LOWERS: |
| 397 |
case ALL_LOWERS: |
| 398 |
Lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); |
| 399 |
break; |
| 400 |
case ALL_UPPERS: |
| 401 |
upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); |
| 402 |
break; |
| 403 |
case BAD_CONVERSION: |
| 404 |
DO_NOTHING; |
| 405 |
break; |
| 406 |
default: |
| 407 |
case_conversion_confusion (); |
| 408 |
break; |
| 409 |
END |
| 410 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 375 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 411 |
|
| 412 |
END |
| 413 |
DECR (ex_buf_ptr); |
| 414 |
END |
| 415 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 371 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 416 |
|
| 417 |
OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; |
| 418 |
END |
| 419 |
else if (ex_buf[ex_buf_ptr] == RIGHT_BRACE) |
| 420 |
BEGIN |
| 421 |
decr_brace_level (pop_lit2); |
| 422 |
prev_colon = FALSE; |
| 423 |
END |
| 424 |
else if (brace_level == 0) |
| 425 |
|
| 426 |
/*************************************************************************** |
| 427 |
* WEB section number: 376 |
| 428 |
* ~~~~~~~~~~~~~~~~~~~ |
| 429 |
* This code does any needed conversion for an ordinary character; it |
| 430 |
* won't touch nonletters. |
| 431 |
***************************************************************************/ |
| 432 |
BEGIN |
| 433 |
switch (conversion_type) |
| 434 |
BEGIN |
| 435 |
case TITLE_LOWERS: |
| 436 |
if (ex_buf_ptr == 0) |
| 437 |
BEGIN |
| 438 |
#ifdef UTF_8 |
| 439 |
/* |
| 440 |
For the case of TITLE_LOWERS, we transform the characters to low case except the first |
| 441 |
character. When it's UTF-8, we should care about the length of charater. 23/sep/2009 |
| 442 |
*/ |
| 443 |
DO_UTF8(ex_buf[ex_buf_ptr], , ex_buf_ptr = 1, ex_buf_ptr = 2, ex_buf_ptr = 3); |
| 444 |
#else |
| 445 |
DO_NOTHING; |
| 446 |
#endif |
| 447 |
END |
| 448 |
else if ((prev_colon) |
| 449 |
&& (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE)) |
| 450 |
BEGIN |
| 451 |
DO_NOTHING; |
| 452 |
END |
| 453 |
else |
| 454 |
BEGIN |
| 455 |
#ifdef UTF_8 |
| 456 |
/* |
| 457 |
When we do lower_case_uni, the length of string have been changed. So we should do some job |
| 458 |
for the precessing after lower case. Here there may be some potential bug. 23/sep/2009 |
| 459 |
*/ |
| 460 |
int16_t llen; |
| 461 |
|
| 462 |
llen=utf8len(ex_buf[ex_buf_ptr]); |
| 463 |
ex_buf_ptr=ex_buf_ptr+lower_case_uni (ex_buf, ex_buf_ptr, llen)-1; |
| 464 |
#else |
| 465 |
lower_case (ex_buf, ex_buf_ptr, 1); |
| 466 |
#endif |
| 467 |
END |
| 468 |
if (ex_buf[ex_buf_ptr] == COLON) |
| 469 |
BEGIN |
| 470 |
prev_colon = TRUE; |
| 471 |
END |
| 472 |
else if (lex_class[ex_buf[ex_buf_ptr]] != WHITE_SPACE) |
| 473 |
BEGIN |
| 474 |
prev_colon = FALSE; |
| 475 |
END |
| 476 |
break; |
| 477 |
case ALL_LOWERS: |
| 478 |
#ifdef UTF_8 |
| 479 |
/* |
| 480 |
Here the same for processing the length of string after change case. 23/sep/2009 |
| 481 |
*/ |
| 482 |
BEGIN |
| 483 |
int16_t llen; |
| 484 |
|
| 485 |
llen=utf8len(ex_buf[ex_buf_ptr]); |
| 486 |
ex_buf_ptr=ex_buf_ptr+lower_case_uni (ex_buf, ex_buf_ptr, llen)-1; |
| 487 |
END |
| 488 |
#else |
| 489 |
lower_case (ex_buf, ex_buf_ptr, 1); |
| 490 |
#endif |
| 491 |
break; |
| 492 |
case ALL_UPPERS: |
| 493 |
#ifdef UTF_8 |
| 494 |
/* |
| 495 |
Here the same for processing the length of string after change case. 23/sep/2009 |
| 496 |
*/ |
| 497 |
BEGIN |
| 498 |
int16_t ulen; |
| 499 |
|
| 500 |
ulen=utf8len(ex_buf[ex_buf_ptr]); |
| 501 |
ex_buf_ptr=ex_buf_ptr+upper_case_uni (ex_buf, ex_buf_ptr, ulen)-1; |
| 502 |
END |
| 503 |
#else |
| 504 |
upper_case (ex_buf, ex_buf_ptr, 1); |
| 505 |
#endif |
| 506 |
break; |
| 507 |
case BAD_CONVERSION: |
| 508 |
DO_NOTHING; |
| 509 |
break; |
| 510 |
default: |
| 511 |
case_conversion_confusion (); |
| 512 |
break; |
| 513 |
END |
| 514 |
END |
| 515 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 376 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 516 |
|
| 517 |
INCR (ex_buf_ptr); |
| 518 |
END |
| 519 |
check_brace_level (pop_lit2); |
| 520 |
END |
| 521 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 370 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 522 |
|
| 523 |
add_pool_buf_and_push (); |
| 524 |
END |
| 525 |
END |
| 526 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 364 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
/*************************************************************************** |
| 532 |
* WEB section number: 377 |
| 533 |
* ~~~~~~~~~~~~~~~~~~~ |
| 534 |
* The |built_in| function chr.to.int$ pops the top (string) |
| 535 |
* literal, makes sure it's a single character, converts it to the |
| 536 |
* corresponding |ASCII_code| integer, and pushes this integer. If the |
| 537 |
* literal isn't an appropriate string, it complains and pushes the |
| 538 |
* integer~0. |
| 539 |
***************************************************************************/ |
| 540 |
void x_chr_to_int (void) |
| 541 |
BEGIN |
| 542 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 543 |
if (pop_typ1 != STK_STR) |
| 544 |
BEGIN |
| 545 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 546 |
push_lit_stk (0, STK_INT); |
| 547 |
END |
| 548 |
#ifdef UTF_8 |
| 549 |
else if (LENGTH (pop_lit1) != utf8len(str_pool[str_start[pop_lit1]])) |
| 550 |
#else |
| 551 |
else if (LENGTH (pop_lit1) != 1) |
| 552 |
#endif |
| 553 |
BEGIN |
| 554 |
PRINT ("\""); |
| 555 |
PRINT_POOL_STR (pop_lit1); |
| 556 |
BST_EX_WARN ("\" isn't a single character"); |
| 557 |
push_lit_stk (0, STK_INT); |
| 558 |
END |
| 559 |
else |
| 560 |
BEGIN |
| 561 |
#ifdef UTF_8 |
| 562 |
UChar32 ch; |
| 563 |
U8_GET_OR_FFFD(&str_pool[str_start[pop_lit1]], 0, 0, -1, ch); |
| 564 |
push_lit_stk (ch, STK_INT); |
| 565 |
#else |
| 566 |
push_lit_stk (str_pool[str_start[pop_lit1]], STK_INT); |
| 567 |
#endif |
| 568 |
END |
| 569 |
END |
| 570 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 377 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
/*************************************************************************** |
| 576 |
* WEB section number: 378 |
| 577 |
* ~~~~~~~~~~~~~~~~~~~ |
| 578 |
* The |built_in| function cite pushes the appropriate string |
| 579 |
* from |cite_list| onto the stack. |
| 580 |
***************************************************************************/ |
| 581 |
void x_cite (void) |
| 582 |
BEGIN |
| 583 |
if ( ! mess_with_entries) |
| 584 |
BEGIN |
| 585 |
bst_cant_mess_with_entries_prin (); |
| 586 |
END |
| 587 |
else |
| 588 |
BEGIN |
| 589 |
push_lit_stk (CUR_CITE_STR, STK_STR); |
| 590 |
END |
| 591 |
END |
| 592 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 378 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
/*************************************************************************** |
| 598 |
* WEB section number: 350 |
| 599 |
* ~~~~~~~~~~~~~~~~~~~ |
| 600 |
* The |built_in| function * pops the top two (string) literals, |
| 601 |
* concatenates them (in reverse order, that is, the order in which |
| 602 |
* pushed), and pushes the resulting string back onto the stack. If |
| 603 |
* either isn't a string literal, it complains and pushes the null |
| 604 |
* string. |
| 605 |
***************************************************************************/ |
| 606 |
void x_concatenate (void) |
| 607 |
BEGIN |
| 608 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 609 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 610 |
if (pop_typ1 != STK_STR) |
| 611 |
BEGIN |
| 612 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 613 |
push_lit_stk (s_null, STK_STR); |
| 614 |
END |
| 615 |
else if (pop_typ2 != STK_STR) |
| 616 |
BEGIN |
| 617 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); |
| 618 |
push_lit_stk (s_null, STK_STR); |
| 619 |
END |
| 620 |
else |
| 621 |
|
| 622 |
/*************************************************************************** |
| 623 |
* WEB section number: 351 |
| 624 |
* ~~~~~~~~~~~~~~~~~~~ |
| 625 |
* Often both strings will be at the top of the string pool, in which |
| 626 |
* case we just move some pointers. Furthermore, it's worth doing some |
| 627 |
* special stuff in case either string is null, since empirically this |
| 628 |
* seems to happen about $20\%$ of the time. In any case, we don't need |
| 629 |
* the execution buffer---we simple move the strings around in the string |
| 630 |
* pool when necessary. |
| 631 |
***************************************************************************/ |
| 632 |
BEGIN |
| 633 |
if (pop_lit2 >= cmd_str_ptr) |
| 634 |
BEGIN |
| 635 |
if (pop_lit1 >= cmd_str_ptr) |
| 636 |
BEGIN |
| 637 |
str_start[pop_lit1] = str_start[pop_lit1 + 1]; |
| 638 |
UNFLUSH_STRING; |
| 639 |
INCR (lit_stk_ptr); |
| 640 |
END |
| 641 |
else if (LENGTH (pop_lit2) == 0) |
| 642 |
BEGIN |
| 643 |
push_lit_stk (pop_lit1, STK_STR); |
| 644 |
END |
| 645 |
else |
| 646 |
BEGIN |
| 647 |
pool_ptr = str_start[pop_lit2 + 1]; |
| 648 |
STR_ROOM (LENGTH (pop_lit1)); |
| 649 |
sp_ptr = str_start[pop_lit1]; |
| 650 |
sp_end = str_start[pop_lit1 + 1]; |
| 651 |
while (sp_ptr < sp_end) |
| 652 |
BEGIN |
| 653 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 654 |
INCR (sp_ptr); |
| 655 |
END |
| 656 |
push_lit_stk (make_string (), STK_STR); |
| 657 |
END |
| 658 |
END |
| 659 |
else |
| 660 |
|
| 661 |
/*************************************************************************** |
| 662 |
* WEB section number: 352 |
| 663 |
* ~~~~~~~~~~~~~~~~~~~ |
| 664 |
* We simply continue the previous module. |
| 665 |
***************************************************************************/ |
| 666 |
BEGIN |
| 667 |
if (pop_lit1 >= cmd_str_ptr) |
| 668 |
BEGIN |
| 669 |
if (LENGTH (pop_lit2) == 0) |
| 670 |
BEGIN |
| 671 |
UNFLUSH_STRING; |
| 672 |
lit_stack[lit_stk_ptr] = pop_lit1; |
| 673 |
INCR (lit_stk_ptr); |
| 674 |
END |
| 675 |
else if (LENGTH (pop_lit1) == 0) |
| 676 |
BEGIN |
| 677 |
INCR (lit_stk_ptr); |
| 678 |
END |
| 679 |
else |
| 680 |
BEGIN |
| 681 |
sp_length = LENGTH (pop_lit1); |
| 682 |
sp2_length = LENGTH (pop_lit2); |
| 683 |
STR_ROOM (sp_length + sp2_length); |
| 684 |
sp_ptr = str_start[pop_lit1 + 1]; |
| 685 |
sp_end = str_start[pop_lit1]; |
| 686 |
sp_xptr1 = sp_ptr + sp2_length; |
| 687 |
while (sp_ptr > sp_end) |
| 688 |
BEGIN |
| 689 |
DECR (sp_ptr); |
| 690 |
DECR (sp_xptr1); |
| 691 |
str_pool[sp_xptr1] = str_pool[sp_ptr]; |
| 692 |
END |
| 693 |
sp_ptr = str_start[pop_lit2]; |
| 694 |
sp_end = str_start[pop_lit2 + 1]; |
| 695 |
while (sp_ptr < sp_end) |
| 696 |
BEGIN |
| 697 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 698 |
INCR (sp_ptr); |
| 699 |
END |
| 700 |
pool_ptr = pool_ptr + sp_length; |
| 701 |
push_lit_stk (make_string (), STK_STR); |
| 702 |
END |
| 703 |
END |
| 704 |
else |
| 705 |
|
| 706 |
/*************************************************************************** |
| 707 |
* WEB section number: 353 |
| 708 |
* ~~~~~~~~~~~~~~~~~~~ |
| 709 |
* Again, we simply continue the previous module. |
| 710 |
***************************************************************************/ |
| 711 |
BEGIN |
| 712 |
if (LENGTH (pop_lit1) == 0) |
| 713 |
BEGIN |
| 714 |
INCR (lit_stk_ptr); |
| 715 |
END |
| 716 |
else if (LENGTH (pop_lit2) == 0) |
| 717 |
BEGIN |
| 718 |
push_lit_stk (pop_lit1, STK_STR); |
| 719 |
END |
| 720 |
else |
| 721 |
BEGIN |
| 722 |
STR_ROOM (LENGTH (pop_lit1) + LENGTH (pop_lit2)); |
| 723 |
sp_ptr = str_start[pop_lit2]; |
| 724 |
sp_end = str_start[pop_lit2 + 1]; |
| 725 |
while (sp_ptr < sp_end) |
| 726 |
BEGIN |
| 727 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 728 |
INCR (sp_ptr); |
| 729 |
END |
| 730 |
sp_ptr = str_start[pop_lit1]; |
| 731 |
sp_end = str_start[pop_lit1 + 1]; |
| 732 |
while (sp_ptr < sp_end) |
| 733 |
BEGIN |
| 734 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 735 |
INCR (sp_ptr); |
| 736 |
END |
| 737 |
push_lit_stk (make_string (), STK_STR); |
| 738 |
END |
| 739 |
END |
| 740 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 353 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 741 |
|
| 742 |
END |
| 743 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 352 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 744 |
|
| 745 |
END |
| 746 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 351 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 747 |
|
| 748 |
END |
| 749 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 350 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
/*************************************************************************** |
| 755 |
* WEB section number: 379 |
| 756 |
* ~~~~~~~~~~~~~~~~~~~ |
| 757 |
* The |built_in| function duplicate$ pops the top literal from |
| 758 |
* the stack and pushes two copies of it. |
| 759 |
***************************************************************************/ |
| 760 |
void x_duplicate (void) |
| 761 |
BEGIN |
| 762 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 763 |
if (pop_typ1 != STK_STR) |
| 764 |
BEGIN |
| 765 |
push_lit_stk (pop_lit1, pop_typ1); |
| 766 |
push_lit_stk (pop_lit1, pop_typ1); |
| 767 |
END |
| 768 |
else |
| 769 |
BEGIN |
| 770 |
REPUSH_STRING; |
| 771 |
if (pop_lit1 < cmd_str_ptr) |
| 772 |
BEGIN |
| 773 |
push_lit_stk (pop_lit1, pop_typ1); |
| 774 |
END |
| 775 |
else |
| 776 |
BEGIN |
| 777 |
STR_ROOM (LENGTH (pop_lit1)); |
| 778 |
sp_ptr = str_start[pop_lit1]; |
| 779 |
sp_end = str_start[pop_lit1 + 1]; |
| 780 |
while (sp_ptr < sp_end) |
| 781 |
BEGIN |
| 782 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 783 |
INCR (sp_ptr); |
| 784 |
END |
| 785 |
push_lit_stk (make_string (), STK_STR); |
| 786 |
END |
| 787 |
END |
| 788 |
END |
| 789 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 379 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
/*************************************************************************** |
| 795 |
* WEB section number: 380 |
| 796 |
* ~~~~~~~~~~~~~~~~~~~ |
| 797 |
* The |built_in| function empty$ pops the top literal and pushes |
| 798 |
* the integer 1 if it's a missing field or a string having no |
| 799 |
* non|white_space| characters, 0 otherwise. If the literal isn't a |
| 800 |
* missing field or a string, it complains and pushes 0. |
| 801 |
***************************************************************************/ |
| 802 |
void x_empty (void) |
| 803 |
BEGIN |
| 804 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 805 |
switch (pop_typ1) |
| 806 |
BEGIN |
| 807 |
case STK_STR: |
| 808 |
|
| 809 |
/*************************************************************************** |
| 810 |
* WEB section number: 381 |
| 811 |
* ~~~~~~~~~~~~~~~~~~~ |
| 812 |
* When we arrive here we're dealing with a legitimate string. If it has |
| 813 |
* no characters, or has nothing but |white_space| characters, we push~1, |
| 814 |
* otherwise we push~0. |
| 815 |
***************************************************************************/ |
| 816 |
BEGIN |
| 817 |
sp_ptr = str_start[pop_lit1]; |
| 818 |
sp_end = str_start[pop_lit1 + 1]; |
| 819 |
while (sp_ptr < sp_end) |
| 820 |
BEGIN |
| 821 |
if (lex_class[str_pool[sp_ptr]] != WHITE_SPACE) |
| 822 |
BEGIN |
| 823 |
push_lit_stk (0, STK_INT); |
| 824 |
goto Exit_Label; |
| 825 |
END |
| 826 |
INCR (sp_ptr); |
| 827 |
END |
| 828 |
push_lit_stk (1, STK_INT); |
| 829 |
END |
| 830 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 381 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 831 |
|
| 832 |
break; |
| 833 |
case STK_FIELD_MISSING: |
| 834 |
push_lit_stk (1, STK_INT); |
| 835 |
break; |
| 836 |
case STK_EMPTY: |
| 837 |
push_lit_stk (0, STK_INT); |
| 838 |
break; |
| 839 |
default: |
| 840 |
print_stk_lit (pop_lit1, pop_typ1); |
| 841 |
BST_EX_WARN (", not a string or missing field,"); |
| 842 |
push_lit_stk (0, STK_INT); |
| 843 |
break; |
| 844 |
END |
| 845 |
Exit_Label: DO_NOTHING; |
| 846 |
END |
| 847 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 380 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
/*************************************************************************** |
| 853 |
* WEB section number: 345 |
| 854 |
* ~~~~~~~~~~~~~~~~~~~ |
| 855 |
* The |built_in| function = pops the top two (integer or string) |
| 856 |
* literals, compares them, and pushes the integer 1 if they're equal, 0 |
| 857 |
* otherwise. If they're not either both string or both integer, it |
| 858 |
* complains and pushes the integer 0. |
| 859 |
***************************************************************************/ |
| 860 |
void x_equals (void) |
| 861 |
BEGIN |
| 862 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 863 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 864 |
if (pop_typ1 != pop_typ2) |
| 865 |
BEGIN |
| 866 |
if ((pop_typ1 != STK_EMPTY) && (pop_typ2 != STK_EMPTY)) |
| 867 |
BEGIN |
| 868 |
print_stk_lit (pop_lit1, pop_typ1); |
| 869 |
PRINT (", "); |
| 870 |
print_stk_lit (pop_lit2, pop_typ2); |
| 871 |
PRINT_NEWLINE; |
| 872 |
BST_EX_WARN ("---they aren't the same literal types"); |
| 873 |
END |
| 874 |
push_lit_stk (0, STK_INT); |
| 875 |
END |
| 876 |
else if ((pop_typ1 != STK_INT) && (pop_typ1 != STK_STR)) |
| 877 |
BEGIN |
| 878 |
if (pop_typ1 != STK_EMPTY) |
| 879 |
BEGIN |
| 880 |
print_stk_lit (pop_lit1, pop_typ1); |
| 881 |
BST_EX_WARN (", not an integer or a string,"); |
| 882 |
END |
| 883 |
push_lit_stk (0, STK_INT); |
| 884 |
END |
| 885 |
else if (pop_typ1 == STK_INT) |
| 886 |
BEGIN |
| 887 |
if (pop_lit2 == pop_lit1) |
| 888 |
BEGIN |
| 889 |
push_lit_stk (1, STK_INT); |
| 890 |
END |
| 891 |
else |
| 892 |
BEGIN |
| 893 |
push_lit_stk (0, STK_INT); |
| 894 |
END |
| 895 |
END |
| 896 |
else if (str_eq_str (pop_lit2, pop_lit1)) |
| 897 |
BEGIN |
| 898 |
push_lit_stk (1, STK_INT); |
| 899 |
END |
| 900 |
else |
| 901 |
BEGIN |
| 902 |
push_lit_stk (0, STK_INT); |
| 903 |
END |
| 904 |
END |
| 905 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 345 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
/*************************************************************************** |
| 911 |
* WEB section number: 382 |
| 912 |
* ~~~~~~~~~~~~~~~~~~~ |
| 913 |
* The |built_in| function format.name$ pops the top three |
| 914 |
* literals (they are a string, an integer, and a string literal, in that |
| 915 |
* order). The last string literal represents a name list (each name |
| 916 |
* corresponding to a person), the integer literal specifies which name |
| 917 |
* to pick from this list, and the first string literal specifies how to |
| 918 |
* format this name, as described in the \BibTeX\ documentation. |
| 919 |
* Finally, this function pushes the formatted name. If any of the types |
| 920 |
* is incorrect, it complains and pushes the null string. |
| 921 |
***************************************************************************/ |
| 922 |
void x_format_name (void) |
| 923 |
BEGIN |
| 924 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 925 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 926 |
pop_lit_stk (&pop_lit3, &pop_typ3); |
| 927 |
if (pop_typ1 != STK_STR) |
| 928 |
BEGIN |
| 929 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 930 |
push_lit_stk (s_null, STK_STR); |
| 931 |
END |
| 932 |
else if (pop_typ2 != STK_INT) |
| 933 |
BEGIN |
| 934 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 935 |
push_lit_stk (s_null, STK_STR); |
| 936 |
END |
| 937 |
else if (pop_typ3 != STK_STR) |
| 938 |
BEGIN |
| 939 |
print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR); |
| 940 |
push_lit_stk (s_null, STK_STR); |
| 941 |
END |
| 942 |
else |
| 943 |
BEGIN |
| 944 |
ex_buf_length = 0; |
| 945 |
add_buf_pool (pop_lit3); |
| 946 |
|
| 947 |
/*************************************************************************** |
| 948 |
* WEB section number: 383 |
| 949 |
* ~~~~~~~~~~~~~~~~~~~ |
| 950 |
* This module skips over undesired names in |pop_lit3| and it throws |
| 951 |
* away the ``and'' from the end of the name if it exists. When it's |
| 952 |
* done, |ex_buf_xptr| points to its first character and |ex_buf_ptr| |
| 953 |
* points just past its last. |
| 954 |
***************************************************************************/ |
| 955 |
BEGIN |
| 956 |
ex_buf_ptr = 0; |
| 957 |
num_names = 0; |
| 958 |
while ((num_names < pop_lit2) && (ex_buf_ptr < ex_buf_length)) |
| 959 |
BEGIN |
| 960 |
INCR (num_names); |
| 961 |
ex_buf_xptr = ex_buf_ptr; |
| 962 |
name_scan_for_and (pop_lit3); |
| 963 |
END |
| 964 |
if (ex_buf_ptr < ex_buf_length) |
| 965 |
BEGIN |
| 966 |
#ifdef UTF_8 |
| 967 |
if (ex_buf[ex_buf_ptr-3]==0xE3 || ex_buf[ex_buf_ptr-3]==0xEF) |
| 968 |
/* expect U+3001 "、" or U+FF0C "," :: Ideographic/Fulwidth Comma */ |
| 969 |
ex_buf_ptr = ex_buf_ptr - 3; |
| 970 |
else |
| 971 |
/* expect "and " or "AND " */ |
| 972 |
#endif |
| 973 |
ex_buf_ptr = ex_buf_ptr - 4; |
| 974 |
END |
| 975 |
if (num_names < pop_lit2) |
| 976 |
BEGIN |
| 977 |
if (pop_lit2 == 1) |
| 978 |
BEGIN |
| 979 |
PRINT ("There is no name in \""); |
| 980 |
END |
| 981 |
else |
| 982 |
BEGIN |
| 983 |
PRINT2 ("There aren't %ld names in \"", (long) pop_lit2); |
| 984 |
END |
| 985 |
PRINT_POOL_STR (pop_lit3); |
| 986 |
BST_EX_WARN ("\""); |
| 987 |
END |
| 988 |
END |
| 989 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 383 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 990 |
|
| 991 |
|
| 992 |
/*************************************************************************** |
| 993 |
* WEB section number: 387 |
| 994 |
* ~~~~~~~~~~~~~~~~~~~ |
| 995 |
* When we arrive here, the desired name is in |ex_buf[ex_buf_xptr]| |
| 996 |
* through |ex_buf[ex_buf_ptr-1]|. This module does its thing for |
| 997 |
* characters only at |brace_level = 0|; the rest get processed verbatim. |
| 998 |
* It removes leading |white_space| (and |sep_char|s), and trailing |
| 999 |
* |white_space| (and |sep_char|s) and |comma|s, complaining for each |
| 1000 |
* trailing |comma|. It then copies the name into |name_buf|, removing |
| 1001 |
* all |white_space|, |sep_char|s and |comma|s, counting |comma|s, and |
| 1002 |
* constructing a list of name tokens, which are sequences of characters |
| 1003 |
* separated (at |brace_level=0|) by |white_space|, |sep_char|s or |
| 1004 |
* |comma|s. Each name token but the first has an associated |
| 1005 |
* |name_sep_char|, the character that separates it from the preceding |
| 1006 |
* token. If there are too many (more than two) |comma|s, a complaint is |
| 1007 |
* in order. |
| 1008 |
***************************************************************************/ |
| 1009 |
BEGIN |
| 1010 |
/*************************************************************************** |
| 1011 |
* WEB section number: 388 |
| 1012 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1013 |
* This module removes all leading |white_space| (and |sep_char|s), and |
| 1014 |
* trailing |white_space| (and |sep_char|s) and |comma|s. It complains |
| 1015 |
* for each trailing |comma|. |
| 1016 |
***************************************************************************/ |
| 1017 |
BEGIN |
| 1018 |
while ((ex_buf_xptr < ex_buf_ptr) |
| 1019 |
&& (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE) |
| 1020 |
&& (lex_class[ex_buf[ex_buf_ptr]] == SEP_CHAR)) |
| 1021 |
BEGIN |
| 1022 |
INCR (ex_buf_xptr); |
| 1023 |
END |
| 1024 |
while (ex_buf_ptr > ex_buf_xptr) |
| 1025 |
BEGIN |
| 1026 |
switch (lex_class[ex_buf[ex_buf_ptr - 1]]) |
| 1027 |
BEGIN |
| 1028 |
case WHITE_SPACE: |
| 1029 |
case SEP_CHAR: |
| 1030 |
DECR (ex_buf_ptr); |
| 1031 |
break; |
| 1032 |
default: |
| 1033 |
if (ex_buf[ex_buf_ptr - 1] == COMMA) |
| 1034 |
BEGIN |
| 1035 |
PRINT2 ("Name %ld in \"", (long) pop_lit2); |
| 1036 |
PRINT_POOL_STR (pop_lit3); |
| 1037 |
PRINT ("\" has a comma at the end"); |
| 1038 |
bst_ex_warn_print (); |
| 1039 |
DECR (ex_buf_ptr); |
| 1040 |
END |
| 1041 |
else |
| 1042 |
BEGIN |
| 1043 |
goto Loop1_Exit_Label; |
| 1044 |
END |
| 1045 |
break; |
| 1046 |
END |
| 1047 |
END |
| 1048 |
Loop1_Exit_Label: DO_NOTHING; |
| 1049 |
END |
| 1050 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 388 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1051 |
|
| 1052 |
name_bf_ptr = 0; |
| 1053 |
num_commas = 0; |
| 1054 |
num_tokens = 0; |
| 1055 |
token_starting = TRUE; |
| 1056 |
while (ex_buf_xptr < ex_buf_ptr) |
| 1057 |
BEGIN |
| 1058 |
switch (ex_buf[ex_buf_xptr]) |
| 1059 |
BEGIN |
| 1060 |
case COMMA: |
| 1061 |
|
| 1062 |
/*************************************************************************** |
| 1063 |
* WEB section number: 389 |
| 1064 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1065 |
* Here we mark the token number at which this comma has occurred. |
| 1066 |
***************************************************************************/ |
| 1067 |
BEGIN |
| 1068 |
if (num_commas == 2) |
| 1069 |
BEGIN |
| 1070 |
PRINT2 ("Too many commas in name %ld of \"", (long) pop_lit2); |
| 1071 |
PRINT_POOL_STR (pop_lit3); |
| 1072 |
PRINT ("\""); |
| 1073 |
bst_ex_warn_print (); |
| 1074 |
END |
| 1075 |
else |
| 1076 |
BEGIN |
| 1077 |
INCR (num_commas); |
| 1078 |
if (num_commas == 1) |
| 1079 |
BEGIN |
| 1080 |
comma1 = num_tokens; |
| 1081 |
END |
| 1082 |
else |
| 1083 |
BEGIN |
| 1084 |
comma2 = num_tokens; |
| 1085 |
END |
| 1086 |
name_sep_char[num_tokens] = COMMA; |
| 1087 |
END |
| 1088 |
INCR (ex_buf_xptr); |
| 1089 |
token_starting = TRUE; |
| 1090 |
END |
| 1091 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 389 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1092 |
|
| 1093 |
break; |
| 1094 |
case LEFT_BRACE: |
| 1095 |
|
| 1096 |
/*************************************************************************** |
| 1097 |
* WEB section number: 390 |
| 1098 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1099 |
* We copy the stuff up through the matching |right_brace| verbatim. |
| 1100 |
***************************************************************************/ |
| 1101 |
BEGIN |
| 1102 |
INCR (brace_level); |
| 1103 |
if (token_starting) |
| 1104 |
BEGIN |
| 1105 |
name_tok[num_tokens] = name_bf_ptr; |
| 1106 |
INCR (num_tokens); |
| 1107 |
END |
| 1108 |
NAME_BUF[name_bf_ptr] = ex_buf[ex_buf_xptr]; |
| 1109 |
INCR (name_bf_ptr); |
| 1110 |
INCR (ex_buf_xptr); |
| 1111 |
while ((brace_level > 0) && (ex_buf_xptr < ex_buf_ptr)) |
| 1112 |
BEGIN |
| 1113 |
if (ex_buf[ex_buf_xptr] == RIGHT_BRACE) |
| 1114 |
BEGIN |
| 1115 |
DECR (brace_level); |
| 1116 |
END |
| 1117 |
else if (ex_buf[ex_buf_xptr] == LEFT_BRACE) |
| 1118 |
BEGIN |
| 1119 |
INCR (brace_level); |
| 1120 |
END |
| 1121 |
NAME_BUF[name_bf_ptr] = ex_buf[ex_buf_xptr]; |
| 1122 |
INCR (name_bf_ptr); |
| 1123 |
INCR (ex_buf_xptr); |
| 1124 |
END |
| 1125 |
token_starting = FALSE; |
| 1126 |
END |
| 1127 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 390 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1128 |
|
| 1129 |
break; |
| 1130 |
case RIGHT_BRACE: |
| 1131 |
|
| 1132 |
/*************************************************************************** |
| 1133 |
* WEB section number: 391 |
| 1134 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1135 |
* We don't copy an extra |right_brace|; this code will almost never be |
| 1136 |
* executed. |
| 1137 |
***************************************************************************/ |
| 1138 |
BEGIN |
| 1139 |
if (token_starting) |
| 1140 |
BEGIN |
| 1141 |
name_tok[num_tokens] = name_bf_ptr; |
| 1142 |
INCR (num_tokens); |
| 1143 |
END |
| 1144 |
PRINT2 ("Name %ld of \"", (long) pop_lit2); |
| 1145 |
PRINT_POOL_STR (pop_lit3); |
| 1146 |
BST_EX_WARN ("\" isn't brace balanced"); |
| 1147 |
INCR (ex_buf_xptr); |
| 1148 |
token_starting = FALSE; |
| 1149 |
END |
| 1150 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 391 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1151 |
|
| 1152 |
break; |
| 1153 |
default: |
| 1154 |
switch (lex_class[ex_buf[ex_buf_xptr]]) |
| 1155 |
BEGIN |
| 1156 |
case WHITE_SPACE: |
| 1157 |
|
| 1158 |
/*************************************************************************** |
| 1159 |
* WEB section number: 392 |
| 1160 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1161 |
* A token will be starting soon in a buffer near you, one way$\ldots$ |
| 1162 |
***************************************************************************/ |
| 1163 |
BEGIN |
| 1164 |
if ( ! token_starting) |
| 1165 |
BEGIN |
| 1166 |
name_sep_char[num_tokens] = SPACE; |
| 1167 |
END |
| 1168 |
INCR (ex_buf_xptr); |
| 1169 |
token_starting = TRUE; |
| 1170 |
END |
| 1171 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 392 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1172 |
|
| 1173 |
break; |
| 1174 |
case SEP_CHAR: |
| 1175 |
|
| 1176 |
/*************************************************************************** |
| 1177 |
* WEB section number: 393 |
| 1178 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1179 |
* or another. If one of the valid |sep_char|s appears between tokens, |
| 1180 |
* we usually use it instead of a |space|. If the user has been silly |
| 1181 |
* enough to have multiple |sep_char|s, or to have both |white_space| and |
| 1182 |
* a |sep_char|, we use the first such character. |
| 1183 |
***************************************************************************/ |
| 1184 |
BEGIN |
| 1185 |
if ( ! token_starting) |
| 1186 |
BEGIN |
| 1187 |
name_sep_char[num_tokens] = ex_buf[ex_buf_xptr]; |
| 1188 |
END |
| 1189 |
INCR (ex_buf_xptr); |
| 1190 |
token_starting = TRUE; |
| 1191 |
END |
| 1192 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 393 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1193 |
|
| 1194 |
break; |
| 1195 |
default: |
| 1196 |
|
| 1197 |
/*************************************************************************** |
| 1198 |
* WEB section number: 394 |
| 1199 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1200 |
* For ordinary characters, we just copy the character. |
| 1201 |
***************************************************************************/ |
| 1202 |
BEGIN |
| 1203 |
if (token_starting) |
| 1204 |
BEGIN |
| 1205 |
name_tok[num_tokens] = name_bf_ptr; |
| 1206 |
INCR (num_tokens); |
| 1207 |
END |
| 1208 |
NAME_BUF[name_bf_ptr] = ex_buf[ex_buf_xptr]; |
| 1209 |
INCR (name_bf_ptr); |
| 1210 |
INCR (ex_buf_xptr); |
| 1211 |
token_starting = FALSE; |
| 1212 |
END |
| 1213 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 394 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1214 |
|
| 1215 |
break; |
| 1216 |
END |
| 1217 |
break; |
| 1218 |
END |
| 1219 |
END |
| 1220 |
name_tok[num_tokens] = name_bf_ptr; |
| 1221 |
END |
| 1222 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 387 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1223 |
|
| 1224 |
/*************************************************************************** |
| 1225 |
* WEB section number: 395 |
| 1226 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1227 |
* Here we set all the pointers for the various parts of the name, |
| 1228 |
* depending on which of the three possible syntaxes this name uses. |
| 1229 |
***************************************************************************/ |
| 1230 |
BEGIN |
| 1231 |
if (num_commas == 0) |
| 1232 |
BEGIN |
| 1233 |
first_start = 0; |
| 1234 |
last_end = num_tokens; |
| 1235 |
jr_end = last_end; |
| 1236 |
|
| 1237 |
/*************************************************************************** |
| 1238 |
* WEB section number: 396 |
| 1239 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1240 |
* When there are no brace-level-0 |comma|s in the name, the von name |
| 1241 |
* starts with the first nonlast token whose first brace-level-0 letter |
| 1242 |
* is in lower case (for the purposes of this determination, an accented |
| 1243 |
* or foreign character at brace-level-1 that's in lower case will do, as |
| 1244 |
* well). A module following this one determines where the von name ends |
| 1245 |
* and the last starts. |
| 1246 |
***************************************************************************/ |
| 1247 |
BEGIN |
| 1248 |
von_start = 0; |
| 1249 |
while (von_start < (last_end - 1)) |
| 1250 |
BEGIN |
| 1251 |
name_bf_ptr = name_tok[von_start]; |
| 1252 |
name_bf_xptr = name_tok[von_start + 1]; |
| 1253 |
if (von_token_found ()) |
| 1254 |
BEGIN |
| 1255 |
von_name_ends_and_last_name_sta (); |
| 1256 |
goto Von_Found_Label; |
| 1257 |
END |
| 1258 |
INCR (von_start); |
| 1259 |
END |
| 1260 |
while (von_start > 0) |
| 1261 |
BEGIN |
| 1262 |
if ((lex_class[name_sep_char[von_start]] != SEP_CHAR) |
| 1263 |
|| (name_sep_char[von_start] == TIE)) |
| 1264 |
BEGIN |
| 1265 |
goto Loop2_Exit_Label; |
| 1266 |
END |
| 1267 |
DECR (von_start); |
| 1268 |
END |
| 1269 |
Loop2_Exit_Label: von_end = von_start; |
| 1270 |
Von_Found_Label: first_end = von_start; |
| 1271 |
END |
| 1272 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 396 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1273 |
|
| 1274 |
END |
| 1275 |
else if (num_commas == 1) |
| 1276 |
BEGIN |
| 1277 |
von_start = 0; |
| 1278 |
last_end = comma1; |
| 1279 |
jr_end = last_end; |
| 1280 |
first_start = jr_end; |
| 1281 |
first_end = num_tokens; |
| 1282 |
von_name_ends_and_last_name_sta (); |
| 1283 |
END |
| 1284 |
else if (num_commas == 2) |
| 1285 |
BEGIN |
| 1286 |
von_start = 0; |
| 1287 |
last_end = comma1; |
| 1288 |
jr_end = comma2; |
| 1289 |
first_start = jr_end; |
| 1290 |
first_end = num_tokens; |
| 1291 |
von_name_ends_and_last_name_sta (); |
| 1292 |
END |
| 1293 |
else |
| 1294 |
BEGIN |
| 1295 |
CONFUSION ("Illegal number of comma,s"); |
| 1296 |
END |
| 1297 |
END |
| 1298 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 395 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1299 |
|
| 1300 |
ex_buf_length = 0; |
| 1301 |
add_buf_pool (pop_lit1); |
| 1302 |
figure_out_the_formatted_name (); |
| 1303 |
add_pool_buf_and_push (); |
| 1304 |
END |
| 1305 |
END |
| 1306 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 382 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
/*************************************************************************** |
| 1312 |
* WEB section number: 354 |
| 1313 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1314 |
* The |built_in| function := pops the top two literals and assigns |
| 1315 |
* to the first (which must be an |int_entry_var|, a |str_entry_var|, an |
| 1316 |
* |int_global_var|, or a |str_global_var|) the value of the second; |
| 1317 |
* it complains if the value isn't of the appropriate type. |
| 1318 |
***************************************************************************/ |
| 1319 |
void x_gets (void) |
| 1320 |
BEGIN |
| 1321 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1322 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 1323 |
if (pop_typ1 != STK_FN) |
| 1324 |
BEGIN |
| 1325 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_FN); |
| 1326 |
END |
| 1327 |
else if (( ! mess_with_entries) |
| 1328 |
&& ((fn_type[pop_lit1] == STR_ENTRY_VAR) |
| 1329 |
|| (fn_type[pop_lit1] == INT_ENTRY_VAR))) |
| 1330 |
BEGIN |
| 1331 |
bst_cant_mess_with_entries_prin (); |
| 1332 |
END |
| 1333 |
else |
| 1334 |
BEGIN |
| 1335 |
switch (fn_type[pop_lit1]) |
| 1336 |
BEGIN |
| 1337 |
case INT_ENTRY_VAR: |
| 1338 |
|
| 1339 |
/*************************************************************************** |
| 1340 |
* WEB section number: 355 |
| 1341 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1342 |
* This module checks that what we're about to assign is really an |
| 1343 |
* integer, and then assigns. |
| 1344 |
***************************************************************************/ |
| 1345 |
if (pop_typ2 != STK_INT) |
| 1346 |
BEGIN |
| 1347 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 1348 |
END |
| 1349 |
else |
| 1350 |
BEGIN |
| 1351 |
entry_ints[(cite_ptr * num_ent_ints) + FN_INFO[pop_lit1]] = pop_lit2; |
| 1352 |
END |
| 1353 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 355 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1354 |
|
| 1355 |
break; |
| 1356 |
case STR_ENTRY_VAR: |
| 1357 |
|
| 1358 |
/*************************************************************************** |
| 1359 |
* WEB section number: 357 |
| 1360 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1361 |
* This module checks that what we're about to assign is really a |
| 1362 |
* string, and then assigns. |
| 1363 |
***************************************************************************/ |
| 1364 |
BEGIN |
| 1365 |
if (pop_typ2 != STK_STR) |
| 1366 |
BEGIN |
| 1367 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); |
| 1368 |
END |
| 1369 |
else |
| 1370 |
BEGIN |
| 1371 |
str_ent_ptr = (cite_ptr * num_ent_strs) + FN_INFO[pop_lit1]; |
| 1372 |
ent_chr_ptr = 0; |
| 1373 |
sp_ptr = str_start[pop_lit2]; |
| 1374 |
sp_xptr1 = str_start[pop_lit2 + 1]; |
| 1375 |
if ((sp_xptr1 - sp_ptr) > Ent_Str_Size) |
| 1376 |
BEGIN |
| 1377 |
BST_STRING_SIZE_EXCEEDED (Ent_Str_Size, ", the entry"); |
| 1378 |
sp_xptr1 = sp_ptr + Ent_Str_Size; |
| 1379 |
END |
| 1380 |
while (sp_ptr < sp_xptr1) |
| 1381 |
BEGIN |
| 1382 |
ENTRY_STRS(str_ent_ptr, ent_chr_ptr) = str_pool[sp_ptr]; |
| 1383 |
INCR (ent_chr_ptr); |
| 1384 |
INCR (sp_ptr); |
| 1385 |
END |
| 1386 |
ENTRY_STRS(str_ent_ptr, ent_chr_ptr) = END_OF_STRING; |
| 1387 |
END |
| 1388 |
END |
| 1389 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 357 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1390 |
|
| 1391 |
break; |
| 1392 |
case INT_GLOBAL_VAR: |
| 1393 |
|
| 1394 |
/*************************************************************************** |
| 1395 |
* WEB section number: 358 |
| 1396 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1397 |
* This module checks that what we're about to assign is really an |
| 1398 |
* integer, and then assigns. |
| 1399 |
***************************************************************************/ |
| 1400 |
if (pop_typ2 != STK_INT) |
| 1401 |
BEGIN |
| 1402 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 1403 |
END |
| 1404 |
else |
| 1405 |
BEGIN |
| 1406 |
FN_INFO[pop_lit1] = pop_lit2; |
| 1407 |
END |
| 1408 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 358 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1409 |
|
| 1410 |
break; |
| 1411 |
case STR_GLOBAL_VAR: |
| 1412 |
|
| 1413 |
/*************************************************************************** |
| 1414 |
* WEB section number: 359 |
| 1415 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1416 |
* This module checks that what we're about to assign is really a |
| 1417 |
* string, and then assigns. |
| 1418 |
***************************************************************************/ |
| 1419 |
BEGIN |
| 1420 |
if (pop_typ2 != STK_STR) |
| 1421 |
BEGIN |
| 1422 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); |
| 1423 |
END |
| 1424 |
else |
| 1425 |
BEGIN |
| 1426 |
str_glb_ptr = FN_INFO[pop_lit1]; |
| 1427 |
if (pop_lit2 < cmd_str_ptr) |
| 1428 |
BEGIN |
| 1429 |
glb_str_ptr[str_glb_ptr] = pop_lit2; |
| 1430 |
END |
| 1431 |
else |
| 1432 |
BEGIN |
| 1433 |
glb_str_ptr[str_glb_ptr] = 0; |
| 1434 |
glob_chr_ptr = 0; |
| 1435 |
sp_ptr = str_start[pop_lit2]; |
| 1436 |
sp_end = str_start[pop_lit2 + 1]; |
| 1437 |
if ((sp_end - sp_ptr) > Glob_Str_Size) |
| 1438 |
BEGIN |
| 1439 |
BST_STRING_SIZE_EXCEEDED (Glob_Str_Size, ", the global"); |
| 1440 |
sp_end = sp_ptr + Glob_Str_Size; |
| 1441 |
END |
| 1442 |
while (sp_ptr < sp_end) |
| 1443 |
BEGIN |
| 1444 |
GLOBAL_STRS(str_glb_ptr, glob_chr_ptr) = str_pool[sp_ptr]; |
| 1445 |
INCR (glob_chr_ptr); |
| 1446 |
INCR (sp_ptr); |
| 1447 |
END |
| 1448 |
glb_str_end[str_glb_ptr] = glob_chr_ptr; |
| 1449 |
END |
| 1450 |
END |
| 1451 |
END |
| 1452 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 359 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1453 |
|
| 1454 |
break; |
| 1455 |
default: |
| 1456 |
PRINT ("You can't assign to type "); |
| 1457 |
print_fn_class (pop_lit1); |
| 1458 |
BST_EX_WARN (", a nonvariable function class"); |
| 1459 |
break; |
| 1460 |
END |
| 1461 |
END |
| 1462 |
END |
| 1463 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 354 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
/*************************************************************************** |
| 1469 |
* WEB section number: 346 |
| 1470 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1471 |
* The |built_in| function > pops the top two (integer) literals, |
| 1472 |
* compares them, and pushes the integer 1 if the second is greater than |
| 1473 |
* the first, 0 otherwise. If either isn't an integer literal, it |
| 1474 |
* complains and pushes the integer 0. |
| 1475 |
***************************************************************************/ |
| 1476 |
void x_greater_than (void) |
| 1477 |
BEGIN |
| 1478 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1479 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 1480 |
if (pop_typ1 != STK_INT) |
| 1481 |
BEGIN |
| 1482 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 1483 |
push_lit_stk (0, STK_INT); |
| 1484 |
END |
| 1485 |
else if (pop_typ2 != STK_INT) |
| 1486 |
BEGIN |
| 1487 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 1488 |
push_lit_stk (0, STK_INT); |
| 1489 |
END |
| 1490 |
else if (pop_lit2 > pop_lit1) |
| 1491 |
BEGIN |
| 1492 |
push_lit_stk (1, STK_INT); |
| 1493 |
END |
| 1494 |
else |
| 1495 |
BEGIN |
| 1496 |
push_lit_stk (0, STK_INT); |
| 1497 |
END |
| 1498 |
END |
| 1499 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 346 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
/*************************************************************************** |
| 1505 |
* WEB section number: 422 |
| 1506 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1507 |
* The |built_in| function int.to.chr$ pops the top (integer) |
| 1508 |
* literal, interpreted as the |ASCII_code| of a single character, |
| 1509 |
* converts it to the corresponding single-character string, and pushes |
| 1510 |
* this string. If the literal isn't an appropriate integer, it |
| 1511 |
* complains and pushes the null string. |
| 1512 |
***************************************************************************/ |
| 1513 |
void x_int_to_chr (void) |
| 1514 |
BEGIN |
| 1515 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1516 |
if (pop_typ1 != STK_INT) |
| 1517 |
BEGIN |
| 1518 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 1519 |
push_lit_stk (s_null, STK_STR); |
| 1520 |
END |
| 1521 |
#if UTF_8 |
| 1522 |
else if ((pop_lit1 < 0) || (pop_lit1 > LAST_UCS_CHAR)) |
| 1523 |
#else |
| 1524 |
else if ((pop_lit1 < 0) || (pop_lit1 > LAST_ASCII_CHAR)) |
| 1525 |
#endif |
| 1526 |
BEGIN |
| 1527 |
BST_EX_WARN2 ("%ld isn't valid character code", (long) pop_lit1); |
| 1528 |
push_lit_stk (s_null, STK_STR); |
| 1529 |
END |
| 1530 |
else |
| 1531 |
BEGIN |
| 1532 |
STR_ROOM (1); |
| 1533 |
#if UTF_8 |
| 1534 |
BEGIN |
| 1535 |
UChar ch0[3] = {0}; |
| 1536 |
unsigned char ch1[5] = {0}, *ch; |
| 1537 |
if (pop_lit1> 0xFFFF) |
| 1538 |
BEGIN |
| 1539 |
ch0[0] = U16_LEAD(pop_lit1); |
| 1540 |
ch0[1] = U16_TRAIL(pop_lit1); |
| 1541 |
END |
| 1542 |
else |
| 1543 |
ch0[0] = pop_lit1; |
| 1544 |
icu_fromUChars(ch1, 5, ch0, 3); |
| 1545 |
ch=ch1; |
| 1546 |
while(*ch) |
| 1547 |
BEGIN |
| 1548 |
APPEND_CHAR (*ch); |
| 1549 |
INCR (ch); |
| 1550 |
END |
| 1551 |
END |
| 1552 |
#else |
| 1553 |
APPEND_CHAR (pop_lit1); |
| 1554 |
#endif |
| 1555 |
push_lit_stk (make_string (), STK_STR); |
| 1556 |
END |
| 1557 |
END |
| 1558 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 422 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
/*************************************************************************** |
| 1564 |
* WEB section number: 423 |
| 1565 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1566 |
* The |built_in| function int.to.str$ pops the top (integer) |
| 1567 |
* literal, converts it to its (unique) string equivalent, and pushes |
| 1568 |
* this string. If the literal isn't an integer, it complains and pushes |
| 1569 |
* the null string. |
| 1570 |
***************************************************************************/ |
| 1571 |
void x_int_to_str (void) |
| 1572 |
BEGIN |
| 1573 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1574 |
if (pop_typ1 != STK_INT) |
| 1575 |
BEGIN |
| 1576 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 1577 |
push_lit_stk (s_null, STK_STR); |
| 1578 |
END |
| 1579 |
else |
| 1580 |
BEGIN |
| 1581 |
int_to_ASCII (pop_lit1, ex_buf, 0, &ex_buf_length); |
| 1582 |
add_pool_buf_and_push (); |
| 1583 |
END |
| 1584 |
END |
| 1585 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 423 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
/*************************************************************************** |
| 1591 |
* WEB section number: 347 |
| 1592 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1593 |
* The |built_in| function < pops the top two (integer) literals, |
| 1594 |
* compares them, and pushes the integer 1 if the second is less than the |
| 1595 |
* first, 0 otherwise. If either isn't an integer literal, it complains |
| 1596 |
* and pushes the integer 0. |
| 1597 |
***************************************************************************/ |
| 1598 |
void x_less_than (void) |
| 1599 |
BEGIN |
| 1600 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1601 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 1602 |
if (pop_typ1 != STK_INT) |
| 1603 |
BEGIN |
| 1604 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 1605 |
push_lit_stk (0, STK_INT); |
| 1606 |
END |
| 1607 |
else if (pop_typ2 != STK_INT) |
| 1608 |
BEGIN |
| 1609 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 1610 |
push_lit_stk (0, STK_INT); |
| 1611 |
END |
| 1612 |
else if (pop_lit2 < pop_lit1) |
| 1613 |
BEGIN |
| 1614 |
push_lit_stk (1, STK_INT); |
| 1615 |
END |
| 1616 |
else |
| 1617 |
BEGIN |
| 1618 |
push_lit_stk (0, STK_INT); |
| 1619 |
END |
| 1620 |
END |
| 1621 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 347 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
/*************************************************************************** |
| 1627 |
* WEB section number: 349 |
| 1628 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1629 |
* The |built_in| function - pops the top two (integer) literals |
| 1630 |
* and pushes their difference (the first subtracted from the second). |
| 1631 |
* If either isn't an integer literal, it complains and pushes the |
| 1632 |
* integer 0. |
| 1633 |
***************************************************************************/ |
| 1634 |
void x_minus (void) |
| 1635 |
BEGIN |
| 1636 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1637 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 1638 |
if (pop_typ1 != STK_INT) |
| 1639 |
BEGIN |
| 1640 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 1641 |
push_lit_stk (0, STK_INT); |
| 1642 |
END |
| 1643 |
else if (pop_typ2 != STK_INT) |
| 1644 |
BEGIN |
| 1645 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 1646 |
push_lit_stk (0, STK_INT); |
| 1647 |
END |
| 1648 |
else |
| 1649 |
BEGIN |
| 1650 |
push_lit_stk (pop_lit2 - pop_lit1, STK_INT); |
| 1651 |
END |
| 1652 |
END |
| 1653 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 349 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
/*************************************************************************** |
| 1659 |
* WEB section number: 424 |
| 1660 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1661 |
* The |built_in| function missing$ pops the top literal and |
| 1662 |
* pushes the integer 1 if it's a missing field, 0 otherwise. If the |
| 1663 |
* literal isn't a missing field or a string, it complains and pushes 0. |
| 1664 |
* Unlike empty$ , this function should be called only when |
| 1665 |
* |mess_with_entries| is true. |
| 1666 |
***************************************************************************/ |
| 1667 |
void x_missing (void) |
| 1668 |
BEGIN |
| 1669 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1670 |
if ( ! mess_with_entries) |
| 1671 |
BEGIN |
| 1672 |
bst_cant_mess_with_entries_prin (); |
| 1673 |
END |
| 1674 |
else if ((pop_typ1 != STK_STR) && (pop_typ1 != STK_FIELD_MISSING)) |
| 1675 |
BEGIN |
| 1676 |
if (pop_typ1 != STK_EMPTY) |
| 1677 |
BEGIN |
| 1678 |
print_stk_lit (pop_lit1, pop_typ1); |
| 1679 |
BST_EX_WARN (", not a string or missing field,"); |
| 1680 |
END |
| 1681 |
push_lit_stk (0, STK_INT); |
| 1682 |
END |
| 1683 |
else if (pop_typ1 == STK_FIELD_MISSING) |
| 1684 |
BEGIN |
| 1685 |
push_lit_stk (1, STK_INT); |
| 1686 |
END |
| 1687 |
else |
| 1688 |
BEGIN |
| 1689 |
push_lit_stk (0, STK_INT); |
| 1690 |
END |
| 1691 |
END |
| 1692 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 424 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
/*************************************************************************** |
| 1698 |
* WEB section number: 426 |
| 1699 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1700 |
* The |built_in| function num.names$ pops the top (string) |
| 1701 |
* literal; it pushes the number of names the string represents---one |
| 1702 |
* plus the number of occurrences of the substring ``and'' (ignoring case |
| 1703 |
* differences) surrounded by nonnull |white_space| at the top brace |
| 1704 |
* level. If the literal isn't a string, it complains and pushes the |
| 1705 |
* value 0. |
| 1706 |
***************************************************************************/ |
| 1707 |
void x_num_names (void) |
| 1708 |
BEGIN |
| 1709 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1710 |
if (pop_typ1 != STK_STR) |
| 1711 |
BEGIN |
| 1712 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 1713 |
push_lit_stk (0, STK_INT); |
| 1714 |
END |
| 1715 |
else |
| 1716 |
BEGIN |
| 1717 |
ex_buf_length = 0; |
| 1718 |
add_buf_pool (pop_lit1); |
| 1719 |
|
| 1720 |
/*************************************************************************** |
| 1721 |
* WEB section number: 427 |
| 1722 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1723 |
* This module, while scanning the list of names, counts the occurrences |
| 1724 |
* of ``and'' (ignoring case differences) surrounded by nonnull |
| 1725 |
* |white_space|, and adds 1. |
| 1726 |
***************************************************************************/ |
| 1727 |
BEGIN |
| 1728 |
ex_buf_ptr = 0; |
| 1729 |
num_names = 0; |
| 1730 |
while (ex_buf_ptr < ex_buf_length) |
| 1731 |
BEGIN |
| 1732 |
name_scan_for_and (pop_lit1); |
| 1733 |
INCR (num_names); |
| 1734 |
END |
| 1735 |
END |
| 1736 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 427 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1737 |
|
| 1738 |
push_lit_stk (num_names, STK_INT); |
| 1739 |
END |
| 1740 |
END |
| 1741 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 426 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
/*************************************************************************** |
| 1746 |
* WEB section number: 348 |
| 1747 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1748 |
* The |built_in| function + pops the top two (integer) literals |
| 1749 |
* and pushes their sum. If either isn't an integer literal, it |
| 1750 |
* complains and pushes the integer 0. |
| 1751 |
***************************************************************************/ |
| 1752 |
void x_plus (void) |
| 1753 |
BEGIN |
| 1754 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1755 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 1756 |
if (pop_typ1 != STK_INT) |
| 1757 |
BEGIN |
| 1758 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 1759 |
push_lit_stk (0, STK_INT); |
| 1760 |
END |
| 1761 |
else if (pop_typ2 != STK_INT) |
| 1762 |
BEGIN |
| 1763 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 1764 |
push_lit_stk (0, STK_INT); |
| 1765 |
END |
| 1766 |
else |
| 1767 |
BEGIN |
| 1768 |
push_lit_stk (pop_lit2 + pop_lit1, STK_INT); |
| 1769 |
END |
| 1770 |
END |
| 1771 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 348 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
/*************************************************************************** |
| 1777 |
* WEB section number: 429 |
| 1778 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1779 |
* The |built_in| function preamble$ pushes onto the stack the |
| 1780 |
* concatenation of all the preamble strings read from the database |
| 1781 |
* files. |
| 1782 |
***************************************************************************/ |
| 1783 |
void x_preamble (void) |
| 1784 |
BEGIN |
| 1785 |
ex_buf_length = 0; |
| 1786 |
preamble_ptr = 0; |
| 1787 |
while (preamble_ptr < num_preamble_strings) |
| 1788 |
BEGIN |
| 1789 |
add_buf_pool (s_preamble[preamble_ptr]); |
| 1790 |
INCR (preamble_ptr); |
| 1791 |
END |
| 1792 |
add_pool_buf_and_push (); |
| 1793 |
END |
| 1794 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 429 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
/*************************************************************************** |
| 1800 |
* WEB section number: 430 |
| 1801 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1802 |
* The |built_in| function purify$ pops the top (string) literal, |
| 1803 |
* removes nonalphanumeric characters except for |white_space| and |
| 1804 |
* |sep_char| characters (these get converted to a |space|) and removes |
| 1805 |
* certain alphabetic characters contained in the control sequences |
| 1806 |
* associated with a special character, and pushes the resulting string. |
| 1807 |
* If the literal isn't a string, it complains and pushes the null |
| 1808 |
* string. |
| 1809 |
***************************************************************************/ |
| 1810 |
void x_purify (void) |
| 1811 |
BEGIN |
| 1812 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 1813 |
if (pop_typ1 != STK_STR) |
| 1814 |
BEGIN |
| 1815 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 1816 |
push_lit_stk (s_null, STK_STR); |
| 1817 |
END |
| 1818 |
else |
| 1819 |
BEGIN |
| 1820 |
ex_buf_length = 0; |
| 1821 |
add_buf_pool (pop_lit1); |
| 1822 |
|
| 1823 |
/*************************************************************************** |
| 1824 |
* WEB section number: 431 |
| 1825 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1826 |
* The resulting string has nonalphanumeric characters removed, and each |
| 1827 |
* |white_space| or |sep_char| character converted to a |space|. The next |
| 1828 |
* module handles special characters. This code doesn't complain if the |
| 1829 |
* string isn't brace balanced. |
| 1830 |
***************************************************************************/ |
| 1831 |
BEGIN |
| 1832 |
brace_level = 0; |
| 1833 |
ex_buf_xptr = 0; |
| 1834 |
ex_buf_ptr = 0; |
| 1835 |
while (ex_buf_ptr < ex_buf_length) |
| 1836 |
BEGIN |
| 1837 |
switch (lex_class[ex_buf[ex_buf_ptr]]) |
| 1838 |
BEGIN |
| 1839 |
case WHITE_SPACE: |
| 1840 |
case SEP_CHAR: |
| 1841 |
BEGIN |
| 1842 |
ex_buf[ex_buf_xptr] = SPACE; |
| 1843 |
INCR (ex_buf_xptr); |
| 1844 |
END |
| 1845 |
break; |
| 1846 |
case ALPHA: |
| 1847 |
case NUMERIC: |
| 1848 |
BEGIN |
| 1849 |
#ifdef UTF_8 |
| 1850 |
/* |
| 1851 |
When we processe the character UTF-8, the length has been changed. This focntion is used in |
| 1852 |
quick_sort. 23/sep/2009 |
| 1853 |
*/ |
| 1854 |
DO_UTF8(ex_buf[ex_buf_ptr], |
| 1855 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; |
| 1856 |
ex_buf_xptr += 1, |
| 1857 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; |
| 1858 |
ex_buf[ex_buf_xptr+1] = ex_buf[ex_buf_ptr+1]; |
| 1859 |
ex_buf_xptr += 2; ex_buf_ptr += 1, |
| 1860 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; |
| 1861 |
ex_buf[ex_buf_xptr+1] = ex_buf[ex_buf_ptr+1]; |
| 1862 |
ex_buf[ex_buf_xptr+2] = ex_buf[ex_buf_ptr+2]; |
| 1863 |
ex_buf_xptr += 3; ex_buf_ptr += 2, |
| 1864 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; |
| 1865 |
ex_buf[ex_buf_xptr+1] = ex_buf[ex_buf_ptr+1]; |
| 1866 |
ex_buf[ex_buf_xptr+2] = ex_buf[ex_buf_ptr+2]; |
| 1867 |
ex_buf[ex_buf_xptr+3] = ex_buf[ex_buf_ptr+3]; |
| 1868 |
ex_buf_xptr += 4; ex_buf_ptr += 3); |
| 1869 |
#else |
| 1870 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; |
| 1871 |
INCR (ex_buf_xptr); |
| 1872 |
#endif |
| 1873 |
END |
| 1874 |
break; |
| 1875 |
default: |
| 1876 |
if (ex_buf[ex_buf_ptr] == LEFT_BRACE) |
| 1877 |
BEGIN |
| 1878 |
INCR (brace_level); |
| 1879 |
if ((brace_level == 1) && ((ex_buf_ptr + 1) < ex_buf_length)) |
| 1880 |
BEGIN |
| 1881 |
if (ex_buf[ex_buf_ptr + 1] == BACKSLASH) |
| 1882 |
|
| 1883 |
/*************************************************************************** |
| 1884 |
* WEB section number: 432 |
| 1885 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1886 |
* Special characters (even without a matching |right_brace|) are |
| 1887 |
* purified by removing the control sequences (but restoring the correct |
| 1888 |
* thing for `\i' and `\j' as well as the eleven alphabetic |
| 1889 |
* foreign characters in Table~3.2 of the \LaTeX\ manual) and removing |
| 1890 |
* all nonalphanumeric characters (including |white_space| and |
| 1891 |
* |sep_char|s). |
| 1892 |
***************************************************************************/ |
| 1893 |
BEGIN |
| 1894 |
INCR (ex_buf_ptr); |
| 1895 |
while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)) |
| 1896 |
BEGIN |
| 1897 |
INCR (ex_buf_ptr); |
| 1898 |
ex_buf_yptr = ex_buf_ptr; |
| 1899 |
while ((ex_buf_ptr < ex_buf_length) |
| 1900 |
&& (lex_class[ex_buf[ex_buf_ptr]] == ALPHA)) |
| 1901 |
BEGIN |
| 1902 |
INCR (ex_buf_ptr); |
| 1903 |
END |
| 1904 |
control_seq_loc = str_lookup (ex_buf, ex_buf_yptr, |
| 1905 |
ex_buf_ptr - ex_buf_yptr, |
| 1906 |
CONTROL_SEQ_ILK, |
| 1907 |
DONT_INSERT); |
| 1908 |
if (hash_found) |
| 1909 |
|
| 1910 |
/*************************************************************************** |
| 1911 |
* WEB section number: 433 |
| 1912 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1913 |
* We consider the purified character to be either the first alphabetic |
| 1914 |
* character of its control sequence, or perhaps both alphabetic |
| 1915 |
* characters. |
| 1916 |
***************************************************************************/ |
| 1917 |
BEGIN |
| 1918 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_yptr]; |
| 1919 |
INCR (ex_buf_xptr); |
| 1920 |
switch (ilk_info[control_seq_loc]) |
| 1921 |
BEGIN |
| 1922 |
case N_OE: |
| 1923 |
case N_OE_UPPER: |
| 1924 |
case N_AE: |
| 1925 |
case N_AE_UPPER: |
| 1926 |
case N_SS: |
| 1927 |
BEGIN |
| 1928 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_yptr + 1]; |
| 1929 |
INCR (ex_buf_xptr); |
| 1930 |
END |
| 1931 |
break; |
| 1932 |
default: |
| 1933 |
DO_NOTHING; |
| 1934 |
break; |
| 1935 |
END |
| 1936 |
END |
| 1937 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 433 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1938 |
|
| 1939 |
while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0) |
| 1940 |
&& (ex_buf[ex_buf_ptr] != BACKSLASH)) |
| 1941 |
BEGIN |
| 1942 |
switch (lex_class[ex_buf[ex_buf_ptr]]) |
| 1943 |
BEGIN |
| 1944 |
case ALPHA: |
| 1945 |
case NUMERIC: |
| 1946 |
BEGIN |
| 1947 |
ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; |
| 1948 |
INCR (ex_buf_xptr); |
| 1949 |
END |
| 1950 |
break; |
| 1951 |
default: |
| 1952 |
if (ex_buf[ex_buf_ptr] == RIGHT_BRACE) |
| 1953 |
BEGIN |
| 1954 |
DECR (brace_level); |
| 1955 |
END |
| 1956 |
else if (ex_buf[ex_buf_ptr] == LEFT_BRACE) |
| 1957 |
BEGIN |
| 1958 |
INCR (brace_level); |
| 1959 |
END |
| 1960 |
break; |
| 1961 |
END |
| 1962 |
INCR (ex_buf_ptr); |
| 1963 |
END |
| 1964 |
END |
| 1965 |
DECR (ex_buf_ptr); |
| 1966 |
END |
| 1967 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 432 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1968 |
|
| 1969 |
END |
| 1970 |
END |
| 1971 |
else if (ex_buf[ex_buf_ptr] == RIGHT_BRACE) |
| 1972 |
BEGIN |
| 1973 |
if (brace_level > 0) |
| 1974 |
BEGIN |
| 1975 |
DECR (brace_level); |
| 1976 |
END |
| 1977 |
END |
| 1978 |
break; |
| 1979 |
END |
| 1980 |
INCR (ex_buf_ptr); |
| 1981 |
END |
| 1982 |
ex_buf_length = ex_buf_xptr; |
| 1983 |
END |
| 1984 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 431 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1985 |
|
| 1986 |
add_pool_buf_and_push (); |
| 1987 |
END |
| 1988 |
END |
| 1989 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 430 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 1990 |
|
| 1991 |
|
| 1992 |
|
| 1993 |
/*************************************************************************** |
| 1994 |
* WEB section number: 434 |
| 1995 |
* ~~~~~~~~~~~~~~~~~~~ |
| 1996 |
* The |built_in| function quote$ pushes the string consisting of |
| 1997 |
* the |double_quote| character. |
| 1998 |
***************************************************************************/ |
| 1999 |
void x_quote (void) |
| 2000 |
BEGIN |
| 2001 |
STR_ROOM (1); |
| 2002 |
APPEND_CHAR (DOUBLE_QUOTE); |
| 2003 |
push_lit_stk (make_string (), STK_STR); |
| 2004 |
END |
| 2005 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 434 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2006 |
|
| 2007 |
|
| 2008 |
/*************************************************************************** |
| 2009 |
* WEB section number: 437 |
| 2010 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2011 |
* The |built_in| function substring$ pops the top three literals |
| 2012 |
* (they are the two integers literals |pop_lit1| and |pop_lit2| and a |
| 2013 |
* string literal, in that order). It pushes the substring of the (at |
| 2014 |
* most) |pop_lit1| consecutive characters starting at the |pop_lit2|th |
| 2015 |
* character (assuming 1-based indexing) if |pop_lit2| is positive, and |
| 2016 |
* ending at the |-pop_lit2|th character from the end if |pop_lit2| is |
| 2017 |
* negative (where the first character from the end is the last |
| 2018 |
* character). If any of the types is incorrect, it complain and pushes |
| 2019 |
* the null string. |
| 2020 |
* |
| 2021 |
* Note: If |sp_length| is compared with a signed quantity (e.g. pop_lit2), |
| 2022 |
* must be first cast to |Integer_T| because it is an UNSIGNED variable. |
| 2023 |
***************************************************************************/ |
| 2024 |
void x_substring (void) |
| 2025 |
BEGIN |
| 2026 |
|
| 2027 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2028 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 2029 |
pop_lit_stk (&pop_lit3, &pop_typ3); |
| 2030 |
if (pop_typ1 != STK_INT) |
| 2031 |
BEGIN |
| 2032 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 2033 |
push_lit_stk (s_null, STK_STR); |
| 2034 |
END |
| 2035 |
else if (pop_typ2 != STK_INT) |
| 2036 |
BEGIN |
| 2037 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 2038 |
push_lit_stk (s_null, STK_STR); |
| 2039 |
END |
| 2040 |
else if (pop_typ3 != STK_STR) |
| 2041 |
BEGIN |
| 2042 |
print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR); |
| 2043 |
push_lit_stk (s_null, STK_STR); |
| 2044 |
END |
| 2045 |
else |
| 2046 |
BEGIN |
| 2047 |
#ifdef UTF_8 |
| 2048 |
/* |
| 2049 |
This is a new code of x_substring for processing the character UTF-8. |
| 2050 |
We transform the character to Unicode and then get the substring, then |
| 2051 |
back to UTF-8. 23/sep/2009 |
| 2052 |
*/ |
| 2053 |
Integer_T str_length = LENGTH (pop_lit3); |
| 2054 |
UChar32 uchs[BUF_SIZE+1]; |
| 2055 |
UChar uch16[BUF_SIZE+1]; |
| 2056 |
int32_t utcap = BUF_SIZE+1; |
| 2057 |
int32_t ulen; |
| 2058 |
unsigned char frUch1[BUF_SIZE+1]; |
| 2059 |
unsigned char frUch2[BUF_SIZE+1]; |
| 2060 |
int32_t frUchCap = BUF_SIZE + 1; |
| 2061 |
int32_t lenfrUch; |
| 2062 |
int32_t ptrfrUch; |
| 2063 |
|
| 2064 |
ulen = icu_toUChar32s(str_pool,str_start[pop_lit3],str_length,uchs,utcap,uch16); |
| 2065 |
sp_length = ulen; |
| 2066 |
#else |
| 2067 |
sp_length = LENGTH (pop_lit3); |
| 2068 |
#endif |
| 2069 |
if (pop_lit1 >= (Integer_T) sp_length) |
| 2070 |
BEGIN |
| 2071 |
if ((pop_lit2 == 1) || (pop_lit2 == -1)) |
| 2072 |
BEGIN |
| 2073 |
REPUSH_STRING; |
| 2074 |
goto Exit_Label; |
| 2075 |
END |
| 2076 |
END |
| 2077 |
|
| 2078 |
if ((pop_lit1 <= 0) || (pop_lit2 == 0) |
| 2079 |
|| (pop_lit2 > (Integer_T) sp_length) |
| 2080 |
|| (pop_lit2 < -(Integer_T) sp_length)) |
| 2081 |
BEGIN |
| 2082 |
push_lit_stk (s_null, STK_STR); |
| 2083 |
goto Exit_Label; |
| 2084 |
END |
| 2085 |
else |
| 2086 |
|
| 2087 |
/*************************************************************************** |
| 2088 |
* WEB section number: 438 |
| 2089 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2090 |
* This module finds the substring as described in the last section, |
| 2091 |
* and slides it into place in the string pool, if necessary. |
| 2092 |
***************************************************************************/ |
| 2093 |
BEGIN |
| 2094 |
if (pop_lit2 > 0) |
| 2095 |
BEGIN |
| 2096 |
if (pop_lit1 > (sp_length - (pop_lit2 - 1))) |
| 2097 |
BEGIN |
| 2098 |
pop_lit1 = sp_length - (pop_lit2 - 1); |
| 2099 |
END |
| 2100 |
#ifdef UTF_8 |
| 2101 |
lenfrUch = icu_fromUChar32s(frUch1, frUchCap, &uchs[pop_lit2-1], pop_lit1, uch16); |
| 2102 |
ptrfrUch = icu_fromUChar32s(frUch2, frUchCap, uchs, pop_lit2-1, uch16); |
| 2103 |
sp_ptr = str_start[pop_lit3] + ptrfrUch; |
| 2104 |
sp_end = sp_ptr + lenfrUch; |
| 2105 |
#else |
| 2106 |
sp_ptr = str_start[pop_lit3] + (pop_lit2 - 1); |
| 2107 |
sp_end = sp_ptr + pop_lit1; |
| 2108 |
#endif |
| 2109 |
if (pop_lit2 == 1) |
| 2110 |
BEGIN |
| 2111 |
if (pop_lit3 >= cmd_str_ptr) |
| 2112 |
BEGIN |
| 2113 |
str_start[pop_lit3 + 1] = sp_end; |
| 2114 |
UNFLUSH_STRING; |
| 2115 |
INCR (lit_stk_ptr); |
| 2116 |
goto Exit_Label; |
| 2117 |
END |
| 2118 |
END |
| 2119 |
END |
| 2120 |
else |
| 2121 |
BEGIN |
| 2122 |
pop_lit2 = -pop_lit2; |
| 2123 |
if (pop_lit1 > (Integer_T) (sp_length - (pop_lit2 - 1))) |
| 2124 |
BEGIN |
| 2125 |
pop_lit1 = sp_length - (pop_lit2 - 1); |
| 2126 |
END |
| 2127 |
#ifdef UTF_8 |
| 2128 |
lenfrUch = icu_fromUChar32s(frUch1, frUchCap, &uchs[ulen - (pop_lit2-1) - pop_lit1], pop_lit1, uch16); |
| 2129 |
ptrfrUch = icu_fromUChar32s(frUch2, frUchCap, uchs, ulen - (pop_lit2-1) - pop_lit1, uch16); |
| 2130 |
sp_ptr = str_start[pop_lit3] + ptrfrUch; |
| 2131 |
sp_end = sp_ptr + lenfrUch; |
| 2132 |
#else |
| 2133 |
sp_end = str_start[pop_lit3 + 1] - (pop_lit2 - 1); |
| 2134 |
sp_ptr = sp_end - pop_lit1; |
| 2135 |
#endif |
| 2136 |
END |
| 2137 |
STR_ROOM (sp_end - sp_ptr); |
| 2138 |
while (sp_ptr < sp_end) |
| 2139 |
BEGIN |
| 2140 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 2141 |
INCR (sp_ptr); |
| 2142 |
END |
| 2143 |
push_lit_stk (make_string (), STK_STR); |
| 2144 |
END |
| 2145 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 438 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2146 |
|
| 2147 |
END |
| 2148 |
Exit_Label: DO_NOTHING; |
| 2149 |
END |
| 2150 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 437 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2151 |
|
| 2152 |
|
| 2153 |
|
| 2154 |
/*************************************************************************** |
| 2155 |
* WEB section number: 439 |
| 2156 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2157 |
* The |built_in| function swap$ pops the top two literals from |
| 2158 |
* the stack and pushes them back swapped. |
| 2159 |
***************************************************************************/ |
| 2160 |
void x_swap (void) |
| 2161 |
BEGIN |
| 2162 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2163 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 2164 |
if ((pop_typ1 != STK_STR) || (pop_lit1 < cmd_str_ptr)) |
| 2165 |
BEGIN |
| 2166 |
push_lit_stk (pop_lit1, pop_typ1); |
| 2167 |
if ((pop_typ2 == STK_STR) && (pop_lit2 >= cmd_str_ptr)) |
| 2168 |
BEGIN |
| 2169 |
UNFLUSH_STRING; |
| 2170 |
END |
| 2171 |
push_lit_stk (pop_lit2, pop_typ2); |
| 2172 |
END |
| 2173 |
else if ((pop_typ2 != STK_STR) || (pop_lit2 < cmd_str_ptr)) |
| 2174 |
BEGIN |
| 2175 |
UNFLUSH_STRING; |
| 2176 |
push_lit_stk (pop_lit1, STK_STR); |
| 2177 |
push_lit_stk (pop_lit2, pop_typ2); |
| 2178 |
END |
| 2179 |
else |
| 2180 |
|
| 2181 |
/*************************************************************************** |
| 2182 |
* WEB section number: 440 |
| 2183 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2184 |
* We have to swap both (a)~the strings at the end of the string pool, |
| 2185 |
* and (b)~their pointers on the literal stack. |
| 2186 |
***************************************************************************/ |
| 2187 |
BEGIN |
| 2188 |
ex_buf_length = 0; |
| 2189 |
add_buf_pool (pop_lit2); |
| 2190 |
sp_ptr = str_start[pop_lit1]; |
| 2191 |
sp_end = str_start[pop_lit1 + 1]; |
| 2192 |
while (sp_ptr < sp_end) |
| 2193 |
BEGIN |
| 2194 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 2195 |
INCR (sp_ptr); |
| 2196 |
END |
| 2197 |
push_lit_stk (make_string (), STK_STR); |
| 2198 |
add_pool_buf_and_push (); |
| 2199 |
END |
| 2200 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 440 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2201 |
|
| 2202 |
END |
| 2203 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 439 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
/*************************************************************************** |
| 2208 |
* WEB section number: 441 |
| 2209 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2210 |
* The |built_in| function text.length$ pops the top (string) |
| 2211 |
* literal, and pushes the number of text characters it contains, where |
| 2212 |
* an accented character (more precisely, a ``special character''$\!$, |
| 2213 |
* defined earlier) counts as a single text character, even if it's |
| 2214 |
* missing its matching |right_brace|, and where braces don't count as |
| 2215 |
* text characters. If the literal isn't a string, it complains and |
| 2216 |
* pushes the null string. |
| 2217 |
***************************************************************************/ |
| 2218 |
void x_text_length (void) |
| 2219 |
BEGIN |
| 2220 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2221 |
if (pop_typ1 != STK_STR) |
| 2222 |
BEGIN |
| 2223 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 2224 |
push_lit_stk (s_null, STK_STR); |
| 2225 |
END |
| 2226 |
else |
| 2227 |
BEGIN |
| 2228 |
num_text_chars = 0; |
| 2229 |
|
| 2230 |
/*************************************************************************** |
| 2231 |
* WEB section number: 442 |
| 2232 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2233 |
* Here we determine the number of text characters in the string, where |
| 2234 |
* an entire special character counts as a single text character (even if |
| 2235 |
* it's missing its matching |right_brace|), and where braces don't count |
| 2236 |
* as text characters. |
| 2237 |
***************************************************************************/ |
| 2238 |
BEGIN |
| 2239 |
sp_ptr = str_start[pop_lit1]; |
| 2240 |
sp_end = str_start[pop_lit1 + 1]; |
| 2241 |
sp_brace_level = 0; |
| 2242 |
while (sp_ptr < sp_end) |
| 2243 |
BEGIN |
| 2244 |
INCR (sp_ptr); |
| 2245 |
if (str_pool[sp_ptr - 1] == LEFT_BRACE) |
| 2246 |
BEGIN |
| 2247 |
INCR (sp_brace_level); |
| 2248 |
if ((sp_brace_level == 1) && (sp_ptr < sp_end)) |
| 2249 |
BEGIN |
| 2250 |
if (str_pool[sp_ptr] == BACKSLASH) |
| 2251 |
BEGIN |
| 2252 |
INCR (sp_ptr); |
| 2253 |
while ((sp_ptr < sp_end) && (sp_brace_level > 0)) |
| 2254 |
BEGIN |
| 2255 |
if (str_pool[sp_ptr] == RIGHT_BRACE) |
| 2256 |
BEGIN |
| 2257 |
DECR (sp_brace_level); |
| 2258 |
END |
| 2259 |
else if (str_pool[sp_ptr] == LEFT_BRACE) |
| 2260 |
BEGIN |
| 2261 |
INCR (sp_brace_level); |
| 2262 |
END |
| 2263 |
INCR (sp_ptr); |
| 2264 |
END |
| 2265 |
#ifdef UTF_8 |
| 2266 |
/* |
| 2267 |
The length of character of UTF-8 is different. 23/sep/2009 |
| 2268 |
*/ |
| 2269 |
DO_UTF8(str_pool[sp_ptr-1], , sp_ptr++, sp_ptr += 2, sp_ptr += 3); |
| 2270 |
#endif |
| 2271 |
INCR (num_text_chars); |
| 2272 |
END |
| 2273 |
END |
| 2274 |
END |
| 2275 |
else if (str_pool[sp_ptr - 1] == RIGHT_BRACE) |
| 2276 |
BEGIN |
| 2277 |
if (sp_brace_level > 0) |
| 2278 |
BEGIN |
| 2279 |
DECR (sp_brace_level); |
| 2280 |
END |
| 2281 |
END |
| 2282 |
else |
| 2283 |
BEGIN |
| 2284 |
#ifdef UTF_8 |
| 2285 |
/* |
| 2286 |
The same for the length of character. 23/sep/2009 |
| 2287 |
*/ |
| 2288 |
DO_UTF8(str_pool[sp_ptr-1], , sp_ptr++, sp_ptr += 2, sp_ptr += 3); |
| 2289 |
#endif |
| 2290 |
INCR (num_text_chars); |
| 2291 |
END |
| 2292 |
END |
| 2293 |
END |
| 2294 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 442 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2295 |
|
| 2296 |
push_lit_stk (num_text_chars, STK_INT); |
| 2297 |
END |
| 2298 |
END |
| 2299 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 441 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2300 |
|
| 2301 |
|
| 2302 |
|
| 2303 |
|
| 2304 |
/*************************************************************************** |
| 2305 |
* WEB section number: 443 |
| 2306 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2307 |
* The |built_in| function text.prefix$ pops the top two literals |
| 2308 |
* (the integer literal |pop_lit1| and a string literal, in that order). |
| 2309 |
* It pushes the substring of the (at most) |pop_lit1| consecutive text |
| 2310 |
* characters starting from the beginning of the string. This function |
| 2311 |
* is similar to substring$ , but this one considers an accented |
| 2312 |
* character (or more precisely, a ``special character''$\!$, even if |
| 2313 |
* it's missing its matching |right_brace|) to be a single text character |
| 2314 |
* (rather than however many |ASCII_code| characters it actually |
| 2315 |
* comprises), and this function doesn't consider braces to be text |
| 2316 |
* characters; furthermore, this function appends any needed matching |
| 2317 |
* |right_brace|s. If any of the types is incorrect, it complains and |
| 2318 |
* pushes the null string. |
| 2319 |
***************************************************************************/ |
| 2320 |
void x_text_prefix (void) |
| 2321 |
BEGIN |
| 2322 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2323 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 2324 |
if (pop_typ1 != STK_INT) |
| 2325 |
BEGIN |
| 2326 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 2327 |
push_lit_stk (s_null, STK_STR); |
| 2328 |
END |
| 2329 |
else if (pop_typ2 != STK_STR) |
| 2330 |
BEGIN |
| 2331 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); |
| 2332 |
push_lit_stk (s_null, STK_STR); |
| 2333 |
END |
| 2334 |
else if (pop_lit1 <= 0) |
| 2335 |
BEGIN |
| 2336 |
push_lit_stk (s_null, STK_STR); |
| 2337 |
goto Exit_Label; |
| 2338 |
END |
| 2339 |
else |
| 2340 |
|
| 2341 |
/*************************************************************************** |
| 2342 |
* WEB section number: 444 |
| 2343 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2344 |
* This module finds the prefix as described in the last section, and |
| 2345 |
* appends any needed matching |right_brace|s. |
| 2346 |
***************************************************************************/ |
| 2347 |
BEGIN |
| 2348 |
sp_ptr = str_start[pop_lit2]; |
| 2349 |
sp_end = str_start[pop_lit2 + 1]; |
| 2350 |
|
| 2351 |
/*************************************************************************** |
| 2352 |
* WEB section number: 445 |
| 2353 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2354 |
* This section scans |pop_lit1| text characters, where an entire special |
| 2355 |
* character counts as a single text character (even if it's missing its |
| 2356 |
* matching |right_brace|), and where braces don't count as text |
| 2357 |
* characters. |
| 2358 |
***************************************************************************/ |
| 2359 |
BEGIN |
| 2360 |
num_text_chars = 0; |
| 2361 |
sp_brace_level = 0; |
| 2362 |
sp_xptr1 = sp_ptr; |
| 2363 |
while ((sp_xptr1 < sp_end) && (num_text_chars < pop_lit1)) |
| 2364 |
BEGIN |
| 2365 |
INCR (sp_xptr1); |
| 2366 |
if (str_pool[sp_xptr1 - 1] == LEFT_BRACE) |
| 2367 |
BEGIN |
| 2368 |
INCR (sp_brace_level); |
| 2369 |
if ((sp_brace_level == 1) && (sp_xptr1 < sp_end)) |
| 2370 |
BEGIN |
| 2371 |
if (str_pool[sp_xptr1] == BACKSLASH) |
| 2372 |
BEGIN |
| 2373 |
INCR (sp_xptr1); |
| 2374 |
while ((sp_xptr1 < sp_end) && (sp_brace_level > 0)) |
| 2375 |
BEGIN |
| 2376 |
if (str_pool[sp_xptr1] == RIGHT_BRACE) |
| 2377 |
BEGIN |
| 2378 |
DECR (sp_brace_level); |
| 2379 |
END |
| 2380 |
else if (str_pool[sp_xptr1] == LEFT_BRACE) |
| 2381 |
BEGIN |
| 2382 |
INCR (sp_brace_level); |
| 2383 |
END |
| 2384 |
INCR (sp_xptr1); |
| 2385 |
END |
| 2386 |
#ifdef UTF_8 |
| 2387 |
/* |
| 2388 |
The same for the length of character UTF-8. 23/sep/2009 |
| 2389 |
*/ |
| 2390 |
DO_UTF8(str_pool[sp_xptr1-1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3); |
| 2391 |
#endif |
| 2392 |
INCR (num_text_chars); |
| 2393 |
END |
| 2394 |
END |
| 2395 |
END |
| 2396 |
else if (str_pool[sp_xptr1 - 1] == RIGHT_BRACE) |
| 2397 |
BEGIN |
| 2398 |
if (sp_brace_level > 0) |
| 2399 |
BEGIN |
| 2400 |
DECR (sp_brace_level); |
| 2401 |
END |
| 2402 |
END |
| 2403 |
else |
| 2404 |
BEGIN |
| 2405 |
#ifdef UTF_8 |
| 2406 |
/* |
| 2407 |
The same for the length of character UTF-8. 23/sep/2009 |
| 2408 |
*/ |
| 2409 |
DO_UTF8(str_pool[sp_xptr1-1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3); |
| 2410 |
#endif |
| 2411 |
INCR (num_text_chars); |
| 2412 |
END |
| 2413 |
END |
| 2414 |
sp_end = sp_xptr1; |
| 2415 |
END |
| 2416 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 445 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2417 |
|
| 2418 |
STR_ROOM (sp_brace_level + sp_end - sp_ptr); |
| 2419 |
if (pop_lit2 >= cmd_str_ptr) |
| 2420 |
BEGIN |
| 2421 |
pool_ptr = sp_end; |
| 2422 |
END |
| 2423 |
else |
| 2424 |
BEGIN |
| 2425 |
while (sp_ptr < sp_end) |
| 2426 |
BEGIN |
| 2427 |
APPEND_CHAR (str_pool[sp_ptr]); |
| 2428 |
INCR (sp_ptr); |
| 2429 |
END |
| 2430 |
END |
| 2431 |
while (sp_brace_level > 0) |
| 2432 |
BEGIN |
| 2433 |
APPEND_CHAR (RIGHT_BRACE); |
| 2434 |
DECR (sp_brace_level); |
| 2435 |
END |
| 2436 |
push_lit_stk (make_string (), STK_STR); |
| 2437 |
END |
| 2438 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 444 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2439 |
|
| 2440 |
Exit_Label: DO_NOTHING; |
| 2441 |
END |
| 2442 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 443 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
/*************************************************************************** |
| 2447 |
* WEB section number: 447 |
| 2448 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2449 |
* The |built_in| function type$ pushes the appropriate string |
| 2450 |
* from |type_list| onto the stack (unless either it's |undefined| or |
| 2451 |
* |empty|, in which case it pushes the null string). |
| 2452 |
***************************************************************************/ |
| 2453 |
void x_type (void) |
| 2454 |
BEGIN |
| 2455 |
if ( ! mess_with_entries) |
| 2456 |
BEGIN |
| 2457 |
bst_cant_mess_with_entries_prin (); |
| 2458 |
END |
| 2459 |
else if ((type_list[cite_ptr] == UNDEFINED) |
| 2460 |
|| (type_list[cite_ptr] == EMPTY)) |
| 2461 |
BEGIN |
| 2462 |
push_lit_stk (s_null, STK_STR); |
| 2463 |
END |
| 2464 |
else |
| 2465 |
BEGIN |
| 2466 |
push_lit_stk (hash_text[type_list[cite_ptr]], STK_STR); |
| 2467 |
END |
| 2468 |
END |
| 2469 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 447 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
/*************************************************************************** |
| 2475 |
* WEB section number: 448 |
| 2476 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2477 |
* The |built_in| function warning$ pops the top (string) literal |
| 2478 |
* and prints it following a warning message. This is implemented as a |
| 2479 |
* special |built_in| function rather than using the top$ function |
| 2480 |
* so that it can |mark_warning|. |
| 2481 |
***************************************************************************/ |
| 2482 |
void x_warning (void) |
| 2483 |
BEGIN |
| 2484 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2485 |
if (pop_typ1 != STK_STR) |
| 2486 |
BEGIN |
| 2487 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 2488 |
END |
| 2489 |
else |
| 2490 |
BEGIN |
| 2491 |
PRINT ("Warning--"); |
| 2492 |
print_lit (pop_lit1, pop_typ1); |
| 2493 |
mark_warning (); |
| 2494 |
END |
| 2495 |
END |
| 2496 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 448 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2497 |
|
| 2498 |
#ifdef UTF_8 |
| 2499 |
Integer_T char_width_uni (ASCIICode_T * str) |
| 2500 |
BEGIN |
| 2501 |
UChar32 ch; |
| 2502 |
U8_GET_OR_FFFD(str, 0, 0, -1, ch); |
| 2503 |
if (ch<=LAST_LATIN_CHAR) |
| 2504 |
return ( char_width[ch] ); |
| 2505 |
else |
| 2506 |
BEGIN |
| 2507 |
switch ( u_getIntPropertyValue(ch, UCHAR_EAST_ASIAN_WIDTH) ) |
| 2508 |
BEGIN |
| 2509 |
case U_EA_WIDE: |
| 2510 |
case U_EA_FULLWIDTH: |
| 2511 |
return ( 1000 ); |
| 2512 |
case U_EA_HALFWIDTH: |
| 2513 |
return ( 500 ); |
| 2514 |
case U_EA_NARROW: |
| 2515 |
case U_EA_NEUTRAL: |
| 2516 |
case U_EA_AMBIGUOUS: |
| 2517 |
default: |
| 2518 |
return ( 700 ); |
| 2519 |
END |
| 2520 |
END |
| 2521 |
END |
| 2522 |
#endif |
| 2523 |
|
| 2524 |
/*************************************************************************** |
| 2525 |
* WEB section number: 450 |
| 2526 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2527 |
* The |built_in| function width$ pops the top (string) literal |
| 2528 |
* and pushes the integer that represents its width in units specified by |
| 2529 |
* the |char_width| array. This function takes the literal literally; |
| 2530 |
* that is, it assumes each character in the string is to be printed as |
| 2531 |
* is, regardless of whether the character has a special meaning to \TeX, |
| 2532 |
* except that special characters (even without their |right_brace|s) are |
| 2533 |
* handled specially. If the literal isn't a string, it complains and |
| 2534 |
* pushes~0. |
| 2535 |
***************************************************************************/ |
| 2536 |
void x_width (void) |
| 2537 |
BEGIN |
| 2538 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2539 |
if (pop_typ1 != STK_STR) |
| 2540 |
BEGIN |
| 2541 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 2542 |
push_lit_stk (0, STK_INT); |
| 2543 |
END |
| 2544 |
else |
| 2545 |
BEGIN |
| 2546 |
ex_buf_length = 0; |
| 2547 |
add_buf_pool (pop_lit1); |
| 2548 |
string_width = 0; |
| 2549 |
|
| 2550 |
/*************************************************************************** |
| 2551 |
* WEB section number: 451 |
| 2552 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2553 |
* We use the natural width for all but special characters, and we |
| 2554 |
* complain if the string isn't brace-balanced. |
| 2555 |
***************************************************************************/ |
| 2556 |
BEGIN |
| 2557 |
brace_level = 0; |
| 2558 |
ex_buf_ptr = 0; |
| 2559 |
while (ex_buf_ptr < ex_buf_length) |
| 2560 |
BEGIN |
| 2561 |
if (ex_buf[ex_buf_ptr] == LEFT_BRACE) |
| 2562 |
BEGIN |
| 2563 |
INCR (brace_level); |
| 2564 |
if ((brace_level == 1) && ((ex_buf_ptr + 1) < ex_buf_length)) |
| 2565 |
BEGIN |
| 2566 |
if (ex_buf[ex_buf_ptr + 1] == BACKSLASH) |
| 2567 |
|
| 2568 |
/*************************************************************************** |
| 2569 |
* WEB section number: 452 |
| 2570 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2571 |
* We use the natural widths of all characters except that some |
| 2572 |
* characters have no width: braces, control sequences (except for the |
| 2573 |
* usual 13 accented and foreign characters, whose widths are given in |
| 2574 |
* the next module), and |white_space| following control sequences (even |
| 2575 |
* a null control sequence). |
| 2576 |
***************************************************************************/ |
| 2577 |
BEGIN |
| 2578 |
INCR (ex_buf_ptr); |
| 2579 |
while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)) |
| 2580 |
BEGIN |
| 2581 |
INCR (ex_buf_ptr); |
| 2582 |
ex_buf_xptr = ex_buf_ptr; |
| 2583 |
while ((ex_buf_ptr < ex_buf_length) |
| 2584 |
&& (lex_class[ex_buf[ex_buf_ptr]] == ALPHA)) |
| 2585 |
BEGIN |
| 2586 |
INCR (ex_buf_ptr); |
| 2587 |
END |
| 2588 |
if ((ex_buf_ptr < ex_buf_length) |
| 2589 |
&& (ex_buf_ptr == ex_buf_xptr)) |
| 2590 |
BEGIN |
| 2591 |
INCR (ex_buf_ptr); |
| 2592 |
END |
| 2593 |
else |
| 2594 |
BEGIN |
| 2595 |
control_seq_loc = str_lookup (ex_buf, ex_buf_xptr, |
| 2596 |
ex_buf_ptr - ex_buf_xptr, |
| 2597 |
CONTROL_SEQ_ILK, DONT_INSERT); |
| 2598 |
if (hash_found) |
| 2599 |
|
| 2600 |
/*************************************************************************** |
| 2601 |
* WEB section number: 453 |
| 2602 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2603 |
* Five of the 13 possibilities resort to special information not present |
| 2604 |
* in the |char_width| array; the other eight simply use |char_width|'s |
| 2605 |
* information for the first letter of the control sequence. |
| 2606 |
***************************************************************************/ |
| 2607 |
BEGIN |
| 2608 |
switch (ilk_info[control_seq_loc]) |
| 2609 |
BEGIN |
| 2610 |
case N_SS: |
| 2611 |
string_width = string_width + SS_WIDTH; |
| 2612 |
break; |
| 2613 |
case N_AE: |
| 2614 |
string_width = string_width + AE_WIDTH; |
| 2615 |
break; |
| 2616 |
case N_OE: |
| 2617 |
string_width = string_width + OE_WIDTH; |
| 2618 |
break; |
| 2619 |
case N_AE_UPPER: |
| 2620 |
string_width = string_width + UPPER_AE_WIDTH; |
| 2621 |
break; |
| 2622 |
case N_OE_UPPER: |
| 2623 |
string_width = string_width + UPPER_OE_WIDTH; |
| 2624 |
break; |
| 2625 |
default: |
| 2626 |
string_width = string_width |
| 2627 |
+ char_width[ex_buf[ex_buf_xptr]]; |
| 2628 |
break; |
| 2629 |
END |
| 2630 |
END |
| 2631 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 453 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2632 |
|
| 2633 |
END |
| 2634 |
while ((ex_buf_ptr < ex_buf_length) |
| 2635 |
&& (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE)) |
| 2636 |
BEGIN |
| 2637 |
INCR (ex_buf_ptr); |
| 2638 |
END |
| 2639 |
while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0) |
| 2640 |
&& (ex_buf[ex_buf_ptr] != BACKSLASH)) |
| 2641 |
BEGIN |
| 2642 |
if (ex_buf[ex_buf_ptr] == RIGHT_BRACE) |
| 2643 |
BEGIN |
| 2644 |
DECR (brace_level); |
| 2645 |
END |
| 2646 |
else if (ex_buf[ex_buf_ptr] == LEFT_BRACE) |
| 2647 |
BEGIN |
| 2648 |
INCR (brace_level); |
| 2649 |
END |
| 2650 |
else |
| 2651 |
BEGIN |
| 2652 |
#if UTF_8 |
| 2653 |
string_width = string_width |
| 2654 |
+ char_width_uni(&ex_buf[ex_buf_ptr]); |
| 2655 |
#else |
| 2656 |
string_width = string_width |
| 2657 |
+ char_width[ex_buf[ex_buf_ptr]]; |
| 2658 |
#endif |
| 2659 |
END |
| 2660 |
#if UTF_8 |
| 2661 |
if (utf8len(ex_buf[ex_buf_ptr])>0) |
| 2662 |
ex_buf_ptr = ex_buf_ptr + utf8len(ex_buf[ex_buf_ptr]); |
| 2663 |
else |
| 2664 |
INCR (ex_buf_ptr); |
| 2665 |
#else |
| 2666 |
INCR (ex_buf_ptr); |
| 2667 |
#endif |
| 2668 |
END |
| 2669 |
END |
| 2670 |
DECR (ex_buf_ptr); |
| 2671 |
END |
| 2672 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 452 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2673 |
|
| 2674 |
else |
| 2675 |
BEGIN |
| 2676 |
string_width = string_width + char_width[LEFT_BRACE]; |
| 2677 |
END |
| 2678 |
END |
| 2679 |
else |
| 2680 |
BEGIN |
| 2681 |
string_width = string_width + char_width[LEFT_BRACE]; |
| 2682 |
END |
| 2683 |
END |
| 2684 |
else if (ex_buf[ex_buf_ptr] == RIGHT_BRACE) |
| 2685 |
BEGIN |
| 2686 |
decr_brace_level (pop_lit1); |
| 2687 |
string_width = string_width + char_width[RIGHT_BRACE]; |
| 2688 |
END |
| 2689 |
else |
| 2690 |
BEGIN |
| 2691 |
#if UTF_8 |
| 2692 |
string_width = string_width + char_width_uni(&ex_buf[ex_buf_ptr]); |
| 2693 |
#else |
| 2694 |
string_width = string_width + char_width[ex_buf[ex_buf_ptr]]; |
| 2695 |
#endif |
| 2696 |
END |
| 2697 |
#if UTF_8 |
| 2698 |
if (utf8len(ex_buf[ex_buf_ptr])>0) |
| 2699 |
ex_buf_ptr = ex_buf_ptr + utf8len(ex_buf[ex_buf_ptr]); |
| 2700 |
else |
| 2701 |
INCR (ex_buf_ptr); |
| 2702 |
#else |
| 2703 |
INCR (ex_buf_ptr); |
| 2704 |
#endif |
| 2705 |
END |
| 2706 |
check_brace_level (pop_lit1); |
| 2707 |
END |
| 2708 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2709 |
|
| 2710 |
push_lit_stk (string_width, STK_INT); |
| 2711 |
END |
| 2712 |
END |
| 2713 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 450 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
|
| 2719 |
/*************************************************************************** |
| 2720 |
* WEB section number: 454 |
| 2721 |
* ~~~~~~~~~~~~~~~~~~~ |
| 2722 |
* The |built_in| function write$ pops the top (string) literal |
| 2723 |
* and writes it onto the output buffer |out_buf| (which will result in |
| 2724 |
* stuff being written onto the .bbl file if the buffer fills up). If |
| 2725 |
* the literal isn't a string, it complains but does nothing else. |
| 2726 |
***************************************************************************/ |
| 2727 |
void x_write (void) |
| 2728 |
BEGIN |
| 2729 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2730 |
if (pop_typ1 != STK_STR) |
| 2731 |
BEGIN |
| 2732 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 2733 |
END |
| 2734 |
else |
| 2735 |
BEGIN |
| 2736 |
add_out_pool (pop_lit1); |
| 2737 |
END |
| 2738 |
END |
| 2739 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 454 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2740 |
void x_bit_and (void) |
| 2741 |
BEGIN |
| 2742 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2743 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 2744 |
if (pop_typ1 != STK_INT) |
| 2745 |
BEGIN |
| 2746 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 2747 |
push_lit_stk (0, STK_INT); |
| 2748 |
END |
| 2749 |
else if (pop_typ2 != STK_INT) |
| 2750 |
BEGIN |
| 2751 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 2752 |
push_lit_stk (0, STK_INT); |
| 2753 |
END |
| 2754 |
else |
| 2755 |
BEGIN |
| 2756 |
push_lit_stk (pop_lit1 & pop_lit2, STK_INT); |
| 2757 |
END |
| 2758 |
END |
| 2759 |
void x_bit_or (void) |
| 2760 |
BEGIN |
| 2761 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2762 |
pop_lit_stk (&pop_lit2, &pop_typ2); |
| 2763 |
if (pop_typ1 != STK_INT) |
| 2764 |
BEGIN |
| 2765 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); |
| 2766 |
push_lit_stk (0, STK_INT); |
| 2767 |
END |
| 2768 |
else if (pop_typ2 != STK_INT) |
| 2769 |
BEGIN |
| 2770 |
print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); |
| 2771 |
push_lit_stk (0, STK_INT); |
| 2772 |
END |
| 2773 |
else |
| 2774 |
BEGIN |
| 2775 |
push_lit_stk (pop_lit1 | pop_lit2, STK_INT); |
| 2776 |
END |
| 2777 |
END |
| 2778 |
#ifdef UTF_8 |
| 2779 |
|
| 2780 |
#define FULLWIDTH_DIGIT_0 0xFF10 |
| 2781 |
#define FULLWIDTH_DIGIT_9 0xFF19 |
| 2782 |
#define FULLWIDTH_CAPITAL_A 0xFF21 |
| 2783 |
#define FULLWIDTH_CAPITAL_Z 0xFF3A |
| 2784 |
#define FULLWIDTH_SMALL_A 0xFF41 |
| 2785 |
#define FULLWIDTH_SMALL_Z 0xFF5A |
| 2786 |
#define HALFWIDTH_KATAKANA_WO 0xFF66 |
| 2787 |
#define HALFWIDTH_KATAKANA_SMALL_TSU 0xFF6F |
| 2788 |
#define HALFWIDTH_KATAKANA_A 0xFF71 |
| 2789 |
#define HALFWIDTH_KATAKANA_N 0xFF9D |
| 2790 |
|
| 2791 |
void x_is_cjk_string (void) |
| 2792 |
BEGIN |
| 2793 |
pop_lit_stk (&pop_lit1, &pop_typ1); |
| 2794 |
if (pop_typ1 != STK_STR) |
| 2795 |
BEGIN |
| 2796 |
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); |
| 2797 |
push_lit_stk (-1, STK_INT); |
| 2798 |
END |
| 2799 |
else |
| 2800 |
BEGIN |
| 2801 |
ex_buf_length = 0; |
| 2802 |
add_buf_pool (pop_lit1); |
| 2803 |
string_width = 0; |
| 2804 |
BEGIN |
| 2805 |
ex_buf_ptr = 0; |
| 2806 |
while (ex_buf_ptr < ex_buf_length) |
| 2807 |
BEGIN |
| 2808 |
UChar32 ch; |
| 2809 |
U8_NEXT_OR_FFFD(ex_buf, ex_buf_ptr, -1, ch); |
| 2810 |
switch ( ublock_getCode(ch) ) |
| 2811 |
BEGIN |
| 2812 |
/* hanzi */ |
| 2813 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS: |
| 2814 |
case UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS: |
| 2815 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A: |
| 2816 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B: |
| 2817 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C: |
| 2818 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D: |
| 2819 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_E: |
| 2820 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_F: |
| 2821 |
#if defined(U_ICU_VERSION_MAJOR_NUM) |
| 2822 |
#if U_ICU_VERSION_MAJOR_NUM > 65 |
| 2823 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_G: |
| 2824 |
#endif |
| 2825 |
#if U_ICU_VERSION_MAJOR_NUM > 71 |
| 2826 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_H: |
| 2827 |
#endif |
| 2828 |
#if U_ICU_VERSION_MAJOR_NUM > 73 |
| 2829 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_I: |
| 2830 |
#endif |
| 2831 |
#if U_ICU_VERSION_MAJOR_NUM > 77 |
| 2832 |
case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_J: |
| 2833 |
#endif |
| 2834 |
#endif |
| 2835 |
string_width |= 0x001; |
| 2836 |
break; |
| 2837 |
/* kana */ |
| 2838 |
case UBLOCK_HIRAGANA: |
| 2839 |
case UBLOCK_KATAKANA: |
| 2840 |
case UBLOCK_KATAKANA_PHONETIC_EXTENSIONS: |
| 2841 |
case UBLOCK_KANA_EXTENDED_A: |
| 2842 |
#if defined(U_ICU_VERSION_MAJOR_NUM) |
| 2843 |
#if U_ICU_VERSION_MAJOR_NUM > 69 |
| 2844 |
case UBLOCK_KANA_EXTENDED_B: |
| 2845 |
#endif |
| 2846 |
#if U_ICU_VERSION_MAJOR_NUM > 63 |
| 2847 |
case UBLOCK_SMALL_KANA_EXTENSION: |
| 2848 |
#endif |
| 2849 |
#endif |
| 2850 |
string_width |= 0x002; |
| 2851 |
break; |
| 2852 |
/* hangul */ |
| 2853 |
case UBLOCK_HANGUL_SYLLABLES: |
| 2854 |
case UBLOCK_HANGUL_JAMO: |
| 2855 |
case UBLOCK_HANGUL_JAMO_EXTENDED_A: |
| 2856 |
case UBLOCK_HANGUL_JAMO_EXTENDED_B: |
| 2857 |
case UBLOCK_HANGUL_COMPATIBILITY_JAMO: |
| 2858 |
string_width |= 0x004; |
| 2859 |
break; |
| 2860 |
/* bopomofo */ |
| 2861 |
case UBLOCK_BOPOMOFO: |
| 2862 |
case UBLOCK_BOPOMOFO_EXTENDED: |
| 2863 |
string_width |= 0x008; |
| 2864 |
break; |
| 2865 |
case UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS: |
| 2866 |
/* Fullwidth ASCII variants except for U+FF01..FF0F, U+FF1A..FF20, U+FF3B..FF40, U+FF5B..FF5E */ |
| 2867 |
if ( (FULLWIDTH_DIGIT_0 <=ch && ch<=FULLWIDTH_DIGIT_9 ) |
| 2868 |
|| (FULLWIDTH_CAPITAL_A<=ch && ch<=FULLWIDTH_CAPITAL_Z) |
| 2869 |
|| (FULLWIDTH_SMALL_A <=ch && ch<=FULLWIDTH_SMALL_Z ) ) |
| 2870 |
string_width |= 0x800; |
| 2871 |
/* Halfwidth Katakana variants except for U+FF65, U+FF70, U+FF9E..FF9F */ |
| 2872 |
if ( (HALFWIDTH_KATAKANA_WO <=ch && ch<=HALFWIDTH_KATAKANA_SMALL_TSU ) |
| 2873 |
|| (HALFWIDTH_KATAKANA_A <=ch && ch<=HALFWIDTH_KATAKANA_N ) ) |
| 2874 |
string_width |= 0x002; |
| 2875 |
break; |
| 2876 |
/* miscellaneous */ |
| 2877 |
case UBLOCK_KANBUN: |
| 2878 |
case UBLOCK_KANGXI_RADICALS: |
| 2879 |
case UBLOCK_CJK_RADICALS_SUPPLEMENT: |
| 2880 |
string_width |= 0x800; |
| 2881 |
break; |
| 2882 |
END |
| 2883 |
END |
| 2884 |
END |
| 2885 |
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
| 2886 |
|
| 2887 |
push_lit_stk (string_width, STK_INT); |
| 2888 |
END |
| 2889 |
END |
| 2890 |
#endif |