mathtex-portable-engine-generated 0.1.2

Machine generated portable TeX engine core for mathtex, translated from the TeX, eTeX and XeTeX sources
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
//! shared TeX core candidates auto-patched from TeX source when compatible (group `e`).
//! Generated by `cargo run -p mathtex-web2c-import --bin patch_engine`.

#![allow(dead_code, non_camel_case_types, non_snake_case, unused_assignments, unused_must_use, unused_mut, unused_variables)]

use crate::runtime::*;

impl<'resources> PortableTexEngine<'resources> {

pub(crate) unsafe fn endfilereading(&mut self) {
    self.state.first = self.state.curinput.startfield as integer;
    self.state.line = *self.state.linestack.offset(self.state.curinput.indexfield as isize);
    if self.state.curinput.namefield == 18 as i32
        || self.state.curinput.namefield == 19 as i32
    {
        (&mut *(self as *mut PortableTexEngine<'_>)).pseudoclose();
    } else if self.state.curinput.namefield > 17 as i32 {
        u_close_file_or_pipe(self.state.inputfile.offset(self.state.curinput.indexfield as isize) as *mut unicodefile);
    }
    self.state.inputptr -= 1;
    self.state.curinput = *self.state.inputstack.offset(self.state.inputptr as isize);
    self.state.inopen -= 1;
}

    pub(crate) unsafe fn endgraf(&mut self) -> EngineFlow<()> {
        Ok(
            if self.state.curlist.modefield as i32 == 105 as i32 {
                if self.state.curlist.headfield == self.state.curlist.tailfield {
                    (&mut *(self as *mut PortableTexEngine<'_>)).popnest();
                } else {
                    (&mut *(self as *mut PortableTexEngine<'_>)).zlinebreak(0 as i32)?;
                }
                if self.state.curlist.eTeXauxfield as i64 != -(268435455 as i64) {
                    (&mut *(self as *mut PortableTexEngine<'_>))
                        .zflushlist(self.state.curlist.eTeXauxfield);
                    self.state.curlist.eTeXauxfield = -(268435455 as i64) as halfword;
                }
                (&mut *(self as *mut PortableTexEngine<'_>)).normalparagraph()?;
                self.state.errorcount = 0 as schar;
            },
        )
    }
    pub(crate) unsafe fn endname(&mut self) -> EngineFlow<()> {
        let mut tempstr: strnumber = 0;
        let mut j: poolpointer = 0;
        if self.state.strptr as i32 + 3 as i32 > self.state.maxstrings {
            match (&mut *(self as *mut PortableTexEngine<'_>))
                .zoverflow(
                    65540 as i64 as strnumber,
                    self.state.maxstrings as strnumber - self.state.initstrptr,
                )?
            {};
        }
        if self.state.areadelimiter == 0 as i32 {
            self.state.curarea = 65626 as i64 as strnumber;
        } else {
            self.state.curarea = self.state.strptr;
            *self
                .state
                .strstart
                .offset(
                    ((self.state.strptr as i32 + 1 as i32) as i64 - 65536 as i64)
                        as isize,
                ) = *self
                .state
                .strstart
                .offset((self.state.strptr as i64 - 65536 as i64) as isize)
                + self.state.areadelimiter;
            self.state.strptr += 1;
            tempstr = (&mut *(self as *mut PortableTexEngine<'_>))
                .zsearchstring(self.state.curarea);
            if tempstr > 0 as i32 {
                self.state.curarea = tempstr;
                self.state.strptr -= 1;
                let mut for_end: integer = 0;
                j = *self
                    .state
                    .strstart
                    .offset(
                        ((self.state.strptr as i32 + 1 as i32) as i64 - 65536 as i64)
                            as isize,
                    );
                for_end = (self.state.poolptr as i32 - 1 as i32) as integer;
                if j <= for_end {
                    loop {
                        *self
                            .state
                            .strpool
                            .offset((j - self.state.areadelimiter) as isize) = *self
                            .state
                            .strpool
                            .offset(j as isize);
                        let fresh12 = j;
                        j = j + 1;
                        if !(fresh12 < for_end) {
                            break;
                        }
                    }
                }
                self.state.poolptr = self.state.poolptr - self.state.areadelimiter;
            }
        }
        if self.state.extdelimiter == 0 as i32 {
            self.state.curext = 65626 as i64 as strnumber;
            self.state.curname = (&mut *(self as *mut PortableTexEngine<'_>))
                .slowmakestring()?;
        } else {
            self.state.curname = self.state.strptr;
            *self
                .state
                .strstart
                .offset(
                    ((self.state.strptr as i32 + 1 as i32) as i64 - 65536 as i64)
                        as isize,
                ) = (*self
                .state
                .strstart
                .offset((self.state.strptr as i64 - 65536 as i64) as isize) as i32
                + self.state.extdelimiter as i32 - self.state.areadelimiter as i32
                - 1 as i32) as poolpointer;
            self.state.strptr += 1;
            self.state.curext = (&mut *(self as *mut PortableTexEngine<'_>))
                .makestring()?;
            self.state.strptr -= 1;
            tempstr = (&mut *(self as *mut PortableTexEngine<'_>))
                .zsearchstring(self.state.curname);
            if tempstr > 0 as i32 {
                self.state.curname = tempstr;
                self.state.strptr -= 1;
                let mut for_end_0: integer = 0;
                j = *self
                    .state
                    .strstart
                    .offset(
                        ((self.state.strptr as i32 + 1 as i32) as i64 - 65536 as i64)
                            as isize,
                    );
                for_end_0 = (self.state.poolptr as i32 - 1 as i32) as integer;
                if j <= for_end_0 {
                    loop {
                        *self
                            .state
                            .strpool
                            .offset(
                                (j as i32 - self.state.extdelimiter as i32
                                    + self.state.areadelimiter as i32 + 1 as i32) as isize,
                            ) = *self.state.strpool.offset(j as isize);
                        let fresh13 = j;
                        j = j + 1;
                        if !(fresh13 < for_end_0) {
                            break;
                        }
                    }
                }
                self.state.poolptr = (self.state.poolptr as i32
                    - self.state.extdelimiter as i32 + self.state.areadelimiter as i32
                    + 1 as i32) as poolpointer;
            }
            self.state.curext = (&mut *(self as *mut PortableTexEngine<'_>))
                .slowmakestring()?;
        };
        Ok(())
    }
    pub(crate) unsafe fn endtokenlist(&mut self) -> EngineFlow<()> {
        Self::src_end_token_list(
            self as *mut PortableTexEngine<'_>,
            self.state.curinput.indexfield as i32,
        );
        if self.state.curinput.indexfield as i32 >= 3 as i32 {
            if self.state.curinput.indexfield as i32 <= 5 as i32 {
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zflushlist(self.state.curinput.startfield);
            } else {
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zdeletetokenref(self.state.curinput.startfield);
                if self.state.curinput.indexfield as i32 == 6 as i32 {
                    while self.state.paramptr > self.state.curinput.limitfield {
                        self.state.paramptr -= 1;
                        (&mut *(self as *mut PortableTexEngine<'_>))
                            .zflushlist(
                                *self.state.paramstack.offset(self.state.paramptr as isize),
                            );
                    }
                } else if self.state.curinput.indexfield as i32 == 7 as i32
                    && self.state.outputcanend == 0
                {
                    match (&mut *(self as *mut PortableTexEngine<'_>))
                        .zfatalerror(65923 as i64 as strnumber)?
                    {};
                }
            }
        } else if self.state.curinput.indexfield as i32 == 1 as i32 {
            if self.state.alignstate as i64 > 500000 as i64 {
                self.state.alignstate = 0 as i32 as integer;
            } else {
                match (&mut *(self as *mut PortableTexEngine<'_>))
                    .zfatalerror(65924 as i64 as strnumber)?
                {};
            }
        }
        self.state.inputptr -= 1;
        self.state.curinput = *self
            .state
            .inputstack
            .offset(self.state.inputptr as isize);
        Ok(
            if self.state.interrupt != 0 as i32 {
                (&mut *(self as *mut PortableTexEngine<'_>)).pauseforinstructions()?;
            },
        )
    }
    pub(crate) unsafe fn error(&mut self) -> EngineFlow<()> {
        let mut c_0: UnicodeScalar = 0;
        let mut s1: integer = 0;
        let mut s2: integer = 0;
        let mut s3: integer = 0;
        let mut s4: integer = 0;
        if (self.state.history as i32) < 2 as i32 {
            self.state.history = 2 as eightbits;
        }
        (&mut *(self as *mut PortableTexEngine<'_>)).zprintchar(46 as i32);
        (&mut *(self as *mut PortableTexEngine<'_>)).showcontext();
        Self::surface_error(self as *mut PortableTexEngine<'_>)?;
        if self.state.haltonerrorp != 0 {
            if self.state.haltingonerrorp != 0 {
                Self::boundary_flush_file(self.state.terminal_output);
                self.state.readyalready = 0 as i32 as integer;
                if self.state.history as i32 != 0 as i32
                    && self.state.history as i32 != 1 as i32
                {
                    match Self::abort_engine(
                        self as *mut PortableTexEngine<'_>,
                        1 as i32,
                    )? {};
                } else {
                    match Self::abort_engine(
                        self as *mut PortableTexEngine<'_>,
                        0 as i32,
                    )? {};
                }
            }
            self.state.haltingonerrorp = true_0 as boolean;
            if self.state.interaction as i32 > 0 as i32 {
                self.state.selector = self.state.selector.wrapping_sub(1);
            }
            if self.state.useerrhelp != 0 {
                (&mut *(self as *mut PortableTexEngine<'_>)).println();
                (&mut *(self as *mut PortableTexEngine<'_>)).giveerrhelp();
            } else {
                while self.state.helpptr as i32 > 0 as i32 {
                    self.state.helpptr = self.state.helpptr.wrapping_sub(1);
                    (&mut *(self as *mut PortableTexEngine<'_>))
                        .zprintnl(self.state.helpline[self.state.helpptr as usize]);
                }
            }
            (&mut *(self as *mut PortableTexEngine<'_>)).println();
            if self.state.interaction as i32 > 0 as i32 {
                self.state.selector = self.state.selector.wrapping_add(1);
            }
            (&mut *(self as *mut PortableTexEngine<'_>)).println();
            self.state.history = 3 as eightbits;
            match Self::boundary_jump_out(self as *mut PortableTexEngine<'_>)? {};
        }
        if self.state.interaction as i32 == 3 as i32 {
            loop {
                if self.state.interaction as i32 != 3 as i32 {
                    return Ok(());
                }
                (&mut *(self as *mut PortableTexEngine<'_>)).clearforerrorprompt();
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprint(65546 as i64 as integer);
                (&mut *(self as *mut PortableTexEngine<'_>)).terminput()?;
                if self.state.last == self.state.first {
                    return Ok(());
                }
                c_0 = *self.state.buffer.offset(self.state.first as isize);
                if c_0 >= 97 as i32 {
                    c_0 = (c_0 as i32 - 32 as i32) as UnicodeScalar;
                }
                match c_0 {
                    48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 => {
                        if self.state.deletionsallowed != 0 {
                            s1 = self.state.curtok as integer;
                            s2 = self.state.curcmd as integer;
                            s3 = self.state.curchr as integer;
                            s4 = self.state.alignstate;
                            self.state.alignstate = 1000000 as i64 as integer;
                            self.state.OKtointerrupt = false_0 as boolean;
                            if self.state.last > self.state.first as i32 + 1 as i32
                                && *self
                                    .state
                                    .buffer
                                    .offset((self.state.first as i32 + 1 as i32) as isize)
                                    >= 48 as i32
                                && *self
                                    .state
                                    .buffer
                                    .offset((self.state.first as i32 + 1 as i32) as isize)
                                    <= 57 as i32
                            {
                                c_0 = (c_0 as i32 * 10 as i32
                                    + *self
                                        .state
                                        .buffer
                                        .offset((self.state.first as i32 + 1 as i32) as isize)
                                        as i32 - 48 as i32 * 11 as i32) as UnicodeScalar;
                            } else {
                                c_0 = (c_0 as i32 - 48 as i32) as UnicodeScalar;
                            }
                            while c_0 > 0 as i32 {
                                (&mut *(self as *mut PortableTexEngine<'_>)).gettoken()?;
                                c_0 -= 1;
                            }
                            self.state.curtok = s1 as halfword;
                            self.state.curcmd = s2 as eightbits;
                            self.state.curchr = s3 as halfword;
                            self.state.alignstate = s4;
                            self.state.OKtointerrupt = true_0 as boolean;
                            self.state.helpptr = 2 as eightbits;
                            self.state.helpline[1 as i32 as usize] = 65559 as i64
                                as strnumber;
                            self.state.helpline[0 as i32 as usize] = 65560 as i64
                                as strnumber;
                            (&mut *(self as *mut PortableTexEngine<'_>)).showcontext();
                            continue;
                        }
                    }
                    69 => {
                        if self.state.baseptr > 0 as i32 {
                            if (*self
                                .state
                                .inputstack
                                .offset(self.state.baseptr as isize))
                                .namefield >= 256 as i32
                            {
                                self.state.editnamestart = *self
                                    .state
                                    .strstart
                                    .offset(
                                        ((*self
                                            .state
                                            .inputstack
                                            .offset(self.state.baseptr as isize))
                                            .namefield as i64 - 65536 as i64) as isize,
                                    );
                                self.state.editnamelength = (*self
                                    .state
                                    .strstart
                                    .offset(
                                        (((*self
                                            .state
                                            .inputstack
                                            .offset(self.state.baseptr as isize))
                                            .namefield as i32 + 1 as i32) as i64 - 65536 as i64)
                                            as isize,
                                    )
                                    - *self
                                        .state
                                        .strstart
                                        .offset(
                                            ((*self
                                                .state
                                                .inputstack
                                                .offset(self.state.baseptr as isize))
                                                .namefield as i64 - 65536 as i64) as isize,
                                        )) as integer;
                                self.state.editline = self.state.line;
                                match Self::boundary_jump_out(
                                    self as *mut PortableTexEngine<'_>,
                                )? {};
                            }
                        }
                    }
                    72 => {
                        if self.state.useerrhelp != 0 {
                            (&mut *(self as *mut PortableTexEngine<'_>)).giveerrhelp();
                            self.state.useerrhelp = false_0 as boolean;
                        } else {
                            if self.state.helpptr as i32 == 0 as i32 {
                                self.state.helpptr = 2 as eightbits;
                                self.state.helpline[1 as i32 as usize] = 65561 as i64
                                    as strnumber;
                                self.state.helpline[0 as i32 as usize] = 65562 as i64
                                    as strnumber;
                            }
                            loop {
                                self.state.helpptr = self.state.helpptr.wrapping_sub(1);
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprint(self.state.helpline[self.state.helpptr as usize]);
                                (&mut *(self as *mut PortableTexEngine<'_>)).println();
                                if self.state.helpptr as i32 == 0 as i32 {
                                    break;
                                }
                            }
                        }
                        self.state.helpptr = 4 as eightbits;
                        self.state.helpline[3 as i32 as usize] = 65563 as i64
                            as strnumber;
                        self.state.helpline[2 as i32 as usize] = 65562 as i64
                            as strnumber;
                        self.state.helpline[1 as i32 as usize] = 65564 as i64
                            as strnumber;
                        self.state.helpline[0 as i32 as usize] = 65565 as i64
                            as strnumber;
                        continue;
                    }
                    73 => {
                        (&mut *(self as *mut PortableTexEngine<'_>)).beginfilereading()?;
                        if self.state.last > self.state.first as i32 + 1 as i32 {
                            self.state.curinput.locfield = (self.state.first as i32
                                + 1 as i32) as halfword;
                            *self.state.buffer.offset(self.state.first as isize) = 32
                                as i32 as UnicodeScalar;
                        } else {
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zprint(65558 as i64 as integer);
                            (&mut *(self as *mut PortableTexEngine<'_>)).terminput()?;
                            self.state.curinput.locfield = self.state.first as halfword;
                        }
                        self.state.first = self.state.last;
                        self.state.curinput.limitfield = (self.state.last as i32
                            - 1 as i32) as halfword;
                        return Ok(());
                    }
                    81 | 82 | 83 => {
                        self.state.errorcount = 0 as schar;
                        self.state.interaction = (0 as i32 + c_0 as i32 - 81 as i32)
                            as eightbits;
                        (&mut *(self as *mut PortableTexEngine<'_>))
                            .zprint(65553 as i64 as integer);
                        match c_0 {
                            81 => {
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintesc(65554 as i64 as strnumber);
                                self.state.selector = self.state.selector.wrapping_sub(1);
                            }
                            82 => {
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintesc(65555 as i64 as strnumber);
                            }
                            83 => {
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintesc(65556 as i64 as strnumber);
                            }
                            _ => {}
                        }
                        (&mut *(self as *mut PortableTexEngine<'_>))
                            .zprint(65557 as i64 as integer);
                        (&mut *(self as *mut PortableTexEngine<'_>)).println();
                        Self::boundary_flush_file(self.state.terminal_output);
                        return Ok(());
                    }
                    88 => {
                        self.state.interaction = 2 as eightbits;
                        match Self::boundary_jump_out(
                            self as *mut PortableTexEngine<'_>,
                        )? {};
                    }
                    _ => {}
                }
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprint(65547 as i64 as integer);
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprintnl(65548 as i64 as strnumber);
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprintnl(65549 as i64 as strnumber);
                if self.state.baseptr > 0 as i32 {
                    if (*self.state.inputstack.offset(self.state.baseptr as isize))
                        .namefield >= 256 as i32
                    {
                        (&mut *(self as *mut PortableTexEngine<'_>))
                            .zprint(65550 as i64 as integer);
                    }
                }
                if self.state.deletionsallowed != 0 {
                    (&mut *(self as *mut PortableTexEngine<'_>))
                        .zprintnl(65551 as i64 as strnumber);
                }
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprintnl(65552 as i64 as strnumber);
            }
        } else {
            self.state.errorcount += 1;
            if self.state.errorcount as i32 == 100 as i32 {
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprintnl(65545 as i64 as strnumber);
                self.state.history = 3 as eightbits;
                match Self::boundary_jump_out(self as *mut PortableTexEngine<'_>)? {};
            }
            if self.state.interaction as i32 > 0 as i32 {
                self.state.selector = self.state.selector.wrapping_sub(1);
            }
            if self.state.useerrhelp != 0 {
                (&mut *(self as *mut PortableTexEngine<'_>)).println();
                (&mut *(self as *mut PortableTexEngine<'_>)).giveerrhelp();
            } else {
                while self.state.helpptr as i32 > 0 as i32 {
                    self.state.helpptr = self.state.helpptr.wrapping_sub(1);
                    (&mut *(self as *mut PortableTexEngine<'_>))
                        .zprintnl(self.state.helpline[self.state.helpptr as usize]);
                }
            }
            (&mut *(self as *mut PortableTexEngine<'_>)).println();
            if self.state.interaction as i32 > 0 as i32 {
                self.state.selector = self.state.selector.wrapping_add(1);
            }
            (&mut *(self as *mut PortableTexEngine<'_>)).println();
            return Ok(());
        };
    }
    pub(crate) unsafe fn expand(&mut self) -> EngineFlow<()> {
        let mut mem: *mut memoryword = self.state.zmem.as_mut_ptr();
        let eqtb = self.state.zeqtb.as_mut_ptr();
        let mut t: halfword = 0;
        let mut b: boolean = 0;
        let mut p: halfword = 0;
        let mut q: halfword = 0;
        let mut r: halfword = 0;
        let mut j: integer = 0;
        let mut cvbackup: integer = 0;
        let mut cvlbackup: smallnumber = 0;
        let mut radixbackup: smallnumber = 0;
        let mut cobackup: smallnumber = 0;
        let mut backupbackup: halfword = 0;
        let mut savescannerstatus: smallnumber = 0;
        self.state.expanddepthcount += 1;
        if self.state.expanddepthcount >= self.state.expanddepth {
            match (&mut *(self as *mut PortableTexEngine<'_>))
                .zoverflow(65951 as i64 as strnumber, self.state.expanddepth)?
            {};
        }
        cvbackup = self.state.curval;
        cvlbackup = self.state.curvallevel as smallnumber;
        radixbackup = self.state.radix;
        cobackup = self.state.curorder as smallnumber;
        backupbackup = (*mem.offset((self.state.memtop as i32 - 13 as i32) as isize))
            .hh
            .v
            .RH;
        loop {
            if (self.state.curcmd as i32) < 114 as i32 {
                if (*eqtb.offset(7892300 as i64 as isize)).u.CINT > 1 as i32 {
                    (&mut *(self as *mut PortableTexEngine<'_>)).showcurcmdchr();
                }
                match self.state.curcmd as i32 {
                    113 => {
                        t = (self.state.curchr as i32 % 5 as i32) as halfword;
                        if self.state.curchr >= 5 as i32 {
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .scanregisternum()?;
                        } else {
                            self.state.curval = 0 as i32 as integer;
                        }
                        if self.state.curval == 0 as i32 {
                            self.state.curptr = self.state.curmark[t as usize];
                        } else {
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zfindsaelement(
                                    7 as i32 as smallnumber,
                                    self.state.curval,
                                    0 as i32,
                                )?;
                            if self.state.curptr as i64 != -(268435455 as i64) {
                                if t as i32 & 1 as i32 != 0 {
                                    self.state.curptr = (*mem
                                        .offset(
                                            (self.state.curptr as i32 + t as i32 / 2 as i32 + 1 as i32)
                                                as isize,
                                        ))
                                        .hh
                                        .v
                                        .RH;
                                } else {
                                    self.state.curptr = (*mem
                                        .offset(
                                            (self.state.curptr as i32 + t as i32 / 2 as i32 + 1 as i32)
                                                as isize,
                                        ))
                                        .hh
                                        .v
                                        .LH;
                                }
                            }
                        }
                        if self.state.curptr as i64 != -(268435455 as i64) {
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zbegintokenlist(
                                    self.state.curptr,
                                    15 as i32 as quarterword,
                                )?;
                        }
                        break;
                    }
                    105 => {
                        if self.state.curchr == 0 as i32 {
                            (&mut *(self as *mut PortableTexEngine<'_>)).gettoken()?;
                            t = self.state.curtok;
                            (&mut *(self as *mut PortableTexEngine<'_>)).gettoken()?;
                            if self.state.curcmd as i32 > 103 as i32 {
                                (&mut *(self as *mut PortableTexEngine<'_>)).expand()?;
                            } else {
                                (&mut *(self as *mut PortableTexEngine<'_>)).backinput()?;
                            }
                            self.state.curtok = t;
                            (&mut *(self as *mut PortableTexEngine<'_>)).backinput()?;
                            break;
                        } else {
                            (&mut *(self as *mut PortableTexEngine<'_>)).gettoken()?;
                            if self.state.curcmd as i32 == 108 as i32
                                && self.state.curchr != 16 as i32
                            {
                                self.state.curchr = (self.state.curchr as i32 + 32 as i32)
                                    as halfword;
                            } else {
                                self.state.interaction as i32 == 3 as i32;
                                if self.state.filelineerrorstylep != 0 {
                                    (&mut *(self as *mut PortableTexEngine<'_>))
                                        .printfileline();
                                } else {
                                    (&mut *(self as *mut PortableTexEngine<'_>))
                                        .zprintnl(65544 as i64 as strnumber);
                                }
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprint(66034 as i64 as integer);
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintesc(66164 as i64 as strnumber);
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprint(66940 as i64 as integer);
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintcmdchr(
                                        self.state.curcmd as quarterword,
                                        self.state.curchr,
                                    );
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintchar(39 as i32);
                                self.state.helpptr = 1 as eightbits;
                                self.state.helpline[0 as i32 as usize] = 65946 as i64
                                    as strnumber;
                                (&mut *(self as *mut PortableTexEngine<'_>)).backerror()?;
                                break;
                            }
                        }
                    }
                    106 => {
                        if self.state.curchr == 0 as i32 {
                            savescannerstatus = self.state.scannerstatus as smallnumber;
                            self.state.scannerstatus = 0 as eightbits;
                            (&mut *(self as *mut PortableTexEngine<'_>)).gettoken()?;
                            self.state.scannerstatus = savescannerstatus as eightbits;
                            t = self.state.curtok;
                            (&mut *(self as *mut PortableTexEngine<'_>)).backinput()?;
                            if t as i64 >= 33554431 as i64 && t as i64 != 34749089 as i64
                            {
                                p = (&mut *(self as *mut PortableTexEngine<'_>))
                                    .getavail()?;
                                (*mem.offset(p as isize)).hh.v.LH = 34749090 as i64
                                    as halfword;
                                (*mem.offset(p as isize)).hh.v.RH = self
                                    .state
                                    .curinput
                                    .locfield;
                                self.state.curinput.startfield = p;
                                self.state.curinput.locfield = p;
                            }
                            break;
                        } else {
                            savescannerstatus = self.state.scannerstatus as smallnumber;
                            self.state.scannerstatus = 0 as eightbits;
                            (&mut *(self as *mut PortableTexEngine<'_>)).gettoken()?;
                            self.state.scannerstatus = savescannerstatus as eightbits;
                            if (self.state.curcs as i64) < 1179650 as i64 {
                                self.state.curcs = (&mut *(self
                                    as *mut PortableTexEngine<'_>))
                                    .zprimlookup(
                                        (self.state.curcs as i64 - 1114113 as i64) as strnumber,
                                    )?;
                            } else {
                                self.state.curcs = (&mut *(self
                                    as *mut PortableTexEngine<'_>))
                                    .zprimlookup(
                                        (*self.state.hash.offset(self.state.curcs as isize)).v.RH,
                                    )?;
                            }
                            if !(self.state.curcs != 0 as i32) {
                                break;
                            }
                            t = (*eqtb
                                .offset(
                                    (1194662 as i64 + self.state.curcs as i64) as isize,
                                ))
                                .hh
                                .u
                                .B0 as halfword;
                            if t > 103 as i32 {
                                self.state.curcmd = t as eightbits;
                                self.state.curchr = (*eqtb
                                    .offset(
                                        (1194662 as i64 + self.state.curcs as i64) as isize,
                                    ))
                                    .hh
                                    .v
                                    .RH;
                                self.state.curtok = (self.state.curcmd as i64
                                    * 2097152 as i64 + self.state.curchr as i64) as halfword;
                                self.state.curcs = 0 as i32 as halfword;
                            } else {
                                (&mut *(self as *mut PortableTexEngine<'_>)).backinput()?;
                                p = (&mut *(self as *mut PortableTexEngine<'_>))
                                    .getavail()?;
                                (*mem.offset(p as isize)).hh.v.LH = 34749092 as i64
                                    as halfword;
                                (*mem.offset(p as isize)).hh.v.RH = self
                                    .state
                                    .curinput
                                    .locfield;
                                self.state.curinput.locfield = p;
                                self.state.curinput.startfield = p;
                                break;
                            }
                        }
                    }
                    110 => {
                        r = (&mut *(self as *mut PortableTexEngine<'_>)).getavail()?;
                        p = r;
                        b = self.state.isincsname;
                        self.state.isincsname = true_0 as boolean;
                        loop {
                            (&mut *(self as *mut PortableTexEngine<'_>)).getxtoken()?;
                            if self.state.curcs == 0 as i32 {
                                q = (&mut *(self as *mut PortableTexEngine<'_>))
                                    .getavail()?;
                                (*mem.offset(p as isize)).hh.v.RH = q;
                                (*mem.offset(q as isize)).hh.v.LH = self.state.curtok;
                                p = q;
                            }
                            if self.state.curcs != 0 as i32 {
                                break;
                            }
                        }
                        if self.state.curcmd as i32 != 67 as i32 {
                            self.state.interaction as i32 == 3 as i32;
                            if self.state.filelineerrorstylep != 0 {
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .printfileline();
                            } else {
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintnl(65544 as i64 as strnumber);
                            }
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zprint(65958 as i64 as integer);
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zprintesc(65818 as i64 as strnumber);
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zprint(65959 as i64 as integer);
                            self.state.helpptr = 2 as eightbits;
                            self.state.helpline[1 as i32 as usize] = 65960 as i64
                                as strnumber;
                            self.state.helpline[0 as i32 as usize] = 65961 as i64
                                as strnumber;
                            (&mut *(self as *mut PortableTexEngine<'_>)).backerror()?;
                        }
                        self.state.isincsname = b;
                        j = self.state.first;
                        p = (*mem.offset(r as isize)).hh.v.RH;
                        while p as i64 != -(268435455 as i64) {
                            if j >= self.state.maxbufstack {
                                self.state.maxbufstack = (j as i32 + 1 as i32) as integer;
                                if self.state.maxbufstack == self.state.bufsize {
                                    match (&mut *(self as *mut PortableTexEngine<'_>))
                                        .zoverflow(65538 as i64 as strnumber, self.state.bufsize)?
                                    {};
                                }
                            }
                            *self.state.buffer.offset(j as isize) = ((*mem
                                .offset(p as isize))
                                .hh
                                .v
                                .LH as i64 % 2097152 as i64) as UnicodeScalar;
                            j += 1;
                            p = (*mem.offset(p as isize)).hh.v.RH;
                        }
                        if j > self.state.first as i32 + 1 as i32
                            || *self.state.buffer.offset(self.state.first as isize)
                                as i64 > 65535 as i64
                        {
                            self.state.nonewcontrolsequence = false_0 as boolean;
                            self.state.curcs = (&mut *(self
                                as *mut PortableTexEngine<'_>))
                                .zidlookup(self.state.first, j - self.state.first)?;
                            self.state.nonewcontrolsequence = true_0 as boolean;
                        } else if j == self.state.first {
                            self.state.curcs = 1179649 as i64 as halfword;
                        } else {
                            self.state.curcs = (1114113 as i64
                                + *self.state.buffer.offset(self.state.first as isize)
                                    as i64) as halfword;
                        }
                        (&mut *(self as *mut PortableTexEngine<'_>)).zflushlist(r);
                        if (*eqtb.offset(self.state.curcs as isize)).hh.u.B0 as i32
                            == 104 as i32
                        {
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zeqdefine(
                                    self.state.curcs,
                                    0 as i32 as quarterword,
                                    1114112 as i64 as halfword,
                                )?;
                        }
                        self.state.curtok = (self.state.curcs as i64 + 33554431 as i64)
                            as halfword;
                        (&mut *(self as *mut PortableTexEngine<'_>)).backinput()?;
                        break;
                    }
                    111 => {
                        (&mut *(self as *mut PortableTexEngine<'_>)).convtoks()?;
                        break;
                    }
                    112 => {
                        (&mut *(self as *mut PortableTexEngine<'_>)).insthetoks()?;
                        break;
                    }
                    108 => {
                        (&mut *(self as *mut PortableTexEngine<'_>)).conditional()?;
                        break;
                    }
                    109 => {
                        if (*eqtb.offset(7892327 as i64 as isize)).u.CINT > 0 as i32 {
                            if (*eqtb.offset(7892300 as i64 as isize)).u.CINT <= 1 as i32
                            {
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .showcurcmdchr();
                            }
                        }
                        if self.state.curchr > self.state.iflimit as i32 {
                            if self.state.iflimit as i32 == 1 as i32 {
                                (&mut *(self as *mut PortableTexEngine<'_>)).insertrelax()?;
                            } else {
                                self.state.interaction as i32 == 3 as i32;
                                if self.state.filelineerrorstylep != 0 {
                                    (&mut *(self as *mut PortableTexEngine<'_>))
                                        .printfileline();
                                } else {
                                    (&mut *(self as *mut PortableTexEngine<'_>))
                                        .zprintnl(65544 as i64 as strnumber);
                                }
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprint(66168 as i64 as integer);
                                (&mut *(self as *mut PortableTexEngine<'_>))
                                    .zprintcmdchr(109 as i32 as quarterword, self.state.curchr);
                                self.state.helpptr = 1 as eightbits;
                                self.state.helpline[0 as i32 as usize] = 66169 as i64
                                    as strnumber;
                                (&mut *(self as *mut PortableTexEngine<'_>)).error()?;
                            }
                        } else {
                            while self.state.curchr != 2 as i32 {
                                (&mut *(self as *mut PortableTexEngine<'_>)).passtext()?;
                            }
                            if *self.state.ifstack.offset(self.state.inopen as isize)
                                == self.state.condptr
                            {
                                (&mut *(self as *mut PortableTexEngine<'_>)).ifwarning();
                            }
                            p = self.state.condptr;
                            self.state.ifline = (*mem
                                .offset((p as i32 + 1 as i32) as isize))
                                .u
                                .CINT;
                            self.state.curif = (*mem.offset(p as isize)).hh.u.B1
                                as smallnumber;
                            self.state.iflimit = (*mem.offset(p as isize)).hh.u.B0
                                as eightbits;
                            self.state.condptr = (*mem.offset(p as isize)).hh.v.RH;
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zfreenode(p, 2 as i32);
                        }
                        break;
                    }
                    107 => {
                        if self.state.curchr == 1 as i32 {
                            self.state.forceeof = true_0 as boolean;
                        } else if self.state.curchr == 2 as i32 {
                            (&mut *(self as *mut PortableTexEngine<'_>)).pseudostart()?;
                        } else if self.state.nameinprogress != 0 {
                            (&mut *(self as *mut PortableTexEngine<'_>)).insertrelax()?;
                        } else {
                            (&mut *(self as *mut PortableTexEngine<'_>)).startinput()?;
                        }
                        break;
                    }
                    _ => {
                        self.state.interaction as i32 == 3 as i32;
                        if self.state.filelineerrorstylep != 0 {
                            (&mut *(self as *mut PortableTexEngine<'_>)).printfileline();
                        } else {
                            (&mut *(self as *mut PortableTexEngine<'_>))
                                .zprintnl(65544 as i64 as strnumber);
                        }
                        (&mut *(self as *mut PortableTexEngine<'_>))
                            .zprint(65952 as i64 as integer);
                        self.state.helpptr = 5 as eightbits;
                        self.state.helpline[4 as i32 as usize] = 65953 as i64
                            as strnumber;
                        self.state.helpline[3 as i32 as usize] = 65954 as i64
                            as strnumber;
                        self.state.helpline[2 as i32 as usize] = 65955 as i64
                            as strnumber;
                        self.state.helpline[1 as i32 as usize] = 65956 as i64
                            as strnumber;
                        self.state.helpline[0 as i32 as usize] = 65957 as i64
                            as strnumber;
                        (&mut *(self as *mut PortableTexEngine<'_>)).error()?;
                        break;
                    }
                }
            } else {
                if (self.state.curcmd as i32) < 118 as i32 {
                    (&mut *(self as *mut PortableTexEngine<'_>)).macrocall()?;
                } else {
                    self.state.curtok = 34749087 as i64 as halfword;
                    (&mut *(self as *mut PortableTexEngine<'_>)).backinput()?;
                }
                break;
            }
        }
        self.state.curval = cvbackup;
        self.state.curvallevel = cvlbackup as eightbits;
        self.state.radix = radixbackup;
        self.state.curorder = cobackup as glueord;
        (*mem.offset((self.state.memtop as i32 - 13 as i32) as isize)).hh.v.RH = backupbackup;
        self.state.expanddepthcount -= 1;
        Ok(())
    }
    pub(crate) unsafe fn extrarightbrace(&mut self) -> EngineFlow<()> {
        self.state.interaction as i32 == 3 as i32;
        if self.state.filelineerrorstylep != 0 {
            (&mut *(self as *mut PortableTexEngine<'_>)).printfileline();
        } else {
            (&mut *(self as *mut PortableTexEngine<'_>))
                .zprintnl(65544 as i64 as strnumber);
        }
        (&mut *(self as *mut PortableTexEngine<'_>)).zprint(66481 as i64 as integer);
        match self.state.curgroup as i32 {
            14 => {
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprintesc(65831 as i64 as strnumber);
            }
            15 => {
                (&mut *(self as *mut PortableTexEngine<'_>)).zprintchar(36 as i32);
            }
            16 => {
                (&mut *(self as *mut PortableTexEngine<'_>))
                    .zprintesc(66287 as i64 as strnumber);
            }
            _ => {}
        }
        self.state.helpptr = 5 as eightbits;
        self.state.helpline[4 as i32 as usize] = 66482 as i64 as strnumber;
        self.state.helpline[3 as i32 as usize] = 66483 as i64 as strnumber;
        self.state.helpline[2 as i32 as usize] = 66484 as i64 as strnumber;
        self.state.helpline[1 as i32 as usize] = 66485 as i64 as strnumber;
        self.state.helpline[0 as i32 as usize] = 66486 as i64 as strnumber;
        (&mut *(self as *mut PortableTexEngine<'_>)).error()?;
        self.state.alignstate += 1;
        Ok(())
    }
}