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 ((cur_input.name_field > 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)
223 if (cur_input.name_field <= 17)
224 if ((cur_input.name_field == 0))
228 print_nl("<insert> ");
233 if (cur_input.name_field == 17)
236 print_int(cur_input.name_field - 1);
246 if (cur_input.name_field > 17)
247 print(cur_input.name_field);
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> ");
303 print_cs(cur_input.name_field);
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);
476 while (param_ptr > limit)
479 flush_list(param_stack[param_ptr]);
483 else if (index == u_template)
484 if (align_state > 500000L)
488 fatal_error("(interwoven alignment preambles are not allowed)");
496 void back_input (void)
500 while ((state == 0) && (loc == 0) &&
501 (index != v_template))
509 if (cur_tok < right_brace_limit)
510 if (cur_tok < left_brace_limit)
522 void back_error (void)
524 OK_to_interrupt = false;
526 OK_to_interrupt = true;
530 void ins_error (void)
532 OK_to_interrupt = false;
535 OK_to_interrupt = true;
539 void begin_file_reading (void)
541 if (in_open == max_in_open)
543 overflow("text input levels", max_in_open);
546 #ifdef ALLOCATEBUFFER
547 if (first == current_buf_size)
548 buffer = realloc_buffer(increment_buf_size);
550 if (first == current_buf_size) /* check again after allocation */
552 overflow("buffer size", current_buf_size);
556 if (first == buf_size)
558 overflow("buffer size", buf_size);
565 if (in_open > high_in_open) /* 1999 Jan 17 */
566 high_in_open = in_open;
570 line_stack[index] = line;
573 cur_input.name_field = 0;
576 void end_file_reading (void)
579 line = line_stack[index];
581 if (cur_input.name_field > 17)
587 /* called only form tex0.c */
589 void clear_for_error_prompt (void)
591 while ((state != 0) && (cur_input.name_field == 0) && (input_ptr > 0) &&
598 void check_outer_validity (void)
603 if (scanner_status != 0)
605 deletions_allowed = false;
609 if ((state == 0) || (cur_input.name_field < 1) || (cur_input.name_field > 17))
612 info(p) = cs_token_flag + cur_cs;
620 if (scanner_status > skipping)
625 print_err("File ended");
629 print_err("Forbidden control sequence found");
632 print_string(" while scanning ");
635 switch (scanner_status)
638 print_string("definition");
639 info(p) = right_brace_token + '}';
645 long_state = outer_call;
649 print_string("preamble");
650 info(p) = right_brace_token + '}';
654 info(p) = cs_token_flag + frozen_cr;
655 align_state = -1000000L;
659 print_string("text");
660 info(p) = right_brace_token + '}';
665 print_string(" of ");
666 sprint_cs(warning_index);
667 help4("I suspect you have forgotten a `}', causing me",
668 "to read past where you wanted me to stop.",
669 "I'll try to recover; but if the error is serious,",
670 "you'd better type `E' or `X' now and fix your file.");
675 print_err("Incomplete ");
676 print_cmd_chr(if_test, cur_if);
677 print_string("; all text was ignored after line ");
678 print_int(skip_line);
679 help3("A forbidden control sequence occurred in skipped text.",
680 "This kind of error happens when you say `\\if...' and forget",
681 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
686 help_line[2] = "The file ended while I was skipping conditional text.";
688 cur_tok = cs_token_flag + frozen_fi;
692 deletions_allowed = true;
696 void firm_up_the_line (void)
703 if (interaction > nonstop_mode)
709 for (k = start; k <= limit - 1; k++)
717 for (k = first; k <= last - 1; k++)
718 buffer[k + start - first] = buffer[k];
720 limit = start + last - first;
725 void get_token (void)
727 no_new_control_sequence = false;
729 no_new_control_sequence = true;
732 cur_tok = (cur_cmd * 256) + cur_chr;
734 cur_tok = cs_token_flag + cur_cs;
737 void macro_call (void)
750 small_number save_scanner_status;
751 halfword save_warning_index;
752 ASCII_code match_chr;
754 save_scanner_status = scanner_status;
755 save_warning_index = warning_index;
756 warning_index = cur_cs;
761 if (tracing_macros > 0)
765 print_cs(warning_index);
766 token_show(ref_count);
767 end_diagnostic(false);
770 if (info(r) != end_match_token)
772 scanner_status = matching;
774 long_state = eq_type(cur_cs);
776 if (long_state >= outer_call)
777 long_state = long_state - 2;
783 if ((info(r) > match_token + 255) || (info(r) < match_token))
787 match_chr = info(r) - match_token;
796 if (cur_tok == info(r))
800 if ((info(r) >= match_token) && (info(r) <= end_match_token))
802 if (cur_tok < left_brace_limit)
814 print_err("Use of ");
815 sprint_cs(warning_index);
816 print_string(" doesn't match its definition");
817 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
818 "put `1' after `\\a', since control sequence names are",
819 "made up of letters only. The macro here has not been",
820 "followed by the required stuff, so I'm ignoring it.");
829 store_new_token(info(t));
837 if (cur_tok != info(v))
845 if (info(u) != info(v))
859 if (cur_tok == par_token)
860 if (long_state != long_call)
862 if (long_state == call)
865 print_err("Paragraph ended before ");
866 sprint_cs(warning_index);
867 print_string("was complete");
868 help3("I suspect you've forgotten a `}', causing me to apply this",
869 "control sequence to too much text. How can we recover?",
870 "My plan is to forget the whole thing and hope for the best.");
874 pstack[n] = link(temp_head);
875 align_state = align_state - unbalance;
877 for (m = 0; m <= n; m++)
878 flush_list(pstack[m]);
883 if (cur_tok < right_brace_limit)
884 if (cur_tok < left_brace_limit)
890 fast_store_new_token(cur_tok);
893 if (cur_tok == par_token)
894 if (long_state != long_call)
896 if (long_state == call)
899 print_err("Paragraph ended before ");
900 sprint_cs(warning_index);
901 print_string(" was complete");
902 help3("I suspect you've forgotten a `}', causing me to apply this",
903 "control sequence to too much text. How can we recover?",
904 "My plan is to forget the whole thing and hope for the best.");
908 pstack[n] = link(temp_head);
909 align_state = align_state - unbalance;
911 for (m = 0; m <= n; m++)
912 flush_list(pstack[m]);
916 if (cur_tok < right_brace_limit)
917 if (cur_tok < left_brace_limit)
929 store_new_token(cur_tok);
934 print_err("Argument of ");
935 sprint_cs(warning_index);
936 print_string(" has an extra }");
937 help6("I've run across a `}' that doesn't seem to match anything.",
938 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
939 "this error. If you simply proceed now, the `\\par' that",
940 "I've just inserted will cause me to report a runaway",
941 "argument that might be the root of the problem. But if",
942 "your `}' was spurious, just type `2' and it will go away.");
951 if (cur_tok == space_token)
952 if (info(r) <= end_match_token)
953 if (info(r) >= match_token)
956 store_new_token(cur_tok);
959 incr(m); /* m may be used without having been ... */
961 if (info(r) > end_match_token)
964 if (info(r) < match_token)
969 if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
971 link(rbrace_ptr) = 0; /* rbrace_ptr may be used without ... */
978 pstack[n] = link(temp_head);
982 if (tracing_macros > 0)
985 //print_nl(match_chr); /* matchchar may be used without ... */
986 print_nl(""); print(match_chr);
989 show_token_list(pstack[n - 1], 0, 1000);
990 end_diagnostic(false);
994 while (!(info(r) == end_match_token));
997 while ((state == token_list) && (loc == 0) &&
998 (index != v_template))
1001 begin_token_list(ref_count, macro);
1002 cur_input.name_field = warning_index;
1007 if (param_ptr + n > max_param_stack)
1009 max_param_stack = param_ptr + n;
1011 #ifdef ALLOCATEPARAMSTACK
1012 if (max_param_stack > current_param_size)
1013 param_stack = realloc_param_stack(increment_param_size);
1015 if (max_param_stack > current_param_size) /* check again after allocation */
1017 overflow("parameter stack size", current_param_size);
1021 if (max_param_stack > param_size)
1023 overflow("parameter stack size", param_size); /* parameter stack - not dynamic */
1029 for (m = 0; m <= n - 1; m++)
1030 param_stack[param_ptr + m] = pstack[m];
1032 param_ptr = param_ptr + n;
1035 scanner_status = save_scanner_status;
1036 warning_index = save_warning_index;
1039 void insert_relax (void)
1041 cur_tok = cs_token_flag + cur_cs;
1043 cur_tok = cs_token_flag + frozen_relax; /* 96/Jan/10 */
1054 small_number cvl_backup, radix_backup, co_backup;
1055 halfword backup_backup;
1056 small_number save_scanner_status;
1058 cv_backup = cur_val;
1059 cvl_backup = cur_val_level;
1060 radix_backup = radix;
1061 co_backup = cur_order;
1062 backup_backup = link(backup_head);
1066 if (tracing_commands > 1)
1072 if (cur_mark[cur_chr] != 0)
1073 begin_token_list(cur_mark[cur_chr], mark_text);
1081 if (cur_cmd > max_command)
1091 save_scanner_status = scanner_status;
1092 scanner_status = normal;
1094 scanner_status = save_scanner_status;
1098 if (t >= cs_token_flag)
1101 info(p) = cs_token_flag + frozen_dont_expand; /*96/Jan/10*/
1116 store_new_token(cur_tok);
1118 while (!(cur_cs != 0));
1120 if (cur_cmd != end_cs_name)
1122 print_err("Missing ");
1123 print_esc("endcsname");
1124 print_string(" inserted");
1125 help2("The control sequence marked <to be read again> should",
1126 "not appear between \\csname and \\endcsname.");
1135 if (j >= max_buf_stack)
1137 max_buf_stack = j + 1;
1139 #ifdef ALLOCATEBUFFER
1140 if (max_buf_stack == current_buf_size)
1141 buffer = realloc_buffer (increment_buf_size);
1143 if (max_buf_stack == current_buf_size) /* check again after allocation */
1145 overflow("buffer size", current_buf_size);
1149 if (max_buf_stack == buf_size)
1151 overflow("buffer size", buf_size); /* buffer size - not dynamic */
1157 buffer[j] = info(p) % 256;
1164 no_new_control_sequence = false;
1165 cur_cs = id_lookup(first, j - first);
1166 no_new_control_sequence = true;
1168 else if (j == first)
1171 cur_cs = single_base + buffer[first];
1175 if (eq_type(cur_cs) == undefined_cs)
1177 eq_define(cur_cs, relax, 256);
1180 cur_tok = cur_cs + cs_token_flag;
1197 if (cur_chr > if_limit)
1202 print_err("Extra ");
1203 print_cmd_chr(fi_or_else, cur_chr);
1204 help1("I'm ignoring this; it doesn't match any \\if.");
1209 while (cur_chr != fi_code)
1214 if_line = if_line_field(p);
1215 cur_if = subtype(p);
1218 free_node(p, if_node_size);
1226 else if (name_in_progress)
1233 print_err("Undefined control sequence");
1234 help5("The control sequence at the end of the top line",
1235 "of your error message was never \\def'ed. If you have",
1236 "misspelled it (e.g., `\\hobx'), type `I' and the correct",
1237 "spelling (e.g., `I\\hbox'). Otherwise just continue,",
1238 "and I'll forget about whatever was undefined.");
1243 else if (cur_cmd < end_template)
1249 cur_tok = cs_token_flag + frozen_endv; /* 96/Jan/10 */
1253 cur_val = cv_backup;
1254 cur_val_level = cvl_backup;
1255 radix = radix_backup;
1256 cur_order = co_backup;
1257 link(backup_head) = backup_backup;
1260 void get_x_token (void)
1265 if (cur_cmd <= max_command)
1268 if (cur_cmd >= call)
1269 if (cur_cmd < end_template)
1273 cur_cs = frozen_endv;
1284 cur_tok = (cur_cmd * 256) + cur_chr;
1286 cur_tok = cs_token_flag + cur_cs;
1291 while (cur_cmd > max_command)
1298 cur_tok = (cur_cmd * 256) + cur_chr;
1300 cur_tok = cs_token_flag + cur_cs;
1303 void scan_left_brace (void)
1309 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1311 if (cur_cmd != left_brace)
1313 print_err("Missing { inserted");
1314 help4("A left brace was mandatory here, so I've put one in.",
1315 "You might want to delete and/or insert some corrections",
1316 "so that I will find a matching right brace soon.",
1317 "(If you're confused by all this, try typing `I}' now.)");
1319 cur_tok = left_brace_token + '{';
1320 cur_cmd = left_brace;
1326 void scan_optional_equals (void)
1332 while (!(cur_cmd != spacer));
1334 if (cur_tok != other_token + '=')
1338 boolean scan_keyword(const char * s)
1352 if ((cur_cs == 0) && ((cur_chr == (*k)) || (cur_chr == (*k) - 'a' + 'A')))
1354 store_new_token(cur_tok);
1357 else if ((cur_cmd != spacer) || (p != backup_head))
1361 if (p != backup_head)
1362 back_list(link(backup_head));
1368 flush_list(link(backup_head));
1373 void mu_error (void)
1375 print_err("Incompatible glue units");
1376 help1("I'm going to assume that 1mu=1pt when they're mixed.");
1380 void scan_eight_bit_int (void)
1384 if ((cur_val < 0) || (cur_val > 255))
1386 print_err("Bad register code");
1387 help2("A register number must be between 0 and 255.",
1388 "I changed this one to zero.");
1394 void scan_char_num (void)
1398 if ((cur_val < 0) || (cur_val > 255))
1400 print_err("Bad character code");
1401 help2("A character number must be between 0 and 255.",
1402 "I changed this one to zero.");
1408 void scan_four_bit_int (void)
1412 if ((cur_val < 0) || (cur_val > 15))
1414 print_err("Bad number");
1415 help2("Since I expected to read a number between 0 and 15,",
1416 "I changed this one to zero.");
1422 void scan_fifteen_bit_int (void)
1426 if ((cur_val < 0) || (cur_val > 32767))
1428 print_err("Bad mathchar");
1429 help2("A mathchar number must be between 0 and 32767.",
1430 "I changed this one to zero.");
1436 void scan_twenty_seven_bit_int (void)
1440 if ((cur_val < 0) || (cur_val > 134217727L)) /* 2^27 - 1 */
1442 print_err("Bad delimiter code");
1443 help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
1444 "I changed this one to zero.");
1450 void scan_font_ident (void)
1452 internal_font_number f;
1459 while (!(cur_cmd != spacer));
1461 if (cur_cmd == def_font)
1463 else if (cur_cmd == set_font)
1465 else if (cur_cmd == def_family)
1468 scan_four_bit_int();
1469 f = equiv(m + cur_val);
1473 print_err("Missing font identifier");
1474 help2("I was looking for a control sequence whose",
1475 "current meaning has been defined by \\font.");
1483 void find_font_dimen_(boolean writing)
1485 internal_font_number f;
1493 if (n < 0 || (n == 0 && font_dimen_zero == 0)) /* change 98/Oct/5 */
1497 if (writing && (n <= space_shrink_code) && (n >= space_code) && (font_glue[f] != 0))
1499 delete_glue_ref(font_glue[f]);
1503 if (n > font_params[f])
1511 if (fmem_ptr == current_font_mem_size)
1512 font_info = realloc_font_info(increment_font_mem_size);
1514 if (fmem_ptr == current_font_mem_size)
1516 overflow("font memory", current_font_mem_size);
1520 if (fmem_ptr == font_mem_size)
1522 overflow("font memory", font_mem_size);
1526 font_info[fmem_ptr].cint = 0;
1528 incr(font_params[f]);
1530 while (!(n == font_params[f]));
1532 cur_val = fmem_ptr - 1;
1535 cur_val = n + param_base[f];
1538 if (cur_val == fmem_ptr)
1541 print_esc(""); print(font_id_text(f));
1542 print_string(" has only ");
1543 print_int(font_params[f]);
1544 print_string(" fontdimen parameters");
1545 help2("To increase the number of font parameters, you must",
1546 "use \\fontdimen immediately after the \\font is loaded.");
1551 void scan_something_internal_(small_number level, boolean negative)
1564 if (m == math_code_base)
1565 scanned_result(math_code(cur_val), int_val);
1566 else if (m < math_code_base)
1567 scanned_result(equiv(m + cur_val), int_val);
1569 scanned_result(eqtb[m + cur_val].cint, int_val);
1578 if (level != tok_val)
1580 print_err("Missing number, treated as zero");
1581 help3("A number should have been here; I inserted `0'.",
1582 "(If you can't figure out why I needed to see a number,",
1583 "look up `weird error' in the index to The TeXbook.)");
1585 scanned_result(0, dimen_val);
1587 else if (cur_cmd <= assign_toks)
1589 if (cur_cmd < assign_toks)
1591 scan_eight_bit_int();
1592 m = toks_base + cur_val;
1595 scanned_result(equiv(m), tok_val);
1601 scanned_result(font_id_base + cur_val, ident_val);
1606 scanned_result(eqtb[m].cint, int_val);
1610 scanned_result(eqtb[m].cint, dimen_val);
1614 scanned_result(equiv(m), glue_val);
1617 case assign_mu_glue:
1618 scanned_result(equiv(m), mu_val);
1624 print_err("Improper ");
1625 print_cmd_chr(set_aux, m);
1626 help4("You can refer to \\spacefactor only in horizontal mode;",
1627 "you can refer to \\prevdepth only in vertical mode; and",
1628 "neither of these is meaningful inside \\write. So",
1629 "I'm forgetting what you said and using zero instead.");
1632 if (level != tok_val)
1633 scanned_result(0, dimen_val);
1635 scanned_result(0, int_val);
1637 else if (m == vmode)
1638 scanned_result(prev_depth, dimen_val);
1640 scanned_result(space_factor, int_val);
1645 scanned_result(0, int_val);
1648 nest[nest_ptr] = cur_list;
1651 while (abs(nest[p].mode_field) != vmode)
1654 scanned_result(nest[p].pg_field, int_val);
1661 cur_val = dead_cycles;
1663 cur_val = insert_penalties;
1669 case set_page_dimen:
1671 if ((page_contents == 0) && (! output_active))
1673 cur_val = max_dimen;
1677 cur_val = page_so_far[m];
1679 cur_val_level = dimen_val;
1685 if (par_shape_ptr == 0)
1688 cur_val = info(par_shape_ptr);
1690 cur_val_level = int_val;
1696 scan_eight_bit_int();
1698 if (box(cur_val) == 0)
1701 cur_val = mem[box(cur_val) + m].cint;
1703 cur_val_level = dimen_val;
1709 scanned_result(cur_chr, int_val);
1712 case assign_font_dimen:
1714 find_font_dimen(false);
1715 font_info[fmem_ptr].cint = 0;
1716 scanned_result(font_info[cur_val].cint, dimen_val);
1720 case assign_font_int:
1725 scanned_result(hyphen_char[cur_val], int_val);
1727 scanned_result(skew_char[cur_val], int_val);
1733 scan_eight_bit_int();
1738 cur_val = count(cur_val);
1742 cur_val = dimen(cur_val);
1746 cur_val = skip(cur_val);
1750 cur_val = mu_skip(cur_val);
1759 if (cur_chr > glue_val)
1761 if (cur_chr == input_line_no_code)
1764 cur_val = last_badness;
1766 cur_val_level = int_val;
1770 if (cur_chr == glue_val)
1771 cur_val = zero_glue;
1775 cur_val_level = cur_chr;
1777 if (!is_char_node(tail) && (mode != 0))
1781 if (type(tail) == penalty_node)
1782 cur_val = penalty(tail);
1786 if (type(tail) == kern_node)
1787 cur_val = width(tail);
1791 if (type(tail) == glue_node)
1793 cur_val = glue_ptr(tail);
1795 if (subtype(tail) == mu_glue)
1796 cur_val_level = mu_val;
1800 else if ((mode == vmode) && (tail == head))
1804 cur_val = last_penalty;
1808 cur_val = last_kern;
1812 if (last_glue != empty_flag)
1813 cur_val = last_glue;
1821 print_err("You can't use `");
1822 print_cmd_chr(cur_cmd, cur_chr);
1823 print_string("' after ");
1825 help1("I'm forgetting what you said and using zero instead.");
1828 if (level != tok_val)
1829 scanned_result(0, dimen_val);
1831 scanned_result(0, int_val);
1836 while (cur_val_level > level)
1838 if (cur_val_level == glue_val)
1839 cur_val = width(cur_val);
1840 else if (cur_val_level == mu_val)
1843 decr(cur_val_level);
1847 if (cur_val_level >= 2)
1849 cur_val = new_spec(cur_val);
1852 width(cur_val) = -width(cur_val);
1853 stretch(cur_val) = -stretch(cur_val);
1854 shrink(cur_val) = -shrink(cur_val);
1859 else if ((cur_val_level >= glue_val) && (cur_val_level <= mu_val))
1860 add_glue_ref(cur_val);
1863 void get_next (void)
1867 /* char cat; */ /* make this an int ? */
1868 int cat; /* make this an int ? 95/Jan/7 */
1875 if (state != token_list)
1880 cur_chr = buffer[loc];
1883 cur_cmd = cat_code(cur_chr);
1885 switch (state + cur_cmd)
1887 case any_state_plus(ignore):
1888 case skip_blanks + spacer:
1889 case new_line + spacer:
1893 case any_state_plus(escape):
1901 cur_chr = buffer[k];
1902 cat = cat_code(cur_chr);
1906 state = skip_blanks;
1907 else if (cat == spacer)
1908 state = skip_blanks;
1912 if ((cat == letter) && (k <= limit))
1916 cur_chr = buffer[k];
1917 cat = cat_code(cur_chr);
1920 while (!((cat != letter) || (k > limit)));
1923 if (buffer[k]== cur_chr)
1924 if (cat == sup_mark)
1944 buffer[k - 1] = cur_chr;
1947 buffer[k - 1] = c + 64;
1949 buffer[k - 1] = c - 64;
1956 buffer[k] = buffer[k + d];
1970 cur_cs = id_lookup(loc, k - loc);
1977 if (buffer[k] == cur_chr)
1978 if (cat == sup_mark)
1983 if (c < 128) /* ? */
1999 buffer[k - 1] = cur_chr;
2002 buffer[k - 1] = c + 64;
2004 buffer[k - 1] = c - 64;
2011 buffer[k] = buffer[k + d];
2018 cur_cs = single_base + buffer[loc];
2022 cur_cmd = eq_type(cur_cs);
2023 cur_chr = equiv(cur_cs);
2025 if (cur_cmd >= outer_call)
2026 check_outer_validity();
2030 case any_state_plus(active_char):
2032 cur_cs = cur_chr + active_base;
2033 cur_cmd = eq_type(cur_cs);
2034 cur_chr = equiv(cur_cs);
2037 if (cur_cmd >= outer_call)
2038 check_outer_validity();
2042 case any_state_plus(sup_mark):
2044 if (cur_chr == buffer[loc])
2047 c = buffer[loc + 1];
2079 case any_state_plus(invalid_char):
2081 print_err("Text line contains an invalid character");
2082 help2("A funny symbol that I can't read has just been input.",
2083 "Continue, and I'll forget that it ever happened.");
2084 deletions_allowed = false;
2086 deletions_allowed = true;
2091 case mid_line + spacer:
2093 state = skip_blanks;
2098 case mid_line + car_ret:
2106 case skip_blanks + car_ret:
2107 case any_state_plus(comment):
2114 case new_line + car_ret:
2118 cur_cmd = eq_type(cur_cs);
2119 cur_chr = equiv(cur_cs);
2121 if (cur_cmd >= outer_call)
2122 check_outer_validity();
2126 case mid_line + left_brace:
2130 case skip_blanks + left_brace:
2131 case new_line + left_brace:
2138 case mid_line + right_brace:
2142 case skip_blanks + right_brace:
2143 case new_line + right_brace:
2150 case add_delims_to(skip_blanks):
2151 case add_delims_to(new_line):
2163 if (cur_input.name_field > 17)
2170 if (input_ln(cur_file, true))
2185 check_outer_validity();
2189 if (end_line_char_inactive())
2192 buffer[limit] = end_line_char;
2199 if (!(cur_input.name_field == 0))
2212 if (selector < log_only)
2215 if (interaction > nonstop_mode)
2217 if (end_line_char_inactive())
2221 print_nl("(Please type a command or say `\\end')");
2228 if (end_line_char_inactive())
2231 buffer[limit]= end_line_char;
2238 fatal_error("*** (job aborted, no legal \\end found)");
2252 if (t >= cs_token_flag)
2254 cur_cs = t - cs_token_flag;
2255 cur_cmd = eq_type(cur_cs);
2256 cur_chr = equiv(cur_cs);
2258 if (cur_cmd >= outer_call)
2259 if (cur_cmd == dont_expand)
2261 cur_cs = info(loc) - cs_token_flag;
2263 cur_cmd = eq_type(cur_cs);
2264 cur_chr = equiv(cur_cs);
2266 if (cur_cmd > max_command)
2269 cur_chr = no_expand_flag;
2274 check_outer_validity();
2294 begin_token_list(param_stack[limit + cur_chr - 1], parameter);
2310 if (cur_cmd <= car_ret)
2311 if (cur_cmd >= tab_mark)
2312 if (align_state == 0)
2314 if ((scanner_status == aligning) && (cur_align == 0))
2316 fatal_error("(interwoven alignment preambles are not allowed)");
2320 cur_cmd = extra_info(cur_align);
2321 extra_info(cur_align) = cur_chr;
2323 if (cur_cmd == omit)
2324 begin_token_list(omit_template, v_template);
2326 begin_token_list(v_part(cur_align), v_template);
2328 align_state = 1000000L;