1
4
5# include "luametatex.h"
6
7
37
38hash_state_info lmt_hash_state = {
39 .hash = NULL,
40 .hash_data = {
41 .minimum = min_hash_size,
42 .maximum = max_hash_size,
43 .size = siz_hash_size,
44 .step = stp_hash_size,
45 .allocated = 0,
46 .itemsize = sizeof(memoryword) + sizeof(memoryword),
47 .top = 0,
48 .ptr = 0,
49 .initial = 0,
50 .offset = 0,
51 .extra = 0,
52 },
53 .eqtb_data = {
54 .minimum = min_hash_size,
55 .maximum = max_hash_size,
56 .size = siz_hash_size,
57 .step = stp_hash_size,
58 .allocated = memory_data_unset,
59 .itemsize = memory_data_unset,
60 .top = frozen_control_sequence,
61 .ptr = 0,
62 .initial = 0,
63 .offset = 0,
64 .extra = 0,
65 },
66 .eqtb = NULL,
67 .no_new_cs = 1,
68 .padding = 0,
69 .destructors = { eq_none},
70};
71
72
86
87primitive_state_info lmt_primitive_state;
88
89
90
91# define prim_base 1
92# define reserved_hash_slots 1
93
94
95
96void tex_initialize_primitives(void)
97{
98 memset(lmt_primitive_state.prim_data, 0, sizeof(prim_info) * (last_cmd + 1));
99 memset(lmt_primitive_state.prim, 0, sizeof(memoryword) * (prim_size + 1));
100 memset(lmt_primitive_state.prim_eqtb, 0, sizeof(memoryword) * (prim_size + 1));
101 for (int k = 0; k <= prim_size; k++) {
102 prim_eq_type(k) = undefined_cs_cmd;
103 }
104 lmt_primitive_state.prim_used = prim_size;
105}
106
107void tex_initialize_hash_mem(void)
108{
109 if (lmt_main_state.run_state == initializing_state) {
110 if (lmt_hash_state.hash_data.minimum == 0) {
111 tex_emergency_message("startup error", "you need at least some hash size");
112 } else {
113 lmt_hash_state.hash_data.allocated = lmt_hash_state.hash_data.minimum;
114 lmt_hash_state.hash_data.top = eqtb_size + lmt_hash_state.hash_data.minimum;
115 }
116 }
117 {
118 int size = lmt_hash_state.hash_data.top + 1;
119 memoryword *hash = aux_allocate_clear_array(sizeof(memoryword), size, reserved_hash_slots);
120 memoryword *eqtb = aux_allocate_clear_array(sizeof(memoryword), size, reserved_hash_slots);
121 if (hash && eqtb) {
122 lmt_hash_state.hash = hash;
123 lmt_hash_state.eqtb = eqtb;
124 if (lmt_main_state.run_state == initializing_state) {
125
126 } else {
127 tex_initialize_undefined_cs();
128 for (int i = eqtb_size + 1; i <= lmt_hash_state.hash_data.top; i++) {
129 copy_eqtb_entry(i, undefined_control_sequence);
130 }
131 }
132 } else {
133 tex_overflow_error("hash", size);
134 }
135 }
136}
137
138static int tex_aux_room_in_hash(void)
139{
140 if (lmt_hash_state.hash_data.allocated + lmt_hash_state.hash_data.step <= lmt_hash_state.hash_data.size) {
141 int size = lmt_hash_state.hash_data.top + lmt_hash_state.hash_data.step + 1;
142 memoryword *hash = aux_reallocate_array(lmt_hash_state.hash, sizeof(memoryword), size, reserved_hash_slots);
143 memoryword *eqtb = aux_reallocate_array(lmt_hash_state.eqtb, sizeof(memoryword), size, reserved_hash_slots);
144 if (hash && eqtb) {
145 memset(hash + lmt_hash_state.hash_data.top + 1, 0, sizeof(memoryword) * (size_t) lmt_hash_state.hash_data.step);
146 memset(eqtb + lmt_hash_state.hash_data.top + 1, 0, sizeof(memoryword) * (size_t) lmt_hash_state.hash_data.step);
147 lmt_hash_state.hash = hash;
148 lmt_hash_state.eqtb = eqtb;
149
153 for (int i = lmt_hash_state.hash_data.top + 1; i <= size; i++) {
154 copy_eqtb_entry(i, undefined_control_sequence);
155 }
156 lmt_hash_state.hash_data.allocated += lmt_hash_state.hash_data.step;
157 lmt_hash_state.hash_data.top += lmt_hash_state.hash_data.step;
158 lmt_run_memory_callback("hash", 1);
159 return 1;
160 } else {
161 lmt_run_memory_callback("hash", 0);
162 tex_overflow_error("hash", size);
163 }
164 }
165 return 0;
166}
167
168
188
189static inline halfword tex_aux_compute_hash(const char *j, unsigned l)
190{
191 halfword h = (unsigned const char) j[0];
192 for (unsigned k = 1; k < l; k++) {
193 h = (h + h + (unsigned const char) j[k]) % hash_prime;
194 }
195 return h;
196}
197
198static inline halfword tex_aux_compute_prim(const char *j, unsigned l)
199{
200 halfword h = (unsigned const char) j[0];
201 for (unsigned k = 1; k < l; k++) {
202 h = (h + h + (unsigned const char) j[k]) % prim_prime;
203 }
204 return h;
205}
206
207halfword tex_prim_lookup(strnumber s)
208{
209
210 if (s >= cs_offset_value) {
211 unsigned char *j = str_string(s);
212
213 halfword l = (halfword) str_length(s);
214 halfword h = tex_aux_compute_prim((char *) j, l);
215
216 halfword p = h + 1;
217 while (1) {
218
219 if ((prim_text(p) > 0) && (str_length(prim_text(p)) == (size_t) l) && tex_str_eq_str(prim_text(p), s)) {
220 return p;
221 } else if (prim_next(p)) {
222 p = prim_next(p);
223 } else if (lmt_hash_state.no_new_cs) {
224 return undefined_primitive;
225 } else {
226
227 if (prim_text(p) > 0) {
228
229 do {
230 if (lmt_primitive_state.prim_used > prim_base) {
231 --lmt_primitive_state.prim_used;
232 } else {
233 tex_overflow_error("primitive size", prim_size);
234 }
235 } while (prim_text(lmt_primitive_state.prim_used));
236 prim_next(p) = lmt_primitive_state.prim_used;
237 p = lmt_primitive_state.prim_used;
238 }
239 prim_text(p) = s;
240 break;
241 }
242 }
243 return p;
244 } else if ((s < 0) || (s == undefined_control_sequence)) {
245 return undefined_primitive;
246 } else {
247 return s;
248 }
249}
250
251
252
253
267
268
269
270
271
272void tex_dump_primitives(dumpstream f)
273{
274
282 dump_things(f, lmt_primitive_state.prim[0], prim_size + 1);
283 dump_things(f, lmt_primitive_state.prim_eqtb[0], prim_size + 1);
284 for (int p = 0; p <= last_cmd; p++) {
285 dump_int(f, lmt_primitive_state.prim_data[p].offset);
286 dump_int(f, lmt_primitive_state.prim_data[p].subids);
287 for (int q = 0; q < lmt_primitive_state.prim_data[p].subids; q++) {
288 dump_int(f, lmt_primitive_state.prim_data[p].names[q]);
289 }
290 }
291}
292
293void tex_undump_primitives(dumpstream f)
294{
295 undump_things(f, lmt_primitive_state.prim[0], prim_size + 1);
296 undump_things(f, lmt_primitive_state.prim_eqtb[0], prim_size + 1);
297 for (int p = 0; p <= last_cmd; p++) {
298 undump_int(f, lmt_primitive_state.prim_data[p].offset);
299 undump_int(f, lmt_primitive_state.prim_data[p].subids);
300 if (lmt_primitive_state.prim_data[p].subids > 0) {
301 int size = lmt_primitive_state.prim_data[p].subids;
302 strnumber *names = aux_allocate_clear_array(sizeof(strnumber *), size, 1);
303 if (names) {
304 lmt_primitive_state.prim_data[p].names = names;
305 for (int q = 0; q < lmt_primitive_state.prim_data[p].subids; q++) {
306 undump_int(f, names[q]);
307 }
308 } else {
309 tex_overflow_error("primitives", size * sizeof(strnumber *));
310 }
311 }
312 }
313}
314
315
323
324void tex_dump_hashtable(dumpstream f)
325{
326 dump_int(f, lmt_hash_state.eqtb_data.top);
327 lmt_hash_state.eqtb_data.ptr = frozen_control_sequence - 1 - lmt_hash_state.eqtb_data.top + lmt_hash_state.hash_data.ptr;
328
329 for (halfword p = hash_base; p <= lmt_hash_state.eqtb_data.top; p++) {
330 if (cs_text(p)) {
331 dump_int(f, p);
332 dump_mem(f, lmt_hash_state.hash[p]);
333 ++lmt_hash_state.eqtb_data.ptr;
334 }
335 }
336
337 dump_things(f, lmt_hash_state.hash[lmt_hash_state.eqtb_data.top + 1], special_sequence_base - lmt_hash_state.eqtb_data.top);
338 if (lmt_hash_state.hash_data.ptr > 0) {
339 dump_things(f, lmt_hash_state.hash[eqtb_size + 1], lmt_hash_state.hash_data.ptr);
340 }
341 dump_int(f, lmt_hash_state.eqtb_data.ptr);
342}
343
344void tex_undump_hashtable(dumpstream f)
345{
346 undump_int(f, lmt_hash_state.eqtb_data.top);
347 if (lmt_hash_state.eqtb_data.top >= hash_base && lmt_hash_state.eqtb_data.top <= frozen_control_sequence) {
348 halfword p = hash_base - 1;
349 do {
350 halfword q;
351 undump_int(f, q);
352 if (q >= (p + 1) && q <= lmt_hash_state.eqtb_data.top) {
353 undump_mem(f, lmt_hash_state.hash[q]);
354 p = q;
355 } else {
356 goto BAD;
357 }
358 } while (p != lmt_hash_state.eqtb_data.top);
359 undump_things(f, lmt_hash_state.hash[lmt_hash_state.eqtb_data.top + 1], special_sequence_base - lmt_hash_state.eqtb_data.top);
360 if (lmt_hash_state.hash_data.ptr > 0) {
361
362 undump_things(f, lmt_hash_state.hash[eqtb_size + 1], lmt_hash_state.hash_data.ptr);
363 }
364 undump_int(f, lmt_hash_state.eqtb_data.ptr);
365 lmt_hash_state.eqtb_data.initial = lmt_hash_state.eqtb_data.ptr;
366 return;
367 }
368 BAD:
369 tex_fatal_undump_error("hash");
370}
371
372
384
385void tex_primitive_def(const char *str, size_t length, singleword cmd, halfword chr)
386{
387
388 cur_val = tex_string_locate(str, length, 1);
389 set_eq_level(cur_val, level_one);
390 set_eq_type(cur_val, cmd);
391 set_eq_flag(cur_val, primitive_flag_bit);
392 set_eq_value(cur_val, chr);
393}
394
395
406
407static void tex_aux_store_primitive_name(strnumber s, singleword cmd, halfword chr, halfword offset)
408{
409 lmt_primitive_state.prim_data[cmd].offset = offset;
410 if (lmt_primitive_state.prim_data[cmd].subids < (chr + 1)) {
411
412 strnumber *newstr = aux_allocate_clear_array(sizeof(strnumber *), chr + 1, 1);
413 if (lmt_primitive_state.prim_data[cmd].names) {
414 memcpy(newstr, lmt_primitive_state.prim_data[cmd].names, (unsigned) (lmt_primitive_state.prim_data[cmd].subids) * sizeof(strnumber));
415 aux_deallocate_array(lmt_primitive_state.prim_data[cmd].names);
416 }
417 lmt_primitive_state.prim_data[cmd].names = newstr;
418 lmt_primitive_state.prim_data[cmd].subids = chr + 1;
419 }
420 lmt_primitive_state.prim_data[cmd].names[chr] = s;
421}
422
423
434
435void tex_primitive(int cmd_origin, const char *str, singleword cmd, halfword chr, halfword offset)
436{
437 int prim_val;
438 strnumber ss;
439 if (cmd_origin != no_command) {
440 tex_primitive_def(str, strlen(str), cmd, offset + chr);
441
442 ss = cs_text(cur_val);
443 } else {
444 ss = tex_maketexstring(str);
445 }
446 prim_val = tex_prim_lookup(ss);
447 prim_origin(prim_val) = (quarterword) cmd_origin;
448 prim_eq_type(prim_val) = cmd;
449 prim_equiv(prim_val) = offset + chr;
450 tex_aux_store_primitive_name(ss, cmd, chr, offset);
451}
452
453
462
463static halfword tex_aux_insert_id(halfword p, const unsigned char *str, unsigned int l)
464{
465 if (cs_text(p) > 0) {
466 RESTART:
467 if (lmt_hash_state.hash_data.ptr < lmt_hash_state.hash_data.allocated) {
468 ++lmt_hash_state.hash_data.ptr;
469 cs_next(p) = lmt_hash_state.hash_data.ptr + eqtb_size;
470 p = cs_next(p);
471 } else if (tex_aux_room_in_hash()) {
472 goto RESTART;
473 } else {
474
480 do {
481 if (lmt_hash_state.eqtb_data.top == hash_base) {
482
483 tex_overflow_error("hash size", hash_size + lmt_hash_state.hash_data.allocated);
484 }
485 --lmt_hash_state.eqtb_data.top;
486 } while (cs_text(lmt_hash_state.eqtb_data.top) != 0);
487 cs_next(p) = lmt_hash_state.eqtb_data.top;
488 p = lmt_hash_state.eqtb_data.top;
489 }
490 }
491 cs_text(p) = tex_push_string(str, l);
492 copy_eqtb_entry(p, undefined_control_sequence);
493 ++lmt_hash_state.eqtb_data.ptr;
494 return p;
495}
496
497
509
510halfword tex_id_locate(int j, int l, int create)
511{
512
513 halfword p = tex_aux_compute_hash((char *) (lmt_fileio_state.io_buffer + j), (unsigned) l) + hash_base;
514
515 while (1) {
516 strnumber s = cs_text(p);
517 if ((s > 0) && (str_length(s) == (unsigned) l) && tex_str_eq_buf(s, j, l)) {
518 return p;
519 } else {
520
521 halfword n = cs_next(p);
522 if (n) {
523 p = n;
524 } else if (create) {
525 return tex_aux_insert_id(p, (lmt_fileio_state.io_buffer + j), (unsigned) l);
526 } else {
527 break;
528 }
529 }
530 }
531 return undefined_control_sequence;
532}
533
534halfword tex_id_locate_only(int j, int l)
535{
536 halfword p = tex_aux_compute_hash((char *) (lmt_fileio_state.io_buffer + j), (unsigned) l) + hash_base;
537 while (p) {
538 strnumber s = cs_text(p);
539 if ((s > 0) && (str_length(s) == (unsigned) l) && tex_str_eq_buf(s, j, l)) {
540
541 return p;
542 } else {
543 p = cs_next(p);
544 }
545 }
546 return undefined_control_sequence;
547}
548
549int tex_id_locate_steps(const char *cs)
550{
551 if (cs) {
552 unsigned int l = (unsigned) strlen(cs);
553 halfword p = tex_aux_compute_hash(cs, l) + hash_base;
554 int steps = 0;
555 while (p) {
556 strnumber s = cs_text(p);
557 ++steps;
558 if ((s > 0) && (str_length(s) == l) && memcmp(str_string(s), cs, l) == 0) {
559 return steps;
560 } else {
561 p = cs_next(p);
562 }
563 }
564 return -steps;
565 } else {
566 return 0;
567 }
568}
569
570
576
577halfword tex_string_locate(const char *s, size_t l, int create)
578{
579
580 halfword h = tex_aux_compute_hash(s, (unsigned) l);
581
582 halfword p = h + hash_base;
583 while (1) {
584 if (cs_text(p) > 0 && tex_str_eq_cstr(cs_text(p), s, (int) l)) {
585 return p;
586 } else {
587 halfword n = cs_next(p);
588 if (n) {
589 p = n;
590 } else if (create) {
591 return tex_aux_insert_id(p, (const unsigned char *) s, (unsigned) l);
592 } else {
593 break;
594 }
595 }
596 }
597 return undefined_control_sequence;
598}
599
600halfword tex_string_locate_only(const char *s, size_t l)
601{
602 halfword p = tex_aux_compute_hash(s, (unsigned) l) + hash_base;
603 while (p) {
604 if (cs_text(p) > 0 && tex_str_eq_cstr(cs_text(p), s, (int) l)) {
605 return p;
606 } else {
607 p = cs_next(p);
608 }
609 }
610 return undefined_control_sequence;
611}
612
613halfword tex_located_string(const char *s)
614{
615 return tex_string_locate_only(s, strlen(s));
616}
617
618
632
633static void tex_aux_print_chr_cmd(const char *s, halfword cmd, halfword chr)
634{
635 tex_print_str(s);
636 if (chr) {
637 tex_print_str(cmd == letter_cmd ? " letter " : " character ");
638 tex_print_uhex(chr);
639 tex_print_char(' ');
640
645
650 if (chr < 32 || chr == 127) {
651 return;
652 } else if (chr <= 0x7F) {
653 switch (chr) {
654 case '\n' : tex_print_str("'line feed'"); return;
655 case '\r' : tex_print_str("'carriage return'"); return;
656 case ' ' : tex_print_str("'space'"); return;
657 case '!' : tex_print_str("'exclamation mark'"); return;
658 case '\"' : tex_print_str("'quotation mark'"); return;
659 case '#' : tex_print_str("'hash tag'"); return;
660 case '$' : tex_print_str("'dollar sign'"); return;
661 case '%' : tex_print_str("'percent sign'"); return;
662 case '&' : tex_print_str("'ampersand'"); return;
663 case '\'' : tex_print_str("'apostrophe'"); return;
664 case '(' : tex_print_str("'left parenthesis'"); return;
665 case ')' : tex_print_str("'right parenthesis'"); return;
666 case '*' : tex_print_str("'asterisk'"); return;
667 case '+' : tex_print_str("'plus sign'"); return;
668 case ',' : tex_print_str("'comma'"); return;
669 case '-' : tex_print_str("'hyphen minus'"); return;
670 case '.' : tex_print_str("'full stop'"); return;
671 case '/' : tex_print_str("'slash'"); return;
672 case ':' : tex_print_str("'colon'"); return;
673 case ';' : tex_print_str("'semicolon'"); return;
674 case '<' : tex_print_str("'less than sign'"); return;
675 case '=' : tex_print_str("'equal sign'"); return;
676 case '>' : tex_print_str("'more than sign'"); return;
677 case '?' : tex_print_str("'question mark'"); return;
678 case '@' : tex_print_str("'at sign'"); return;
679 case '[' : tex_print_str("'left square bracket'"); return;
680 case '\\' : tex_print_str("'backslash'"); return;
681 case ']' : tex_print_str("'right square bracket'"); return;
682 case '^' : tex_print_str("'circumflex accent'"); return;
683 case '_' : tex_print_str("'low line'"); return;
684 case '`' : tex_print_str("'grave accent'"); return;
685 case '{' : tex_print_str("'left curly bracket'"); return;
686 case '|' : tex_print_str("'vertical bar'"); return;
687 case '}' : tex_print_str("'right curly bracket'"); return;
688 case '~' : tex_print_str("'tilde'"); return;
689 }
690 tex_print_char(chr);
691 } else if (chr <= 0x7FF) {
692 tex_print_char(0xC0 + (chr / 0x40));
693 tex_print_char(0x80 + (chr % 0x40));
694 } else if (chr <= 0xFFFF) {
695 tex_print_char(0xE0 + (chr / 0x1000));
696 tex_print_char(0x80 + ((chr % 0x1000) / 0x40));
697 tex_print_char(0x80 + ((chr % 0x1000) % 0x40));
698 } else if (chr <= 0x10FFFF) {
699 tex_print_char(0xF0 + (chr / 0x40000));
700 tex_print_char(0x80 + ((chr % 0x40000) / 0x1000));
701 tex_print_char(0x80 + (((chr % 0x40000) % 0x1000) / 0x40));
702 tex_print_char(0x80 + (((chr % 0x40000) % 0x1000) % 0x40));
703 }
704 }
705}
706
707
708
709static void tex_aux_prim_cmd_chr(quarterword cmd, halfword idx, int is_chr)
710{
711 if (cmd <= last_visible_cmd) {
712 if (is_chr) {
713 idx -= lmt_primitive_state.prim_data[cmd].offset;
714 }
715 if (idx >= 0 && idx < lmt_primitive_state.prim_data[cmd].subids) {
716 if (lmt_primitive_state.prim_data[cmd].names && lmt_primitive_state.prim_data[cmd].names[idx]) {
717 tex_print_tex_str_esc(lmt_primitive_state.prim_data[cmd].names[idx]);
718 } else {
719 tex_print_format("[warning: cmd %i, chr %i, no name]", cmd, idx);
720 }
721 } else if (cmd == internal_integer_cmd && idx < number_integer_pars) {
722
723 tex_print_format("[integer: chr %i, class specific]", cmd);
724 } else {
725 tex_print_format("[warning: cmd %i, chr %i, out of range]", cmd, idx);
726 }
727 } else {
728 tex_print_format("[warning: cmd %i, invalid]", cmd);
729 }
730}
731
732static void tex_aux_show_lua_call(const char *what, int slot)
733{
734 int callback_id = lmt_callback_defined(show_lua_call_callback);
735 if (callback_id) {
736 char *ss = NULL;
737 int lua_retval = lmt_run_callback(lmt_lua_state.lua_instance, callback_id, "Sd->S", what, slot, &ss);
738 if (lua_retval && ss && strlen(ss) > 0) {
739 tex_print_str(ss);
740 lmt_memory_free(ss);
741 return;
742 }
743 }
744 tex_print_format("%s %i", what, slot);
745}
746
747void tex_print_cmd_flags(halfword cs, halfword cmd, int flags, int escaped)
748{
749 if (flags) {
750 flags = eq_flag(cs);
751 if (eq_level(cs) == level_one) {
752 (escaped ? tex_print_str_esc : tex_print_str)("global ");
753 }
754 if (is_frozen (flags)) { (escaped ? tex_print_str_esc : tex_print_str)("frozen " ); }
755 if (is_permanent(flags)) { (escaped ? tex_print_str_esc : tex_print_str)("permanent "); }
756 if (is_immutable(flags)) { (escaped ? tex_print_str_esc : tex_print_str)("immutable "); }
757 if (is_primitive(flags)) { (escaped ? tex_print_str_esc : tex_print_str)("primitive "); }
758 if (is_mutable (flags)) { (escaped ? tex_print_str_esc : tex_print_str)("mutable " ); }
759 if (is_noaligned(flags)) { (escaped ? tex_print_str_esc : tex_print_str)("noaligned "); }
760 if (is_instance (flags)) { (escaped ? tex_print_str_esc : tex_print_str)("instance " ); }
761 if (is_untraced (flags)) { (escaped ? tex_print_str_esc : tex_print_str)("untraced " ); }
762 }
763 if (is_constant_cmd(cmd)) {
764 (escaped ? tex_print_str_esc : tex_print_str)("constant " );
765 }
766 if (is_tolerant_cmd(cmd)) {
767 (escaped ? tex_print_str_esc : tex_print_str)("tolerant " );
768 }
769 if (is_protected_cmd(cmd)) {
770 (escaped ? tex_print_str_esc : tex_print_str)("protected ");
771 } else if (is_semi_protected_cmd(cmd)) {
772 (escaped ? tex_print_str_esc : tex_print_str)("semiprotected ");
773 }
774}
775
776void tex_print_cmd_chr(singleword cmd, halfword chr)
777{
778 switch (cmd) {
779 case left_brace_cmd:
780 tex_aux_print_chr_cmd("begin group", cmd, chr);
781 break;
782 case right_brace_cmd:
783 tex_aux_print_chr_cmd("end group", cmd, chr);
784 break;
785 case math_shift_cmd:
786 tex_aux_print_chr_cmd("math shift", cmd, chr);
787 break;
788 case alignment_tab_cmd:
789 tex_aux_print_chr_cmd("alignment tab", cmd, chr);
790 break;
791 case parameter_cmd:
792 tex_aux_print_chr_cmd("parameter", cmd, chr);
793 break;
794 case superscript_cmd:
795 tex_aux_print_chr_cmd("superscript", cmd, chr);
796 break;
797 case subscript_cmd:
798 tex_aux_print_chr_cmd("subscript", cmd, chr);
799 break;
800 case spacer_cmd:
801 tex_aux_print_chr_cmd("blank space", cmd, chr);
802 break;
803 case letter_cmd:
804 case other_char_cmd:
805 tex_aux_print_chr_cmd("the", cmd, chr);
806 break;
807 case active_char_cmd:
808 tex_aux_print_chr_cmd("active", cmd, chr);
809 break;
810
815 case end_template_cmd:
816
817 tex_print_str_esc("endtemplate");
818
819 break;
820 case if_test_cmd:
821 if (chr <= last_if_test_code) {
822 tex_aux_prim_cmd_chr(cmd, chr, 1);
823 } else {
824 tex_aux_show_lua_call("luacondition", chr - last_if_test_code);
825 }
826 break;
827 case char_given_cmd:
828 tex_print_str_esc("char");
829 tex_print_qhex(chr);
830 break;
831 case lua_call_cmd:
832 tex_aux_show_lua_call("luacall", chr);
833 break;
834 case lua_local_call_cmd:
835 tex_aux_show_lua_call("local luacall", chr);
836 break;
837 case lua_protected_call_cmd:
838 tex_aux_show_lua_call("protected luacall", chr);
839 break;
840 case lua_semi_protected_call_cmd:
841 tex_aux_show_lua_call("semiprotected luacall", chr);
842 break;
843 case lua_value_cmd:
844 tex_aux_show_lua_call("luavalue", chr);
845 break;
846 case set_font_cmd:
847 tex_print_str("select font ");
848 tex_print_font(chr);
849 break;
850 case undefined_cs_cmd:
851 tex_print_str("undefined");
852 break;
853 case call_cmd:
854 case protected_call_cmd:
855 case semi_protected_call_cmd:
856 case constant_call_cmd:
857 case tolerant_call_cmd:
858 case tolerant_protected_call_cmd:
859 case tolerant_semi_protected_call_cmd:
860 tex_print_cmd_flags(cur_cs, cur_cmd, 1, 0);
861 tex_print_str("macro");
862 break;
863 case internal_toks_cmd:
864 tex_aux_prim_cmd_chr(cmd, chr, 1);
865 break;
866 case register_toks_cmd:
867 tex_print_str_esc("toks");
868 tex_print_int(register_toks_number(chr));
869 break;
870 case internal_integer_cmd:
871 tex_aux_prim_cmd_chr(cmd, chr, 1);
872 break;
873 case register_integer_cmd:
874 tex_print_str_esc("count");
875 tex_print_int(register_integer_number(chr));
876 break;
877 case internal_attribute_cmd:
878 tex_aux_prim_cmd_chr(cmd, chr, 1);
879 break;
880 case register_attribute_cmd:
881 tex_print_str_esc("attribute");
882 tex_print_int(register_attribute_number(chr));
883 break;
884 case register_posit_cmd:
885 tex_print_str_esc("posit");
886 tex_print_int(register_posit_number(chr));
887 break;
888 case internal_posit_cmd:
889 tex_aux_prim_cmd_chr(cmd, chr, 1);
890 break;
891 case internal_dimension_cmd:
892 tex_aux_prim_cmd_chr(cmd, chr, 1);
893 break;
894 case register_dimension_cmd:
895 tex_print_str_esc("dimen");
896 tex_print_int(register_dimension_number(chr));
897 break;
898 case internal_glue_cmd:
899 tex_aux_prim_cmd_chr(cmd, chr, 1);
900 break;
901 case register_glue_cmd:
902 tex_print_str_esc("skip");
903 tex_print_int(register_glue_number(chr));
904 break;
905 case internal_muglue_cmd:
906 tex_aux_prim_cmd_chr(cmd, chr, 1);
907 break;
908 case register_muglue_cmd:
909 tex_print_str_esc("muskip");
910 tex_print_int(register_muglue_number(chr));
911 break;
912 case node_cmd:
913 tex_print_str(node_token_flagged(chr) ? "large" : "small");
914 tex_print_str(" node reference");
915 break;
916 case integer_cmd:
917 tex_print_str("integer ");
918 tex_print_int(chr);
919 break;
920 case dimension_cmd:
921 tex_print_str("dimension ");
922 tex_print_dimension(chr, pt_unit);
923 break;
924 case posit_cmd:
925 tex_print_str("posit ");
926 tex_print_posit(chr);
927 break;
928 case gluespec_cmd:
929 tex_print_str("gluespec ");
930 tex_print_spec(chr, pt_unit);
931 break;
932 case mugluespec_cmd:
933 tex_print_str("mugluespec ");
934 tex_print_spec(chr, mu_unit);
935 break;
936 case index_cmd:
937 tex_print_str("parameter ");
938 tex_print_int(chr);
939 break;
940# if (match_experiment)
941case integer_reference_cmd:
942 tex_print_str(node_token_flagged(chr) ? "large" : "small");
943 tex_print_str(" integer reference");
944 break;
945case dimension_reference_cmd:
946 tex_print_str(node_token_flagged(chr) ? "large" : "small");
947 tex_print_str(" dimension reference");
948 break;
949# endif
950 case mathspec_cmd:
951 switch (node_subtype(chr)) {
952 case tex_mathcode:
953 tex_print_str_esc("mathchar");
954 break;
955 case umath_mathcode:
956
957 tex_print_str_esc("Umathchar");
958 break;
959 case mathspec_mathcode:
960 tex_print_str("mathspec ");
961 }
962 tex_print_mathspec(chr);
963 break;
964 case fontspec_cmd:
965
966 tex_print_str("fontspec ");
967 tex_print_fontspec(chr);
968 break;
969 case specificationspec_cmd:
970
971 tex_print_str("specification ");
972 if (chr) {
973 switch (node_subtype(chr)) {
974 case integer_list_code:
975 tex_print_str_esc("count");
976 break;
977 case dimension_list_code:
978 tex_print_str_esc("dimen");
979 break;
980 case posit_list_code:
981 tex_print_str_esc("posit");
982 break;
983 default:
984 tex_aux_prim_cmd_chr(specification_cmd, node_subtype(chr), 0);
985 break;
986 }
987 } else {
988 tex_print_str("<unset>");
989 }
990 break;
991 case deep_frozen_end_template_cmd:
992
993 tex_print_str_esc("endtemplate");
994 break;
995 case deep_frozen_dont_expand_cmd:
996
997 tex_print_str_esc("notexpanded");
998 break;
999 case deep_frozen_keep_constant_cmd:
1000
1001 tex_print_str_esc("keepconstant");
1002 break;
1003 case internal_box_reference_cmd:
1004 tex_print_str_esc("hiddenlocalbox");
1005 break;
1006 default:
1007
1008 tex_aux_prim_cmd_chr(cmd, chr, 1);
1009 break;
1010 }
1011}
1012 |