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 (pointer p, const 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");
111 cur_group = save_level(save_ptr);
112 cur_boundary = save_index(save_ptr);
116 confusion("curlevel");
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 (pointer 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_ (pointer 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);
548 #ifdef ALLOCATEBUFFER
549 if (first == current_buf_size)
550 buffer = realloc_buffer(increment_buf_size);
552 if (first == current_buf_size)
554 overflow("buffer size", current_buf_size);
558 if (first == buf_size)
560 overflow("buffer size", buf_size);
567 if (in_open > high_in_open) /* 1999 Jan 17 */
568 high_in_open = in_open;
572 line_stack[index] = line;
578 void end_file_reading (void)
581 line = line_stack[index];
589 /* called only form tex0.c */
591 void clear_for_error_prompt (void)
593 while ((state != 0) && (name == 0) &&
594 (input_ptr > 0) && (loc > limit))
600 void check_outer_validity (void)
605 if (scanner_status != 0)
607 deletions_allowed = false;
611 if ((state == 0) || (name < 1) || (name > 17))
614 info(p) = cs_token_flag + cur_cs;
622 if (scanner_status > skipping)
627 print_err("File ended");
631 print_err("Forbidden control sequence found");
634 prints(" while scanning ");
637 switch (scanner_status)
640 prints("definition");
641 info(p) = right_brace_token + '}';
647 long_state = outer_call;
652 info(p) = right_brace_token + '}';
656 info(p) = cs_token_flag + frozen_cr;
657 align_state = -1000000L;
662 info(p) = right_brace_token + '}';
668 sprint_cs(warning_index);
669 help4("I suspect you have forgotten a `}', causing me",
670 "to read past where you wanted me to stop.",
671 "I'll try to recover; but if the error is serious,",
672 "you'd better type `E' or `X' now and fix your file.");
677 print_err("Incomplete ");
678 print_cmd_chr(if_test, cur_if);
679 prints("; all text was ignored after line ");
680 print_int(skip_line);
681 help3("A forbidden control sequence occurred in skipped text.",
682 "This kind of error happens when you say `\\if...' and forget",
683 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
688 help_line[2] = "The file ended while I was skipping conditional text.";
690 cur_tok = cs_token_flag + frozen_fi;
694 deletions_allowed = true;
698 void firm_up_the_line (void)
705 if (interaction > nonstop_mode)
711 for (k = start; k <= limit - 1; k++)
719 for (k = first; k <= last - 1; k++)
720 buffer[k + start - first] = buffer[k];
722 limit = start + last - first;
727 void get_token (void)
729 no_new_control_sequence = false;
731 no_new_control_sequence = true;
734 cur_tok = (cur_cmd * 256) + cur_chr;
736 cur_tok = cs_token_flag + cur_cs;
739 void macro_call (void)
752 small_number save_scanner_status;
753 pointer save_warning_index;
754 ASCII_code match_chr;
756 save_scanner_status = scanner_status;
757 save_warning_index = warning_index;
758 warning_index = cur_cs;
763 if (tracing_macros > 0)
767 print_cs(warning_index);
768 token_show(ref_count);
769 end_diagnostic(false);
772 if (info(r) != end_match_token)
774 scanner_status = matching;
776 long_state = eq_type(cur_cs);
778 if (long_state >= outer_call)
779 long_state = long_state - 2;
785 if ((info(r) > match_token + 255) || (info(r) < match_token))
789 match_chr = info(r) - match_token;
799 if (cur_tok == info(r))
803 if ((info(r) >= match_token) && (info(r) <= end_match_token))
805 if (cur_tok < left_brace_limit)
817 print_err("Use of ");
818 sprint_cs(warning_index);
819 prints(" doesn't match its definition");
820 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
821 "put `1' after `\\a', since control sequence names are",
822 "made up of letters only. The macro here has not been",
823 "followed by the required stuff, so I'm ignoring it.");
833 store_new_token(info(t));
841 if (cur_tok != info(v))
849 if (info(u) != info(v))
863 if (cur_tok == par_token)
864 if (long_state != long_call)
866 if (long_state == call)
869 print_err("Paragraph ended before ");
870 sprint_cs(warning_index);
871 prints("was complete");
872 help3("I suspect you've forgotten a `}', causing me to apply this",
873 "control sequence to too much text. How can we recover?",
874 "My plan is to forget the whole thing and hope for the best.");
878 pstack[n] = link(temp_head);
879 align_state = align_state - unbalance;
881 for (m = 0; m <= n; m++)
882 flush_list(pstack[m]);
887 if (cur_tok < right_brace_limit)
888 if (cur_tok < left_brace_limit)
894 fast_store_new_token(cur_tok);
897 if (cur_tok == par_token)
898 if (long_state != long_call)
900 if (long_state == call)
903 print_err("Paragraph ended before ");
904 sprint_cs(warning_index);
905 prints(" was complete");
906 help3("I suspect you've forgotten a `}', causing me to apply this",
907 "control sequence to too much text. How can we recover?",
908 "My plan is to forget the whole thing and hope for the best.");
912 pstack[n] = link(temp_head);
913 align_state = align_state - unbalance;
915 for (m = 0; m <= n; m++)
916 flush_list(pstack[m]);
920 if (cur_tok < right_brace_limit)
921 if (cur_tok < left_brace_limit)
933 store_new_token(cur_tok);
938 print_err("Argument of ");
939 sprint_cs(warning_index);
940 prints(" has an extra }");
941 help6("I've run across a `}' that doesn't seem to match anything.",
942 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
943 "this error. If you simply proceed now, the `\\par' that",
944 "I've just inserted will cause me to report a runaway",
945 "argument that might be the root of the problem. But if",
946 "your `}' was spurious, just type `2' and it will go away.");
955 if (cur_tok == space_token)
956 if (info(r) <= end_match_token)
957 if (info(r) >= match_token)
960 store_new_token(cur_tok);
965 if (info(r) > end_match_token)
968 if (info(r) < match_token)
974 if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
976 link(rbrace_ptr) = 0;
983 pstack[n] = link(temp_head);
987 if (tracing_macros > 0)
990 //print_nl(match_chr);
991 print_nl(""); print(match_chr);
994 show_token_list(pstack[n - 1], 0, 1000);
995 end_diagnostic(false);
999 while (!(info(r) == end_match_token));
1002 while ((state == token_list) && (loc == 0) &&
1003 (index != v_template))
1006 begin_token_list(ref_count, macro);
1007 name = warning_index;
1012 if (param_ptr + n > max_param_stack)
1014 max_param_stack = param_ptr + n;
1016 #ifdef ALLOCATEPARAMSTACK
1017 if (max_param_stack > current_param_size)
1018 param_stack = realloc_param_stack(increment_param_size);
1020 if (max_param_stack > current_param_size)
1022 overflow("parameter stack size", current_param_size);
1026 if (max_param_stack > param_size)
1028 overflow("parameter stack size", param_size);
1034 for (m = 0; m <= n - 1; m++)
1035 param_stack[param_ptr + m] = pstack[m];
1037 param_ptr = param_ptr + n;
1041 scanner_status = save_scanner_status;
1042 warning_index = save_warning_index;
1045 void insert_relax (void)
1047 cur_tok = cs_token_flag + cur_cs;
1049 cur_tok = cs_token_flag + frozen_relax;
1060 small_number cvl_backup, radix_backup, co_backup;
1061 pointer backup_backup;
1062 small_number save_scanner_status;
1064 cv_backup = cur_val;
1065 cvl_backup = cur_val_level;
1066 radix_backup = radix;
1067 co_backup = cur_order;
1068 backup_backup = link(backup_head);
1072 if (tracing_commands > 1)
1078 if (cur_mark[cur_chr] != 0)
1079 begin_token_list(cur_mark[cur_chr], mark_text);
1087 if (cur_cmd > max_command)
1097 save_scanner_status = scanner_status;
1098 scanner_status = normal;
1100 scanner_status = save_scanner_status;
1104 if (t >= cs_token_flag)
1107 info(p) = cs_token_flag + frozen_dont_expand;
1123 store_new_token(cur_tok);
1125 while (!(cur_cs != 0));
1127 if (cur_cmd != end_cs_name)
1129 print_err("Missing ");
1130 print_esc("endcsname");
1131 prints(" inserted");
1132 help2("The control sequence marked <to be read again> should",
1133 "not appear between \\csname and \\endcsname.");
1142 if (j >= max_buf_stack)
1144 max_buf_stack = j + 1;
1146 #ifdef ALLOCATEBUFFER
1147 if (max_buf_stack == current_buf_size)
1148 buffer = realloc_buffer (increment_buf_size);
1150 if (max_buf_stack == current_buf_size)
1152 overflow("buffer size", current_buf_size);
1156 if (max_buf_stack == buf_size)
1158 overflow("buffer size", buf_size);
1164 buffer[j] = info(p) % 256;
1171 no_new_control_sequence = false;
1172 cur_cs = id_lookup(first, j - first);
1173 no_new_control_sequence = true;
1175 else if (j == first)
1178 cur_cs = single_base + buffer[first];
1182 if (eq_type(cur_cs) == undefined_cs)
1184 eq_define(cur_cs, relax, 256);
1187 cur_tok = cur_cs + cs_token_flag;
1204 if (cur_chr > if_limit)
1209 print_err("Extra ");
1210 print_cmd_chr(fi_or_else, cur_chr);
1211 help1("I'm ignoring this; it doesn't match any \\if.");
1216 while (cur_chr != fi_code)
1221 if_line = if_line_field(p);
1222 cur_if = subtype(p);
1225 free_node(p, if_node_size);
1233 else if (name_in_progress)
1240 print_err("Undefined control sequence");
1241 help5("The control sequence at the end of the top line",
1242 "of your error message was never \\def'ed. If you have",
1243 "misspelled it (e.g., `\\hobx'), type `I' and the correct",
1244 "spelling (e.g., `I\\hbox'). Otherwise just continue,",
1245 "and I'll forget about whatever was undefined.");
1250 else if (cur_cmd < end_template)
1256 cur_tok = cs_token_flag + frozen_endv;
1260 cur_val = cv_backup;
1261 cur_val_level = cvl_backup;
1262 radix = radix_backup;
1263 cur_order = co_backup;
1264 link(backup_head) = backup_backup;
1267 void get_x_token (void)
1272 if (cur_cmd <= max_command)
1275 if (cur_cmd >= call)
1276 if (cur_cmd < end_template)
1280 cur_cs = frozen_endv;
1291 cur_tok = (cur_cmd * 256) + cur_chr;
1293 cur_tok = cs_token_flag + cur_cs;
1298 while (cur_cmd > max_command)
1305 cur_tok = (cur_cmd * 256) + cur_chr;
1307 cur_tok = cs_token_flag + cur_cs;
1310 void scan_left_brace (void)
1316 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1318 if (cur_cmd != left_brace)
1320 print_err("Missing { inserted");
1321 help4("A left brace was mandatory here, so I've put one in.",
1322 "You might want to delete and/or insert some corrections",
1323 "so that I will find a matching right brace soon.",
1324 "(If you're confused by all this, try typing `I}' now.)");
1326 cur_tok = left_brace_token + '{';
1327 cur_cmd = left_brace;
1333 void scan_optional_equals (void)
1339 while (!(cur_cmd != spacer));
1341 if (cur_tok != other_token + '=')
1345 boolean scan_keyword (const char * s)
1359 if ((cur_cs == 0) && ((cur_chr == (*k)) || (cur_chr == (*k) - 'a' + 'A')))
1361 store_new_token(cur_tok);
1364 else if ((cur_cmd != spacer) || (p != backup_head))
1368 if (p != backup_head)
1369 back_list(link(backup_head));
1375 flush_list(link(backup_head));
1380 void mu_error (void)
1382 print_err("Incompatible glue units");
1383 help1("I'm going to assume that 1mu=1pt when they're mixed.");
1387 void scan_eight_bit_int (void)
1391 if ((cur_val < 0) || (cur_val > 255))
1393 print_err("Bad register code");
1394 help2("A register number must be between 0 and 255.",
1395 "I changed this one to zero.");
1401 void scan_char_num (void)
1405 if ((cur_val < 0) || (cur_val > 255))
1407 print_err("Bad character code");
1408 help2("A character number must be between 0 and 255.",
1409 "I changed this one to zero.");
1415 void scan_four_bit_int (void)
1419 if ((cur_val < 0) || (cur_val > 15))
1421 print_err("Bad number");
1422 help2("Since I expected to read a number between 0 and 15,",
1423 "I changed this one to zero.");
1429 void scan_fifteen_bit_int (void)
1433 if ((cur_val < 0) || (cur_val > 32767))
1435 print_err("Bad mathchar");
1436 help2("A mathchar number must be between 0 and 32767.",
1437 "I changed this one to zero.");
1443 void scan_twenty_seven_bit_int (void)
1447 if ((cur_val < 0) || (cur_val > 134217727L))
1449 print_err("Bad delimiter code");
1450 help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
1451 "I changed this one to zero.");
1457 void scan_font_ident (void)
1459 internal_font_number f;
1466 while (!(cur_cmd != spacer));
1468 if (cur_cmd == def_font)
1470 else if (cur_cmd == set_font)
1472 else if (cur_cmd == def_family)
1475 scan_four_bit_int();
1476 f = equiv(m + cur_val);
1480 print_err("Missing font identifier");
1481 help2("I was looking for a control sequence whose",
1482 "current meaning has been defined by \\font.");
1490 void find_font_dimen (boolean writing)
1492 internal_font_number f;
1504 if (writing && (n <= space_shrink_code) && (n >= space_code) && (font_glue[f] != 0))
1506 delete_glue_ref(font_glue[f]);
1510 if (n > font_params[f])
1518 if (fmem_ptr == current_font_mem_size)
1519 font_info = realloc_font_info(increment_font_mem_size);
1521 if (fmem_ptr == current_font_mem_size)
1523 overflow("font memory", current_font_mem_size);
1527 if (fmem_ptr == font_mem_size)
1529 overflow("font memory", font_mem_size);
1533 font_info[fmem_ptr].cint = 0;
1535 incr(font_params[f]);
1537 while (!(n == font_params[f]));
1539 cur_val = fmem_ptr - 1;
1542 cur_val = n + param_base[f];
1545 if (cur_val == fmem_ptr)
1548 print_esc(""); print(font_id_text(f));
1549 prints(" has only ");
1550 print_int(font_params[f]);
1551 prints(" fontdimen parameters");
1552 help2("To increase the number of font parameters, you must",
1553 "use \\fontdimen immediately after the \\font is loaded.");
1558 void scan_something_internal (small_number level, boolean negative)
1571 if (m == math_code_base)
1572 scanned_result(math_code(cur_val), int_val);
1573 else if (m < math_code_base)
1574 scanned_result(equiv(m + cur_val), int_val);
1576 scanned_result(eqtb[m + cur_val].cint, int_val);
1585 if (level != tok_val)
1587 print_err("Missing number, treated as zero");
1588 help3("A number should have been here; I inserted `0'.",
1589 "(If you can't figure out why I needed to see a number,",
1590 "look up `weird error' in the index to The TeXbook.)");
1592 scanned_result(0, dimen_val);
1594 else if (cur_cmd <= assign_toks)
1596 if (cur_cmd < assign_toks)
1598 scan_eight_bit_int();
1599 m = toks_base + cur_val;
1602 scanned_result(equiv(m), tok_val);
1608 scanned_result(font_id_base + cur_val, ident_val);
1613 scanned_result(eqtb[m].cint, int_val);
1617 scanned_result(eqtb[m].cint, dimen_val);
1621 scanned_result(equiv(m), glue_val);
1624 case assign_mu_glue:
1625 scanned_result(equiv(m), mu_val);
1631 print_err("Improper ");
1632 print_cmd_chr(set_aux, m);
1633 help4("You can refer to \\spacefactor only in horizontal mode;",
1634 "you can refer to \\prevdepth only in vertical mode; and",
1635 "neither of these is meaningful inside \\write. So",
1636 "I'm forgetting what you said and using zero instead.");
1639 if (level != tok_val)
1640 scanned_result(0, dimen_val);
1642 scanned_result(0, int_val);
1644 else if (m == vmode)
1645 scanned_result(prev_depth, dimen_val);
1647 scanned_result(space_factor, int_val);
1652 scanned_result(0, int_val);
1655 nest[nest_ptr] = cur_list;
1658 while (abs(nest[p].mode_field) != vmode)
1661 scanned_result(nest[p].pg_field, int_val);
1668 cur_val = dead_cycles;
1670 cur_val = insert_penalties;
1676 case set_page_dimen:
1678 if ((page_contents == 0) && (! output_active))
1680 cur_val = max_dimen;
1684 cur_val = page_so_far[m];
1686 cur_val_level = dimen_val;
1692 if (par_shape_ptr == 0)
1695 cur_val = info(par_shape_ptr);
1697 cur_val_level = int_val;
1703 scan_eight_bit_int();
1705 if (box(cur_val) == 0)
1708 cur_val = mem[box(cur_val) + m].cint;
1710 cur_val_level = dimen_val;
1716 scanned_result(cur_chr, int_val);
1719 case assign_font_dimen:
1721 find_font_dimen(false);
1722 font_info[fmem_ptr].cint = 0;
1723 scanned_result(font_info[cur_val].cint, dimen_val);
1727 case assign_font_int:
1732 scanned_result(hyphen_char[cur_val], int_val);
1734 scanned_result(skew_char[cur_val], int_val);
1740 scan_eight_bit_int();
1745 cur_val = count(cur_val);
1749 cur_val = dimen(cur_val);
1753 cur_val = skip(cur_val);
1757 cur_val = mu_skip(cur_val);
1766 if (cur_chr > glue_val)
1768 if (cur_chr == input_line_no_code)
1771 cur_val = last_badness;
1773 cur_val_level = int_val;
1777 if (cur_chr == glue_val)
1778 cur_val = zero_glue;
1782 cur_val_level = cur_chr;
1784 if (!is_char_node(tail) && (mode != 0))
1788 if (type(tail) == penalty_node)
1789 cur_val = penalty(tail);
1793 if (type(tail) == kern_node)
1794 cur_val = width(tail);
1798 if (type(tail) == glue_node)
1800 cur_val = glue_ptr(tail);
1802 if (subtype(tail) == mu_glue)
1803 cur_val_level = mu_val;
1807 else if ((mode == vmode) && (tail == head))
1811 cur_val = last_penalty;
1815 cur_val = last_kern;
1819 if (last_glue != empty_flag)
1820 cur_val = last_glue;
1828 print_err("You can't use `");
1829 print_cmd_chr(cur_cmd, cur_chr);
1832 help1("I'm forgetting what you said and using zero instead.");
1835 if (level != tok_val)
1836 scanned_result(0, dimen_val);
1838 scanned_result(0, int_val);
1843 while (cur_val_level > level)
1845 if (cur_val_level == glue_val)
1846 cur_val = width(cur_val);
1847 else if (cur_val_level == mu_val)
1850 decr(cur_val_level);
1854 if (cur_val_level >= 2)
1856 cur_val = new_spec(cur_val);
1859 width(cur_val) = -width(cur_val);
1860 stretch(cur_val) = -stretch(cur_val);
1861 shrink(cur_val) = -shrink(cur_val);
1866 else if ((cur_val_level >= glue_val) && (cur_val_level <= mu_val))
1867 add_glue_ref(cur_val);
1870 void get_next (void)
1882 if (state != token_list)
1887 cur_chr = buffer[loc];
1891 cur_cmd = cat_code(cur_chr);
1893 switch (state + cur_cmd)
1895 case any_state_plus(ignore):
1896 case skip_blanks + spacer:
1897 case new_line + spacer:
1901 case any_state_plus(escape):
1909 cur_chr = buffer[k];
1910 cat = cat_code(cur_chr);
1914 state = skip_blanks;
1915 else if (cat == spacer)
1916 state = skip_blanks;
1920 if ((cat == letter) && (k <= limit))
1924 cur_chr = buffer[k];
1925 cat = cat_code(cur_chr);
1928 while (!((cat != letter) || (k > limit)));
1931 if (buffer[k]== cur_chr)
1932 if (cat == sup_mark)
1952 buffer[k - 1] = cur_chr;
1955 buffer[k - 1] = c + 64;
1957 buffer[k - 1] = c - 64;
1964 buffer[k] = buffer[k + d];
1978 cur_cs = id_lookup(loc, k - loc);
1985 if (buffer[k] == cur_chr)
1986 if (cat == sup_mark)
2007 buffer[k - 1] = cur_chr;
2010 buffer[k - 1] = c + 64;
2012 buffer[k - 1] = c - 64;
2019 buffer[k] = buffer[k + d];
2028 cur_cs = single_base + buffer[loc];
2032 cur_cmd = eq_type(cur_cs);
2033 cur_chr = equiv(cur_cs);
2035 if (cur_cmd >= outer_call)
2036 check_outer_validity();
2040 case any_state_plus(active_char):
2042 cur_cs = cur_chr + active_base;
2043 cur_cmd = eq_type(cur_cs);
2044 cur_chr = equiv(cur_cs);
2047 if (cur_cmd >= outer_call)
2048 check_outer_validity();
2052 case any_state_plus(sup_mark):
2054 if (cur_chr == buffer[loc])
2057 c = buffer[loc + 1];
2089 case any_state_plus(invalid_char):
2091 print_err("Text line contains an invalid character");
2092 help2("A funny symbol that I can't read has just been input.",
2093 "Continue, and I'll forget that it ever happened.");
2094 deletions_allowed = false;
2096 deletions_allowed = true;
2101 case mid_line + spacer:
2103 state = skip_blanks;
2108 case mid_line + car_ret:
2116 case skip_blanks + car_ret:
2117 case any_state_plus(comment):
2124 case new_line + car_ret:
2128 cur_cmd = eq_type(cur_cs);
2129 cur_chr = equiv(cur_cs);
2131 if (cur_cmd >= outer_call)
2132 check_outer_validity();
2136 case mid_line + left_brace:
2140 case skip_blanks + left_brace:
2141 case new_line + left_brace:
2148 case mid_line + right_brace:
2152 case skip_blanks + right_brace:
2153 case new_line + right_brace:
2160 case add_delims_to(skip_blanks):
2161 case add_delims_to(new_line):
2180 if (input_ln(cur_file, true))
2193 check_outer_validity();
2197 if (end_line_char_inactive())
2200 buffer[limit] = end_line_char;
2220 if (selector < log_only)
2223 if (interaction > nonstop_mode)
2225 if (end_line_char_inactive())
2229 print_nl("(Please type a command or say `\\end')");
2236 if (end_line_char_inactive())
2239 buffer[limit]= end_line_char;
2246 fatal_error("*** (job aborted, no legal \\end found)");
2260 if (t >= cs_token_flag)
2262 cur_cs = t - cs_token_flag;
2263 cur_cmd = eq_type(cur_cs);
2264 cur_chr = equiv(cur_cs);
2266 if (cur_cmd >= outer_call)
2267 if (cur_cmd == dont_expand)
2269 cur_cs = info(loc) - cs_token_flag;
2271 cur_cmd = eq_type(cur_cs);
2272 cur_chr = equiv(cur_cs);
2274 if (cur_cmd > max_command)
2277 cur_chr = no_expand_flag;
2282 check_outer_validity();
2302 begin_token_list(param_stack[limit + cur_chr - 1], parameter);
2318 if (cur_cmd <= car_ret)
2319 if (cur_cmd >= tab_mark)
2320 if (align_state == 0)
2322 if ((scanner_status == aligning) && (cur_align == 0))
2324 fatal_error("(interwoven alignment preambles are not allowed)");
2328 cur_cmd = extra_info(cur_align);
2329 extra_info(cur_align) = cur_chr;
2331 if (cur_cmd == omit)
2332 begin_token_list(omit_template, v_template);
2334 begin_token_list(v_part(cur_align), v_template);
2336 align_state = 1000000L;