1 /* Copyright 2014 Clerk Ma
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 /* following bit used to be end of tex1.c */
25 void restore_trace_(halfword p, char * s)
33 end_diagnostic(false);
43 if (cur_level > level_one)
51 if (save_type(save_ptr) == level_boundary)
54 p = save_index(save_ptr);
56 if (save_type(save_ptr) == insert_token)
65 if (save_type(save_ptr) == restore_old_value)
67 l = save_level(save_ptr);
71 save_stack[save_ptr] = eqtb[undefined_control_sequence];
74 if (eq_level(p) == level_one)
76 eq_destroy(save_stack[save_ptr]);
78 if (tracing_restores > 0)
79 restore_trace(p, "retaining");
85 eqtb[p] = save_stack[save_ptr];
87 if (tracing_restores > 0)
88 restore_trace(p, "restoring");
91 else if (xeq_level[p] != level_one)
93 eqtb[p] = save_stack[save_ptr];
96 if (tracing_restores > 0)
97 restore_trace(p, "restoring");
103 if (tracing_restores > 0)
104 restore_trace(p, "retaining");
110 cur_group = save_level(save_ptr);
111 cur_boundary = save_index(save_ptr);
115 confusion("curlevel");
119 /* This is where the old tex2.c used to start */
121 void prepare_mag (void)
123 if ((mag_set > 0) && (mag != mag_set))
125 print_err("Incompatible magnification (");
128 print_nl(" the previous value will be retained");
129 help2("I can handle only one magnification ratio per job. So I've",
130 "reverted to the magnification you used earlier on this run.");
132 geq_word_define(int_base + mag_code, mag_set);
135 if ((mag <= 0) || (mag > 32768L))
137 print_err("Illegal magnification has been changed to 1000");
138 help1("The magnification ratio must be between 1 and 32768.");
140 geq_word_define(int_base + mag_code, 1000);
146 void token_show_ (halfword p)
149 show_token_list(link(p), 0, 10000000L);
152 void print_meaning (void)
154 print_cmd_chr(cur_cmd, cur_chr);
162 else if (cur_cmd == top_bot_mark)
166 token_show(cur_mark[cur_chr]);
170 void show_cur_cmd_chr (void)
175 if (mode != shown_mode)
182 print_cmd_chr(cur_cmd, cur_chr);
184 end_diagnostic(false);
187 void show_context (void)
200 base_ptr = input_ptr;
201 input_stack[base_ptr] = cur_input;
207 cur_input = input_stack[base_ptr];
209 if ((state != token_list))
210 if ((name > 17) || (base_ptr == 0))
213 if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines))
215 if ((base_ptr == input_ptr) || (state != token_list) ||
216 (index != backed_up) || (loc != 0))
219 old_setting = selector;
221 if (state != token_list)
228 print_nl("<insert> ");
263 if (buffer[limit] == end_line_char)
269 for (i = start; i <= j - 1; i++)
282 print_nl("<argument> ");
287 print_nl("<template> ");
292 print_nl("<recently read> ");
294 print_nl("<to be read again> ");
298 print_nl("<inserted text> ");
307 print_nl("<output> ");
311 print_nl("<everypar> ");
314 case every_math_text:
315 print_nl("<everymath> ");
318 case every_display_text:
319 print_nl("<everydisplay> ");
322 case every_hbox_text:
323 print_nl("<everyhbox> ");
326 case every_vbox_text:
327 print_nl("<everyvbox> ");
331 print_nl("<everyjob> ");
335 print_nl("<everycr> ");
343 print_nl("<write> ");
354 show_token_list(start, loc, 100000L);
356 show_token_list(link(start), loc, 100000L);
359 selector = old_setting;
361 if (trick_count == 1000000L)
364 if (tally < trick_count)
365 m = tally - first_count;
367 m = trick_count - first_count;
369 if (l + first_count <= half_error_line)
377 p = l + first_count - half_error_line + 3;
381 for (q = p; q <= first_count - 1; q++)
382 print_char(trick_buf[q % error_line]);
386 for (q = 1; q <= n; q++)
389 if (m + n <= error_line)
392 p = first_count +(error_line - n - 3);
394 for (q = first_count; q <= p - 1; q++)
395 print_char(trick_buf[q % error_line]);
397 if (m + n > error_line)
403 else if (nn == error_context_lines)
416 cur_input = input_stack[input_ptr];
419 void begin_token_list_ (halfword p, quarterword t)
436 if (tracing_macros > 1)
452 print_cmd_chr(assign_toks, t - output_text + output_routine_loc);
458 end_diagnostic(false);
466 void end_token_list (void)
468 if (index >= backed_up)
470 if (index <= inserted)
474 delete_token_ref(start);
477 while (param_ptr > limit)
480 flush_list(param_stack[param_ptr]);
484 else if (index == u_template)
485 if (align_state > 500000L)
489 fatal_error("(interwoven alignment preambles are not allowed)");
497 void back_input (void)
501 while ((state == 0) && (loc == 0) &&
502 (index != v_template))
510 if (cur_tok < right_brace_limit)
511 if (cur_tok < left_brace_limit)
523 void back_error (void)
525 OK_to_interrupt = false;
527 OK_to_interrupt = true;
531 void ins_error (void)
533 OK_to_interrupt = false;
536 OK_to_interrupt = true;
540 void begin_file_reading (void)
542 if (in_open == max_in_open)
544 overflow("text input levels", max_in_open);
547 #ifdef ALLOCATEBUFFER
548 if (first == current_buf_size)
549 buffer = realloc_buffer(increment_buf_size);
551 if (first == current_buf_size) /* check again after allocation */
553 overflow("buffer size", current_buf_size);
557 if (first == buf_size)
559 overflow("buffer size", buf_size);
566 if (in_open > high_in_open) /* 1999 Jan 17 */
567 high_in_open = in_open;
571 line_stack[index] = line;
577 void end_file_reading (void)
580 line = line_stack[index];
588 /* called only form tex0.c */
590 void clear_for_error_prompt (void)
592 while ((state != 0) && (name == 0) &&
593 (input_ptr > 0) && (loc > limit))
599 void check_outer_validity (void)
604 if (scanner_status != 0)
606 deletions_allowed = false;
610 if ((state == 0) || (name < 1) || (name > 17))
613 info(p) = cs_token_flag + cur_cs;
621 if (scanner_status > skipping)
626 print_err("File ended");
630 print_err("Forbidden control sequence found");
633 prints(" while scanning ");
636 switch (scanner_status)
639 prints("definition");
640 info(p) = right_brace_token + '}';
646 long_state = outer_call;
651 info(p) = right_brace_token + '}';
655 info(p) = cs_token_flag + frozen_cr;
656 align_state = -1000000L;
661 info(p) = right_brace_token + '}';
667 sprint_cs(warning_index);
668 help4("I suspect you have forgotten a `}', causing me",
669 "to read past where you wanted me to stop.",
670 "I'll try to recover; but if the error is serious,",
671 "you'd better type `E' or `X' now and fix your file.");
676 print_err("Incomplete ");
677 print_cmd_chr(if_test, cur_if);
678 prints("; all text was ignored after line ");
679 print_int(skip_line);
680 help3("A forbidden control sequence occurred in skipped text.",
681 "This kind of error happens when you say `\\if...' and forget",
682 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
687 help_line[2] = "The file ended while I was skipping conditional text.";
689 cur_tok = cs_token_flag + frozen_fi;
693 deletions_allowed = true;
697 void firm_up_the_line (void)
704 if (interaction > nonstop_mode)
710 for (k = start; k <= limit - 1; k++)
718 for (k = first; k <= last - 1; k++)
719 buffer[k + start - first] = buffer[k];
721 limit = start + last - first;
726 void get_token (void)
728 no_new_control_sequence = false;
730 no_new_control_sequence = true;
733 cur_tok = (cur_cmd * 256) + cur_chr;
735 cur_tok = cs_token_flag + cur_cs;
738 void macro_call (void)
751 small_number save_scanner_status;
752 halfword save_warning_index;
753 ASCII_code match_chr;
755 save_scanner_status = scanner_status;
756 save_warning_index = warning_index;
757 warning_index = cur_cs;
762 if (tracing_macros > 0)
766 print_cs(warning_index);
767 token_show(ref_count);
768 end_diagnostic(false);
771 if (info(r) != end_match_token)
773 scanner_status = matching;
775 long_state = eq_type(cur_cs);
777 if (long_state >= outer_call)
778 long_state = long_state - 2;
784 if ((info(r) > match_token + 255) || (info(r) < match_token))
788 match_chr = info(r) - match_token;
797 if (cur_tok == info(r))
801 if ((info(r) >= match_token) && (info(r) <= end_match_token))
803 if (cur_tok < left_brace_limit)
815 print_err("Use of ");
816 sprint_cs(warning_index);
817 prints(" doesn't match its definition");
818 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
819 "put `1' after `\\a', since control sequence names are",
820 "made up of letters only. The macro here has not been",
821 "followed by the required stuff, so I'm ignoring it.");
830 store_new_token(info(t));
838 if (cur_tok != info(v))
846 if (info(u) != info(v))
860 if (cur_tok == par_token)
861 if (long_state != long_call)
863 if (long_state == call)
866 print_err("Paragraph ended before ");
867 sprint_cs(warning_index);
868 prints("was complete");
869 help3("I suspect you've forgotten a `}', causing me to apply this",
870 "control sequence to too much text. How can we recover?",
871 "My plan is to forget the whole thing and hope for the best.");
875 pstack[n] = link(temp_head);
876 align_state = align_state - unbalance;
878 for (m = 0; m <= n; m++)
879 flush_list(pstack[m]);
884 if (cur_tok < right_brace_limit)
885 if (cur_tok < left_brace_limit)
891 fast_store_new_token(cur_tok);
894 if (cur_tok == par_token)
895 if (long_state != long_call)
897 if (long_state == call)
900 print_err("Paragraph ended before ");
901 sprint_cs(warning_index);
902 prints(" was complete");
903 help3("I suspect you've forgotten a `}', causing me to apply this",
904 "control sequence to too much text. How can we recover?",
905 "My plan is to forget the whole thing and hope for the best.");
909 pstack[n] = link(temp_head);
910 align_state = align_state - unbalance;
912 for (m = 0; m <= n; m++)
913 flush_list(pstack[m]);
917 if (cur_tok < right_brace_limit)
918 if (cur_tok < left_brace_limit)
930 store_new_token(cur_tok);
935 print_err("Argument of ");
936 sprint_cs(warning_index);
937 prints(" has an extra }");
938 help6("I've run across a `}' that doesn't seem to match anything.",
939 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
940 "this error. If you simply proceed now, the `\\par' that",
941 "I've just inserted will cause me to report a runaway",
942 "argument that might be the root of the problem. But if",
943 "your `}' was spurious, just type `2' and it will go away.");
952 if (cur_tok == space_token)
953 if (info(r) <= end_match_token)
954 if (info(r) >= match_token)
957 store_new_token(cur_tok);
962 if (info(r) > end_match_token)
965 if (info(r) < match_token)
970 if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
972 link(rbrace_ptr) = 0;
979 pstack[n] = link(temp_head);
983 if (tracing_macros > 0)
986 //print_nl(match_chr);
987 print_nl(""); print(match_chr);
990 show_token_list(pstack[n - 1], 0, 1000);
991 end_diagnostic(false);
995 while (!(info(r) == end_match_token));
998 while ((state == token_list) && (loc == 0) &&
999 (index != v_template))
1002 begin_token_list(ref_count, macro);
1003 name = warning_index;
1008 if (param_ptr + n > max_param_stack)
1010 max_param_stack = param_ptr + n;
1012 #ifdef ALLOCATEPARAMSTACK
1013 if (max_param_stack > current_param_size)
1014 param_stack = realloc_param_stack(increment_param_size);
1016 if (max_param_stack > current_param_size)
1018 overflow("parameter stack size", current_param_size);
1022 if (max_param_stack > param_size)
1024 overflow("parameter stack size", param_size);
1030 for (m = 0; m <= n - 1; m++)
1031 param_stack[param_ptr + m] = pstack[m];
1033 param_ptr = param_ptr + n;
1036 scanner_status = save_scanner_status;
1037 warning_index = save_warning_index;
1040 void insert_relax (void)
1042 cur_tok = cs_token_flag + cur_cs;
1044 cur_tok = cs_token_flag + frozen_relax; /* 96/Jan/10 */
1055 small_number cvl_backup, radix_backup, co_backup;
1056 halfword backup_backup;
1057 small_number save_scanner_status;
1059 cv_backup = cur_val;
1060 cvl_backup = cur_val_level;
1061 radix_backup = radix;
1062 co_backup = cur_order;
1063 backup_backup = link(backup_head);
1067 if (tracing_commands > 1)
1073 if (cur_mark[cur_chr] != 0)
1074 begin_token_list(cur_mark[cur_chr], mark_text);
1082 if (cur_cmd > max_command)
1092 save_scanner_status = scanner_status;
1093 scanner_status = normal;
1095 scanner_status = save_scanner_status;
1099 if (t >= cs_token_flag)
1102 info(p) = cs_token_flag + frozen_dont_expand; /*96/Jan/10*/
1117 store_new_token(cur_tok);
1119 while (!(cur_cs != 0));
1121 if (cur_cmd != end_cs_name)
1123 print_err("Missing ");
1124 print_esc("endcsname");
1125 prints(" inserted");
1126 help2("The control sequence marked <to be read again> should",
1127 "not appear between \\csname and \\endcsname.");
1136 if (j >= max_buf_stack)
1138 max_buf_stack = j + 1;
1140 #ifdef ALLOCATEBUFFER
1141 if (max_buf_stack == current_buf_size)
1142 buffer = realloc_buffer (increment_buf_size);
1144 if (max_buf_stack == current_buf_size) /* check again after allocation */
1146 overflow("buffer size", current_buf_size);
1150 if (max_buf_stack == buf_size)
1152 overflow("buffer size", buf_size); /* buffer size - not dynamic */
1158 buffer[j] = info(p) % 256;
1165 no_new_control_sequence = false;
1166 cur_cs = id_lookup(first, j - first);
1167 no_new_control_sequence = true;
1169 else if (j == first)
1172 cur_cs = single_base + buffer[first];
1176 if (eq_type(cur_cs) == undefined_cs)
1178 eq_define(cur_cs, relax, 256);
1181 cur_tok = cur_cs + cs_token_flag;
1198 if (cur_chr > if_limit)
1203 print_err("Extra ");
1204 print_cmd_chr(fi_or_else, cur_chr);
1205 help1("I'm ignoring this; it doesn't match any \\if.");
1210 while (cur_chr != fi_code)
1215 if_line = if_line_field(p);
1216 cur_if = subtype(p);
1219 free_node(p, if_node_size);
1227 else if (name_in_progress)
1234 print_err("Undefined control sequence");
1235 help5("The control sequence at the end of the top line",
1236 "of your error message was never \\def'ed. If you have",
1237 "misspelled it (e.g., `\\hobx'), type `I' and the correct",
1238 "spelling (e.g., `I\\hbox'). Otherwise just continue,",
1239 "and I'll forget about whatever was undefined.");
1244 else if (cur_cmd < end_template)
1250 cur_tok = cs_token_flag + frozen_endv; /* 96/Jan/10 */
1254 cur_val = cv_backup;
1255 cur_val_level = cvl_backup;
1256 radix = radix_backup;
1257 cur_order = co_backup;
1258 link(backup_head) = backup_backup;
1261 void get_x_token (void)
1266 if (cur_cmd <= max_command)
1269 if (cur_cmd >= call)
1270 if (cur_cmd < end_template)
1274 cur_cs = frozen_endv;
1285 cur_tok = (cur_cmd * 256) + cur_chr;
1287 cur_tok = cs_token_flag + cur_cs;
1292 while (cur_cmd > max_command)
1299 cur_tok = (cur_cmd * 256) + cur_chr;
1301 cur_tok = cs_token_flag + cur_cs;
1304 void scan_left_brace (void)
1310 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1312 if (cur_cmd != left_brace)
1314 print_err("Missing { inserted");
1315 help4("A left brace was mandatory here, so I've put one in.",
1316 "You might want to delete and/or insert some corrections",
1317 "so that I will find a matching right brace soon.",
1318 "(If you're confused by all this, try typing `I}' now.)");
1320 cur_tok = left_brace_token + '{';
1321 cur_cmd = left_brace;
1327 void scan_optional_equals (void)
1333 while (!(cur_cmd != spacer));
1335 if (cur_tok != other_token + '=')
1339 boolean scan_keyword(const char * s)
1353 if ((cur_cs == 0) && ((cur_chr == (*k)) || (cur_chr == (*k) - 'a' + 'A')))
1355 store_new_token(cur_tok);
1358 else if ((cur_cmd != spacer) || (p != backup_head))
1362 if (p != backup_head)
1363 back_list(link(backup_head));
1369 flush_list(link(backup_head));
1374 void mu_error (void)
1376 print_err("Incompatible glue units");
1377 help1("I'm going to assume that 1mu=1pt when they're mixed.");
1381 void scan_eight_bit_int (void)
1385 if ((cur_val < 0) || (cur_val > 255))
1387 print_err("Bad register code");
1388 help2("A register number must be between 0 and 255.",
1389 "I changed this one to zero.");
1395 void scan_char_num (void)
1399 if ((cur_val < 0) || (cur_val > 255))
1401 print_err("Bad character code");
1402 help2("A character number must be between 0 and 255.",
1403 "I changed this one to zero.");
1409 void scan_four_bit_int (void)
1413 if ((cur_val < 0) || (cur_val > 15))
1415 print_err("Bad number");
1416 help2("Since I expected to read a number between 0 and 15,",
1417 "I changed this one to zero.");
1423 void scan_fifteen_bit_int (void)
1427 if ((cur_val < 0) || (cur_val > 32767))
1429 print_err("Bad mathchar");
1430 help2("A mathchar number must be between 0 and 32767.",
1431 "I changed this one to zero.");
1437 void scan_twenty_seven_bit_int (void)
1441 if ((cur_val < 0) || (cur_val > 134217727L))
1443 print_err("Bad delimiter code");
1444 help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
1445 "I changed this one to zero.");
1451 void scan_font_ident (void)
1453 internal_font_number f;
1460 while (!(cur_cmd != spacer));
1462 if (cur_cmd == def_font)
1464 else if (cur_cmd == set_font)
1466 else if (cur_cmd == def_family)
1469 scan_four_bit_int();
1470 f = equiv(m + cur_val);
1474 print_err("Missing font identifier");
1475 help2("I was looking for a control sequence whose",
1476 "current meaning has been defined by \\font.");
1484 void find_font_dimen_(boolean writing)
1486 internal_font_number f;
1494 if (n < 0 || (n == 0 && font_dimen_zero == 0)) /* change 98/Oct/5 */
1498 if (writing && (n <= space_shrink_code) && (n >= space_code) && (font_glue[f] != 0))
1500 delete_glue_ref(font_glue[f]);
1504 if (n > font_params[f])
1512 if (fmem_ptr == current_font_mem_size)
1513 font_info = realloc_font_info(increment_font_mem_size);
1515 if (fmem_ptr == current_font_mem_size)
1517 overflow("font memory", current_font_mem_size);
1521 if (fmem_ptr == font_mem_size)
1523 overflow("font memory", font_mem_size);
1527 font_info[fmem_ptr].cint = 0;
1529 incr(font_params[f]);
1531 while (!(n == font_params[f]));
1533 cur_val = fmem_ptr - 1;
1536 cur_val = n + param_base[f];
1539 if (cur_val == fmem_ptr)
1542 print_esc(""); print(font_id_text(f));
1543 prints(" has only ");
1544 print_int(font_params[f]);
1545 prints(" fontdimen parameters");
1546 help2("To increase the number of font parameters, you must",
1547 "use \\fontdimen immediately after the \\font is loaded.");
1552 void scan_something_internal_(small_number level, boolean negative)
1565 if (m == math_code_base)
1566 scanned_result(math_code(cur_val), int_val);
1567 else if (m < math_code_base)
1568 scanned_result(equiv(m + cur_val), int_val);
1570 scanned_result(eqtb[m + cur_val].cint, int_val);
1579 if (level != tok_val)
1581 print_err("Missing number, treated as zero");
1582 help3("A number should have been here; I inserted `0'.",
1583 "(If you can't figure out why I needed to see a number,",
1584 "look up `weird error' in the index to The TeXbook.)");
1586 scanned_result(0, dimen_val);
1588 else if (cur_cmd <= assign_toks)
1590 if (cur_cmd < assign_toks)
1592 scan_eight_bit_int();
1593 m = toks_base + cur_val;
1596 scanned_result(equiv(m), tok_val);
1602 scanned_result(font_id_base + cur_val, ident_val);
1607 scanned_result(eqtb[m].cint, int_val);
1611 scanned_result(eqtb[m].cint, dimen_val);
1615 scanned_result(equiv(m), glue_val);
1618 case assign_mu_glue:
1619 scanned_result(equiv(m), mu_val);
1625 print_err("Improper ");
1626 print_cmd_chr(set_aux, m);
1627 help4("You can refer to \\spacefactor only in horizontal mode;",
1628 "you can refer to \\prevdepth only in vertical mode; and",
1629 "neither of these is meaningful inside \\write. So",
1630 "I'm forgetting what you said and using zero instead.");
1633 if (level != tok_val)
1634 scanned_result(0, dimen_val);
1636 scanned_result(0, int_val);
1638 else if (m == vmode)
1639 scanned_result(prev_depth, dimen_val);
1641 scanned_result(space_factor, int_val);
1646 scanned_result(0, int_val);
1649 nest[nest_ptr] = cur_list;
1652 while (abs(nest[p].mode_field) != vmode)
1655 scanned_result(nest[p].pg_field, int_val);
1662 cur_val = dead_cycles;
1664 cur_val = insert_penalties;
1670 case set_page_dimen:
1672 if ((page_contents == 0) && (! output_active))
1674 cur_val = max_dimen;
1678 cur_val = page_so_far[m];
1680 cur_val_level = dimen_val;
1686 if (par_shape_ptr == 0)
1689 cur_val = info(par_shape_ptr);
1691 cur_val_level = int_val;
1697 scan_eight_bit_int();
1699 if (box(cur_val) == 0)
1702 cur_val = mem[box(cur_val) + m].cint;
1704 cur_val_level = dimen_val;
1710 scanned_result(cur_chr, int_val);
1713 case assign_font_dimen:
1715 find_font_dimen(false);
1716 font_info[fmem_ptr].cint = 0;
1717 scanned_result(font_info[cur_val].cint, dimen_val);
1721 case assign_font_int:
1726 scanned_result(hyphen_char[cur_val], int_val);
1728 scanned_result(skew_char[cur_val], int_val);
1734 scan_eight_bit_int();
1739 cur_val = count(cur_val);
1743 cur_val = dimen(cur_val);
1747 cur_val = skip(cur_val);
1751 cur_val = mu_skip(cur_val);
1760 if (cur_chr > glue_val)
1762 if (cur_chr == input_line_no_code)
1765 cur_val = last_badness;
1767 cur_val_level = int_val;
1771 if (cur_chr == glue_val)
1772 cur_val = zero_glue;
1776 cur_val_level = cur_chr;
1778 if (!is_char_node(tail) && (mode != 0))
1782 if (type(tail) == penalty_node)
1783 cur_val = penalty(tail);
1787 if (type(tail) == kern_node)
1788 cur_val = width(tail);
1792 if (type(tail) == glue_node)
1794 cur_val = glue_ptr(tail);
1796 if (subtype(tail) == mu_glue)
1797 cur_val_level = mu_val;
1801 else if ((mode == vmode) && (tail == head))
1805 cur_val = last_penalty;
1809 cur_val = last_kern;
1813 if (last_glue != empty_flag)
1814 cur_val = last_glue;
1822 print_err("You can't use `");
1823 print_cmd_chr(cur_cmd, cur_chr);
1826 help1("I'm forgetting what you said and using zero instead.");
1829 if (level != tok_val)
1830 scanned_result(0, dimen_val);
1832 scanned_result(0, int_val);
1837 while (cur_val_level > level)
1839 if (cur_val_level == glue_val)
1840 cur_val = width(cur_val);
1841 else if (cur_val_level == mu_val)
1844 decr(cur_val_level);
1848 if (cur_val_level >= 2)
1850 cur_val = new_spec(cur_val);
1853 width(cur_val) = -width(cur_val);
1854 stretch(cur_val) = -stretch(cur_val);
1855 shrink(cur_val) = -shrink(cur_val);
1860 else if ((cur_val_level >= glue_val) && (cur_val_level <= mu_val))
1861 add_glue_ref(cur_val);
1864 void get_next (void)
1868 /* char cat; */ /* make this an int ? */
1869 int cat; /* make this an int ? 95/Jan/7 */
1876 if (state != token_list)
1881 cur_chr = buffer[loc];
1884 cur_cmd = cat_code(cur_chr);
1886 switch (state + cur_cmd)
1888 case any_state_plus(ignore):
1889 case skip_blanks + spacer:
1890 case new_line + spacer:
1894 case any_state_plus(escape):
1902 cur_chr = buffer[k];
1903 cat = cat_code(cur_chr);
1907 state = skip_blanks;
1908 else if (cat == spacer)
1909 state = skip_blanks;
1913 if ((cat == letter) && (k <= limit))
1917 cur_chr = buffer[k];
1918 cat = cat_code(cur_chr);
1921 while (!((cat != letter) || (k > limit)));
1924 if (buffer[k]== cur_chr)
1925 if (cat == sup_mark)
1945 buffer[k - 1] = cur_chr;
1948 buffer[k - 1] = c + 64;
1950 buffer[k - 1] = c - 64;
1957 buffer[k] = buffer[k + d];
1971 cur_cs = id_lookup(loc, k - loc);
1978 if (buffer[k] == cur_chr)
1979 if (cat == sup_mark)
1984 if (c < 128) /* ? */
2000 buffer[k - 1] = cur_chr;
2003 buffer[k - 1] = c + 64;
2005 buffer[k - 1] = c - 64;
2012 buffer[k] = buffer[k + d];
2019 cur_cs = single_base + buffer[loc];
2023 cur_cmd = eq_type(cur_cs);
2024 cur_chr = equiv(cur_cs);
2026 if (cur_cmd >= outer_call)
2027 check_outer_validity();
2031 case any_state_plus(active_char):
2033 cur_cs = cur_chr + active_base;
2034 cur_cmd = eq_type(cur_cs);
2035 cur_chr = equiv(cur_cs);
2038 if (cur_cmd >= outer_call)
2039 check_outer_validity();
2043 case any_state_plus(sup_mark):
2045 if (cur_chr == buffer[loc])
2048 c = buffer[loc + 1];
2080 case any_state_plus(invalid_char):
2082 print_err("Text line contains an invalid character");
2083 help2("A funny symbol that I can't read has just been input.",
2084 "Continue, and I'll forget that it ever happened.");
2085 deletions_allowed = false;
2087 deletions_allowed = true;
2092 case mid_line + spacer:
2094 state = skip_blanks;
2099 case mid_line + car_ret:
2107 case skip_blanks + car_ret:
2108 case any_state_plus(comment):
2115 case new_line + car_ret:
2119 cur_cmd = eq_type(cur_cs);
2120 cur_chr = equiv(cur_cs);
2122 if (cur_cmd >= outer_call)
2123 check_outer_validity();
2127 case mid_line + left_brace:
2131 case skip_blanks + left_brace:
2132 case new_line + left_brace:
2139 case mid_line + right_brace:
2143 case skip_blanks + right_brace:
2144 case new_line + right_brace:
2151 case add_delims_to(skip_blanks):
2152 case add_delims_to(new_line):
2171 if (input_ln(cur_file, true))
2184 check_outer_validity();
2188 if (end_line_char_inactive())
2191 buffer[limit] = end_line_char;
2211 if (selector < log_only)
2214 if (interaction > nonstop_mode)
2216 if (end_line_char_inactive())
2220 print_nl("(Please type a command or say `\\end')");
2227 if (end_line_char_inactive())
2230 buffer[limit]= end_line_char;
2237 fatal_error("*** (job aborted, no legal \\end found)");
2251 if (t >= cs_token_flag)
2253 cur_cs = t - cs_token_flag;
2254 cur_cmd = eq_type(cur_cs);
2255 cur_chr = equiv(cur_cs);
2257 if (cur_cmd >= outer_call)
2258 if (cur_cmd == dont_expand)
2260 cur_cs = info(loc) - cs_token_flag;
2262 cur_cmd = eq_type(cur_cs);
2263 cur_chr = equiv(cur_cs);
2265 if (cur_cmd > max_command)
2268 cur_chr = no_expand_flag;
2273 check_outer_validity();
2293 begin_token_list(param_stack[limit + cur_chr - 1], parameter);
2309 if (cur_cmd <= car_ret)
2310 if (cur_cmd >= tab_mark)
2311 if (align_state == 0)
2313 if ((scanner_status == aligning) && (cur_align == 0))
2315 fatal_error("(interwoven alignment preambles are not allowed)");
2319 cur_cmd = extra_info(cur_align);
2320 extra_info(cur_align) = cur_chr;
2322 if (cur_cmd == omit)
2323 begin_token_list(omit_template, v_template);
2325 begin_token_list(v_part(cur_align), v_template);
2327 align_state = 1000000L;