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");
120 /* This is where the old tex2.c used to start */
122 void prepare_mag (void)
124 if ((mag_set > 0) && (mag != mag_set))
126 print_err("Incompatible magnification (");
129 print_nl(" the previous value will be retained");
130 help2("I can handle only one magnification ratio per job. So I've",
131 "reverted to the magnification you used earlier on this run.");
133 geq_word_define(int_base + mag_code, mag_set);
136 if ((mag <= 0) || (mag > 32768L))
138 print_err("Illegal magnification has been changed to 1000");
139 help1("The magnification ratio must be between 1 and 32768.");
141 geq_word_define(int_base + mag_code, 1000);
147 void token_show (pointer p)
150 show_token_list(link(p), 0, 10000000L);
153 void print_meaning (void)
155 print_cmd_chr(cur_cmd, cur_chr);
163 else if (cur_cmd == top_bot_mark)
167 token_show(cur_mark[cur_chr]);
171 void show_cur_cmd_chr (void)
176 if (mode != shown_mode)
183 print_cmd_chr(cur_cmd, cur_chr);
185 end_diagnostic(false);
188 void show_context (void)
201 base_ptr = input_ptr;
202 input_stack[base_ptr] = cur_input;
208 cur_input = input_stack[base_ptr];
210 if ((state != token_list))
211 if ((name > 17) || (base_ptr == 0))
214 if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines))
216 if ((base_ptr == input_ptr) || (state != token_list) ||
217 (index != backed_up) || (loc != 0))
220 old_setting = selector;
222 if (state != token_list)
229 print_nl("<insert> ");
264 if (buffer[limit] == end_line_char)
270 for (i = start; i <= j - 1; i++)
283 print_nl("<argument> ");
288 print_nl("<template> ");
293 print_nl("<recently read> ");
295 print_nl("<to be read again> ");
299 print_nl("<inserted text> ");
308 print_nl("<output> ");
312 print_nl("<everypar> ");
315 case every_math_text:
316 print_nl("<everymath> ");
319 case every_display_text:
320 print_nl("<everydisplay> ");
323 case every_hbox_text:
324 print_nl("<everyhbox> ");
327 case every_vbox_text:
328 print_nl("<everyvbox> ");
332 print_nl("<everyjob> ");
336 print_nl("<everycr> ");
344 print_nl("<write> ");
355 show_token_list(start, loc, 100000L);
357 show_token_list(link(start), loc, 100000L);
360 selector = old_setting;
362 if (trick_count == 1000000L)
365 if (tally < trick_count)
366 m = tally - first_count;
368 m = trick_count - first_count;
370 if (l + first_count <= half_error_line)
378 p = l + first_count - half_error_line + 3;
382 for (q = p; q <= first_count - 1; q++)
383 print_char(trick_buf[q % error_line]);
387 for (q = 1; q <= n; q++)
390 if (m + n <= error_line)
393 p = first_count +(error_line - n - 3);
395 for (q = first_count; q <= p - 1; q++)
396 print_char(trick_buf[q % error_line]);
398 if (m + n > error_line)
404 else if (nn == error_context_lines)
417 cur_input = input_stack[input_ptr];
420 void begin_token_list_ (pointer p, quarterword t)
437 if (tracing_macros > 1)
453 print_cmd_chr(assign_toks, t - output_text + output_routine_loc);
459 end_diagnostic(false);
467 void end_token_list (void)
469 if (index >= backed_up)
471 if (index <= inserted)
475 delete_token_ref(start);
478 while (param_ptr > limit)
481 flush_list(param_stack[param_ptr]);
485 else if (index == u_template)
486 if (align_state > 500000L)
490 fatal_error("(interwoven alignment preambles are not allowed)");
498 void back_input (void)
502 while ((state == 0) && (loc == 0) &&
503 (index != v_template))
511 if (cur_tok < right_brace_limit)
512 if (cur_tok < left_brace_limit)
524 void back_error (void)
526 OK_to_interrupt = false;
528 OK_to_interrupt = true;
532 void ins_error (void)
534 OK_to_interrupt = false;
537 OK_to_interrupt = true;
541 void begin_file_reading (void)
543 if (in_open == max_in_open)
545 overflow("text input levels", max_in_open);
549 #ifdef ALLOCATEBUFFER
550 if (first == current_buf_size)
551 buffer = realloc_buffer(increment_buf_size);
553 if (first == current_buf_size)
555 overflow("buffer size", current_buf_size);
559 if (first == buf_size)
561 overflow("buffer size", buf_size);
568 if (in_open > high_in_open) /* 1999 Jan 17 */
569 high_in_open = in_open;
573 line_stack[index] = line;
579 void end_file_reading (void)
582 line = line_stack[index];
590 /* called only form tex0.c */
592 void clear_for_error_prompt (void)
594 while ((state != 0) && (name == 0) &&
595 (input_ptr > 0) && (loc > limit))
601 void check_outer_validity (void)
606 if (scanner_status != 0)
608 deletions_allowed = false;
612 if ((state == 0) || (name < 1) || (name > 17))
615 info(p) = cs_token_flag + cur_cs;
623 if (scanner_status > skipping)
628 print_err("File ended");
632 print_err("Forbidden control sequence found");
635 prints(" while scanning ");
638 switch (scanner_status)
641 prints("definition");
642 info(p) = right_brace_token + '}';
648 long_state = outer_call;
653 info(p) = right_brace_token + '}';
657 info(p) = cs_token_flag + frozen_cr;
658 align_state = -1000000L;
663 info(p) = right_brace_token + '}';
669 sprint_cs(warning_index);
670 help4("I suspect you have forgotten a `}', causing me",
671 "to read past where you wanted me to stop.",
672 "I'll try to recover; but if the error is serious,",
673 "you'd better type `E' or `X' now and fix your file.");
678 print_err("Incomplete ");
679 print_cmd_chr(if_test, cur_if);
680 prints("; all text was ignored after line ");
681 print_int(skip_line);
682 help3("A forbidden control sequence occurred in skipped text.",
683 "This kind of error happens when you say `\\if...' and forget",
684 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
689 help_line[2] = "The file ended while I was skipping conditional text.";
691 cur_tok = cs_token_flag + frozen_fi;
695 deletions_allowed = true;
699 void firm_up_the_line (void)
706 if (interaction > nonstop_mode)
712 for (k = start; k <= limit - 1; k++)
720 for (k = first; k <= last - 1; k++)
721 buffer[k + start - first] = buffer[k];
723 limit = start + last - first;
728 void get_token (void)
730 no_new_control_sequence = false;
732 no_new_control_sequence = true;
735 cur_tok = (cur_cmd * 256) + cur_chr;
737 cur_tok = cs_token_flag + cur_cs;
740 void macro_call (void)
753 small_number save_scanner_status;
754 pointer save_warning_index;
755 ASCII_code match_chr;
757 save_scanner_status = scanner_status;
758 save_warning_index = warning_index;
759 warning_index = cur_cs;
764 if (tracing_macros > 0)
768 print_cs(warning_index);
769 token_show(ref_count);
770 end_diagnostic(false);
773 if (info(r) != end_match_token)
775 scanner_status = matching;
777 long_state = eq_type(cur_cs);
779 if (long_state >= outer_call)
780 long_state = long_state - 2;
786 if ((info(r) > match_token + 255) || (info(r) < match_token))
790 match_chr = info(r) - match_token;
800 if (cur_tok == info(r))
804 if ((info(r) >= match_token) && (info(r) <= end_match_token))
806 if (cur_tok < left_brace_limit)
818 print_err("Use of ");
819 sprint_cs(warning_index);
820 prints(" doesn't match its definition");
821 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
822 "put `1' after `\\a', since control sequence names are",
823 "made up of letters only. The macro here has not been",
824 "followed by the required stuff, so I'm ignoring it.");
834 store_new_token(info(t));
842 if (cur_tok != info(v))
850 if (info(u) != info(v))
864 if (cur_tok == par_token)
865 if (long_state != long_call)
867 if (long_state == call)
870 print_err("Paragraph ended before ");
871 sprint_cs(warning_index);
872 prints("was complete");
873 help3("I suspect you've forgotten a `}', causing me to apply this",
874 "control sequence to too much text. How can we recover?",
875 "My plan is to forget the whole thing and hope for the best.");
879 pstack[n] = link(temp_head);
880 align_state = align_state - unbalance;
882 for (m = 0; m <= n; m++)
883 flush_list(pstack[m]);
888 if (cur_tok < right_brace_limit)
889 if (cur_tok < left_brace_limit)
895 fast_store_new_token(cur_tok);
898 if (cur_tok == par_token)
899 if (long_state != long_call)
901 if (long_state == call)
904 print_err("Paragraph ended before ");
905 sprint_cs(warning_index);
906 prints(" was complete");
907 help3("I suspect you've forgotten a `}', causing me to apply this",
908 "control sequence to too much text. How can we recover?",
909 "My plan is to forget the whole thing and hope for the best.");
913 pstack[n] = link(temp_head);
914 align_state = align_state - unbalance;
916 for (m = 0; m <= n; m++)
917 flush_list(pstack[m]);
921 if (cur_tok < right_brace_limit)
922 if (cur_tok < left_brace_limit)
934 store_new_token(cur_tok);
939 print_err("Argument of ");
940 sprint_cs(warning_index);
941 prints(" has an extra }");
942 help6("I've run across a `}' that doesn't seem to match anything.",
943 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
944 "this error. If you simply proceed now, the `\\par' that",
945 "I've just inserted will cause me to report a runaway",
946 "argument that might be the root of the problem. But if",
947 "your `}' was spurious, just type `2' and it will go away.");
956 if (cur_tok == space_token)
957 if (info(r) <= end_match_token)
958 if (info(r) >= match_token)
961 store_new_token(cur_tok);
966 if (info(r) > end_match_token)
969 if (info(r) < match_token)
975 if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
977 link(rbrace_ptr) = 0;
984 pstack[n] = link(temp_head);
988 if (tracing_macros > 0)
991 //print_nl(match_chr);
992 print_nl(""); print(match_chr);
995 show_token_list(pstack[n - 1], 0, 1000);
996 end_diagnostic(false);
1000 while (!(info(r) == end_match_token));
1003 while ((state == token_list) && (loc == 0) &&
1004 (index != v_template))
1007 begin_token_list(ref_count, macro);
1008 name = warning_index;
1013 if (param_ptr + n > max_param_stack)
1015 max_param_stack = param_ptr + n;
1017 #ifdef ALLOCATEPARAMSTACK
1018 if (max_param_stack > current_param_size)
1019 param_stack = realloc_param_stack(increment_param_size);
1021 if (max_param_stack > current_param_size)
1023 overflow("parameter stack size", current_param_size);
1027 if (max_param_stack > param_size)
1029 overflow("parameter stack size", param_size);
1035 for (m = 0; m <= n - 1; m++)
1036 param_stack[param_ptr + m] = pstack[m];
1038 param_ptr = param_ptr + n;
1042 scanner_status = save_scanner_status;
1043 warning_index = save_warning_index;
1046 void insert_relax (void)
1048 cur_tok = cs_token_flag + cur_cs;
1050 cur_tok = cs_token_flag + frozen_relax;
1061 small_number cvl_backup, radix_backup, co_backup;
1062 pointer backup_backup;
1063 small_number save_scanner_status;
1065 cv_backup = cur_val;
1066 cvl_backup = cur_val_level;
1067 radix_backup = radix;
1068 co_backup = cur_order;
1069 backup_backup = link(backup_head);
1073 if (tracing_commands > 1)
1079 if (cur_mark[cur_chr] != 0)
1080 begin_token_list(cur_mark[cur_chr], mark_text);
1088 if (cur_cmd > max_command)
1098 save_scanner_status = scanner_status;
1099 scanner_status = normal;
1101 scanner_status = save_scanner_status;
1105 if (t >= cs_token_flag)
1108 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)
1991 if (c < 128) /* ? */
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;