-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmf.h
1786 lines (1654 loc) · 67.7 KB
/
mf.h
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
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define EXTERN
#define STAT
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#ifdef _WIN32
#pragma warning(disable:4459)
#pragma warning(disable:4047)
#pragma warning(disable:4024)
#pragma warning(disable:4700)
#endif
/* < emulate pascal's internal functions */
#define chr(x) i
#define odd(x) ((x) % 2)
#define ho(a) a
#define qo(a) a
#define qi(a) a
/* > */
typedef int32_t integer;
typedef uint32_t boolean;
const int32_t debug, stat, inimf;
const char * dump_name;
/* 11 */
#define mem_max 30000 /*{greatest index in \MF's internal |mem| array;
must be strictly less than |max_halfword|;
must be equal to |mem_top| in \.{INIMF}, otherwise |>=mem_top|}*/
#define max_internal 100 //{maximum number of internal quantities}
#define buf_size 500 /*{maximum number of characters simultaneously present in
current lines of open files; must not exceed |max_halfword|}*/
#define error_line 72 //{width of context lines on terminal error messages}
#define half_error_line 42 /*{width of first lines of contexts in terminal
error messages; should be between 30 and |error_line-15|}*/
#define max_print_line 79 //{width of longest text lines output; should be at least 60}
#define screen_width 768 //{number of pixels in each row of screen display}
#define screen_depth 1024 //{number of pixels in each column of screen display}
#define stack_size 30 //{maximum number of simultaneous input sources}
#define max_strings 2000 //{maximum number of strings; must not exceed |max_halfword|}
#define string_vacancies 8000 /*{the minimum number of characters that should be
available for the user's identifier names and strings,
after \MF's own error messages are stored}*/
#define pool_size 32000 /*{maximum number of characters in strings, including all
error messages and help texts, and the names of all identifiers;
must exceed |string_vacancies| by the total
length of \MF's own strings, which is currently about 22000}*/
#define move_size 5000 //{space for storing moves in a single octant}
#define max_wiggle 300 //{number of autorounded points per cycle}
#define gf_buf_size 800 //{size of the output buffer, must be a multiple of 8}
#define file_name_size 40 //{file names shouldn't be longer than this}
const uint8_t* pool_name = "MFbases:MF.POOL ";
//{string of length |file_name_size|; tells where the string pool appears}
#define path_size 300 //{maximum number of knots between breakpoints of a path}
#define bistack_size 785 /*{size of stack for bisection algorithms;
should probably be left at this value}*/
#define header_size 100 //{maximum number of \.{TFM} header words, times~4}
#define lig_table_size 5000 /*{maximum number of ligature/kern steps, must be
at least 255 and at most 32510}*/
#define max_kerns 500 //{maximum number of distinct kern amounts}
#define max_font_dimen 50 //{maximum number of \&{fontdimen} parameters}
typedef uint8_t ASCII_code;
typedef uint8_t eight_bits;
typedef FILE * alpha_file;
typedef FILE * byte_file;
typedef integer pool_pointer;
typedef integer str_number;
typedef uint8_t packed_ASCII_code;
typedef integer scaled;
typedef uint8_t small_number;
typedef integer fraction;
typedef integer angle;
typedef uint8_t quarterword;
typedef integer halfword;
typedef uint8_t twochoices;
typedef uint8_t threechoices;
typedef struct {
halfword rh;
union {
halfword lh;
struct {
quarterword b0, b1;
};
};
} two_halves;
typedef struct {
quarterword b0, b1, b2, b3;
} four_quarters;
typedef union {
int32_t cint;
two_halves hh;
four_quarters qqqq;
} memory_word;
typedef FILE * word_file;
typedef uint8_t command_code;
typedef short screen_row;
typedef short screen_col;
typedef screen_col * trans_spec;
typedef uint8_t pixel_color;
typedef uint8_t window_number;
typedef struct {
quarterword index_field;
halfword start_field, loc_field, limit_field, name_field;
} in_state_record;
typedef integer gf_index;
EXTERN integer bad;
#ifdef INIMF
EXTERN boolean iniversion;
EXTERN boolean dumpoption;
EXTERN boolean dumpline;
#endif
EXTERN integer mainmemory;
EXTERN integer mem_top;
//EXTERN integer mem_max;
//EXTERN integer buf_size;
//EXTERN integer error_line;
//EXTERN integer half_error_line;
//EXTERN integer max_print_line;
EXTERN integer screenwidth;
EXTERN integer screendepth;
//EXTERN integer gf_buf_size;
EXTERN ASCII_code xord[256];
EXTERN ASCII_code xchr[256];
EXTERN ASCII_code * name_of_file;
EXTERN integer name_length;
EXTERN ASCII_code * buffer;
EXTERN integer first;
EXTERN integer last;
EXTERN integer max_buf_stack;
EXTERN packed_ASCII_code str_pool[pool_size + 1];
EXTERN pool_pointer str_start[max_strings + 1];
EXTERN pool_pointer pool_ptr;
EXTERN str_number str_ptr;
EXTERN pool_pointer init_pool_ptr;
EXTERN str_number init_str_ptr;
EXTERN pool_pointer max_pool_ptr;
EXTERN str_number max_str_ptr;
EXTERN uint8_t str_ref[max_strings + 1];
#ifdef INIMF
EXTERN alpha_file pool_file;
#endif
EXTERN alpha_file log_file;
EXTERN uint8_t selector;
EXTERN uint8_t dig[23];
EXTERN integer tally;
EXTERN integer term_offset;
EXTERN integer file_offset;
EXTERN ASCII_code trick_buf[256];
EXTERN integer trick_count;
EXTERN integer first_count;
EXTERN uint8_t interaction;
EXTERN uint8_t interactionoption;
EXTERN boolean deletions_allowed;
EXTERN uint8_t history;
EXTERN int8_t error_count;
EXTERN char * help_line[6];
EXTERN uint8_t help_ptr;
EXTERN boolean use_err_help;
EXTERN str_number err_help;
EXTERN integer interrupt;
EXTERN boolean OK_to_interrupt;
EXTERN boolean arith_error;
EXTERN integer two_to_the[31];
EXTERN integer spec_log[29];
EXTERN angle spec_atan[27];
EXTERN fraction n_sin, n_cos;
EXTERN fraction randoms[55];
EXTERN uint8_t j_random;
EXTERN memory_word * mem;
EXTERN halfword lo_mem_max;
EXTERN halfword hi_mem_min;
EXTERN integer var_used, dyn_used;
EXTERN halfword avail;
EXTERN halfword mem_end;
EXTERN halfword rover;
#ifdef DEBUG
EXTERN boolean freearr[2];
EXTERN boolean was_free[2];
EXTERN halfword was_mem_end, was_lo_max, was_hi_min;
EXTERN boolean panicking;
#endif
EXTERN scaled internal[max_internal + 1];
EXTERN str_number int_name[max_internal + 1];
EXTERN integer int_ptr;
EXTERN uint8_t old_setting;
EXTERN uint8_t char_class[256];
EXTERN halfword hash_used;
EXTERN integer st_count;
EXTERN two_halves hash[9770];
EXTERN two_halves eqtb[9770];
EXTERN halfword g_pointer;
EXTERN small_number
#define big_node_size (zzzaa -13)
zzzaa[2];
EXTERN halfword save_ptr;
EXTERN halfword path_tail;
EXTERN scaled delta_x[path_size + 1], delta_y[path_size + 1], delta[path_size + 1];
EXTERN angle psi[path_size + 1];
EXTERN angle theta[path_size + 1];
EXTERN fraction uu[path_size + 1];
EXTERN angle vv[path_size + 1];
EXTERN fraction ww[path_size + 1];
EXTERN fraction st, ct, sf, cf;
EXTERN integer move[move_size + 1];
EXTERN integer move_ptr;
EXTERN integer bisect_stack[bistack_size + 1];
EXTERN integer bisect_ptr;
EXTERN halfword cur_edges;
EXTERN integer cur_wt;
EXTERN integer trace_x;
EXTERN integer trace_y;
EXTERN integer trace_yy;
EXTERN uint8_t octant;
EXTERN scaled cur_x, cur_y;
EXTERN str_number octant_dir[9];
EXTERN halfword cur_spec;
EXTERN integer turning_number;
EXTERN halfword cur_pen;
EXTERN uint8_t cur_path_type;
EXTERN scaled max_allowed;
EXTERN scaled before[max_wiggle + 1], after[max_wiggle + 1];
EXTERN halfword node_to_round[max_wiggle + 1];
EXTERN integer cur_rounding_ptr;
EXTERN integer max_rounding_ptr;
EXTERN scaled cur_gran;
EXTERN uint8_t octant_number[9];
EXTERN uint8_t octant_code[9];
EXTERN boolean rev_turns;
EXTERN uint8_t y_corr[9], xy_corr[9], z_corr[9];
EXTERN int8_t x_corr[9];
EXTERN integer m0, n0, m1, n1;
EXTERN uint8_t d0, d1;
EXTERN integer env_move[move_size + 1];
EXTERN uint8_t tol_step;
EXTERN integer cur_t, cur_tt;
EXTERN integer time_to_go;
EXTERN integer max_t;
EXTERN integer delx, dely;
EXTERN integer tol;
EXTERN integer uv, xy;
EXTERN integer three_l;
EXTERN integer appr_t, appr_tt;
EXTERN pixel_color ** screen_pixel;
EXTERN boolean screen_started;
EXTERN boolean screen_OK;
EXTERN boolean window_open[16];
EXTERN screen_col left_col[16];
EXTERN screen_col right_col[16];
EXTERN screen_row top_row[16];
EXTERN screen_row bot_row[16];
EXTERN integer m_window[16];
EXTERN integer n_window[16];
EXTERN integer window_time[16];
EXTERN trans_spec row_transition;
EXTERN integer serial_no;
EXTERN boolean fix_needed;
EXTERN boolean watch_coefs;
EXTERN halfword dep_final;
EXTERN eight_bits cur_cmd;
EXTERN integer cur_mod;
EXTERN halfword cur_sym;
EXTERN in_state_record input_stack[stack_size + 1];
EXTERN integer input_ptr;
EXTERN integer max_in_stack;
EXTERN in_state_record cur_input;
EXTERN uint8_t in_open;
EXTERN uint8_t open_parens;
EXTERN alpha_file input_file[16];
EXTERN integer line;
EXTERN integer line_stack[16];
EXTERN halfword param_stack[151];
EXTERN uint8_t param_ptr;
EXTERN integer max_param_stack;
EXTERN integer file_ptr;
EXTERN uint8_t scanner_status;
EXTERN integer warning_info;
EXTERN boolean force_eof;
EXTERN short bg_loc, eg_loc;
EXTERN halfword cond_ptr;
EXTERN uint8_t if_limit;
EXTERN small_number cur_if;
EXTERN integer if_line;
EXTERN halfword loop_ptr;
EXTERN str_number cur_name;
EXTERN str_number cur_area;
EXTERN str_number cur_ext;
EXTERN pool_pointer area_delimiter;
EXTERN pool_pointer ext_delimiter;
EXTERN integer base_default_length;
EXTERN char * MF_base_default;
EXTERN str_number job_name;
EXTERN boolean log_opened;
EXTERN str_number log_name;
EXTERN str_number gf_ext;
EXTERN byte_file gf_file;
EXTERN str_number output_file_name;
EXTERN small_number cur_type;
EXTERN integer cur_exp;
EXTERN integer
#define max_c (zzzab -17)
zzzab[2];
EXTERN halfword
#define max_ptr (zzzac -17)
zzzac[2];
EXTERN halfword
#define max_link (zzzad -17)
zzzad[2];
EXTERN uint8_t var_flag;
EXTERN scaled txx, txy, tyx, tyy, tx, ty;
EXTERN halfword start_sym;
EXTERN boolean long_help_seen;
EXTERN byte_file tfm_file;
EXTERN str_number metric_file_name;
EXTERN eight_bits bc, ec;
EXTERN scaled tfm_width[256];
EXTERN scaled tfm_height[256];
EXTERN scaled tfm_depth[256];
EXTERN scaled tfm_ital_corr[256];
EXTERN boolean char_exists[256];
EXTERN uint8_t char_tag[256];
EXTERN integer char_remainder[256];
EXTERN short header_byte[header_size + 1];
EXTERN four_quarters lig_kern[lig_table_size + 1];
EXTERN short nl;
EXTERN scaled kern[max_kerns + 1];
EXTERN integer nk;
EXTERN four_quarters exten[256];
EXTERN short ne;
EXTERN scaled param[max_font_dimen + 1];
EXTERN integer np;
EXTERN short nw, nh, nd, ni;
EXTERN integer skip_table[256];
EXTERN boolean lk_started;
EXTERN integer bchar;
EXTERN integer bch_label;
EXTERN integer ll, lll;
EXTERN integer label_loc[257];
EXTERN eight_bits label_char[257];
EXTERN short label_ptr;
EXTERN scaled perturbation;
EXTERN integer excess;
EXTERN halfword dimen_head[5];
EXTERN scaled max_tfm_dimen;
EXTERN integer tfm_changed;
EXTERN integer gf_min_m, gf_max_m, gf_min_n, gf_max_n;
EXTERN integer gf_prev_ptr;
EXTERN integer total_chars;
EXTERN integer char_ptr[256];
EXTERN integer gf_dx[256], gf_dy[256];
EXTERN eight_bits * gf_buf;
EXTERN gf_index half_buf;
EXTERN gf_index gf_limit;
EXTERN gf_index gf_ptr;
EXTERN integer gf_offset;
EXTERN integer boc_c, boc_p;
EXTERN str_number base_ident;
EXTERN word_file base_file;
EXTERN integer ready_already;
/* M A C R O S */
#define banner "This is METAFONT, Version 2.7182818"
/* 12 */
#define mem_min 0 /*{smallest index in the |mem| array, must not be less
than |min_halfword|}*/
#define mem_top 30000 /*{largest index in the |mem| array dumped by \.{INIMF};
must be substantially larger than |mem_min|
and not greater than |mem_max|}*/
#define hash_size 2100 /*{maximum number of symbolic tokens,
must be less than |max_halfword-3*param_size|}*/
#define hash_prime 1777 //{a prime number equal to about 85\pct! of |hash_size|}
#define max_in_open 6 /*{maximum number of input files and error insertions that
can be going on simultaneously}*/
#define param_size 150 //{maximum number of simultaneous macro parameters}
/* 16 */
#define incr(a) a=a+1 //{increase a variable by unity}
#define decr(a) a=a-1 //{decrease a variable by unity}
#define negate(a) a=-a //{change the sign of a variable}
#define _double(a) a=a+a //{multiply a variable by two}
#define do_nothing() //{empty statement}
/* 19 */
#define text_char char //{the data type of characters in text files}
#define first_text_char 0 //{ordinal number of the smallest element of |text_char|}
#define last_text_char 255 //{ordinal number of the largest element of |text_char|}
/* 26 */
#define reset_OK(a)
#define rewrite_OK(a)
/* 32 */
#define t_open_in()
#define t_open_out()
/* 33 */
#define update_terminal()
#define clear_terminal() fflush(stdout)
#define wake_up_terminal()
/* 35 */
#define loc cur_input.loc_field //{location of first unread character in |buffer|}
/* 37 */
#define si(a) a //{convert from |ASCII_code| to |packed_ASCII_code|}
#define so(a) a //{convert from |packed_ASCII_code| to |ASCII_code|}
/* 39 */
#define length(a) (str_start[a+1]-str_start[a]) /*{the number of characters
in string number \#}*/
/* 40 */
#define cur_length (pool_ptr - str_start[str_ptr])
/* 41 */
#define append_char(a) \
do { \
str_pool[pool_ptr] = si(a); \
incr(pool_ptr); \
} while (0)
#define str_room(a) \
do { \
if (pool_ptr + a > max_pool_ptr) \
{ \
if (pool_ptr + a > pool_size) \
overflow("pool size", pool_size - init_pool_ptr); \
max_pool_ptr = pool_ptr + a; \
} \
} while (0)
/* 42 */
#define max_str_ref 127 //{``infinite'' number of references}
#define add_str_ref(a) \
do { \
if (str_ref[a] < max_str_ref) \
incr(str_ref[a]); \
} while (0)
/* 43 */
#define delete_str_ref(a) \
do { \
if (str_ref[a] < max_str_ref) \
{ \
if (str_ref[a] > 1) \
decr(str_ref[a]); \
else \
flush_string(a); \
} \
} while (0)
/* 48 */
#define app_lc_hex(a) \
do { \
l = a; \
if (l < 10) \
append_char(l + '0'); \
else \
append_char(l - 10 + 'a'); \
} while (0)
/* 54 */
#define no_print 0 //{|selector| setting that makes data disappear}
#define term_only 1 //{printing is destined for the terminal only}
#define log_only 2 //{printing is destined for the transcript file only}
#define term_and_log 3 //{normal |selector| setting}
#define pseudo 4 //{special |selector| setting for |show_context|}
#define new_string 5 //{printing is deflected to the string pool}
#define max_selector 5 //{highest selector setting}
/* 66 */
#define prompt_input(a) \
do { \
wake_up_terminal(); \
r_print(a); \
term_input(); \
} while (0)
/* 68 */
#define batch_mode 0 //{omits all stops and omits terminal output}
#define nonstop_mode 1 //{omits all stops}
#define scroll_mode 2 //{omits error stops}
#define error_stop_mode 3 //{stops at every opportunity to interact}
#define print_err(a) \
do { \
if (interaction == error_stop_mode) \
wake_up_terminal(); \
r_print_nl("! "); \
r_print(a); \
} while (0)
/* 71 */
#define spotless 0 //{|history| value when nothing has been amiss yet}
#define warning_issued 1 //{|history| value when |begin_diagnostic| has been called}
#define error_message_issued 2 //{|history| value when |error| has been called}
#define fatal_error_stop 3 //{|history| value when termination was premature}
/* 74 */
static inline void mf_help (unsigned int n, ...)
{
int i;
va_list help_arg;
if (n > 6)
n = 6;
help_ptr = n;
va_start(help_arg, n);
for (i = n - 1; i > -1; --i)
help_line[i] = va_arg(help_arg, char *);
va_end(help_arg);
}
#define help0() mf_help(0)
#define help1(...) mf_help(1, __VA_ARGS__)
#define help2(...) mf_help(2, __VA_ARGS__)
#define help3(...) mf_help(3, __VA_ARGS__)
#define help4(...) mf_help(4, __VA_ARGS__)
#define help5(...) mf_help(5, __VA_ARGS__)
#define help6(...) mf_help(6, __VA_ARGS__)
/* 88 */
#define succumb() \
do { \
if (interaction == error_stop_mode) \
interaction = scroll_mode; \
if (log_opened) \
error(); \
history = fatal_error_stop; \
jump_out(); \
} while (0)
/* 91 */
#define check_interrupt() \
do { \
if (interrupt != 0) \
pause_for_instructions(); \
} while (0)
/* 95 */
#define el_gordo 017777777777 //{$2^{31}-1$, the largest value that \MF\ likes}
/* 96 */
#define half(a) (a)/2
/* 99 */
#define check_arith() \
do { \
if (arith_error) \
clear_arith(); \
} while (0)
/* 101 */
#define quarter_unit 040000 //{$2^{14}$, represents 0.250000}
#define half_unit 0100000 //{$2^{15}$, represents 0.50000}
#define three_quarter_unit 0140000 //{$3\cdot2^{14}$, represents 0.75000}
#define unity 0200000 //{$2^{16}$, represents 1.00000}
#define two 0400000 //{$2^{17}$, represents 2.00000}
#define three 0600000 //{$2^{17}+2^{16}$, represents 3.00000}
/* 105 */
#define fraction_half 01000000000 //{$2^{27}$, represents 0.50000000}
#define fraction_one 02000000000 //{$2^{28}$, represents 1.00000000}
#define fraction_two 04000000000 //{$2^{29}$, represents 2.00000000}
#define fraction_three 06000000000 //{$3\cdot2^{28}$, represents 3.00000000}
#define fraction_four 010000000000 //{$2^{30}$, represents 4.00000000}
/* 106 */
#define forty_five_deg 0264000000 //{$45\cdot2^{20}$, represents $45^\circ$}
#define ninety_deg 0550000000 //{$90\cdot2^{20}$, represents $90^\circ$}
#define one_eighty_deg 01320000000 //{$180\cdot2^{20}$, represents $180^\circ$}
#define three_sixty_deg 02640000000 //{$360\cdot2^{20}$, represents $360^\circ$}
/* 117 */
#define return_sign(a) do { \
Result = a; \
goto l_exit; \
} while (0)
/* 139 */
#define negate_x 1
#define negate_y 2
#define switch_x_and_y 4
#define first_octant 1
#define second_octant (first_octant+switch_x_and_y)
#define third_octant (first_octant+switch_x_and_y+negate_x)
#define fourth_octant (first_octant+negate_x)
#define fifth_octant (first_octant+negate_x+negate_y)
#define sixth_octant (first_octant+switch_x_and_y+negate_x+negate_y)
#define seventh_octant (first_octant+switch_x_and_y+negate_y)
#define eighth_octant (first_octant+negate_y)
/* 149 */
#define next_random() \
do { \
if (j_random == 0)\
new_randoms(); \
else \
decr(j_random); \
} while (0)
/* 153 */
#define min_quarterword 0
#define max_quarterword 255
#define min_halfword 0
#define max_halfword 65536
/* 156 */
#define sc cint
/* 158 */
#define pointer halfword //{a flag or a location in |mem| or |eqtb|}
#define null mem_min //{the null pointer}
/* 161 */
#define link(a) mem[a].hh.rh //{the |link| field of a memory word}
#define info(a) mem[a].hh.lh //{the |info| field of a memory word}
/* 164 */
#define free_avail(a) \
do { \
link(a) = avail; \
avail = a; \
} while(0)
/* 165 */
#define fast_get_avail(a) \
do { \
a = avail; \
if (a == null) \
a = get_avail(); \
else \
{ \
avail = link(a); \
link(a) = null; \
if (stat) \
incr(dyn_used); \
} \
} while (0)
/* 166 */
#define empty_flag max_halfword //{the |link| of an empty variable-size node}
#define is_empty(a) (link(a) == empty_flag) //{tests for empty node}
#define node_size info //{the size field in empty variable-size nodes}
#define llink(a) info(a+1) //{left link in doubly-linked list of empty nodes}
#define rlink(a) link(a+1) //{right link in doubly-linked list of empty nodes}
/* 175 */
#define null_coords mem_min //{specification for pen offsets of $(0,0)$}
#define null_pen (null_coords+3) //{we will define |coord_node_size=3|}
#define dep_head (null_pen+10) //{and |pen_node_size=10|}
#define zero_val (dep_head+2) //{two words for a permanently zero value}
#define temp_val (zero_val+2) //{two words for a temporary value node}
#define end_attr (temp_val) //{we use |end_attr+2| only}
#define inf_val (end_attr+2) //{and |inf_val+1| only}
#define bad_vardef (inf_val+2) //{two words for \&{vardef} error recovery}
#define lo_mem_stat_max (bad_vardef+1) /*{largest statically
allocated word in the variable-size |mem|}*/
#define sentinel mem_top //{end of sorted lists}
#define temp_head (mem_top-1) //{head of a temporary list of some kind}
#define hold_head (mem_top-2) //{head of a temporary list of another kind}
#define hi_mem_stat_min (mem_top-2) /*{smallest statically allocated word in
the one-word |mem|}*/
/* 186 */
#define if_test 1 //{conditional text (\&{if})}
#define fi_or_else 2 //{delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
#define input 3 //{input a source file (\&{input}, \&{endinput})}
#define iteration 4 //{iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
#define repeat_loop 5 //{special command substituted for \&{endfor}}
#define exit_test 6 //{premature exit from a loop (\&{exitif})}
#define relax 7 //{do nothing (\.{\char`\\})}
#define scan_tokens 8 //{put a string into the input buffer}
#define expand_after 9 //{look ahead one token}
#define defined_macro 10 //{a macro defined by the user}
#define min_command (defined_macro+1)
#define display_command 11 //{online graphic output (\&{display})}
#define save_command 12 //{save a list of tokens (\&{save})}
#define interim_command 13 //{save an internal quantity (\&{interim})}
#define let_command 14 //{redefine a symbolic token (\&{let})}
#define new_internal 15 //{define a new internal quantity (\&{newinternal})}
#define macro_def 16 //{define a macro (\&{def}, \&{vardef}, etc.)}
#define ship_out_command 17 //{output a character (\&{shipout})}
#define add_to_command 18 //{add to edges (\&{addto})}
#define cull_command 19 //{cull and normalize edges (\&{cull})}
#define tfm_command 20 //{command for font metric info (\&{ligtable}, etc.)}
#define protection_command 21 //{set protection flag (\&{outer}, \&{inner})}
#define show_command 22 //{diagnostic output (\&{show}, \&{showvariable}, etc.)}
#define mode_command 23 //{set interaction level (\&{batchmode}, etc.)}
#define random_seed 24 //{initialize random number generator (\&{randomseed})}
#define message_command 25 //{communicate to user (\&{message}, \&{errmessage})}
#define every_job_command 26 //{designate a starting token (\&{everyjob})}
#define delimiters 27 //{define a pair of delimiters (\&{delimiters})}
#define open_window 28 //{define a window on the screen (\&{openwindow})}
#define special_command 29 //{output special info (\&{special}, \&{numspecial})}
#define type_name 30 //{declare a type (\&{numeric}, \&{pair}, etc.)}
#define max_statement_command type_name
#define min_primary_command type_name
#define left_delimiter 31 //{the left delimiter of a matching pair}
#define begin_group 32 //{beginning of a group (\&{begingroup})}
#define nullary 33 //{an operator without arguments (e.g., \&{normaldeviate})}
#define unary 34 //{an operator with one argument (e.g., \&{sqrt})}
#define str_op 35 //{convert a suffix to a string (\&{str})}
#define cycle 36 //{close a cyclic path (\&{cycle})}
#define primary_binary 37 //{binary operation taking `\&{of}' (e.g., \&{point})}
#define capsule_token 38 //{a value that has been put into a token list}
#define string_token 39 //{a string constant (e.g., |"hello"|)}
#define internal_quantity 40 //{internal numeric parameter (e.g., \&{pausing})}
#define min_suffix_token internal_quantity
#define tag_token 41 //{a symbolic token without a primitive meaning}
#define numeric_token 42 //{a numeric constant (e.g., \.{3.14159})}
#define max_suffix_token numeric_token
#define plus_or_minus 43 //{either `\.+' or `\.-'}
#define max_primary_command plus_or_minus //{should also be |numeric_token+1|}
#define min_tertiary_command plus_or_minus
#define tertiary_secondary_macro 44 //{a macro defined by \&{secondarydef}}
#define tertiary_binary 45 //{an operator at the tertiary level (e.g., `\.{++}')}
#define max_tertiary_command tertiary_binary
#define left_brace 46 //{the operator `\.{\char`\{}'}
#define min_expression_command left_brace
#define path_join 47 //{the operator `\.{..}'}
#define ampersand 48 //{the operator `\.\&'}
#define expression_tertiary_macro 49 //{a macro defined by \&{tertiarydef}}
#define expression_binary 50 //{an operator at the expression level (e.g., `\.<')}
#define equals 51 //{the operator `\. '}
#define max_expression_command equals
#define and_command 52 //{the operator `\&{and}'}
#define min_secondary_command and_command
#define secondary_primary_macro 53 //{a macro defined by \&{primarydef}}
#define slash 54 //{the operator `\./'}
#define secondary_binary 55 //{an operator at the binary level (e.g., \&{shifted})}
#define max_secondary_command secondary_binary
#define param_type 56 //{type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
#define controls 57 //{specify control points explicitly (\&{controls})}
#define tension 58 //{specify tension between knots (\&{tension})}
#define at_least 59 //{bounded tension value (\&{atleast})}
#define curl_command 60 //{specify curl at an end knot (\&{curl})}
#define macro_special 61 //{special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
#define right_delimiter 62 //{the right delimiter of a matching pair}
#define left_bracket 63 //{the operator `\.['}
#define right_bracket 64 //{the operator `\.]'}
#define right_brace 65 //{the operator `\.{\char`\}}'}
#define with_option 66 //{option for filling (\&{withpen}, \&{withweight})}
#define cull_op 67 //{the operator `\&{keeping}' or `\&{dropping}'}
#define thing_to_add 68 //{variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
#define of_token 69 //{the operator `\&{of}'}
#define from_token 70 //{the operator `\&{from}'}
#define to_token 71 //{the operator `\&{to}'}
#define at_token 72 //{the operator `\&{at}'}
#define in_window 73 //{the operator `\&{inwindow}'}
#define step_token 74 //{the operator `\&{step}'}
#define until_token 75 //{the operator `\&{until}'}
#define lig_kern_token 76 //{the operators `\&{kern}' and `\.{ :}' and `\.{ :\char'174}', etc.}
#define assignment 77 //{the operator `\.{: }'}
#define skip_to 78 //{the operation `\&{skipto}'}
#define bchar_label 79 //{the operator `\.{\char'174\char'174:}'}
#define double_colon 80 //{the operator `\.{::}'}
#define colon 81 //{the operator `\.:'}
#define comma 82 //{the operator `\.,', must be |colon+1|}
#define end_of_statement (cur_cmd>comma)
#define semicolon 83 //{the operator `\.;', must be |comma+1|}
#define end_group 84 //{end a group (\&{endgroup}), must be |semicolon+1|}
#define stop 85 //{end a job (\&{end}, \&{dump}), must be |end_group+1|}
#define max_command_code stop
#define outer_tag (max_command_code+1) //{protection code added to command code}
/* 187 */
#define undefined 0 //{no type has been declared}
#define unknown_tag 1 //{this constant is added to certain type codes below}
#define vacuous 1 //{no expression was present}
#define boolean_type 2 //{\&{boolean} with a known value}
#define unknown_boolean (boolean_type+unknown_tag)
#define string_type 4 //{\&{string} with a known value}
#define unknown_string (string_type+unknown_tag)
#define pen_type 6 //{\&{pen} with a known value}
#define unknown_pen (pen_type+unknown_tag)
#define future_pen 8 //{subexpression that will become a \&{pen} at a higher level}
#define path_type 9 //{\&{path} with a known value}
#define unknown_path (path_type+unknown_tag)
#define picture_type 11 //{\&{picture} with a known value}
#define unknown_picture (picture_type+unknown_tag)
#define transform_type 13 //{\&{transform} variable or capsule}
#define pair_type 14 //{\&{pair} variable or capsule}
#define numeric_type 15 //{variable that has been declared \&{numeric} but not used}
#define known 16 //{\&{numeric} with a known value}
#define dependent 17 //{a linear combination with |fraction| coefficients}
#define proto_dependent 18 //{a linear combination with |scaled| coefficients}
#define independent 19 //{\&{numeric} with unknown value}
#define token_list 20 //{variable name or suffix argument or text argument}
#define structured 21 //{variable with subscripts and attributes}
#define unsuffixed_macro 22 //{variable defined with \&{vardef} but no \.{\AT!\#}}
#define suffixed_macro 23 //{variable defined with \&{vardef} and \.{\AT!\#}}
#define unknown_types \
unknown_boolean: case unknown_string:\
case unknown_pen: case unknown_picture: case unknown_path
/* 188 */
#define root 0 //{|name_type| at the top level of a variable}
#define saved_root 1 //{same, when the variable has been saved}
#define structured_root 2 //{|name_type| where a |structured| branch occurs}
#define subscr 3 //{|name_type| in a subscript node}
#define attr 4 //{|name_type| in an attribute node}
#define x_part_sector 5 //{|name_type| in the \&{xpart} of a node}
#define y_part_sector 6 //{|name_type| in the \&{ypart} of a node}
#define xx_part_sector 7 //{|name_type| in the \&{xxpart} of a node}
#define xy_part_sector 8 //{|name_type| in the \&{xypart} of a node}
#define yx_part_sector 9 //{|name_type| in the \&{yxpart} of a node}
#define yy_part_sector 10 //{|name_type| in the \&{yypart} of a node}
#define capsule 11 //{|name_type| in stashed-away subexpressions}
#define token 12 //{|name_type| in a numeric token or string token}
/* 189 */
#define true_code 30 //{operation code for \.{true}}
#define false_code 31 //{operation code for \.{false}}
#define null_picture_code 32 //{operation code for \.{nullpicture}}
#define null_pen_code 33 //{operation code for \.{nullpen}}
#define job_name_op 34 //{operation code for \.{jobname}}
#define read_string_op 35 //{operation code for \.{readstring}}
#define pen_circle 36 //{operation code for \.{pencircle}}
#define normal_deviate 37 //{operation code for \.{normaldeviate}}
#define odd_op 38 //{operation code for \.{odd}}
#define known_op 39 //{operation code for \.{known}}
#define unknown_op 40 //{operation code for \.{unknown}}
#define not_op 41 //{operation code for \.{not}}
#define decimal 42 //{operation code for \.{decimal}}
#define reverse 43 //{operation code for \.{reverse}}
#define make_path_op 44 //{operation code for \.{makepath}}
#define make_pen_op 45 //{operation code for \.{makepen}}
#define total_weight_op 46 //{operation code for \.{totalweight}}
#define oct_op 47 //{operation code for \.{oct}}
#define hex_op 48 //{operation code for \.{hex}}
#define ASCII_op 49 //{operation code for \.{ASCII}}
#define char_op 50 //{operation code for \.{char}}
#define length_op 51 //{operation code for \.{length}}
#define turning_op 52 //{operation code for \.{turningnumber}}
#define x_part 53 //{operation code for \.{xpart}}
#define y_part 54 //{operation code for \.{ypart}}
#define xx_part 55 //{operation code for \.{xxpart}}
#define xy_part 56 //{operation code for \.{xypart}}
#define yx_part 57 //{operation code for \.{yxpart}}
#define yy_part 58 //{operation code for \.{yypart}}
#define sqrt_op 59 //{operation code for \.{sqrt}}
#define m_exp_op 60 //{operation code for \.{mexp}}
#define m_log_op 61 //{operation code for \.{mlog}}
#define sin_d_op 62 //{operation code for \.{sind}}
#define cos_d_op 63 //{operation code for \.{cosd}}
#define floor_op 64 //{operation code for \.{floor}}
#define uniform_deviate 65 //{operation code for \.{uniformdeviate}}
#define char_exists_op 66 //{operation code for \.{charexists}}
#define angle_op 67 //{operation code for \.{angle}}
#define cycle_op 68 //{operation code for \.{cycle}}
#define plus 69 //{operation code for \.+}
#define minus 70 //{operation code for \.-}
#define times 71 //{operation code for \.*}
#define over 72 //{operation code for \./}
#define pythag_add 73 //{operation code for \.{++}}
#define pythag_sub 74 //{operation code for \.{+-+}}
#define or_op 75 //{operation code for \.{or}}
#define and_op 76 //{operation code for \.{and}}
#define less_than 77 //{operation code for \.<}
#define less_or_equal 78 //{operation code for \.{< }}
#define greater_than 79 //{operation code for \.>}
#define greater_or_equal 80 //{operation code for \.{> }}
#define equal_to 81 //{operation code for \. }
#define unequal_to 82 //{operation code for \.{<>}}
#define concatenate 83 //{operation code for \.\&}
#define rotated_by 84 //{operation code for \.{rotated}}
#define slanted_by 85 //{operation code for \.{slanted}}
#define scaled_by 86 //{operation code for \.{scaled}}
#define shifted_by 87 //{operation code for \.{shifted}}
#define transformed_by 88 //{operation code for \.{transformed}}
#define x_scaled 89 //{operation code for \.{xscaled}}
#define y_scaled 90 //{operation code for \.{yscaled}}
#define z_scaled 91 //{operation code for \.{zscaled}}
#define intersect 92 //{operation code for \.{intersectiontimes}}
#define double_dot 93 //{operation code for improper \.{..}}
#define substring_of 94 //{operation code for \.{substring}}
#define min_of substring_of
#define subpath_of 95 //{operation code for \.{subpath}}
#define direction_time_of 96 //{operation code for \.{directiontime}}
#define point_of 97 //{operation code for \.{point}}
#define precontrol_of 98 //{operation code for \.{precontrol}}
#define postcontrol_of 99 //{operation code for \.{postcontrol}}
#define pen_offset_of 100 //{operation code for \.{penoffset}}
/* 190 */
#define tracing_titles 1 //{show titles online when they appear}
#define tracing_equations 2 //{show each variable when it becomes known}
#define tracing_capsules 3 //{show capsules too}
#define tracing_choices 4 //{show the control points chosen for paths}
#define tracing_specs 5 //{show subdivision of paths into octants before digitizing}
#define tracing_pens 6 //{show details of pens that are made}
#define tracing_commands 7 //{show commands and operations before they are performed}
#define tracing_restores 8 //{show when a variable or internal is restored}
#define tracing_macros 9 //{show macros before they are expanded}
#define tracing_edges 10 //{show digitized edges as they are computed}
#define tracing_output 11 //{show digitized edges as they are output}
#define tracing_stats 12 //{show memory usage at end of job}
#define tracing_online 13 //{show long diagnostics on terminal and in the log file}
#define year 14 //{the current year (e.g., 1984)}
#define month 15 //{the current month (e.g., 3 $\equiv$ March)}
#define day 16 //{the current day of the month}
#define time 17 //{the number of minutes past midnight when this job started}
#define char_code 18 //{the number of the next character to be output}
#define char_ext 19 //{the extension code of the next character to be output}
#define char_wd 20 //{the width of the next character to be output}
#define char_ht 21 //{the height of the next character to be output}
#define char_dp 22 //{the depth of the next character to be output}
#define char_ic 23 //{the italic correction of the next character to be output}
#define char_dx 24 //{the device's $x$ movement for the next character, in pixels}
#define char_dy 25 //{the device's $y$ movement for the next character, in pixels}
#define design_size 26 //{the unit of measure used for |char_wd..char_ic|, in points}
#define hppp 27 //{the number of horizontal pixels per point}
#define vppp 28 //{the number of vertical pixels per point}
#define x_offset 29 //{horizontal displacement of shipped-out characters}
#define y_offset 30 //{vertical displacement of shipped-out characters}
#define pausing 31 //{positive to display lines on the terminal before they are read}
#define showstopping 32 //{positive to stop after each \&{show} command}
#define fontmaking 33 //{positive if font metric output is to be produced}
#define proofing 34 //{positive for proof mode, negative to suppress output}
#define smoothing 35 //{positive if moves are to be ``smoothed''}
#define autorounding 36 //{controls path modification to ``good'' points}
#define granularity 37 //{autorounding uses this pixel size}
#define fillin 38 //{extra darkness of diagonal lines}
#define turning_check 39 //{controls reorientation of clockwise paths}
#define warning_check 40 //{controls error message when variable value is large}
#define boundary_char 41 //{the right boundary character for ligatures}
#define max_given_internal 41
/* 198 */
#define digit_class 0 //{the class number of \.{0123456789}}
#define period_class 1 //{the class number of `\..'}
#define space_class 2 //{the class number of spaces and nonstandard characters}
#define percent_class 3 //{the class number of `\.\%'}
#define string_class 4 //{the class number of `\."'}
#define right_paren_class 8 //{the class number of `\.)'}
#define isolated_classes 5: case 6: case 7: case 8 //{characters that make length-one tokens only}
#define letter_class 9 //{letters and the underline character}
#define left_bracket_class 17 //{`\.['}
#define right_bracket_class 18 //{`\.]'}
#define invalid_class 20 //{bad character in the input}
#define max_class 20 //{the largest class number}
/* 200 */
#define next(a) hash[a].lh //{link for coalesced lists}