-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathexterns.h
3923 lines (3569 loc) · 202 KB
/
externs.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
/*@externs.h:External Declarations:Directories and file conventions@**********/
/* */
/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.43) */
/* COPYRIGHT (C) 1991, 2008 Jeffrey H. Kingston */
/* */
/* Jeffrey H. Kingston (jeff@it.usyd.edu.au) */
/* School of Information Technologies */
/* The University of Sydney 2006 */
/* AUSTRALIA */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either Version 3, or (at your option) */
/* any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA */
/* */
/* FILE: externs.h */
/* MODULE: External Declarations */
/* */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <locale.h>
#if LOCALE_ON
#include <nl_types.h>
extern nl_catd MsgCat;
#define condcatgets(cat, set, msg, s) (cat ? catgets(cat, set, msg, s) : s)
#else
#define condcatgets(cat, set, msg, s) s
#endif
/*****************************************************************************/
/* */
/* Include, font and database directories, and the DEBUG_ON and ASSERT_ON */
/* flags (defined by -D options on the cc command line in the makefile). */
/* */
/* LATIN Non-zero means compile for ISO-LATIN-1 char set. */
/* LIB_DIR The system directory where library files are kept */
/* INCL_DIR The subdirectory of LIB_DIR where @Include files are kept */
/* FONT_DIR The subdirectory of LIB_DIR where .AFM font files are kept */
/* MAPS_DIR The subdirectory of LIB_DIR where .LCM files are kept */
/* DATA_DIR The subdirectory of LIB_DIR where database files are kept */
/* HYPH_DIR The subdirectory of LIB_DIR where hyphenation files kept */
/* LOCALE_DIR The subdirectory of LIB_DIR where locale files are kept */
/* CHAR_IN Determines assignment of input chars to lex classes */
/* CHAR_OUT Determines appearance of literal chars in output */
/* DEBUG_ON Non-zero means compile debug code (lout -d) */
/* ASSERT_ON Non-zero means test assertions */
/* LOCALE_ON Non-zero means compile setlocale() etc. code */
/* */
/* #define LIB_DIR "/usr/local/lib/lout" */
/* #define INCL_DIR "include" */
/* #define FONT_DIR "font" */
/* #define MAPS_DIR "maps" */
/* #define DATA_DIR "data" */
/* #define HYPH_DIR "hyph" */
/* #define LOCALE_DIR "locale" (only used if LOCALE_ON) */
/* #define CHAR_IN 0 */
/* #define CHAR_OUT 0 */
/* #define DEBUG_ON 0 */
/* #define ASSERT_ON 1 */
/* #define LOCALE_ON 1 */
/* */
/*****************************************************************************/
/*@::File naming conventions and version@*************************************/
/* */
/* File naming conventions and version */
/* */
/* LOUT_VERSION Version information */
/* CROSS_DB The default name of the cross reference database */
/* SOURCE_SUFFIX Optional suffix of source files and include files */
/* INDEX_SUFFIX The suffix of database index files */
/* NEW_INDEX_SUFFIX The suffix of new database index files */
/* DATA_SUFFIX The suffix of database data files */
/* NEW_DATA_SUFFIX The additional suffix of new database data files */
/* HYPH_SUFFIX The suffix of unpacked hyphenation files */
/* HYPH_PACKED_SUFFIX The suffix of packed hyphenation files */
/* FILTER_IN The prefix of the name of the input file to filters */
/* FILTER_OUT The prefix of the name of the output file to filters */
/* FILTER_ERR The name of the error file to filters */
/* */
/*****************************************************************************/
#define LOUT_VERSION AsciiToFull("Basser Lout Version 3.43 (Jan 2024)")
#define CROSS_DB AsciiToFull("lout")
#define SOURCE_SUFFIX AsciiToFull(".lt")
#define INDEX_SUFFIX AsciiToFull(".li")
#define NEW_INDEX_SUFFIX AsciiToFull(".lix")
#define DATA_SUFFIX AsciiToFull(".ld")
#define NEW_DATA_SUFFIX AsciiToFull("x")
#define HYPH_SUFFIX AsciiToFull(".lh")
#define HYPH_PACKED_SUFFIX AsciiToFull(".lp")
#define FILTER_IN AsciiToFull("louti")
#define FILTER_OUT AsciiToFull("lout")
#define FILTER_ERR AsciiToFull("lout.err")
/*****************************************************************************/
/* */
/* Operating system dependent things */
/* */
/* (1) Reading files */
/* */
/* Starting from Version 3.27, Lout reads all files in "binary mode", so */
/* that the actual characters in the file are presented to Lout. Lout */
/* accepts any of LF, CR, LF+CR, CR+LF as a valid line ending on any */
/* line of any file, taking the longest match as usual. */
/* */
/* This strategy has two major advantages: files transferred between */
/* operating systems are always read correctly without needing any */
/* conversion, and ftell() always works properly on binary files (its */
/* behaviour on text files has been observed to vary). */
/* */
/* READ_FILE Mode passed to fopen() when reading any file at all */
/* */
/* (2) Writing files */
/* */
/* Starting from Version 3.27, Lout writes all files in "binary mode", */
/* so that the actual characters in the file are all explicitly written */
/* by Lout. The macro STR_NEWLINE defines what character(s) Lout will */
/* write when it wants to end the line; throughout Lout the "\n" thing */
/* never appears, only STR_NEWLINE. STR_NEWLINE is defined below to be */
/* "\n" on Unix, "\r\n" on DOS, and "\r" on Mac. */
/* */
/* This strategy might seem to be overkill, given that writing "\n" on */
/* a DOS text file would write "\r\n" anyway. Unfortunately, when Lout */
/* is writing a database file, it uses ftell() as it is writing to find */
/* out where it's up to. Since we can only be sure that ftell() will */
/* work on binary files, we've made all file writing be binary. */
/* */
/* WRITE_FILE Mode passed to fopen() when writing any file at all */
/* APPEND_FILE Mode passed to fopen() when appending any file at all */
/* STR_NEWLINE The string to write to a binary file to end a line */
/* */
/* (3) Directory character */
/* */
/* Operating systems differ in the character used in path names. */
/* */
/* STR_DIR Directory character used in file path names */
/* */
/* (4) System command and file name for uncompressing EPS files */
/* */
/* UNCOMPRESS_COM System command for uncompressing compressed EPS file */
/* LOUT_EPS Name of temporary uncompressed EPS file */
/* */
/* There is one further call to system() in the Lout source code: the one */
/* that implements filtered parameters such as prg2lout. The strings */
/* passed to this call to system() are the values of @Filter symbols */
/* within Lout definitions. */
/* */
/*****************************************************************************/
#if OS_UNIX
#define READ_FILE "r"
#define WRITE_FILE "w"
#define APPEND_FILE "a"
#define STR_NEWLINE AsciiToFull("\n")
#define STR_DIR AsciiToFull("/")
#define UNCOMPRESS_COM "gunzip -c %s > %s"
#define PDFTOPS_COM "pdftops -eps '%s' '%s'"
#define CONVERT_COM "convert '%s' 'eps2:%s'"
#define LOUT_EPS "lout.eps"
#else
#if OS_DOS
#define READ_FILE "rb"
#define WRITE_FILE "wb"
#define APPEND_FILE "ab"
#define STR_NEWLINE AsciiToFull("\r\n")
#define STR_DIR AsciiToFull("/")
#define UNCOMPRESS_COM "gunzip -c %s > %s"
#define PDFTOPS_COM "pdftops -eps %s %s"
#define CONVERT_COM "convert %s eps2:%s"
#define LOUT_EPS "lout.eps"
#else
#if OS_MAC
#define READ_FILE "r"
#define WRITE_FILE "w"
#define APPEND_FILE "a"
#define STR_NEWLINE AsciiToFull("\r")
#define STR_DIR AsciiToFull("/")
#define UNCOMPRESS_COM "gunzip -c %s > %s"
#define PDFTOPS_COM "pdftops -eps %s %s"
#define CONVERT_COM "convert %s eps2:%s"
#define LOUT_EPS "lout.eps"
#else
If you're compiling this, you've got the wrong settings in the makefile!
#endif
#endif
#endif
/*@::Significant limits@******************************************************/
/* */
/* Significant Limits (other insignificant ones appear in other files) */
/* */
/* MAX_FULL_LENGTH The maximum value storable in type FULL_LENGTH. */
/* NB this cannot be 2**31 - 1 because there are */
/* intermediate results that exceed MAX_FULL_LENGTH */
/* and are subsequently reduced to MAX_FULL_LENGTH. */
/* For example, some intermediate results may exceed */
/* MAX_FULL_LENGTH by a factor of SF, which is defined */
/* below to be 256 (2**8). The value given is 2**23-1, */
/* which is about 148 metres in Lout's precision. */
/* */
/* MAX_FILES The maximum number of files. This could only be */
/* increased if the file_num() field of type FILE_POS */
/* is enlarged beyond its present 16 bits. */
/* */
/* MAX_LINE 1 + the maximum length of an input line in source */
/* and database files. This is used for the lexical */
/* analyser's input line buffer only, and could be */
/* increased immediately to 4096, and even further if */
/* more than the current 12 bits was assigned to the */
/* col_num() field of type FILE_POS. */
/* */
/* MAX_WORD 1 + the maximum length of a word storable in an */
/* object record, which includes all file path names */
/* too. It is reasonable to make this MAX_LINE, since */
/* a word longer than MAX_LINE cannot be read in. */
/* */
/* MAX_OBJECT_REC 1 + the maximum size of an object record, measured */
/* in ALIGNs. The value chosen should exceed */
/* ceiling( (wr + MAX_WORD - 4) / sizeof(ALIGN) ) */
/* where wr = sizeof(struct word_rec), so that words of */
/* length MAX_WORD-1 can be stored in an object record. */
/* */
/* MAX_BUFF 1 + the maximum length of a "standard buffer"; these */
/* buffers are used in a variety of places throughout */
/* the program for holding one line of a font file, */
/* one file path name, one symbol full name, etc. This */
/* may be increased immediately without limit. */
/* */
/* MAX_FONT The maximum number of sized fonts allowed. */
/* */
/* MAX_COLOUR The maximum number of distinct left parameters of */
/* @SetColour and @SetColor symbols allowed (after */
/* evaluation). */
/* */
/* MAX_TEXTURE The maximum number of distinct left parameters of */
/* the @SetTexture symbol allowed (after evaluation). */
/* */
/* MAX_LANGUAGE The maximum number of distinct languages allowed. */
/* This can be increased beyond 256 only by setting */
/* aside a larger word_language() field. */
/* */
/* MAX_LEX_STACK The maximum depth of @Includes and @Databases. This */
/* can be increased immediately by any small amount. */
/* */
/* MAX_CHARS The maximimum number of characters in a font. This */
/* cannot be increased easily. */
/* */
/* MAX_HCOPIES The maximimum number of copies of one running header */
/* that can appear correctly on one page. Can be */
/* increased to any small positive integer. */
/* */
/* MAX_FORMAT The maximum number of characters for sscanf formats */
/* for splitting strings with tab-delimited fields. */
/* */
/*****************************************************************************/
/*@::Significant limits@******************************************************/
/* */
/* ALT_SCALE_FACTOR_SHIFT Scaling for included images is calculated by */
/* trunc(SF * available_space / image_size) */
/* The default value of SF is 256 (SHIFT of 8). */
/* When printing a document with proofs of pages that */
/* contain several pages per sheet, images might be */
/* reduced by a factor of 10. If such an image needs a */
/* a scale factor of 25.9, lout rounds it to 25. */
/* If the image was originally about 11" (792pt), */
/* it will be printed as 792*25/256 = 77.3pt instead of */
/* 792*25.9/256 = 80.1pt. This difference can create a */
/* visible misalignment of images in a @Graph. */
/* Increasing SF improves the scaling accuracy at the */
/* expense of reducing MAX_FULL_LENGTH, the maximum */
/* page size. */
/* ALT_SCALE_FACTOR 8 MAX_FULL_LENGTH 148.0m */
/* ALT_SCALE_FACTOR 9 MAX_FULL_LENGTH 74.0m */
/* ALT_SCALE_FACTOR 10 MAX_FULL_LENGTH 37.0m */
/* ALT_SCALE_FACTOR 11 MAX_FULL_LENGTH 18.5m */
/* ALT_SCALE_FACTOR 12 MAX_FULL_LENGTH 9.2m */
/* ALT_SCALE_FACTOR 13 MAX_FULL_LENGTH 4.6m */
/* ALT_SCALE_FACTOR 14 MAX_FULL_LENGTH 2.3m */
/* ALT_SCALE_FACTOR 15 MAX_FULL_LENGTH 1.2m */
/* */
/*****************************************************************************/
#define ALT_SCALE_FACTOR_SHIFT 12
#ifdef ALT_SCALE_FACTOR_SHIFT
#define MAX_FULL_LENGTH ((1 << (31 - ALT_SCALE_FACTOR_SHIFT)) - 1)
#else
#define MAX_FULL_LENGTH 8388607 /* 2**23 - 1, about 148 metres */
#endif
#define MAX_FILES 65535
#define MAX_LINE 2048
#define MAX_WORD 2048
#define MAX_OBJECT_REC ceiling(sizeof(struct word_type)+MAX_WORD,sizeof(ALIGN))
#define MAX_BUFF 512
#define MAX_FONT 65535
#define MAX_COLOUR 65535
#define MAX_TEXTURE 65535
#define MAX_LANGUAGE 64
#define MAX_LEX_STACK 20
#define MAX_CHARS 256
#define MAX_HCOPIES 3
#define MAX_FORMAT 100
/*****************************************************************************/
/* */
/* Miscellaneous Macros */
/* */
/*****************************************************************************/
#define BOOLEAN unsigned
#define FALSE 0
#define TRUE 1
#define bool_str(x) (x ? AsciiToFull("TRUE") : AsciiToFull("FALSE") )
#define CHILD 0
#define PARENT 1
#define COLM 0
#define ROWM 1
#define dimen(x) (x == COLM ? AsciiToFull("COLM") : AsciiToFull("ROWM") )
#define nilobj ( (OBJECT) NULL )
#define null ( (FILE *) NULL )
#define find_max(a, b) ((a) < (b) ? (b) : (a))
#define find_min(a, b) ((a) < (b) ? (a) : (b))
#define ceiling(a, b) ( ((a) - 1)/(b) + 1 ) /* ceiling(a/b) */
#define is_odd(x) ( (x) & 1 ) /* TRUE if x is odd number */
/*@::Some straightforward typedefs@*******************************************/
/* */
/* typedef ALIGN - used for forcing record alignment. */
/* */
/*****************************************************************************/
typedef char *ALIGN;
/*****************************************************************************/
/* */
/* typedef FULL_LENGTH - an integer physical distance. */
/* */
/*****************************************************************************/
typedef int FULL_LENGTH;
/*****************************************************************************/
/* */
/* FONT_NUM - internal name for a font. */
/* */
/*****************************************************************************/
typedef unsigned short FONT_NUM;
/*****************************************************************************/
/* */
/* COLOUR_NUM - internal name for a colour. */
/* */
/*****************************************************************************/
typedef unsigned short COLOUR_NUM;
/*****************************************************************************/
/* */
/* TEXTURE_NUM - internal name for a texture. */
/* */
/*****************************************************************************/
typedef unsigned short TEXTURE_NUM;
/*****************************************************************************/
/* */
/* LANGUAGE_NUM - internal name for a language. */
/* */
/*****************************************************************************/
typedef unsigned int LANGUAGE_NUM;
/*****************************************************************************/
/* */
/* MAPPING - internal name for a character mapping vector. */
/* */
/*****************************************************************************/
typedef unsigned int MAPPING;
/*****************************************************************************/
/* */
/* LINE - a line from a database index file. */
/* */
/*****************************************************************************/
typedef char *LINE;
/*****************************************************************************/
/* */
/* typedef FULL_CHAR - one of the characters manipulated by Lout. */
/* */
/* This program does not deal with 7-bit ASCII characters. Instead, its */
/* characters are defined by the FULL_CHAR typedef, and could be anything */
/* from 7-bit ASCII to 8-bit ISO-LATIN-1 to 16-bit UNICODE and beyond. */
/* */
/* Unfortunately C favours signed 8-bit characters: literal strings are */
/* pointers to them, argv[] and the standard libraries assume them. We get */
/* around these problems by using our own library, including AsciiToFull() */
/* to convert an ASCII string (such as a C string) into a FULL_CHAR string. */
/* */
/* Formally this library appears in module z39.c; however since this */
/* implementation uses 8-bit unsigned characters, most of the routines */
/* can be implemented by macros containing type-cast calls to C standard */
/* library routines. These appear in the z39.c externs list below. */
/* */
/*****************************************************************************/
typedef unsigned char FULL_CHAR;
/*****************************************************************************/
/* */
/* typedef POINTER- name for type of generic pointer */
/* */
/*****************************************************************************/
typedef void *POINTER;
/*@::Character literals@******************************************************/
/* */
/* Character Literals */
/* */
/* The following macros ensure that no Lout source is ever compared to a */
/* literal character other than '\0': */
/* */
/*****************************************************************************/
#define CH_FLAG_ALTERR 'a' /* the -a command line flag */
#define CH_FLAG_CROSS 'c' /* the -c command line flag */
#define CH_FLAG_ENCPATH 'C' /* the -C command line flag */
#define CH_FLAG_DEBUG 'd' /* the -d command line flag */
#define CH_FLAG_DIRPATH 'D' /* the -D command line flag */
#define CH_FLAG_ERRFILE 'e' /* the -e command line flag */
#define CH_FLAG_EPSFIRST 'E' /* first letter of the -EPS flag */
#define CH_FLAG_FNTPATH 'F' /* the -F command line flag */
#define CH_FLAG_HYPHEN 'h' /* the -h command line flag */
#define CH_FLAG_HYPPATH 'H' /* the -H command line flag */
#define CH_FLAG_INCLUDE 'i' /* the -i command line flag */
#define CH_FLAG_INCPATH 'I' /* the -I command line flag */
#define CH_FLAG_NOKERN 'k' /* the -k command line flag */
#define CH_FLAG_NOCOLLATE 'l' /* the -l command line flag */
#define CH_FLAG_COLLATE 'L' /* the -L command line flag */
#define CH_FLAG_MEMCHECK 'm' /* the -m command line flag */
#define CH_FLAG_MEMCR 'M' /* the -M command line flag */
#define CH_FLAG_OUTFILE 'o' /* the -o command line flag */
#define CH_FLAG_PLAIN 'p' /* the -p command line flag */
#define CH_FLAG_FFPLAIN 'P' /* the -P command line flag */
#define CH_FLAG_RUNS 'r' /* the -r command line flag */
#define CH_FLAG_SUPPRESS 's' /* the -s command line flag */
#define CH_FLAG_SAFE 'S' /* the -S command line flag */
#define CH_FLAG_NOTEXTURE 't' /* the -t command line flag */
#define CH_FLAG_USAGE 'u' /* the -u command line flag */
#define CH_FLAG_UNSAFE 'U' /* the -U command line flag */
#define CH_FLAG_VERSION 'V' /* the -V command line flag */
#define CH_FLAG_INITALL 'x' /* the -x command line flag */
#define CH_FLAG_OPTION '-' /* the -- command line flag */
#define CH_FLAG_WORDS 'w' /* the -w command line flag */
#define CH_FLAG_PDF 'Z' /* the -Z command line flag */
#define CH_SPACE ' ' /* space character */
/* #define CH_NEWLINE '\n'*/ /* the newline character */
#define CH_LF '\n' /* the line feed character */
#define CH_CR '\r' /* the carriage return character */
#define CH_SYMSTART '@' /* extra letter symbols may have */
#define CH_UNDERSCORE '_' /* extra letter symbols may have */
#define CH_QUOTE '"' /* the quote character */
#define CH_ZERO '0' /* the first digit character, zero */
#define CH_EIGHT '8' /* the last even digit character */
#define CH_NINE '9' /* the last odd digit character */
#define CH_INCGAP '+' /* begins an incrementing gap */
#define CH_DECGAP '-' /* begins a decrementing gap */
#define CH_MINUS '-' /* minus sign */
#define CH_HYPHEN '-' /* the hyphen character */
#define CH_SLASH '/' /* the slash character */
#define CH_NOBREAK 'u' /* `unbreakable' character for gaps */
#define CH_UNIT_CM 'c' /* unit of measurement: centimetres */
#define CH_UNIT_IN 'i' /* unit of measurement: inches */
#define CH_UNIT_PT 'p' /* unit of measurement: points */
#define CH_UNIT_EM 'm' /* unit of measurement: ems */
#define CH_UNIT_FT 'f' /* unit of measurement: fontsizes */
#define CH_UNIT_SP 's' /* unit of measurement: spacewidths */
#define CH_UNIT_VS 'v' /* unit of measurement: vspaces */
#define CH_UNIT_WD 'w' /* unit of measurement: follwidths */
#define CH_UNIT_BD 'b' /* unit of measurement: boundwidths */
#define CH_UNIT_RL 'r' /* unit of measurement: relwidths */
#define CH_UNIT_DG 'd' /* unit of measurement: degrees */
#define CH_UNIT_YU 'y' /* unit of measurement: y unit */
#define CH_UNIT_ZU 'z' /* unit of measurement: z unit */
#define CH_MODE_EDGE 'e' /* spacing mode: edge-to-edge */
#define CH_MODE_HYPH 'h' /* spacing mode: hyphenation */
#define CH_MODE_MARK 'x' /* spacing mode: mark-to-mark */
#define CH_MODE_OVER 'o' /* spacing mode: overstrike */
#define CH_MODE_KERN 'k' /* spacing mode: kerning */
#define CH_MODE_TABL 't' /* spacing mode: tabulation */
#define octaldigit(ch) ( (ch) >= '0' && (ch) <= '7' )
#define decimaldigit(ch) ( (ch) >= '0' && (ch) <= '9' )
#define digitchartonum(ch) ( (ch) - '0' )
#define numtodigitchar(ch) ( (ch) + '0' )
#define beginsbreakstyle(ch) ( (ch) >= 'a' && (ch) <= 'z' )
#define numericchar(ch) ( decimaldigit(ch) || (ch) == '.' )
/*@::String literals, FULL_CHAR type@*****************************************/
/* */
/* String Literals. */
/* */
/* All significant string literals are defined here. The program has many */
/* others, however: format strings, debug output, etc. */
/* */
/*****************************************************************************/
#define STR_EMPTY AsciiToFull("")
#define STR_QUOTE AsciiToFull("\"")
#define STR_ESCAPE AsciiToFull("\\")
#define STR_COMMENT AsciiToFull("#")
#define STR_SPACE AsciiToFull(" ")
#define STR_FORMFEED AsciiToFull("\f")
#define STR_TAB AsciiToFull("\t")
#define STR_LETTERS_LOWER AsciiToFull("abcdefghijklmnopqrstuvwxyz")
#define STR_LETTERS_UPPER AsciiToFull("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#define STR_LETTERS_SYMSTART AsciiToFull("@")
#define STR_LETTERS_UNDERSCORE AsciiToFull("_")
#if CHAR_IN==0
#define STR_LETTERS_EXTRA0 AsciiToFull("")
#define STR_LETTERS_EXTRA1 AsciiToFull("")
#define STR_LETTERS_EXTRA2 AsciiToFull("")
#define STR_LETTERS_EXTRA3 AsciiToFull("")
#define STR_LETTERS_EXTRA4 AsciiToFull("")
#define STR_LETTERS_EXTRA5 AsciiToFull("")
#define STR_LETTERS_EXTRA6 AsciiToFull("")
#define STR_LETTERS_EXTRA7 AsciiToFull("")
#else
#define STR_LETTERS_EXTRA0 AsciiToFull("\300\301\302\303\304\305\306\307")
#define STR_LETTERS_EXTRA1 AsciiToFull("\310\311\312\313\314\315\316\317")
#define STR_LETTERS_EXTRA2 AsciiToFull("\320\321\322\323\324\325\326")
#define STR_LETTERS_EXTRA3 AsciiToFull("\330\331\332\333\334\335\336\337")
#define STR_LETTERS_EXTRA4 AsciiToFull("\340\341\342\343\344\345\346\347")
#define STR_LETTERS_EXTRA5 AsciiToFull("\350\351\352\353\354\355\356\357")
#define STR_LETTERS_EXTRA6 AsciiToFull("\360\361\362\363\364\365\366")
#define STR_LETTERS_EXTRA7 AsciiToFull("\370\371\372\373\374\375\376\377")
#endif
#define STR_STDIN AsciiToFull("-")
#define STR_STDOUT AsciiToFull("-")
#define STR_HYPHEN AsciiToFull("-")
#define STR_EPS AsciiToFull("EPS")
#define STR_POSTSCRIPT AsciiToFull("PostScript")
#define STR_PLAINTEXT AsciiToFull("PlainText")
#define STR_PDF AsciiToFull("PDF")
#define STR_ELSE AsciiToFull("else")
#define STR_NOCROSS AsciiToFull("??")
#define STR_BADKEY AsciiToFull("badkey")
#define STR_NONE AsciiToFull("none")
#define STR_NOCHAR AsciiToFull("-none-")
#define STR_ZERO AsciiToFull("0")
#define STR_PS_SPACENAME AsciiToFull("space")
#define STR_FONT_RECODE AsciiToFull("Recode")
#define STR_FONT_NORECODE AsciiToFull("NoRecode")
#define STR_COLOUR_NOCHANGE AsciiToFull("nochange")
#define STR_TEXTURE_NOCHANGE AsciiToFull("nochange")
#define STR_BREAK_HYPHEN AsciiToFull("hyphen")
#define STR_BREAK_NOHYPHEN AsciiToFull("nohyphen")
#define STR_BREAK_ADJUST AsciiToFull("adjust")
#define STR_BREAK_OUTDENT AsciiToFull("outdent")
#define STR_BREAK_RAGGED AsciiToFull("ragged")
#define STR_BREAK_CRAGGED AsciiToFull("cragged")
#define STR_BREAK_RRAGGED AsciiToFull("rragged")
#define STR_BREAK_ORAGGED AsciiToFull("oragged")
#define STR_BREAK_LINES AsciiToFull("lines")
#define STR_BREAK_CLINES AsciiToFull("clines")
#define STR_BREAK_RLINES AsciiToFull("rlines")
#define STR_BREAK_OLINES AsciiToFull("olines")
#define STR_BREAK_SCALE AsciiToFull("blanklinescale")
#define STR_BREAK_NOFIRST AsciiToFull("unbreakablefirst")
#define STR_BREAK_FIRST AsciiToFull("breakablefirst")
#define STR_BREAK_NOLAST AsciiToFull("unbreakablelast")
#define STR_BREAK_LAST AsciiToFull("breakablelast")
#define STR_BREAK_SETOUTDENT AsciiToFull("setoutdent")
#define STR_BREAK_MARGINKERNING AsciiToFull("marginkerning")
#define STR_BREAK_NOMARGINKERNING AsciiToFull("nomarginkerning")
#define STR_SPACE_LOUT AsciiToFull("lout")
#define STR_SPACE_COMPRESS AsciiToFull("compress")
#define STR_SPACE_SEPARATE AsciiToFull("separate")
#define STR_SPACE_TROFF AsciiToFull("troff")
#define STR_SPACE_TEX AsciiToFull("tex")
#define STR_SMALL_CAPS_ON AsciiToFull("smallcaps")
#define STR_SMALL_CAPS_OFF AsciiToFull("nosmallcaps")
#define STR_SMALL_CAPS_SET AsciiToFull("setsmallcaps")
#define STR_BASELINE_MARK AsciiToFull("baselinemark")
#define STR_LIG AsciiToFull("lig")
#define STR_NOLIG AsciiToFull("nolig")
#define STR_XHEIGHT2_MARK AsciiToFull("xheight2mark")
#define STR_NOSTRUT AsciiToFull("nostrut")
#define STR_STRUT AsciiToFull("strut")
#define STR_GAP_RJUSTIFY AsciiToFull("1rt")
#define STR_GAP_ZERO_HYPH AsciiToFull("0ch")
#define STR_SCALE_DOWN AsciiToFull("downifneeded")
/*@::GAP, STYLE@**************************************************************/
/* */
/* typedef GAP - what separates one object from another. */
/* */
/*****************************************************************************/
typedef struct
{ FULL_LENGTH owidth; /* width of the gap */
BOOLEAN onobreak : 1; /* TRUE if this gap is unbreakable */
BOOLEAN omark : 1; /* TRUE if this gap is marked */
BOOLEAN ojoin : 1; /* TRUE if joins exist across gap */
unsigned ounits : 3; /* units of measurement: fixed, etc */
unsigned omode : 3; /* spacing mode: edge-to-edge, etc */
} GAP;
#define nobreak(x) (x).onobreak
#define mark(x) (x).omark
#define join(x) (x).ojoin
#define units(x) (x).ounits
#define mode(x) (x).omode
#define width(x) (x).owidth
#define SetGap(x, xnobreak, xmark, xjoin, xunits, xmode, xwidth) \
( nobreak(x) = xnobreak, mark(x) = xmark, join(x) = xjoin, \
units(x) = xunits, mode(x) = xmode, width(x) = xwidth \
)
#define GapCopy(x, y) \
( nobreak(x) = nobreak(y), mark(x) = mark(y), join(x) = join(y), \
units(x) = units(y), mode(x) = mode(y), width(x) = width(y) \
)
#define GapEqual(x, y) \
( nobreak(x) == nobreak(y) && mark(x) == mark(y) && join(x) == join(y) \
&& units(x) == units(y) && mode(x) == mode(y) && width(x) == width(y) \
)
#define ClearGap(x) SetGap(x, FALSE, FALSE, TRUE, FIXED_UNIT, NO_MODE, 0)
/*****************************************************************************/
/* */
/* typedef STYLE - information about how to break text, etc. */
/* */
/*****************************************************************************/
/* A key-value pair. */
typedef struct context_type
{
union rec *okey; /* name of a context variable */
union rec *ovalue; /* associated value */
union rec *oenv; /* environment for this value */
struct style_type *ostyle; /* style for this value */
} CONTEXT;
#define context_key(x) (x).okey
#define context_value(x) (x).ovalue
#define context_env(x) (x).oenv
#define context_style(x) (x).ostyle
typedef struct style_type
{
GAP oline_gap; /* separation between lines */
GAP ospace_gap; /* separation induced by white space */
FULL_LENGTH oyunit; /* value of y unit of measurement */
FULL_LENGTH ozunit; /* value of z unit of measurement */
FULL_LENGTH ooutdent_len; /* amount to outdent in outdent style*/
FULL_LENGTH osmallcaps_len; /* size of small capitals */
FONT_NUM ofont; /* current font */
COLOUR_NUM ocolour; /* current colour */
COLOUR_NUM ounderline_colour; /* current underline colour */
TEXTURE_NUM otexture; /* current texture */
unsigned short oblanklinescale; /* scale factor for blank lines */
LANGUAGE_NUM olanguage : 6; /* current language */
BOOLEAN ovadjust : 1; /* @VAdjust in effect */
BOOLEAN ohadjust : 1; /* @HAdjust in effect */
BOOLEAN opadjust : 1; /* @PAdjust in effect */
unsigned osmall_caps : 1; /* small capitals */
unsigned ospace_style : 3; /* space style: lout, troff, tex, .. */
unsigned ohyph_style : 2; /* hyphenation off or on */
unsigned ofill_style : 2; /* fill lines with text off/on */
unsigned odisplay_style : 3; /* display lines adjusted, ragged... */
BOOLEAN ooutline : 2; /* TRUE if outlining words */
BOOLEAN onobreakfirst : 1; /* no break after first line of para */
BOOLEAN onobreaklast : 1; /* no break after last line of para */
BOOLEAN obaselinemark : 1; /* baseline char metrics */
BOOLEAN ostrut : 1; /* strut char metrics */
BOOLEAN oligatures : 1; /* use ligatures */
BOOLEAN omarginkerning : 1; /* perform margin kerning */
CONTEXT ocontext; /* context stack */
} STYLE;
#define line_gap(x) (x).oline_gap
#define space_gap(x) (x).ospace_gap
#define yunit(x) (x).oyunit
#define zunit(x) (x).ozunit
#define outdent_len(x) (x).ooutdent_len
#define smallcaps_len(x)(x).osmallcaps_len
#define font(x) (x).ofont
#define colour(x) (x).ocolour
#define underline_colour(x) (x).ounderline_colour
#define texture(x) (x).otexture
#define blanklinescale(x)(x).oblanklinescale
#define language(x) (x).olanguage
#define vadjust(x) (x).ovadjust
#define hadjust(x) (x).ohadjust
#define padjust(x) (x).opadjust
#define small_caps(x) (x).osmall_caps
#define space_style(x) (x).ospace_style
#define hyph_style(x) (x).ohyph_style
#define fill_style(x) (x).ofill_style
#define display_style(x)(x).odisplay_style
#define outline(x) (x).ooutline
#define nobreakfirst(x) (x).onobreakfirst
#define nobreaklast(x) (x).onobreaklast
#define baselinemark(x) (x).obaselinemark
#define strut(x) (x).ostrut
#define ligatures(x) (x).oligatures
#define marginkerning(x)(x).omarginkerning
#define context(x) (x).ocontext
#define StyleCopy(x, y) \
( GapCopy(line_gap(x), line_gap(y)), \
GapCopy(space_gap(x), space_gap(y)), \
yunit(x) = yunit(y), \
zunit(x) = zunit(y), \
outdent_len(x) = outdent_len(y), \
smallcaps_len(x) = smallcaps_len(y), \
font(x) = font(y), \
colour(x) = colour(y), \
underline_colour(x) = underline_colour(y), \
texture(x) = texture(y), \
blanklinescale(x) = blanklinescale(y), \
language(x) = language(y), \
vadjust(x) = vadjust(y), \
hadjust(x) = hadjust(y), \
padjust(x) = padjust(y), \
small_caps(x) = small_caps(y), \
space_style(x) = space_style(y), \
hyph_style(x) = hyph_style(y), \
fill_style(x) = fill_style(y), \
display_style(x) = display_style(y), \
outline(x) = outline(y), \
nobreakfirst(x) = nobreakfirst(y), \
nobreaklast(x) = nobreaklast(y), \
baselinemark(x) = baselinemark(y), \
strut(x) = strut(y), \
ligatures(x) = ligatures(y), \
marginkerning(x) = marginkerning(y), \
context(x) = context(y) \
)
/*@::CONSTRAINT, FILE_NUM, FILE_POS, LIST@************************************/
/* */
/* typedef CONSTRAINT - a size constraint. */
/* */
/*****************************************************************************/
typedef struct
{ FULL_LENGTH obc;
FULL_LENGTH obfc;
FULL_LENGTH ofc;
FULL_LENGTH osparec;
} CONSTRAINT;
#define bc(x) (x).obc
#define bfc(x) (x).obfc
#define fc(x) (x).ofc
#define sparec(x) (x).osparec
#define constrained(x) (bc(x) != MAX_FULL_LENGTH || \
bfc(x) != MAX_FULL_LENGTH || fc(x) != MAX_FULL_LENGTH)
#define SetConstraint(c,x,y,z) (bc(c) = (x), bfc(c) = (y), fc(c) = (z))
#define CopyConstraint(x, y) (bc(x) = bc(y), bfc(x) = bfc(y), fc(x) = fc(y))
#define FlipConstraint(x, y) (bc(x) = fc(y), bfc(x) = bfc(y), fc(x) = bc(y))
#define FitsConstraint(b, f, c) (b <= bc(c) && b + f <= bfc(c) && f <= fc(c))
#define EqualConstraint(a, b) (bc(a)==bc(b) && bfc(a)==bfc(b) && fc(a)==fc(b) )
#define ig_fnum(x) bc(constraint(x))
#define ig_xtrans(x) bfc(constraint(x))
#define ig_ytrans(x) fc(constraint(x))
/*****************************************************************************/
/* */
/* typedef FILE_NUM - the internal representation of a file. */
/* */
/*****************************************************************************/
typedef unsigned short FILE_NUM;
#define NO_FILE 0
/*****************************************************************************/
/* */
/* typedef FILE_POS - a position in the set of input files. */
/* */
/*****************************************************************************/
typedef struct
{ unsigned char otype; /* space for object type field */
unsigned char orec_size; /* space for object record size */
FILE_NUM ofile_num; /* no. of file this record is from */
unsigned oline_num : 20; /* the line number of this record */
unsigned ocol_num : 12; /* column number this is related to */
} FILE_POS;
#define file_num(x) (x).ofile_num
#define col_num(x) (x).ocol_num
#define line_num(x) (x).oline_num
#define FposCopy(x, y) \
( file_num(x) = file_num(y), \
line_num(x) = line_num(y), \
col_num(x) = col_num(y) \
)
/*****************************************************************************/
/* */
/* typedef LIST - two pointers used to make one doubly linked list */
/* */
/*****************************************************************************/
typedef struct { union rec *opred, *osucc; } LIST;
/*@::FIRST_UNION@*************************************************************/
/* */
/* typedef FIRST_UNION - first eight bytes of object record (after LISTs). */
/* */
/* The fpos is overwritten in WORDs and QWORDs during FixAndPrintObject by */
/* the horizontal coordinate of the word, which has to be remembered. */
/* This part of the record is also used by font records to hold font */
/* bounding box data. */
/* */
/*****************************************************************************/
typedef union
{
FILE_POS ofpos;
struct
{ unsigned char otype, orec_size;
int oword_save_mark;
} os11;
} FIRST_UNION;
/*@::SECOND_UNION, THIRD_UNION, FOURTH_UNION@*********************************/
/* */
/* typedef SECOND_UNION - twelve bytes holding various flags etc. */
/* */
/*****************************************************************************/
typedef union
{
struct /* used by all tokens */
{ unsigned char oprecedence;
unsigned char ohspace, ovspace;
} os21;
struct /* used by WORD objects only, except underline used by all */
/* objects, including GAP_OBJ */
{ FONT_NUM oword_font;
COLOUR_NUM oword_colour;
COLOUR_NUM oword_underline_colour;
TEXTURE_NUM oword_texture;
unsigned ounderline : 2; /* aligns with os23.underline */
BOOLEAN oword_outline : 1;
LANGUAGE_NUM oword_language : 6;
BOOLEAN oword_baselinemark : 1;
BOOLEAN oword_strut : 1;
BOOLEAN oword_ligatures : 1;
unsigned oword_hyph : 1;
} os22;
struct /* used by non-WORD objects */
{ unsigned short ofoll_or_prec;
unsigned short ocross_type; /* CROSS objects only */
unsigned short ounused_os23_a;
unsigned short ounused_os23_b;
unsigned ounderline : 2; /* aligns with os22.underline */
BOOLEAN onon_blocking: 1;
BOOLEAN osized : 1;
BOOLEAN othreaded : 1;
BOOLEAN oexternal_hor: 1;
BOOLEAN oexternal_ver: 1;
BOOLEAN oblocked : 1;
BOOLEAN otrigger_ext : 1;
BOOLEAN omust_expand : 1;
BOOLEAN ogall_dir : 1;
BOOLEAN oopt_hyph : 1;
BOOLEAN oopt_gazumped: 1;
BOOLEAN oadjust_cat : 1;
BOOLEAN oforce_gall : 1;
/* don't forget ounderline from os22 applies in this union! */
} os23;
struct /* used by WORD and QWORD when they are database nodes */
{ unsigned short oleft_pos;
unsigned char oreading;
unsigned char oin_memory;
} os24;
struct /* used by WORD and QWORD when they are font records */
{
FULL_LENGTH ofont_bbox_lly;
FULL_LENGTH ofont_bbox_ury;
} os25;
struct /* used by symbol table entries */
{ unsigned char oprecedence;
BOOLEAN ois_tag : 1;
BOOLEAN ohas_tag : 1;
BOOLEAN ohas_lpar : 1;
BOOLEAN ohas_rpar : 1;
BOOLEAN oright_assoc : 1;
BOOLEAN ois_target : 1;
BOOLEAN ohas_target : 1;
BOOLEAN oforce_target : 1;
BOOLEAN ohas_body : 1;
BOOLEAN oindefinite : 1;
BOOLEAN orecursive : 1;
BOOLEAN ouses_extern_target : 1;
BOOLEAN ois_extern_target : 1;
BOOLEAN ois_key : 1;
BOOLEAN ohas_key : 1;
BOOLEAN odirty : 1;
BOOLEAN ovisible : 1;
BOOLEAN ohas_mark : 1;
BOOLEAN ohas_join : 1;
BOOLEAN ohas_par : 1;
BOOLEAN ouses_galley : 1;
BOOLEAN ohoriz_galley : 1;
BOOLEAN oimports_encl : 1;
} os26;
} SECOND_UNION;
/*****************************************************************************/
/* */
/* typedef THIRD_UNION - sixteen bytes usually holding an object size. */
/* */
/* In database records this space is used for a file pointer, or a pointer */
/* to a LINE array if the database is in-memory; in certain */
/* WORD objects used privately in z10.c it is used for a galley-position. */
/* In font records it holds the font size, space width, etc. In filter */
/* words it holds a pointer to the symbol being filtered. */
/* */
/*****************************************************************************/
typedef union
{
struct
{ FULL_LENGTH oback[2];
FULL_LENGTH ofwd[2];
} os31;
FILE *odb_filep;
LINE *odb_lines;