1 /*@externs.h:External Declarations:Directories and file conventions@**********/
2 /*                                                                           */
3 /*  THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.39)                       */
4 /*  COPYRIGHT (C) 1991, 2008 Jeffrey H. Kingston                             */
5 /*                                                                           */
6 /*  Jeffrey H. Kingston (jeff@it.usyd.edu.au)                                */
7 /*  School of Information Technologies                                       */
8 /*  The University of Sydney 2006                                            */
9 /*  AUSTRALIA                                                                */
10 /*                                                                           */
11 /*  This program is free software; you can redistribute it and/or modify     */
12 /*  it under the terms of the GNU General Public License as published by     */
13 /*  the Free Software Foundation; either Version 3, or (at your option)      */
14 /*  any later version.                                                       */
15 /*                                                                           */
16 /*  This program is distributed in the hope that it will be useful,          */
17 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of           */
18 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            */
19 /*  GNU General Public License for more details.                             */
20 /*                                                                           */
21 /*  You should have received a copy of the GNU General Public License        */
22 /*  along with this program; if not, write to the Free Software              */
23 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA   */
24 /*                                                                           */
25 /*  FILE:         externs.h                                                  */
26 /*  MODULE:       External Declarations                                      */
27 /*                                                                           */
28 /*****************************************************************************/
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <stdarg.h>
33 #include <locale.h>
34 
35 #if LOCALE_ON
36 #include <nl_types.h>
37 extern nl_catd MsgCat;
38 #define condcatgets(cat, set, msg, s) (cat ? catgets(cat, set, msg, s) : s)
39 #else
40 #define condcatgets(cat, set, msg, s) s
41 #endif
42 
43 
44 /*****************************************************************************/
45 /*                                                                           */
46 /*  Include, font and database directories, and the DEBUG_ON and ASSERT_ON   */
47 /*  flags (defined by -D options on the cc command line in the makefile).    */
48 /*                                                                           */
49 /*  LATIN         Non-zero means compile for ISO-LATIN-1 char set.           */
50 /*  LIB_DIR       The system directory where library files are kept          */
51 /*  INCL_DIR      The subdirectory of LIB_DIR where @Include files are kept  */
52 /*  FONT_DIR      The subdirectory of LIB_DIR where .AFM font files are kept */
53 /*  MAPS_DIR      The subdirectory of LIB_DIR where .LCM files are kept      */
54 /*  DATA_DIR      The subdirectory of LIB_DIR where database files are kept  */
55 /*  HYPH_DIR      The subdirectory of LIB_DIR where hyphenation files kept   */
56 /*  LOCALE_DIR    The subdirectory of LIB_DIR where locale files are kept    */
57 /*  CHAR_IN       Determines assignment of input chars to lex classes        */
58 /*  CHAR_OUT      Determines appearance of literal chars in output           */
59 /*  DEBUG_ON      Non-zero means compile debug code (lout -d)                */
60 /*  ASSERT_ON     Non-zero means test assertions                             */
61 /*  LOCALE_ON     Non-zero means compile setlocale() etc. code               */
62 /*                                                                           */
63 /*  #define  LIB_DIR    "/usr/local/lib/lout"                                */
64 /*  #define  INCL_DIR   "include"                                            */
65 /*  #define  FONT_DIR   "font"                                               */
66 /*  #define  MAPS_DIR   "maps"                                               */
67 /*  #define  DATA_DIR   "data"                                               */
68 /*  #define  HYPH_DIR   "hyph"                                               */
69 /*  #define  LOCALE_DIR "locale"  (only used if LOCALE_ON)                   */
70 /*  #define  CHAR_IN    0                                                    */
71 /*  #define  CHAR_OUT   0                                                    */
72 /*  #define  DEBUG_ON   0                                                    */
73 /*  #define  ASSERT_ON  1                                                    */
74 /*  #define  LOCALE_ON  1                                                    */
75 /*                                                                           */
76 /*****************************************************************************/
77 
78 
79 /*@::File naming conventions and version@*************************************/
80 /*                                                                           */
81 /*  File naming conventions and version                                      */
82 /*                                                                           */
83 /*  LOUT_VERSION        Version information                                  */
84 /*  CROSS_DB            The default name of the cross reference database     */
85 /*  SOURCE_SUFFIX       Optional suffix of source files and include files    */
86 /*  INDEX_SUFFIX        The suffix of database index files                   */
87 /*  NEW_INDEX_SUFFIX    The suffix of new database index files               */
88 /*  DATA_SUFFIX         The suffix of database data files                    */
89 /*  NEW_DATA_SUFFIX     The additional suffix of new database data files     */
90 /*  HYPH_SUFFIX         The suffix of unpacked hyphenation files             */
91 /*  HYPH_PACKED_SUFFIX  The suffix of packed hyphenation files               */
92 /*  FILTER_IN           The prefix of the name of the input file to filters  */
93 /*  FILTER_OUT          The prefix of the name of the output file to filters */
94 /*  FILTER_ERR          The name of the error file to filters                */
95 /*                                                                           */
96 /*****************************************************************************/
97 
98 #define	LOUT_VERSION   AsciiToFull("Basser Lout Version 3.40 (June 2013)")
99 #define	CROSS_DB	   AsciiToFull("lout")
100 #define	SOURCE_SUFFIX	   AsciiToFull(".lt")
101 #define	INDEX_SUFFIX	   AsciiToFull(".li")
102 #define	NEW_INDEX_SUFFIX   AsciiToFull(".lix")
103 #define	DATA_SUFFIX	   AsciiToFull(".ld")
104 #define	NEW_DATA_SUFFIX	   AsciiToFull("x")
105 #define	HYPH_SUFFIX	   AsciiToFull(".lh")
106 #define	HYPH_PACKED_SUFFIX AsciiToFull(".lp")
107 #define	FILTER_IN	   AsciiToFull("louti")
108 #define	FILTER_OUT	   AsciiToFull("lout")
109 #define	FILTER_ERR	   AsciiToFull("lout.err")
110 
111 
112 /*****************************************************************************/
113 /*                                                                           */
114 /*  Operating system dependent things                                        */
115 /*                                                                           */
116 /*  (1) Reading files                                                        */
117 /*                                                                           */
118 /*  Starting from Version 3.27, Lout reads all files in "binary mode", so    */
119 /*  that the actual characters in the file are presented to Lout.  Lout      */
120 /*  accepts any of LF, CR, LF+CR, CR+LF as a valid line ending on any        */
121 /*  line of any file, taking the longest match as usual.                     */
122 /*                                                                           */
123 /*  This strategy has two major advantages:  files transferred between       */
124 /*  operating systems are always read correctly without needing any          */
125 /*  conversion, and ftell() always works properly on binary files (its       */
126 /*  behaviour on text files has been observed to vary).                      */
127 /*                                                                           */
128 /*  READ_FILE         Mode passed to fopen() when reading any file at all    */
129 /*                                                                           */
130 /*  (2) Writing files                                                        */
131 /*                                                                           */
132 /*  Starting from Version 3.27, Lout writes all files in "binary mode",      */
133 /*  so that the actual characters in the file are all explicitly written     */
134 /*  by Lout.  The macro STR_NEWLINE defines what character(s) Lout will      */
135 /*  write when it wants to end the line; throughout Lout the "\n" thing      */
136 /*  never appears, only STR_NEWLINE.  STR_NEWLINE is defined below to be     */
137 /*  "\n" on Unix, "\r\n" on DOS, and "\r" on Mac.                            */
138 /*                                                                           */
139 /*  This strategy might seem to be overkill, given that writing "\n" on      */
140 /*  a DOS text file would write "\r\n" anyway.  Unfortunately, when Lout     */
141 /*  is writing a database file, it uses ftell() as it is writing to find     */
142 /*  out where it's up to.  Since we can only be sure that ftell() will       */
143 /*  work on binary files, we've made all file writing be binary.             */
144 /*                                                                           */
145 /*  WRITE_FILE        Mode passed to fopen() when writing any file at all    */
146 /*  APPEND_FILE       Mode passed to fopen() when appending any file at all  */
147 /*  STR_NEWLINE       The string to write to a binary file to end a line     */
148 /*                                                                           */
149 /*  (3) Directory character                                                  */
150 /*                                                                           */
151 /*  Operating systems differ in the character used in path names.            */
152 /*                                                                           */
153 /*  STR_DIR           Directory character used in file path names            */
154 /*                                                                           */
155 /*  (4) System command and file name for uncompressing EPS files             */
156 /*                                                                           */
157 /*  UNCOMPRESS_COM    System command for uncompressing compressed EPS file   */
158 /*  LOUT_EPS          Name of temporary uncompressed EPS file                */
159 /*                                                                           */
160 /*  There is one further call to system() in the Lout source code:  the one  */
161 /*  that implements filtered parameters such as prg2lout.  The strings       */
162 /*  passed to this call to system() are the values of @Filter symbols        */
163 /*  within Lout definitions.                                                 */
164 /*                                                                           */
165 /*****************************************************************************/
166 
167 #if OS_UNIX
168 #define	READ_FILE	"r"
169 #define	WRITE_FILE	"w"
170 #define	APPEND_FILE	"a"
171 #define	STR_NEWLINE	AsciiToFull("\n")
172 #define	STR_DIR		AsciiToFull("/")
173 #define	UNCOMPRESS_COM	"gunzip -c %s > %s"
174 #define	LOUT_EPS	"lout.eps"
175 #else
176 #if OS_DOS
177 #define	READ_FILE	"rb"
178 #define	WRITE_FILE	"wb"
179 #define	APPEND_FILE	"ab"
180 #define	STR_NEWLINE	AsciiToFull("\r\n")
181 #define	STR_DIR		AsciiToFull("/")
182 #define	UNCOMPRESS_COM	"gunzip -c %s > %s"
183 #define	LOUT_EPS	"lout.eps"
184 #else
185 #if OS_MAC
186 #define	READ_FILE	"r"
187 #define	WRITE_FILE	"w"
188 #define	APPEND_FILE	"a"
189 #define	STR_NEWLINE	AsciiToFull("\r")
190 #define	STR_DIR		AsciiToFull("/")
191 #define	UNCOMPRESS_COM	"gunzip -c %s > %s"
192 #define	LOUT_EPS	"lout.eps"
193 #else
194 If you're compiling this, you've got the wrong settings in the makefile!
195 #endif
196 #endif
197 #endif
198 
199 /*@::Significant limits@******************************************************/
200 /*                                                                           */
201 /*  Significant Limits (other insignificant ones appear in other files)      */
202 /*                                                                           */
203 /*  MAX_FULL_LENGTH     The maximum value storable in type FULL_LENGTH.      */
204 /*                      NB this cannot be 2**31 - 1 because there are        */
205 /*                      intermediate results that exceed MAX_FULL_LENGTH     */
206 /*                      and are subsequently reduced to MAX_FULL_LENGTH.     */
207 /*                      For example, some intermediate results may exceed    */
208 /*                      MAX_FULL_LENGTH by a factor of SF, which is defined  */
209 /*                      below to be 256 (2**8).  The value given is 2**23-1, */
210 /*                      which is about 148 metres in Lout's precision.       */
211 /*                                                                           */
212 /*  MAX_FILES           The maximum number of files.  This could only be     */
213 /*                      increased if the file_num() field of type FILE_POS   */
214 /*                      is enlarged beyond its present 16 bits.              */
215 /*                                                                           */
216 /*  MAX_LINE            1 + the maximum length of an input line in source    */
217 /*                      and database files.  This is used for the lexical    */
218 /*                      analyser's input line buffer only, and could be      */
219 /*                      increased immediately to 4096, and even further if   */
220 /*                      more than the current 12 bits was assigned to the    */
221 /*                      col_num() field of type FILE_POS.                    */
222 /*                                                                           */
223 /*  MAX_WORD            1 + the maximum length of a word storable in an      */
224 /*                      object record, which includes all file path names    */
225 /*                      too.  It is reasonable to make this MAX_LINE, since  */
226 /*                      a word longer than MAX_LINE cannot be read in.       */
227 /*                                                                           */
228 /*  MAX_OBJECT_REC      1 + the maximum size of an object record, measured   */
229 /*                      in ALIGNs.  The value chosen should exceed           */
230 /*                      ceiling( (wr + MAX_WORD - 4) / sizeof(ALIGN) )       */
231 /*                      where wr = sizeof(struct word_rec), so that words of */
232 /*                      length MAX_WORD-1 can be stored in an object record. */
233 /*                                                                           */
234 /*  MAX_BUFF            1 + the maximum length of a "standard buffer"; these */
235 /*                      buffers are used in a variety of places throughout   */
236 /*                      the program for holding one line of a font file,     */
237 /*                      one file path name, one symbol full name, etc.  This */
238 /*                      may be increased immediately without limit.          */
239 /*                                                                           */
240 /*  MAX_FONT            The maximum number of sized fonts allowed.           */
241 /*                                                                           */
242 /*  MAX_COLOUR          The maximum number of distinct left parameters of    */
243 /*                      @SetColour and @SetColor symbols allowed (after      */
244 /*                      evaluation).                                         */
245 /*                                                                           */
246 /*  MAX_TEXTURE         The maximum number of distinct left parameters of    */
247 /*                      the @SetTexture symbol allowed (after evaluation).   */
248 /*                                                                           */
249 /*  MAX_LANGUAGE        The maximum number of distinct languages allowed.    */
250 /*                      This can be increased beyond 256 only by setting     */
251 /*                      aside a larger word_language() field.                */
252 /*                                                                           */
253 /*  MAX_LEX_STACK       The maximum depth of @Includes and @Databases.  This */
254 /*                      can be increased immediately by any small amount.    */
255 /*                                                                           */
256 /*  MAX_CHARS		The maximimum number of characters in a font.  This  */
257 /*                      cannot be increased easily.                          */
258 /*                                                                           */
259 /*  MAX_HCOPIES         The maximimum number of copies of one running header */
260 /*                      that can appear correctly on one page.  Can be       */
261 /*                      increased to any small positive integer.             */
262 /*                                                                           */
263 /*****************************************************************************/
264 
265 #define	MAX_FULL_LENGTH	8388607	/* 2**23 - 1, about 148 metres */
266 #define	MAX_FILES	65535
267 #define MAX_LINE        2048
268 #define MAX_WORD        2048
269 #define	MAX_OBJECT_REC	ceiling(sizeof(struct word_type)+MAX_WORD,sizeof(ALIGN))
270 #define MAX_BUFF        512
271 #define MAX_FONT	65535
272 #define MAX_COLOUR	65535
273 #define MAX_TEXTURE	65535
274 #define	MAX_LANGUAGE	64
275 #define	MAX_LEX_STACK	20
276 #define	MAX_CHARS	256
277 #define MAX_HCOPIES	3
278 
279 /*****************************************************************************/
280 /*                                                                           */
281 /*  Miscellaneous Macros                                                     */
282 /*                                                                           */
283 /*****************************************************************************/
284 
285 #define	BOOLEAN		unsigned
286 #define	FALSE		0
287 #define	TRUE		1
288 #define	bool(x)		(x ? AsciiToFull("TRUE") : AsciiToFull("FALSE") )
289 #define	CHILD		0
290 #define	PARENT		1
291 #define	COLM		0
292 #define	ROWM		1
293 #define	dimen(x)	(x == COLM ? AsciiToFull("COLM") : AsciiToFull("ROWM") )
294 #define	nilobj		( (OBJECT) NULL )
295 #define	null		( (FILE *) NULL )
296 
297 #define find_max(a, b)	((a) < (b) ? (b) : (a))
298 #define find_min(a, b)	((a) < (b) ? (a) : (b))
299 #define	ceiling(a, b)	( ((a) - 1)/(b) + 1 )	/* ceiling(a/b)              */
300 #define is_odd(x)	( (x) & 1 )		/* TRUE if x is odd number   */
301 
302 /*@::Some straightforward typedefs@*******************************************/
303 /*                                                                           */
304 /*  typedef ALIGN - used for forcing record alignment.                       */
305 /*                                                                           */
306 /*****************************************************************************/
307 
308 typedef char *ALIGN;
309 
310 
311 /*****************************************************************************/
312 /*                                                                           */
313 /*  typedef FULL_LENGTH - an integer physical distance.                      */
314 /*                                                                           */
315 /*****************************************************************************/
316 
317 typedef int FULL_LENGTH;
318 
319 
320 /*****************************************************************************/
321 /*                                                                           */
322 /*  FONT_NUM - internal name for a font.                                     */
323 /*                                                                           */
324 /*****************************************************************************/
325 
326 typedef unsigned short FONT_NUM;
327 
328 
329 /*****************************************************************************/
330 /*                                                                           */
331 /*  COLOUR_NUM - internal name for a colour.                                 */
332 /*                                                                           */
333 /*****************************************************************************/
334 
335 typedef unsigned short COLOUR_NUM;
336 
337 
338 /*****************************************************************************/
339 /*                                                                           */
340 /*  TEXTURE_NUM - internal name for a texture.                               */
341 /*                                                                           */
342 /*****************************************************************************/
343 
344 typedef unsigned short TEXTURE_NUM;
345 
346 
347 /*****************************************************************************/
348 /*                                                                           */
349 /*  LANGUAGE_NUM - internal name for a language.                             */
350 /*                                                                           */
351 /*****************************************************************************/
352 
353 typedef unsigned int LANGUAGE_NUM;
354 
355 
356 /*****************************************************************************/
357 /*                                                                           */
358 /*  MAPPING - internal name for a character mapping vector.                  */
359 /*                                                                           */
360 /*****************************************************************************/
361 
362 typedef unsigned int MAPPING;
363 
364 
365 /*****************************************************************************/
366 /*                                                                           */
367 /*  LINE - a line from a database index file.                                */
368 /*                                                                           */
369 /*****************************************************************************/
370 
371 typedef char *LINE;
372 
373 
374 /*****************************************************************************/
375 /*                                                                           */
376 /*  typedef FULL_CHAR - one of the characters manipulated by Lout.           */
377 /*                                                                           */
378 /*  This program does not deal with 7-bit ASCII characters.  Instead, its    */
379 /*  characters are defined by the FULL_CHAR typedef, and could be anything   */
380 /*  from 7-bit ASCII to 8-bit ISO-LATIN-1 to 16-bit UNICODE and beyond.      */
381 /*                                                                           */
382 /*  Unfortunately C favours signed 8-bit characters: literal strings are     */
383 /*  pointers to them, argv[] and the standard libraries assume them.  We get */
384 /*  around these problems by using our own library, including AsciiToFull()  */
385 /*  to convert an ASCII string (such as a C string) into a FULL_CHAR string. */
386 /*                                                                           */
387 /*  Formally this library appears in module z39.c; however since this        */
388 /*  implementation uses 8-bit unsigned characters, most of the routines      */
389 /*  can be implemented by macros containing type-cast calls to C standard    */
390 /*  library routines.  These appear in the z39.c externs list below.         */
391 /*                                                                           */
392 /*****************************************************************************/
393 
394 typedef unsigned char FULL_CHAR;
395 
396 /*****************************************************************************/
397 /*                                                                           */
398 /*  typedef POINTER- name for type of generic pointer                        */
399 /*                                                                           */
400 /*****************************************************************************/
401 
402 typedef void *POINTER;
403 
404 /*@::Character literals@******************************************************/
405 /*                                                                           */
406 /*  Character Literals                                                       */
407 /*                                                                           */
408 /*  The following macros ensure that no Lout source is ever compared to a    */
409 /*  literal character other than '\0':                                       */
410 /*                                                                           */
411 /*****************************************************************************/
412 
413 #define	CH_FLAG_ALTERR		'a'	/* the -a command line flag          */
414 #define	CH_FLAG_CROSS		'c'	/* the -c command line flag          */
415 #define	CH_FLAG_ENCPATH		'C'	/* the -C command line flag          */
416 #define	CH_FLAG_DEBUG		'd'	/* the -d command line flag          */
417 #define	CH_FLAG_DIRPATH		'D'	/* the -D command line flag          */
418 #define	CH_FLAG_ERRFILE		'e'	/* the -e command line flag          */
419 #define	CH_FLAG_EPSFIRST	'E'	/* first letter of the -EPS flag     */
420 #define	CH_FLAG_FNTPATH		'F'	/* the -F command line flag          */
421 #define	CH_FLAG_HYPHEN		'h'	/* the -h command line flag          */
422 #define	CH_FLAG_HYPPATH		'H'	/* the -H command line flag          */
423 #define	CH_FLAG_INCLUDE		'i'	/* the -i command line flag          */
424 #define	CH_FLAG_INCPATH		'I'	/* the -I command line flag          */
425 #define	CH_FLAG_NOKERN		'k'	/* the -k command line flag          */
426 #define CH_FLAG_NOCOLLATE       'l'     /* the -l command line flag          */
427 #define CH_FLAG_COLLATE         'L'     /* the -L command line flag          */
428 #define CH_FLAG_MEMCHECK        'm'     /* the -m command line flag          */
429 #define	CH_FLAG_MEMCR		'M'	/* the -M command line flag	     */
430 #define	CH_FLAG_OUTFILE		'o'	/* the -o command line flag          */
431 #define	CH_FLAG_PLAIN		'p'	/* the -p command line flag          */
432 #define	CH_FLAG_FFPLAIN		'P'	/* the -P command line flag          */
433 #define	CH_FLAG_RUNS		'r'	/* the -r command line flag          */
434 #define	CH_FLAG_SUPPRESS	's'	/* the -s command line flag          */
435 #define	CH_FLAG_SAFE		'S'	/* the -S command line flag          */
436 #define	CH_FLAG_NOTEXTURE	't'	/* the -t command line flag          */
437 #define	CH_FLAG_USAGE		'u'	/* the -u command line flag          */
438 #define	CH_FLAG_UNSAFE		'U'	/* the -U command line flag          */
439 #define	CH_FLAG_VERSION		'V'	/* the -V command line flag          */
440 #define	CH_FLAG_INITALL		'x'	/* the -x command line flag          */
441 #define	CH_FLAG_OPTION		'-'	/* the -- command line flag          */
442 #define	CH_FLAG_WORDS		'w'	/* the -w command line flag          */
443 #define	CH_FLAG_PDF		'Z'	/* the -Z command line flag	     */
444 
445 #define	CH_SPACE		' '	/* space character                   */
446 /* #define	CH_NEWLINE		'\n'*/ 	/* the newline character     */
447 #define	CH_LF			'\n'	/* the line feed character           */
448 #define	CH_CR			'\r'	/* the carriage return character     */
449 #define	CH_SYMSTART		'@'	/* extra letter symbols may have     */
450 #define	CH_UNDERSCORE		'_'	/* extra letter symbols may have     */
451 #define	CH_QUOTE		'"'	/* the quote character		     */
452 #define	CH_ZERO			'0'	/* the first digit character, zero   */
453 #define	CH_EIGHT		'8'	/* the last even digit character     */
454 #define	CH_NINE			'9'	/* the last odd digit character      */
455 #define	CH_INCGAP		'+'	/* begins an incrementing gap	     */
456 #define	CH_DECGAP		'-'	/* begins a decrementing gap	     */
457 #define	CH_MINUS		'-'	/* minus sign                        */
458 #define	CH_HYPHEN		'-'	/* the hyphen character		     */
459 #define	CH_SLASH		'/'	/* the slash character		     */
460 #define	CH_NOBREAK		'u'	/* `unbreakable' character for gaps  */
461 
462 #define	CH_UNIT_CM		'c'	/* unit of measurement: centimetres  */
463 #define	CH_UNIT_IN		'i'	/* unit of measurement: inches       */
464 #define	CH_UNIT_PT		'p'	/* unit of measurement: points       */
465 #define	CH_UNIT_EM		'm'	/* unit of measurement: ems          */
466 #define	CH_UNIT_FT		'f'	/* unit of measurement: fontsizes    */
467 #define	CH_UNIT_SP		's'	/* unit of measurement: spacewidths  */
468 #define	CH_UNIT_VS		'v'	/* unit of measurement: vspaces      */
469 #define	CH_UNIT_WD		'w'	/* unit of measurement: follwidths   */
470 #define	CH_UNIT_BD		'b'	/* unit of measurement: boundwidths  */
471 #define	CH_UNIT_RL		'r'	/* unit of measurement: relwidths    */
472 #define	CH_UNIT_DG		'd'	/* unit of measurement: degrees      */
473 #define	CH_UNIT_YU		'y'	/* unit of measurement: y unit       */
474 #define	CH_UNIT_ZU		'z'	/* unit of measurement: z unit       */
475 
476 #define	CH_MODE_EDGE		'e'	/* spacing mode: edge-to-edge        */
477 #define	CH_MODE_HYPH		'h'	/* spacing mode: hyphenation         */
478 #define	CH_MODE_MARK		'x'	/* spacing mode: mark-to-mark        */
479 #define	CH_MODE_OVER		'o'	/* spacing mode: overstrike          */
480 #define	CH_MODE_KERN		'k'	/* spacing mode: kerning             */
481 #define	CH_MODE_TABL		't'	/* spacing mode: tabulation          */
482 
483 #define octaldigit(ch)		( (ch) >= '0' && (ch) <= '7' )
484 #define decimaldigit(ch)	( (ch) >= '0' && (ch) <= '9' )
485 #define	digitchartonum(ch)	( (ch) - '0' )
486 #define	numtodigitchar(ch)	( (ch) + '0' )
487 #define	beginsbreakstyle(ch)	( (ch) >= 'a' && (ch) <= 'z' )
488 #define	numericchar(ch)		( decimaldigit(ch) || (ch) == '.' )
489 
490 
491 /*@::String literals, FULL_CHAR type@*****************************************/
492 /*                                                                           */
493 /*  String Literals.                                                         */
494 /*                                                                           */
495 /*  All significant string literals are defined here.  The program has many  */
496 /*  others, however: format strings, debug output, etc.                      */
497 /*                                                                           */
498 /*****************************************************************************/
499 
500 #define	STR_EMPTY		AsciiToFull("")
501 #define	STR_QUOTE		AsciiToFull("\"")
502 #define	STR_ESCAPE		AsciiToFull("\\")
503 #define	STR_COMMENT		AsciiToFull("#")
504 #define	STR_SPACE		AsciiToFull(" ")
505 #define	STR_FORMFEED		AsciiToFull("\f")
506 #define	STR_TAB			AsciiToFull("\t")
507 #define	STR_LETTERS_LOWER	AsciiToFull("abcdefghijklmnopqrstuvwxyz")
508 #define	STR_LETTERS_UPPER	AsciiToFull("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
509 #define	STR_LETTERS_SYMSTART	AsciiToFull("@")
510 #define	STR_LETTERS_UNDERSCORE	AsciiToFull("_")
511 
512 #if CHAR_IN==0
513 #define	STR_LETTERS_EXTRA0	AsciiToFull("")
514 #define	STR_LETTERS_EXTRA1	AsciiToFull("")
515 #define	STR_LETTERS_EXTRA2	AsciiToFull("")
516 #define	STR_LETTERS_EXTRA3	AsciiToFull("")
517 #define	STR_LETTERS_EXTRA4	AsciiToFull("")
518 #define	STR_LETTERS_EXTRA5	AsciiToFull("")
519 #define	STR_LETTERS_EXTRA6	AsciiToFull("")
520 #define	STR_LETTERS_EXTRA7	AsciiToFull("")
521 #else
522 #define	STR_LETTERS_EXTRA0	AsciiToFull("\300\301\302\303\304\305\306\307")
523 #define	STR_LETTERS_EXTRA1	AsciiToFull("\310\311\312\313\314\315\316\317")
524 #define	STR_LETTERS_EXTRA2	AsciiToFull("\320\321\322\323\324\325\326")
525 #define	STR_LETTERS_EXTRA3	AsciiToFull("\330\331\332\333\334\335\336\337")
526 #define	STR_LETTERS_EXTRA4	AsciiToFull("\340\341\342\343\344\345\346\347")
527 #define	STR_LETTERS_EXTRA5	AsciiToFull("\350\351\352\353\354\355\356\357")
528 #define	STR_LETTERS_EXTRA6	AsciiToFull("\360\361\362\363\364\365\366")
529 #define	STR_LETTERS_EXTRA7	AsciiToFull("\370\371\372\373\374\375\376\377")
530 #endif
531 
532 #define	STR_STDIN		AsciiToFull("-")
533 #define	STR_STDOUT		AsciiToFull("-")
534 #define	STR_HYPHEN		AsciiToFull("-")
535 #define	STR_EPS			AsciiToFull("EPS")
536 #define	STR_POSTSCRIPT		AsciiToFull("PostScript")
537 #define	STR_PLAINTEXT		AsciiToFull("PlainText")
538 #define	STR_PDF			AsciiToFull("PDF")
539 #define	STR_ELSE		AsciiToFull("else")
540 #define	STR_NOCROSS		AsciiToFull("??")
541 #define	STR_BADKEY		AsciiToFull("badkey")
542 #define	STR_NONE		AsciiToFull("none")
543 #define	STR_NOCHAR		AsciiToFull("-none-")
544 #define	STR_ZERO		AsciiToFull("0")
545 #define	STR_PS_SPACENAME	AsciiToFull("space")
546 #define	STR_FONT_RECODE		AsciiToFull("Recode")
547 #define	STR_FONT_NORECODE	AsciiToFull("NoRecode")
548 #define	STR_COLOUR_NOCHANGE	AsciiToFull("nochange")
549 #define	STR_TEXTURE_NOCHANGE	AsciiToFull("nochange")
550 
551 #define	STR_BREAK_HYPHEN	AsciiToFull("hyphen")
552 #define	STR_BREAK_NOHYPHEN	AsciiToFull("nohyphen")
553 #define	STR_BREAK_ADJUST	AsciiToFull("adjust")
554 #define	STR_BREAK_OUTDENT	AsciiToFull("outdent")
555 #define	STR_BREAK_RAGGED	AsciiToFull("ragged")
556 #define	STR_BREAK_CRAGGED	AsciiToFull("cragged")
557 #define	STR_BREAK_RRAGGED	AsciiToFull("rragged")
558 #define	STR_BREAK_ORAGGED	AsciiToFull("oragged")
559 #define	STR_BREAK_LINES		AsciiToFull("lines")
560 #define	STR_BREAK_CLINES	AsciiToFull("clines")
561 #define	STR_BREAK_RLINES	AsciiToFull("rlines")
562 #define	STR_BREAK_OLINES	AsciiToFull("olines")
563 #define	STR_BREAK_SCALE		AsciiToFull("blanklinescale")
564 #define	STR_BREAK_NOFIRST	AsciiToFull("unbreakablefirst")
565 #define	STR_BREAK_FIRST		AsciiToFull("breakablefirst")
566 #define	STR_BREAK_NOLAST	AsciiToFull("unbreakablelast")
567 #define	STR_BREAK_LAST		AsciiToFull("breakablelast")
568 #define	STR_BREAK_SETOUTDENT	AsciiToFull("setoutdent")
569 #define STR_BREAK_MARGINKERNING AsciiToFull("marginkerning")
570 #define STR_BREAK_NOMARGINKERNING AsciiToFull("nomarginkerning")
571 
572 #define STR_SPACE_LOUT		AsciiToFull("lout")
573 #define STR_SPACE_COMPRESS	AsciiToFull("compress")
574 #define STR_SPACE_SEPARATE	AsciiToFull("separate")
575 #define STR_SPACE_TROFF		AsciiToFull("troff")
576 #define STR_SPACE_TEX		AsciiToFull("tex")
577 
578 #define	STR_SMALL_CAPS_ON	AsciiToFull("smallcaps")
579 #define	STR_SMALL_CAPS_OFF	AsciiToFull("nosmallcaps")
580 #define	STR_SMALL_CAPS_SET	AsciiToFull("setsmallcaps")
581 #define	STR_BASELINE_MARK	AsciiToFull("baselinemark")
582 #define	STR_LIG			AsciiToFull("lig")
583 #define	STR_NOLIG		AsciiToFull("nolig")
584 #define	STR_XHEIGHT2_MARK	AsciiToFull("xheight2mark")
585 #define	STR_NOSTRUT		AsciiToFull("nostrut")
586 #define	STR_STRUT		AsciiToFull("strut")
587 
588 #define	STR_GAP_RJUSTIFY	AsciiToFull("1rt")
589 #define	STR_GAP_ZERO_HYPH	AsciiToFull("0ch")
590 
591 #define	STR_SCALE_DOWN		AsciiToFull("downifneeded")
592 
593 
594 /*@::GAP, STYLE@**************************************************************/
595 /*                                                                           */
596 /*  typedef GAP - what separates one object from another.                    */
597 /*                                                                           */
598 /*****************************************************************************/
599 
600 typedef struct
601 { FULL_LENGTH	owidth;			/* width of the gap                  */
602   BOOLEAN	onobreak : 1;		/* TRUE if this gap is unbreakable   */
603   BOOLEAN	omark	 : 1;		/* TRUE if this gap is marked        */
604   BOOLEAN	ojoin	 : 1;		/* TRUE if joins exist across gap    */
605   unsigned	ounits	 : 3;		/* units of measurement: fixed, etc  */
606   unsigned	omode	 : 3;		/* spacing mode: edge-to-edge, etc   */
607 } GAP;
608 
609 #define	nobreak(x)	(x).onobreak
610 #define	mark(x)		(x).omark
611 #define	join(x)		(x).ojoin
612 #define	units(x)	(x).ounits
613 #define	mode(x)		(x).omode
614 #define	width(x)	(x).owidth
615 
616 #define SetGap(x, xnobreak, xmark, xjoin, xunits, xmode, xwidth)	\
617 ( nobreak(x) = xnobreak, mark(x) = xmark, join(x) = xjoin,		\
618   units(x) = xunits, mode(x) = xmode, width(x) = xwidth			\
619 )
620 
621 #define GapCopy(x, y)							\
622 ( nobreak(x) = nobreak(y), mark(x) = mark(y), join(x) = join(y),	\
623   units(x) = units(y), mode(x) = mode(y), width(x) = width(y)		\
624 )
625 
626 #define GapEqual(x, y)							\
627 ( nobreak(x) == nobreak(y) && mark(x) == mark(y) && join(x) == join(y)	\
628   && units(x) == units(y) && mode(x) == mode(y) && width(x) == width(y)	\
629 )
630 
631 #define ClearGap(x)	SetGap(x, FALSE, FALSE, TRUE, FIXED_UNIT, NO_MODE, 0)
632 
633 
634 /*****************************************************************************/
635 /*                                                                           */
636 /*  typedef STYLE - information about how to break text, etc.                */
637 /*                                                                           */
638 /*****************************************************************************/
639 
640 /* A key-value pair.  */
641 typedef struct context_type
642 {
643   union rec	    *okey;		/* name of a context variable        */
644   union rec	    *ovalue;		/* associated value		     */
645   union rec         *oenv;		/* environment for this value        */
646   struct style_type *ostyle;		/* style for this value              */
647 } CONTEXT;
648 
649 #define	context_key(x)		(x).okey
650 #define	context_value(x)	(x).ovalue
651 #define	context_env(x)		(x).oenv
652 #define	context_style(x)	(x).ostyle
653 
654 typedef struct style_type
655 {
656   GAP		oline_gap;		/* separation between lines          */
657   GAP		ospace_gap;		/* separation induced by white space */
658   FULL_LENGTH	oyunit;			/* value of y unit of measurement    */
659   FULL_LENGTH	ozunit;			/* value of z unit of measurement    */
660   FULL_LENGTH	ooutdent_len;		/* amount to outdent in outdent style*/
661   FULL_LENGTH	osmallcaps_len;		/* size of small capitals            */
662   FONT_NUM	ofont;			/* current font                      */
663   COLOUR_NUM	ocolour;		/* current colour		     */
664   COLOUR_NUM	ounderline_colour;	/* current underline colour	     */
665   TEXTURE_NUM	otexture;		/* current texture		     */
666   unsigned short oblanklinescale;	/* scale factor for blank lines      */
667   LANGUAGE_NUM	olanguage       : 6;	/* current language		     */
668   BOOLEAN	ovadjust	: 1;	/* @VAdjust in effect                */
669   BOOLEAN	ohadjust	: 1;	/* @HAdjust in effect                */
670   BOOLEAN	opadjust	: 1;	/* @PAdjust in effect                */
671   unsigned	osmall_caps	: 1;	/* small capitals                    */
672   unsigned	ospace_style	: 3;	/* space style: lout, troff, tex, .. */
673   unsigned	ohyph_style	: 2;	/* hyphenation off or on             */
674   unsigned	ofill_style	: 2;	/* fill lines with text off/on       */
675   unsigned	odisplay_style	: 3;	/* display lines adjusted, ragged... */
676   BOOLEAN	ooutline	: 2;	/* TRUE if outlining words           */
677   BOOLEAN	onobreakfirst	: 1;	/* no break after first line of para */
678   BOOLEAN	onobreaklast	: 1;	/* no break after last line of para  */
679   BOOLEAN	obaselinemark	: 1;	/* baseline char metrics             */
680   BOOLEAN	ostrut		: 1;	/* strut char metrics                */
681   BOOLEAN	oligatures	: 1;	/* use ligatures                     */
682   BOOLEAN	omarginkerning	: 1;	/* perform margin kerning            */
683   CONTEXT	ocontext;		/* context stack		     */
684 } STYLE;
685 
686 #define	line_gap(x)	(x).oline_gap
687 #define	space_gap(x)	(x).ospace_gap
688 #define	yunit(x)	(x).oyunit
689 #define	zunit(x)	(x).ozunit
690 #define	outdent_len(x)	(x).ooutdent_len
691 #define	smallcaps_len(x)(x).osmallcaps_len
692 #define	font(x)		(x).ofont
693 #define	colour(x)	(x).ocolour
694 #define	underline_colour(x) (x).ounderline_colour
695 #define	texture(x)	(x).otexture
696 #define	blanklinescale(x)(x).oblanklinescale
697 #define	language(x)	(x).olanguage
698 #define	vadjust(x)	(x).ovadjust
699 #define	hadjust(x)	(x).ohadjust
700 #define	padjust(x)	(x).opadjust
701 #define	small_caps(x)	(x).osmall_caps
702 #define	space_style(x)	(x).ospace_style
703 #define	hyph_style(x)	(x).ohyph_style
704 #define	fill_style(x)	(x).ofill_style
705 #define	display_style(x)(x).odisplay_style
706 #define	outline(x)	(x).ooutline
707 #define	nobreakfirst(x)	(x).onobreakfirst
708 #define	nobreaklast(x)	(x).onobreaklast
709 #define	baselinemark(x)	(x).obaselinemark
710 #define	strut(x)	(x).ostrut
711 #define	ligatures(x)	(x).oligatures
712 #define	marginkerning(x)(x).omarginkerning
713 #define	context(x)	(x).ocontext
714 
715 #define StyleCopy(x, y)							\
716 ( GapCopy(line_gap(x), line_gap(y)),					\
717   GapCopy(space_gap(x), space_gap(y)),					\
718   yunit(x) = yunit(y),							\
719   zunit(x) = zunit(y),							\
720   outdent_len(x) = outdent_len(y),					\
721   smallcaps_len(x) = smallcaps_len(y),					\
722   font(x) = font(y),							\
723   colour(x) = colour(y),						\
724   underline_colour(x) = underline_colour(y),				\
725   texture(x) = texture(y),						\
726   blanklinescale(x) = blanklinescale(y),				\
727   language(x) = language(y), 						\
728   vadjust(x) = vadjust(y), 						\
729   hadjust(x) = hadjust(y), 						\
730   padjust(x) = padjust(y), 						\
731   small_caps(x) = small_caps(y),					\
732   space_style(x) = space_style(y),					\
733   hyph_style(x) = hyph_style(y),					\
734   fill_style(x) = fill_style(y),					\
735   display_style(x) = display_style(y),					\
736   outline(x) = outline(y),						\
737   nobreakfirst(x) = nobreakfirst(y),					\
738   nobreaklast(x) = nobreaklast(y),					\
739   baselinemark(x) = baselinemark(y),					\
740   strut(x) = strut(y),							\
741   ligatures(x) = ligatures(y),						\
742   marginkerning(x) = marginkerning(y),					\
743   context(x) = context(y)						\
744 )
745 
746 
747 /*@::CONSTRAINT, FILE_NUM, FILE_POS, LIST@************************************/
748 /*                                                                           */
749 /*  typedef CONSTRAINT - a size constraint.                                  */
750 /*                                                                           */
751 /*****************************************************************************/
752 
753 typedef struct
754 { FULL_LENGTH  obc;
755   FULL_LENGTH  obfc;
756   FULL_LENGTH  ofc;
757   FULL_LENGTH  osparec;
758 } CONSTRAINT;
759 
760 #define	bc(x)		(x).obc
761 #define	bfc(x)		(x).obfc
762 #define	fc(x)		(x).ofc
763 #define	sparec(x)	(x).osparec
764 #define	constrained(x)	(bc(x) != MAX_FULL_LENGTH ||			\
765 			 bfc(x) != MAX_FULL_LENGTH || fc(x) != MAX_FULL_LENGTH)
766 
767 #define	SetConstraint(c,x,y,z)	(bc(c) = (x),   bfc(c) = (y),    fc(c) = (z))
768 #define	CopyConstraint(x, y)	(bc(x) = bc(y), bfc(x) = bfc(y), fc(x) = fc(y))
769 #define	FlipConstraint(x, y)	(bc(x) = fc(y), bfc(x) = bfc(y), fc(x) = bc(y))
770 #define FitsConstraint(b, f, c)	(b <= bc(c)  && b + f <= bfc(c) && f <= fc(c))
771 #define EqualConstraint(a, b) (bc(a)==bc(b) && bfc(a)==bfc(b) && fc(a)==fc(b) )
772 
773 #define	ig_fnum(x)	bc(constraint(x))
774 #define	ig_xtrans(x)	bfc(constraint(x))
775 #define	ig_ytrans(x)	fc(constraint(x))
776 
777 
778 /*****************************************************************************/
779 /*                                                                           */
780 /*  typedef FILE_NUM - the internal representation of a file.                */
781 /*                                                                           */
782 /*****************************************************************************/
783 
784 typedef unsigned short	FILE_NUM;
785 #define	NO_FILE		0
786 
787 
788 /*****************************************************************************/
789 /*                                                                           */
790 /*  typedef FILE_POS - a position in the set of input files.                 */
791 /*                                                                           */
792 /*****************************************************************************/
793 
794 typedef	struct
795 { unsigned char	 otype;			/* space for object type field	     */
796   unsigned char	 orec_size;		/* space for object record size      */
797   FILE_NUM	 ofile_num;		/* no. of file this record is from   */
798   unsigned       oline_num  : 20;	/* the line number of this record    */
799   unsigned       ocol_num   : 12;	/* column number this is related to  */
800 } FILE_POS;
801 
802 #define	file_num(x)	(x).ofile_num
803 #define	col_num(x)	(x).ocol_num
804 #define	line_num(x)	(x).oline_num
805 
806 #define FposCopy(x, y)							\
807 ( file_num(x) = file_num(y),						\
808   line_num(x) = line_num(y),						\
809   col_num(x)  = col_num(y)						\
810 )
811 
812 
813 /*****************************************************************************/
814 /*                                                                           */
815 /*  typedef LIST - two pointers used to make one doubly linked list          */
816 /*                                                                           */
817 /*****************************************************************************/
818 
819 typedef struct { union rec *opred, *osucc; } LIST;
820 
821 
822 /*@::FIRST_UNION@*************************************************************/
823 /*                                                                           */
824 /*  typedef FIRST_UNION - first eight bytes of object record (after LISTs).  */
825 /*                                                                           */
826 /*  The fpos is overwritten in WORDs and QWORDs during FixAndPrintObject by  */
827 /*  the horizontal coordinate of the word, which has to be remembered.       */
828 /*  This part of the record is also used by font records to hold font        */
829 /*  bounding box data.                                                       */
830 /*                                                                           */
831 /*****************************************************************************/
832 
833 typedef union
834 {
835   FILE_POS	ofpos;
836   struct
837   {	unsigned char	otype, orec_size;
838 	int		oword_save_mark;
839   } os11;
840 
841 } FIRST_UNION;
842 
843 
844 /*@::SECOND_UNION, THIRD_UNION, FOURTH_UNION@*********************************/
845 /*                                                                           */
846 /*  typedef SECOND_UNION - twelve bytes holding various flags etc.           */
847 /*                                                                           */
848 /*****************************************************************************/
849 
850 typedef union
851 {
852   struct /* used by all tokens */
853   {	unsigned char	oprecedence;
854 	unsigned char	ohspace, ovspace;
855   } os21;
856 
857   struct /* used by WORD objects only, except underline used by all */
858 	 /* objects, including GAP_OBJ                              */
859   {	FONT_NUM	oword_font;
860 	COLOUR_NUM	oword_colour;
861 	COLOUR_NUM	oword_underline_colour;
862 	TEXTURE_NUM	oword_texture;
863 	unsigned	ounderline	   : 2; /* aligns with os23.underline */
864 	BOOLEAN		oword_outline	   : 1;
865 	LANGUAGE_NUM	oword_language	   : 6;
866 	BOOLEAN		oword_baselinemark : 1;
867 	BOOLEAN		oword_strut	   : 1;
868 	BOOLEAN		oword_ligatures	   : 1;
869 	unsigned	oword_hyph	   : 1;
870   } os22;
871 
872   struct /* used by non-WORD objects */
873   {	unsigned short	ofoll_or_prec;
874 	unsigned short	ocross_type;	     /* CROSS objects only */
875 	unsigned short  ounused_os23_a;
876 	unsigned short  ounused_os23_b;
877 	unsigned	ounderline   : 2;    /* aligns with os22.underline */
878 	BOOLEAN		onon_blocking: 1;
879 	BOOLEAN		osized       : 1;
880 	BOOLEAN		othreaded    : 1;
881 	BOOLEAN		oexternal_hor: 1;
882 	BOOLEAN		oexternal_ver: 1;
883 	BOOLEAN		oblocked     : 1;
884 	BOOLEAN		otrigger_ext : 1;
885 	BOOLEAN	        omust_expand : 1;
886 	BOOLEAN		ogall_dir    : 1;
887 	BOOLEAN		oopt_hyph    : 1;
888 	BOOLEAN		oopt_gazumped: 1;
889 	BOOLEAN		oadjust_cat  : 1;
890 	BOOLEAN		oforce_gall  : 1;
891 	/* don't forget ounderline from os22 applies in this union! */
892   } os23;
893 
894   struct /* used by WORD and QWORD when they are database nodes */
895   {	unsigned short	oleft_pos;
896 	unsigned char	oreading;
897 	unsigned char	oin_memory;
898   } os24;
899 
900   struct /* used by WORD and QWORD when they are font records */
901   {
902     	FULL_LENGTH	ofont_bbox_lly;
903     	FULL_LENGTH	ofont_bbox_ury;
904   } os25;
905 
906   struct /* used by symbol table entries */
907   {	unsigned char	oprecedence;
908 	BOOLEAN		ois_tag		     : 1;
909 	BOOLEAN		ohas_tag             : 1;
910 	BOOLEAN		ohas_lpar            : 1;
911 	BOOLEAN		ohas_rpar            : 1;
912 	BOOLEAN		oright_assoc         : 1;
913 	BOOLEAN		ois_target           : 1;
914 	BOOLEAN		ohas_target          : 1;
915 	BOOLEAN		oforce_target	     : 1;
916 	BOOLEAN		ohas_body            : 1;
917 	BOOLEAN		oindefinite          : 1;
918 	BOOLEAN		orecursive           : 1;
919 	BOOLEAN		ouses_extern_target  : 1;
920 	BOOLEAN		ois_extern_target    : 1;
921 	BOOLEAN		ois_key		     : 1;
922 	BOOLEAN		ohas_key	     : 1;
923 	BOOLEAN		odirty               : 1;
924 	BOOLEAN		ovisible	     : 1;
925 	BOOLEAN		ohas_mark	     : 1;
926 	BOOLEAN		ohas_join	     : 1;
927 	BOOLEAN		ohas_par             : 1;
928 	BOOLEAN		ouses_galley	     : 1;
929 	BOOLEAN		ohoriz_galley	     : 1;
930 	BOOLEAN		oimports_encl	     : 1;
931   } os26;
932 
933 } SECOND_UNION;
934 
935 
936 /*****************************************************************************/
937 /*                                                                           */
938 /*  typedef THIRD_UNION - sixteen bytes usually holding an object size.      */
939 /*                                                                           */
940 /*  In database records this space is used for a file pointer, or a pointer  */
941 /*  to a LINE array if the database is in-memory; in certain                 */
942 /*  WORD objects used privately in z10.c it is used for a galley-position.   */
943 /*  In font records it holds the font size, space width, etc.  In filter     */
944 /*  words it holds a pointer to the symbol being filtered.                   */
945 /*                                                                           */
946 /*****************************************************************************/
947 
948 typedef union
949 {
950   struct
951   {	FULL_LENGTH	oback[2];
952 	FULL_LENGTH	ofwd[2];
953   } os31;
954 
955   FILE *odb_filep;
956   LINE *odb_lines;
957 
958   struct
959   {	FULL_LENGTH	ofont_size;
960 	FULL_LENGTH	ofont_xheight2;
961 	FULL_LENGTH	ofont_spacewidth;
962     	FONT_NUM	ofont_num;
963 	unsigned short	ofont_page;
964 	MAPPING		ofont_mapping	: 7;
965 	BOOLEAN		ofont_recoded	: 1;
966   } os32;
967 
968   struct
969   {	unsigned char	ocs_type;
970 	FILE_NUM	ocs_fnum;
971 	int		ocs_pos;
972 	int		ocs_lnum;
973   } os33;
974 
975   struct /* words used as file definitions */
976   {
977 	unsigned int	oline_count;
978 	unsigned short	ofile_number;
979 	unsigned char	otype_of_file;
980 	unsigned char	oused_suffix;
981 	unsigned char	oupdated;
982 	unsigned char	opath;
983   } os34;
984 
985   union rec *ofilter_actual;
986 
987 } THIRD_UNION;
988 
989 
990 /*****************************************************************************/
991 /*                                                                           */
992 /*  typedef FOURTH_UNION - 11 32-bit words holding a STYLE or CONSTRAINT.    */
993 /*                                                                           */
994 /*****************************************************************************/
995 
996 typedef union
997 {
998   STYLE		osave_style;
999   CONSTRAINT	oconstraint;
1000 
1001 } FOURTH_UNION;
1002 
1003 
1004 /*@::OBJECT@******************************************************************/
1005 /*                                                                           */
1006 /*  typedef OBJECT - the general-purpose record used throughout Lout.        */
1007 /*                                                                           */
1008 /*  This record is a complex union type.  Which fields are defined in any    */
1009 /*  given record depends on its type() tag field, as follows.  But first     */
1010 /*  we define some collections of fields that are commonly defined together. */
1011 /*                                                                           */
1012 /*  ALL - these fields are defined in all objects.  They won't be mentioned  */
1013 /*        again, but they are always there.                                  */
1014 /*                                                                           */
1015 /*      type            Tag field for the record                             */
1016 /*      rec_size        Size of this record, in words (for memory allocator) */
1017 /*      succ            Next element on list of parents, children            */
1018 /*      pred            Previous element on list of parents, children        */
1019 /*      fpos            Position in input file which gave rise to this       */
1020 /*                      object (could be null; overwritten by word_save_mark */
1021 /*                      locally in FixAndPrintOjbect).  It sub-fields are:   */
1022 /*                                                                           */
1023 /*                          file_num   internal file number                  */
1024 /*                          line_num   line number in that file              */
1025 /*                          col_num    column number on that line            */
1026 /*                                                                           */
1027 /*                      Lout attempts to put a meaningful fpos into every    */
1028 /*                      object, so that error messages related to that       */
1029 /*                      object can have meaningful line numbers.  This has   */
1030 /*                      not been done in every case; it ought to be.         */
1031 /*                                                                           */
1032 /*  TOKEN - these fields are defined for all objects that are input tokens.  */
1033 /*          They may be overwritten after parsing is completed.              */
1034 /*                                                                           */
1035 /*      precedence      Precedence of this token (0 if has no parameters)    */
1036 /*      hspace          Horizontal space preceding this token                */
1037 /*      vspace          Vertical space preceding this token                  */
1038 /*                                                                           */
1039 /*  SIZED - these fields are defined for all objects that represent Lout     */
1040 /*          objects and hence have a horizontal and vertical size.  They     */
1041 /*          will be undefined until after MinSize() is called on the object, */
1042 /*          and defined thereafter.                                          */
1043 /*                                                                           */
1044 /*      back[COLM]      Horizontal size to left of object's mark             */
1045 /*      fwd[COLM]       Horizontal size to right of object's mark            */
1046 /*      back[ROWM]      Vertical size above object's mark                    */
1047 /*      fwd[ROWM]       Vertical size below object's mark                    */
1048 /*                                                                           */
1049 /*  GAP - a gap between two Lout objects.                                    */
1050 /*                                                                           */
1051 /*      nobreak         TRUE if gap is unbreakable (has u tag)               */
1052 /*      mark            TRUE if gap is marked (has ^ tag)                    */
1053 /*      join            TRUE if a mark-joining gap (e.g. | not ||)           */
1054 /*      units           units of measurement (fixed, or r or d etc)          */
1055 /*      mode            gap mode (mark-to-mark, etc.)                        */
1056 /*      width           width of gap in the given units                      */
1057 /*                                                                           */
1058 /*  STYLE - the style (attributes affecting the appearance) of an object.    */
1059 /*                                                                           */
1060 /*      line_gap        separation between lines                             */
1061 /*      space_gap       separation induced by white space                    */
1062 /*      yunit           value of y unit of measurement                       */
1063 /*      zunit           value of z unit of measurement                       */
1064 /*      outdent_len     amount to outdent in outdent style                   */
1065 /*      smallcaps_len   size of small capitals                               */
1066 /*      font            current font                                         */
1067 /*      colour          current colour		                             */
1068 /*      texture         current texture		                             */
1069 /*      blanklinescale  scale factor for blank lines                         */
1070 /*      language        current language		                     */
1071 /*      vadjust	        @VAdjust in effect                                   */
1072 /*      hadjust	        @HAdjust in effect                                   */
1073 /*      padjust	        @PAdjust in effect                                   */
1074 /*      small_caps	small capitals                                       */
1075 /*      space_style	space style: lout, troff, tex, ..                    */
1076 /*      hyph_style	hyphenation off or on                                */
1077 /*      fill_style	fill lines with text off/on                          */
1078 /*      display_style	display lines adjusted, ragged...                    */
1079 /*      outline	: 2     TRUE if outlining words                              */
1080 /*      nobreakfirst	no break after first line of para                    */
1081 /*      nobreaklast	no break after last line of para                     */
1082 /*      baselinemark	baseline char metrics                                */
1083 /*      strut       	strut char metrics                                   */
1084 /*      ligatures	use ligatures                                        */
1085 /*      marginkerning	perform margin kerning                               */
1086 /*                                                                           */
1087 /*  CONSTRAINT - a constraint on how large some object is allowed to be,     */
1088 /*               either horizontally or vertically                           */
1089 /*                                                                           */
1090 /*      bc              how large back may be (MAX_FULL_LEN if infinite)     */
1091 /*      fc              how large fwd may be (MAX_FULL_LEN if infinite)      */
1092 /*      bfc             how large back + fwd may be (MAX_FULL_LEN if inf.)   */
1093 /*                                                                           */
1094 /*                                                                           */
1095 /*  Here now is the list of all object types, what they represent, and       */
1096 /*  what fields they contain.  The list also indicates what children each    */
1097 /*  object of the given type can expect to have.                             */
1098 /*                                                                           */
1099 /*  LINK - one link in the directed acyclic graph which is Lout's universal  */
1100 /*         internal data structure.  All the other types below are various   */
1101 /*         types of nodes.  Has ALL only (and no fpos) except see CROSS_SYM  */
1102 /*                                                                           */
1103 /*  GAP_OBJ - a gap between two Lout objects                                 */
1104 /*                                                                           */
1105 /*      gap             The gap itself (type GAP)                            */
1106 /*      underline       TRUE if continuous underlining crosses this gap      */
1107 /*      save_*          These fields used by optimum paragraph breaker only  */
1108 /*      first child     If the gap is not just white space, the gap object   */
1109 /*                                                                           */
1110 /*  CLOSURE - an invocation of a user-defined symbol, not yet expanded       */
1111 /*                                                                           */
1112 /*      TOKEN           While still being parsed                             */
1113 /*      SIZED           After sizing if indefinite (the sizes will be zero)  */
1114 /*      save_style      Style to print this invocation in when expanded      */
1115 /*      actual          The symbol table record defining this symbol         */
1116 /*      threaded        TRUE if symbol lies on a vertical thread             */
1117 /*      external_ver    TRUE if symbol is external in a vertical galley      */
1118 /*      external_hor    TRUE if symbol is external in a horizontal galley    */
1119 /*      children        PAR objects whose children are the actual parameters */
1120 /*                                                                           */
1121 /*  UNDER_REC - a temporary object inserted by FixAndPrintObject to help     */
1122 /*              with working out continuous underlining                      */
1123 /*                                                                           */
1124 /*      back(COLM)      Horizontal position of start of underline            */
1125 /*      fwd(COLM)       Horizontal position of end of underline              */
1126 /*      word_font       Font determining underline appearance                */
1127 /*      word_underline_colour  The colour of the underline                   */
1128 /*      word_texture    The texture of the underline                         */
1129 /*                                                                           */
1130 /*  PAGE_LABEL - a @PageLabel object                                         */
1131 /*                                                                           */
1132 /*      TOKEN           While still being parsed                             */
1133 /*      SIZED           Indefinite, so all sizes will be zero                */
1134 /*      first child     The parameter of the @PageLabel object               */
1135 /*                                                                           */
1136 /*  NULL_CLOS - a @Null object                                               */
1137 /*                                                                           */
1138 /*      TOKEN           While still being parsed                             */
1139 /*      SIZED           Indefinite, so all sizes will be zero                */
1140 /*                                                                           */
1141 /*  CROSS, FORCE_CROSS - a cross reference (or forcing cross reference) obj  */
1142 /*                                                                           */
1143 /*      TOKEN           While still being parsed                             */
1144 /*      SIZED           Indefinite, so all sizes will be zero                */
1145 /*      cross_type      Type of cross reference (preceding, following, etc.) */
1146 /*      children        The two parameters of the cross reference            */
1147 /*                                                                           */
1148 /*  HEAD - the header record for a galley invocation                         */
1149 /*                                                                           */
1150 /*      force_gall      TRUE if this is a forcing galley (i.e. "force into") */
1151 /*      actual          The symbol table record defining this galley         */
1152 /*      enclose_obj     If galley has @Enclose, the enclose object           */
1153 /*      limiter         Helps decide whether to break off or scale if stuck  */
1154 /*      opt_components  If optimizing, the sequence of components            */
1155 /*      opt_constraints If optimizing, the sequence of size constraints      */
1156 /*      opt_counts      If optimizing, the sequence of numbers of components */
1157 /*                      In each child of opt_counts, comp_count has the num  */
1158 /*      opt_comps_permitted number of components left before opt break       */
1159 /*      opt_hyph        If optimizing, whether to hyphenate the galley       */
1160 /*      opt_gazumped    If optimizing, galley has been gazumped recently     */
1161 /*      gall_dir        Promotion direction (COLM for horizontal galleys)    */
1162 /*      ready_galls     Galleys read in from cross reference database        */
1163 /*      must_expand     TRUE if must expand galley object even if indefinite */
1164 /*      sized           TRUE after galley object has been sized              */
1165 /*      foll_or_prec    Direction of search for target (forward, back, etc.) */
1166 /*      whereto         Symbol this galley is targeted at                    */
1167 /*      seen_nojoin     TRUE if // op found within galley anywhere           */
1168 /*      headers[i]      each either nilobj or an ACAT of header components   */
1169 /*      head_next       which header[i] we will use next.                    */
1170 /*                                                                           */
1171 /*  SPLIT - a split object, used for building tables                         */
1172 /*                                                                           */
1173 /*      SIZED           The size of the whole object                         */
1174 /*      first child     An object whose horizontal size is the overall size  */
1175 /*      second child    An object whose vertical size is the overall size    */
1176 /*                                                                           */
1177 /*  PAR - actual parameter of a symbol invocation (always child of CLOSURE)  */
1178 /*                                                                           */
1179 /*      TOKEN           While still being parsed                             */
1180 /*      actual          The symbol table record defining this parameter      */
1181 /*      first child     A Lout object, the value of this parameter           */
1182 /*                                                                           */
1183 /*  WORD, QWORD - a literal word, or a literal word entered in quotes ""     */
1184 /*                                                                           */
1185 /*      TOKEN           While still being parsed                             */
1186 /*      SIZED           The size of the word                                 */
1187 /*      word_font       Font to print this word in (from style)              */
1188 /*      word_colour     Colour to print this word in (from style)            */
1189 /*      word_underline_colour  Colour to print underlines in (from style)    */
1190 /*      word_texture    texture to print this word in (from style)           */
1191 /*      word_outline    If TRUE, print this word in outline (from style)     */
1192 /*      word_language   Language (for hyphenation) of this word (from style) */
1193 /*      word_baselinemark TRUE if mark of this word goes through baseline    */
1194 /*      word_strut      TRUE if this word's char metrics are to be strutted  */
1195 /*      word_ligatures  TRUE if ligatures wanted in this word                */
1196 /*      underline       TRUE if continuous underlining goes under this word  */
1197 /*      word_hyph       Hyphenation wanted for this word (from style)        */
1198 /*      word_save_mark  Coord of column mark, temporarily in FixAndPrint     */
1199 /*      string[]        The characters of the word, null-terminated          */
1200 /*                                                                           */
1201 /*  WORD, QWORD when used as database header records                         */
1202 /*                                                                           */
1203 /*      string[]        Database index file name                             */
1204 /*      reading         TRUE if this database can be read from               */
1205 /*      in_memory       TRUE if this database's index is held in memory      */
1206 /*      db_filep        Pointer to database file (if not in_memory)          */
1207 /*      left_pos        Seek pos of 1st entry in db_filep (if not in_memory) */
1208 /*      db_lines        Pointer to database index lines (if in_memory)       */
1209 /*      db_lineslen     Number of database index lines (if in_memory)        */
1210 /*      first child     List of symbols held in this database                */
1211 /*      other children  CROSS_SYM symbols of symbols in this database        */
1212 /*                      The *links* to these have the following fields:      */
1213 /*                          number   An ID number for this sym in this db    */
1214 /*                          db_targ  TRUE if sym is a galley target          */
1215 /*                                                                           */
1216 /*  WORD, QWORD when used as font records (consult z37.c for more detail)    */
1217 /*                                                                           */
1218 /*      string[]        Font name                                            */
1219 /*      font_num        The number of this font                              */
1220 /*      font_page       Number of most recent page using this font           */
1221 /*      font_size       Size of this font                                    */
1222 /*      font_xheight2   Half-x height of this font                           */
1223 /*      font_bbox_lly   The lly value of the font bounding box               */
1224 /*      font_bbox_ury   The ury value of the font bounding box               */
1225 /*      font_spacewidth Preferred width of space between words in this font  */
1226 /*      font_mapping    The mapping to apply with this font                  */
1227 /*      font_recoded    TRUE if font needs recoding in PostScript output     */
1228 /*                                                                           */
1229 /*  WORD, QWORD when used in hash table to check whether crs defined twice   */
1230 /*                                                                           */
1231 /*      db_checksym     Symbol of the cross reference                        */
1232 /*      string[]        Tag of the cross reference                           */
1233 /*                                                                           */
1234 /*  HSPANNER (VSPANNER) - An object that spans columns (rows)                */
1235 /*                                                                           */
1236 /*      TOKEN           While still being parsed                             */
1237 /*      SIZED           The size of the object                               */
1238 /*      spanner_broken  TRUE after BreakObject() applied to this object      */
1239 /*      spanner_count   Number of columns (rows) spanned by this spanner     */
1240 /*      spanner_sized   Number of cols (rows) of this spanner sized so far   */
1241 /*      spanner_fixed   Number of cols (rows) of this spanner fixed so far   */
1242 /*      save_mark       used temporarily by FixAndPrintObject                */
1243 /*      constraint      Space available for this object as known to MinSize  */
1244 /*      first child     The object that is doing the spanning                */
1245 /*                                                                           */
1246 /*  COL_THR (ROW_THR) - object representing all objects on a col (row) mark  */
1247 /*                                                                           */
1248 /*      SIZED           The horizontal (vertical) size only                  */
1249 /*      thr_state       Tells whether thread is sized or not yet             */
1250 /*      children        The objects on the mark                              */
1251 /*      parents         The parents of the children (one-to-one)             */
1252 /*                                                                           */
1253 /*  ACAT - a paragraph (sequence of objects separated by & or white space)   */
1254 /*                                                                           */
1255 /*      SIZED           The size of the object                               */
1256 /*      save_style      The style to print this paragraph in                 */
1257 /*      children        The paragraph's objects and gaps (obj-gap-obj...obj) */
1258 /*                                                                           */
1259 /*  HCAT (VCAT) - a horizontal (vertical) sequence of objects                */
1260 /*                                                                           */
1261 /*      SIZED           The size of the object                               */
1262 /*      save_style      The style to print this object in                    */
1263 /*      children        The objects and gaps (obj-gap-obj...obj)             */
1264 /*      adjust_cat      Whether to perform adjustment (@VAdjust, etc.)       */
1265 /*                                                                           */
1266 /*  WIDE (HIGH) - @Wide (@High) object                                       */
1267 /*                                                                           */
1268 /*      TOKEN           While still being parsed                             */
1269 /*      SIZED           The size of the object                               */
1270 /*      constraint      The horizontal (vertical) size constraint            */
1271 /*      first child     The right parameter of this symbol                   */
1272 /*                                                                           */
1273 /*  HSHIFT (VSHIFT) - @HShift (@VShift) object                               */
1274 /*                                                                           */
1275 /*      TOKEN           While still being parsed                             */
1276 /*      SIZED           The size of the object                               */
1277 /*      shift_type      left, right etc.                                     */
1278 /*      shift_gap       The amount to shift                                  */
1279 /*      first child     The right parameter of this symbol                   */
1280 /*                                                                           */
1281 /*  HMIRROR (VMIRROR) - @HMirror (@VMirror) object                           */
1282 /*                                                                           */
1283 /*      TOKEN           While still being parsed                             */
1284 /*      SIZED           The size of the object                               */
1285 /*      save_mark       used temporarily by FixAndPrintObject                */
1286 /*      first child     The right parameter of this symbol                   */
1287 /*                                                                           */
1288 /*  HSCALE (VSCALE) - @HScale (@VScale) object                               */
1289 /*                                                                           */
1290 /*      TOKEN           While still being parsed                             */
1291 /*      SIZED           The size of the object                               */
1292 /*      save_mark       used temporarily by FixAndPrintObject                */
1293 /*      constraint      used temporarily by FixAndPrintObject                */
1294 /*      first child     The right parameter of this symbol                   */
1295 /*                                                                           */
1296 /*  SCALE - @Scale object                                                    */
1297 /*                                                                           */
1298 /*      TOKEN           While still being parsed                             */
1299 /*      SIZED           The size of the object                               */
1300 /*      bc(constraint)  The horizontal scale factor                          */
1301 /*      fc(constraint)  The vertical scale factor                            */
1302 /*      save_mark       used temporarily by FixAndPrintObject                */
1303 /*      vert_sized      TRUE if vertical size of object is known             */
1304 /*      first child     The right parameter of this symbol                   */
1305 /*                                                                           */
1306 /*  BEGIN_HEADER, SET_HEADER - @BeginHeaderComponent, @SetHeaderComponent    */
1307 /*                                                                           */
1308 /*      TOKEN           While still being parsed                             */
1309 /*      SIZED           The size of the object (will be 0)                   */
1310 /*      first child     The gap for after this header (before manifesting)   */
1311 /*      last child      The right parameter of this symbol                   */
1312 /*                                                                           */
1313 /*  END_HEADER, CLEAR_HEADER - @EndHeaderComponent, @ClearHeaderComponent    */
1314 /*                                                                           */
1315 /*      TOKEN           While still being parsed                             */
1316 /*      SIZED           The size of the object (will be 0)                   */
1317 /*                                                                           */
1318 /*  ONE_COL (ONE_ROW) - @OneCol (@OneRow) object                             */
1319 /*  HCOVER (VCOVER) - @HCover (@VCover) object                               */
1320 /*  HCONTRACT (VCONTRACT) - @HContract (@VContract) object                   */
1321 /*  HEXPAND (VEXPAND) - @HExpand (@VExpand) object                           */
1322 /*  START_HSPAN, START_VSPAN - @StartHSpan, @StartVSpan                      */
1323 /*  START_HVSPAN - @StartHVSpan                                              */
1324 /*  HSPAN (VSPAN) - @HSpan (@VSpan) symbols                                  */
1325 /*  KERN_SHRINK - @KernShrink object                                         */
1326 /*                                                                           */
1327 /*      TOKEN           While still being parsed                             */
1328 /*      SIZED           The size of the object                               */
1329 /*      first child     The right parameter of this symbol (if any)          */
1330 /*                                                                           */
1331 /*  PADJUST (HADJUST, VADJUST) - @PAdjust (@HAdjust, @VAdjust) symbols       */
1332 /*                                                                           */
1333 /*      TOKEN           While still being parsed                             */
1334 /*      first child     The right parameter of this symbol                   */
1335 /*                                                                           */
1336 /*  ROTATE - @Rotate symbol                                                  */
1337 /*                                                                           */
1338 /*      TOKEN           While still being parsed                             */
1339 /*      SIZED           The size of the object                               */
1340 /*      save_mark       used temporarily by FixAndPrintObject                */
1341 /*      sparec(cons)    Amount to rotate by (after manifesting)              */
1342 /*      first child     Amount to rotate by (before manifesting)             */
1343 /*      last child      The right parameter of this symbol                   */
1344 /*                                                                           */
1345 /*  BACKGROUND - @Background symbol                                          */
1346 /*                                                                           */
1347 /*      TOKEN           While still being parsed                             */
1348 /*      SIZED           The size of the object                               */
1349 /*      children        The two parameters of this symbol                    */
1350 /*                                                                           */
1351 /*  GRAPHIC, PLAIN_GRAPHIC - @Graphic, @PlainGraphic symbols                 */
1352 /*                                                                           */
1353 /*      TOKEN           While still being parsed                             */
1354 /*      SIZED           The size of the object                               */
1355 /*      save_mark       used temporarily by FixAndPrintObject                */
1356 /*      children        The two parameters of this symbol                    */
1357 /*                                                                           */
1358 /*  LINK_SOURCE, LINK_DEST, LINK_URL - @LinkSource, @LinkDest, @URLLink      */
1359 /*                                                                           */
1360 /*      TOKEN           While still being parsed                             */
1361 /*      SIZED           The size of the object                               */
1362 /*      save_mark       used temporarily by FixAndPrintObject                */
1363 /*      children        The two parameters of this symbol                    */
1364 /*                                                                           */
1365 /*  CASE - @Case symbol                                                      */
1366 /*                                                                           */
1367 /*      TOKEN           While still being parsed                             */
1368 /*      first child     The left parameter of @Case                          */
1369 /*      last child      The right parameter (sequence of @Yield objects)     */
1370 /*                                                                           */
1371 /*  VERBATIM (RAWVERBATIM) - @Verbatim (@RawVerbatim) symbol                 */
1372 /*                                                                           */
1373 /*      TOKEN           While still being parsed                             */
1374 /*      first child     The right parameter of this symbol                   */
1375 /*                                                                           */
1376 /*  FILTERED - object recording filtered Lout object                         */
1377 /*                                                                           */
1378 /*      filter_use_begin TRUE if filter enclosed in @Begin ... @End          */
1379 /*      filter_actual   The symbol this is an invocation of                  */
1380 /*      first child     WORD containing file name of filter input file       */
1381 /*      second child    WORD containing file name of filter output file      */
1382 /*      last child      Scope snapshot for reading filter output file        */
1383 /*                                                                           */
1384 /*  XCHAR - @Char symbol                                                     */
1385 /*  NEXT - @Next symbol                                                      */
1386 /*  ONE_OF - @OneOf symbol                                                   */
1387 /*  UNDERLINE - @Underline symbol                                            */
1388 /*                                                                           */
1389 /*      TOKEN           While still being parsed                             */
1390 /*      last child      The right parameter of this symbol                   */
1391 /*                                                                           */
1392 /*  FONT, SPACE, BREAK - @Font, @Space, @Break symbols                       */
1393 /*  YUNIT, ZUNIT - @YUnit, @ZUnit symbols                                    */
1394 /*  COLOUR, UNDERLINE_COLOUR, TEXTURE - @SetColour, @SetUnderlineColour      */
1395 /*  TEXTURE - @SetTexture                                                    */
1396 /*  OUTLINE, LANGUAGE - @Outline, @Language symbols                          */
1397 /*  PLUS, MINUS, - @Plus, @Minus symbols                                     */
1398 /*  MELD, COMMON, RUMP, INSERT - @Meld, @Common, @Rump, @Insert symbols      */
1399 /*  OPEN, TAGGED - @Open, @Tagged symbols                                    */
1400 /*  YIELD - @Yield symbol                                                    */
1401 /*                                                                           */
1402 /*      TOKEN           While still being parsed                             */
1403 /*      first child     The left parameter of this symbol                    */
1404 /*      last child      The right parameter of this symbol                   */
1405 /*                                                                           */
1406 /*  ENV_OBJ - a Lout object with environment attached                        */
1407 /*                                                                           */
1408 /*      first child     The Lout object                                      */
1409 /*      last child      Its environment (ENV object)                         */
1410 /*                                                                           */
1411 /*  ENV - environment of some Lout object                                    */
1412 /*                                                                           */
1413 /*      children        Components of the environment                        */
1414 /*                                                                           */
1415 /*  INCGRAPHIC, SINCGRAPHIC - @IncludeGraphic, @SysIncludeGraphic symbols    */
1416 /*                                                                           */
1417 /*      TOKEN           While still being parsed                             */
1418 /*      SIZED           The size of the object                               */
1419 /*      save_mark       used temporarily by FixAndPrintObject                */
1420 /*      incgraphic_ok   TRUE if file name pans out OK                        */
1421 /*      last child      The right parameter of this symbol                   */
1422 /*                                                                           */
1423 /*  TSPACE, TJUXTA - tokens representing white space                         */
1424 /*                                                                           */
1425 /*      TOKEN           While still being parsed                             */
1426 /*      mark(gap)       FALSE                                                */
1427 /*      join(gap)       TRUE                                                 */
1428 /*                                                                           */
1429 /*  BEGIN - @Begin symbol                                                    */
1430 /*                                                                           */
1431 /*      TOKEN           While still being parsed                             */
1432 /*      actual          Symbol this @Begin starts parameter of               */
1433 /*                                                                           */
1434 /*  END - @End symbol                                                        */
1435 /*  LBR, RBR - tokens representing left brace and right brace                */
1436 /*  USE, NOT_REVEALED - @Use, @NotRevealed symbols                           */
1437 /*  GSTUB_EXT, GSTUB_INT, GSTUB_NONE - stubs for transferred galleys         */
1438 /*  UNEXPECTED_EOF - unexpected end of file token                            */
1439 /*  INCLUDE, SYS_INCLUDE - @Include, @SysInclude symbols                     */
1440 /*  INCG_REPEATED, SINCG_REPEATED -                                          */
1441 /*    @IncludeGraphicRepeated, @SysIncludeGraphicRepeated symbols            */
1442 /*  PREPEND, SYS_PREPEND - @PrependGraphic, @SysPrependGraphic symbols       */
1443 /*  ENVA, ENVB, ENVC, ENVD - @LEnvA, @LEnvB, @LEnvC, @LEnvD tokens only      */
1444 /*  CENV, CLOS, LVIS, LUSE, LEO - @LCEnv, @LClos, @LVis, @LUse, @LEO tokens  */
1445 /*  BACKEND - @BackEnd symbol                                                */
1446 /*  CURR_LANG, CURR_FAMILY, CURR_FACE - @CurrLang, @CurrFamily, @CurrFace    */
1447 /*  CURR_YUNIT, CURR_ZUNIT - @CurrYUnit, @CurrZUnit                          */
1448 /*                                                                           */
1449 /*      TOKEN           While still being parsed                             */
1450 /*                                                                           */
1451 /*  DEAD - the index of a dead galley                                        */
1452 /*                                                                           */
1453 /*  UNATTACHED - the index of an unattached galley                           */
1454 /*                                                                           */
1455 /*      actual          The galley referred to                               */
1456 /*      non_blocking    TRUE if this index should not block galley flushing  */
1457 /*      blocked         TRUE if this index is now blocking galley flushing   */
1458 /*      pinpoint        Exact anchor point of this index                     */
1459 /*                                                                           */
1460 /*  RECEPTIVE, RECEIVING - the index of a receptive or receiving object      */
1461 /*                                                                           */
1462 /*      actual          The object (symbol invocation) referred to           */
1463 /*      trigger_externs TRUE is this index's galley has external galleys     */
1464 /*      non_blocking    TRUE if this index should not block galley flushing  */
1465 /*      blocked         TRUE if this index is now blocking galley flushing   */
1466 /*                                                                           */
1467 /*  RECURSIVE - the index of a recursive but definite object                 */
1468 /*                                                                           */
1469 /*      actual          The recursive symbol invocation referred to          */
1470 /*                                                                           */
1471 /*  PRECEDES - an index recording a precedes/follows flushing constraint     */
1472 /*                                                                           */
1473 /*      first child     Other parent of this is the corresponding FOLLOWS    */
1474 /*                                                                           */
1475 /*  FOLLOWS - an index recording a precedes/follows flushing constraint      */
1476 /*                                                                           */
1477 /*      blocked         TRUE if this index is now blocking galley flushing   */
1478 /*      first child     Other parent of this is the corresponding PRECEDES   */
1479 /*                                                                           */
1480 /*  CROSS_LIT - not actually an object at all                                */
1481 /*                                                                           */
1482 /*  CROSS_PREC, CROSS_FOLL, CROSS_FOLL_OR_PREC - the index of a cross ref    */
1483 /*                                                                           */
1484 /*      actual          The cross reference referred to                      */
1485 /*      underline       TRUE if continuous underline goes through here       */
1486 /*      first child     Equal to actual                                      */
1487 /*                                                                           */
1488 /*  GALL_PREC, GALL_FOLL, GALL_FOLL_OR_PREC - index of a galley              */
1489 /*                                                                           */
1490 /*      actual          The galley referred to                               */
1491 /*      underline       TRUE if continuous underline goes through here       */
1492 /*      pinpoint        Exact anchor point of this index                     */
1493 /*                                                                           */
1494 /*  GALL_TARG - index of the target of a galley                              */
1495 /*                                                                           */
1496 /*      actual          The galley target (symbol invocation) referred to    */
1497 /*      underline       TRUE if continuous underline goes through here       */
1498 /*                                                                           */
1499 /*  PAGE_LABEL_IND - the index of a @PageLabel object                        */
1500 /*                                                                           */
1501 /*      actual          The @PageLabel object referred to                    */
1502 /*      underline       TRUE if continuous underline goes through here       */
1503 /*      first child     Equal to actual                                      */
1504 /*                                                                           */
1505 /*  SCALE_IND - the index of a @Scale symbol with empty left parameter       */
1506 /*  COVER_IND - the index of an @HCover or @VCover object                    */
1507 /*  EXPAND_IND - the index of an @HExpand or @VExpand object                 */
1508 /*                                                                           */
1509 /*      actual          The object referred to                               */
1510 /*      underline       TRUE if continuous underline goes through here       */
1511 /*                                                                           */
1512 /*  THREAD - a sequence of threads (basically local to Manifest)             */
1513 /*                                                                           */
1514 /*      children        The threads                                          */
1515 /*                                                                           */
1516 /*  CROSS_SYM - a record of the cross reference state of some symbol         */
1517 /*                                                                           */
1518 /*      target_state    Whether we currently have a preceding target         */
1519 /*      target_file     Which file target is written to                      */
1520 /*      target_val      Value of target (if target_state == SEEN_TARGET)     */
1521 /*      target_seq      A sequence number                                    */
1522 /*      target_pos      Seek position of target in target_file               */
1523 /*      target_lnum     Line number of target in target_file                 */
1524 /*      gall_seq        Sequence number for galleys targeted to here         */
1525 /*      symb            The symbol table record of the symbol this is for    */
1526 /*      gall_tag        I forget!                                            */
1527 /*      gall_tfile      The most recent cr database file for this sym        */
1528 /*      children        Cross references and galleys waiting for a target    */
1529 /*                      These children have the following fields:            */
1530 /*                                                                           */
1531 /*                          string[]   The sequence number                   */
1532 /*                          cs_type    The cross reference type              */
1533 /*                          cs_fnum    File number where value written       */
1534 /*                          cs_pos     File seek position                    */
1535 /*                          cs_lnum    File line number                      */
1536 /*                                                                           */
1537 /*  CR_ROOT - all CROSS_SYM objects are children of this singleton           */
1538 /*                                                                           */
1539 /*      children        All CROSS_SYM symbols                                */
1540 /*                                                                           */
1541 /*  MACRO - a symbol table entry for a symbol which is a macro               */
1542 /*  LOCAL - a symbol table entry for a symbol which is a local symbol        */
1543 /*  LPAR - a symbol table entry for a symbol which is a left parameter       */
1544 /*  RPAR - a symbol table entry for a symbol which is a right parameter      */
1545 /*  NPAR - a symbol table entry for a symbol which is a named parameter      */
1546 /*                                                                           */
1547 /*      enclosing       The symbol that this one is defined within, if any   */
1548 /*      sym_body        The symbol body (token sequence if MACRO)            */
1549 /*      base_uses       Local to symbol table, for calculating call graph    */
1550 /*      uses            Call graph info                                      */
1551 /*      marker          For call graph calculation                           */
1552 /*      imports         The import list preceding this symbol, if any        */
1553 /*      filter          Child @Filter symbol, if any                         */
1554 /*      use_invocation  A @Use clause containing this symbol, if any         */
1555 /*      predefined      If predefined symbol, its non-zero enum code         */
1556 /*      has_compulsory  Number of parameters with "compulsory" tag           */
1557 /*      uses_count      Number of times this symbol is used                  */
1558 /*      npar_code       One-letter abbreviation for this NPAR                */
1559 /*      cross_sym       The CROSS_SYM record for this symbol, if any         */
1560 /*      recursive       TRUE if symbol is recursive                          */
1561 /*      has_body        TRUE if symbol has a body parameter                  */
1562 /*      imports_encl    TRUE if symbol imports the symbol enclosing itself   */
1563 /*      right_assoc     TRUE if this symbol has "associativity right"        */
1564 /*      precedence      The precedence of this symbol                        */
1565 /*      indefinite      TRUE if this symbol is indefinite (e.g. receptive)   */
1566 /*      recursive       TRUE if symbol is recursive                          */
1567 /*      is_extern_target   TRUE if symbol is the target of external galley   */
1568 /*      uses_extern_target TRUE if symbol uses target of an external galley  */
1569 /*      visible         TRUE if symbol is exported                           */
1570 /*      uses_galley     TRUE if symbol uses a galley                         */
1571 /*      horiz_galley    if galley, ROWM if vertical, COLM if horizontal      */
1572 /*      is_compulsory   TRUE if this is a parameter with "compulsory" tag    */
1573 /*      dirty           TRUE if must copy this parameter, not link it        */
1574 /*      has_par         TRUE if this symbol has at least one parameter       */
1575 /*      has_lpar        TRUE if this symbol has a left parameter             */
1576 /*      has_rpar        TRUE if this symbol has a right or body parameter    */
1577 /*      has_target      TRUE if this symbol has a target (is a galley)       */
1578 /*      force_target    TRUE if this symbol has a forcing target             */
1579 /*      is_target       TRUE if this symbol is @Target, defining a target    */
1580 /*      has_tag         TRUE if this symbol has a @Tag parameter             */
1581 /*      is_tag          TRUE if this symbol is a @Tag parameter              */
1582 /*      has_key         TRUE if this symbol has a @Key parameter             */
1583 /*      is_key          TRUE if this symbol is a @Key parameter              */
1584 /*      has_optimize    TRUE if this symbol has an @Optimize parameter       */
1585 /*      is_optimize     TRUE if this symbol is an @Optimize parameter        */
1586 /*      has_merge       TRUE if this symbol has a @Merge parameter           */
1587 /*      is_merge        TRUE if this symbol is a @Merge parameter            */
1588 /*      has_enclose     TRUE if this symbol has an @Enclose parameter        */
1589 /*      is_enclose      TRUE if this symbol is an @Enclose parameter         */
1590 /*                                                                           */
1591 /*  EXT_GALL - a record of an external galley, not actually read in yet      */
1592 /*                                                                           */
1593 /*      eg_fnum         Number of file read from                             */
1594 /*      eg_fpos         Position in that file                                */
1595 /*      eg_lnum         Line number in that file                             */
1596 /*      eg_cont         Continuation (where to look for next galley)         */
1597 /*      eg_symbol       The symbol that is the target of this galley         */
1598 /*      first child     The galley tag                                       */
1599 /*      second child    The galley sequence string                           */
1600 /*                                                                           */
1601 /*  CR_LIST - a list of cross references                                     */
1602 /*                                                                           */
1603 /*      children        The cross-references                                 */
1604 /*                                                                           */
1605 /*  SCOPE_SNAPSHOT - a snapshot of one element of the current scope stack    */
1606 /*                                                                           */
1607 /*      ss_npars_only   Value of npars_only in this element                  */
1608 /*      ss_vis_only     Value of vis_only in this element                    */
1609 /*      ss_body_ok      Value of body_ok in this element                     */
1610 /*      ss_suppress     Value of suppress_visible in this element            */
1611 /*                                                                           */
1612 /*  DISPOSED - a disposed object (available for reallocation)                */
1613 /*                                                                           */
1614 /*****************************************************************************/
1615 
1616 typedef union rec
1617 {
1618   struct word_type	/* all fields of WORD and QWORD, token and object */
1619   {  LIST		olist[2];
1620      FIRST_UNION	ou1;
1621      SECOND_UNION	ou2;
1622      THIRD_UNION	ou3;
1623      FULL_CHAR		ostring[4];
1624   } os1;
1625 
1626   struct closure_type	/* all fields of CLOSURE, both as token and object */
1627   {  LIST		olist[2];
1628      FIRST_UNION	ou1;
1629      SECOND_UNION	ou2;
1630      THIRD_UNION	ou3;
1631      FOURTH_UNION	ou4;
1632      union rec		*oactual;
1633      union
1634      { union rec *owhereto;
1635        union rec *opinpoint;
1636        FULL_LENGTH    osave_mark;
1637      } oux;
1638   } os2;
1639 
1640   struct head_type	/* all fields of HEAD, both as token and object */
1641   {  LIST		olist[2];
1642      FIRST_UNION	ou1;
1643      SECOND_UNION	ou2;
1644      THIRD_UNION	ou3;
1645      FOURTH_UNION	ou4;
1646      union rec		*oactual;
1647      union
1648      { union rec *owhereto;
1649        union rec *opinpoint;
1650        FULL_LENGTH    osave_mark;
1651      } oux;
1652      union rec *oready_galls;
1653      union rec *oopt_components;
1654      union rec *oopt_constraints;
1655      union rec *oopt_counts;
1656      union rec *olimiter;
1657      union rec *oenclose_obj;
1658      union rec *oheaders[MAX_HCOPIES];
1659      int	ohead_next;
1660      int        oopt_comps_permitted;
1661   } os2a;
1662 
1663   struct object_type	/* the general OBJECT */
1664   {  LIST		olist[2];
1665      FIRST_UNION	ou1;
1666      SECOND_UNION	ou2;
1667      THIRD_UNION	ou3;
1668      FOURTH_UNION	ou4;
1669   } os3;
1670 
1671   struct link_type	/* LINK */
1672   {  LIST		olist[2];
1673      unsigned char	otype;
1674      unsigned char	onumber;
1675      unsigned char	odb_targ;
1676   } os4;
1677 
1678   struct gapobj_type	/* GAP_OBJ */
1679   {  LIST		olist[2];
1680      FIRST_UNION	ou1;
1681      SECOND_UNION	ou2;
1682      GAP		ogap;
1683      int		osave_badness;		/* optimum paragraph breaker */
1684      FULL_LENGTH	osave_space;		/* optimum paragraph breaker */
1685      FULL_LENGTH	osave_actual_gap;	/* optimum paragraph breaker */
1686      union rec  	*osave_prev;		/* optimum paragraph breaker */
1687      union rec  	*osave_cwid;		/* optimum paragraph breaker */
1688   } os5;
1689 
1690   struct symbol_type
1691   {  LIST		olist[2];
1692      FIRST_UNION	ou1;
1693      SECOND_UNION	ou2;
1694      union rec		*oenclosing;
1695      union rec		*osym_body;
1696      union rec		*obase_uses;
1697      union rec		*ouses;
1698      union rec		*omarker;
1699      union rec		*ocross_sym;
1700      union rec		*oimports;
1701      union rec		*ofilter;
1702      union rec		*ouse_invocation;
1703      unsigned short 	opredefined;
1704      unsigned short 	ohas_compulsory;
1705      unsigned char	ouses_count;
1706      unsigned char	onpar_code;
1707      BOOLEAN		ois_optimize	     : 1;
1708      BOOLEAN		ohas_optimize	     : 1;
1709      BOOLEAN		ois_merge	     : 1;
1710      BOOLEAN		ohas_merge	     : 1;
1711      BOOLEAN		ois_enclose	     : 1;
1712      BOOLEAN		ohas_enclose	     : 1;
1713      BOOLEAN		ois_compulsory	     : 1;
1714   } os6;
1715 
1716   struct cr_type
1717   {  LIST		olist[2];
1718      unsigned char	otype;
1719      unsigned char	otarget_state;
1720      FILE_NUM		otarget_file;
1721      union rec		*otarget_val;
1722      int		otarget_seq;
1723      int		otarget_pos;
1724      int		otarget_lnum;
1725      int		ogall_seq;
1726      union rec		*osymb;
1727      union rec		*ogall_tag;
1728      FILE_NUM		ogall_tfile;
1729   } os7;
1730 
1731   struct ext_gall_type
1732   {  LIST		olist[2];
1733      unsigned char	otype;
1734      FILE_NUM		oeg_fnum;
1735      int		oeg_lnum;
1736      long		oeg_fpos;
1737      long		oeg_cont;
1738      union rec		*oeg_symbol;
1739   } os8;
1740 
1741   struct uses_type
1742   {  union rec	*oitem;
1743      union rec	*onext;
1744   } os9;
1745 #define	USES_SIZE ceiling( sizeof(struct uses_type), sizeof(ALIGN) )
1746 
1747   struct hash_entry_type
1748   {  LIST	olist[1];
1749   } os10;
1750 
1751 } *OBJECT;
1752 
1753 
1754 /*@::macros for fields of OBJECT@*********************************************/
1755 /*                                                                           */
1756 /*  Macros for fields of OBJECT.                                             */
1757 /*                                                                           */
1758 /*****************************************************************************/
1759 
1760 #define	succ(x, dim)		(x)->os1.olist[dim].osucc
1761 #define	pred(x, dim)		(x)->os1.olist[dim].opred
1762 
1763 #define type(x)			(x)->os1.ou1.os11.otype
1764 #define	rec_size(x)		(x)->os1.ou1.os11.orec_size
1765 #define font_bbox_lly(x)	(x)->os1.ou2.os25.ofont_bbox_lly
1766 #define font_bbox_ury(x)	(x)->os1.ou2.os25.ofont_bbox_ury
1767 #define	precedence(x)		(x)->os1.ou2.os21.oprecedence
1768 #define	hspace(x)		(x)->os1.ou2.os21.ohspace
1769 #define	vspace(x)		(x)->os1.ou2.os21.ovspace
1770 
1771 #define	word_font(x)		(x)->os1.ou2.os22.oword_font
1772 #define spanner_count(x)	word_font(x)
1773 #define incg_type(x)		word_font(x)
1774 #define	word_colour(x)		(x)->os1.ou2.os22.oword_colour
1775 #define	word_underline_colour(x) (x)->os1.ou2.os22.oword_underline_colour
1776 #define	word_texture(x)		(x)->os1.ou2.os22.oword_texture
1777 #define spanner_sized(x)	word_colour(x)
1778 #define	word_outline(x)		(x)->os1.ou2.os22.oword_outline
1779 #define	word_language(x)	(x)->os1.ou2.os22.oword_language
1780 #define	word_baselinemark(x)	(x)->os1.ou2.os22.oword_baselinemark
1781 #define	word_strut(x)		(x)->os1.ou2.os22.oword_strut
1782 #define	word_ligatures(x)	(x)->os1.ou2.os22.oword_ligatures
1783 #define	spanner_fixed(x)	word_language(x)
1784 #define	spanner_broken(x)	word_outline(x)
1785 #define	underline(x)		(x)->os1.ou2.os22.ounderline
1786 #define	word_hyph(x)		(x)->os1.ou2.os22.oword_hyph
1787 #define	filter_use_begin(x)	(x)->os1.ou2.os22.oword_colour
1788 
1789 #define	ss_npars_only(x)	word_font(x)
1790 #define	ss_vis_only(x)		word_colour(x)
1791 #define	ss_body_ok(x)		word_outline(x)
1792 #define	ss_suppress(x)		word_language(x)
1793 
1794 #define	non_blocking(x)		(x)->os1.ou2.os23.onon_blocking
1795 #define	vert_sized(x)		non_blocking(x)
1796 #define	sized(x)		(x)->os1.ou2.os23.osized
1797 #define	threaded(x)		(x)->os1.ou2.os23.othreaded
1798 #define	external_ver(x)		(x)->os1.ou2.os23.oexternal_ver
1799 #define	external_hor(x)		(x)->os1.ou2.os23.oexternal_hor
1800 #define	blocked(x)		(x)->os1.ou2.os23.oblocked
1801 #define	seen_nojoin(x)		blocked(x)
1802 #define	trigger_externs(x)	(x)->os1.ou2.os23.otrigger_ext
1803 #define	must_expand(x)		(x)->os1.ou2.os23.omust_expand
1804 #define	gall_dir(x)		(x)->os1.ou2.os23.ogall_dir
1805 #define	opt_hyph(x)		(x)->os1.ou2.os23.oopt_hyph
1806 #define	opt_gazumped(x)		(x)->os1.ou2.os23.oopt_gazumped
1807 #define	adjust_cat(x)		(x)->os1.ou2.os23.oadjust_cat
1808 #define	force_gall(x)		(x)->os1.ou2.os23.oforce_gall
1809 #define	cross_type(x)		(x)->os1.ou2.os23.ocross_type
1810 #define	foll_or_prec(x)		(x)->os1.ou2.os23.ofoll_or_prec
1811 #define	thr_state(x)		cross_type(x)
1812 #define	incgraphic_ok(x)	cross_type(x)
1813 
1814 #define	left_pos(x)		(x)->os1.ou2.os24.oleft_pos
1815 #define	db_lineslen(x)		left_pos(x)
1816 #define	reading(x)		(x)->os1.ou2.os24.oreading
1817 #define	in_memory(x)		(x)->os1.ou2.os24.oin_memory
1818 
1819 #define	is_tag(x)		(x)->os1.ou2.os26.ois_tag
1820 #define	has_tag(x)		(x)->os1.ou2.os26.ohas_tag
1821 #define	has_lpar(x)		(x)->os1.ou2.os26.ohas_lpar
1822 #define	has_rpar(x)		(x)->os1.ou2.os26.ohas_rpar
1823 #define	right_assoc(x)		(x)->os1.ou2.os26.oright_assoc
1824 #define	is_target(x)		(x)->os1.ou2.os26.ois_target
1825 #define	has_target(x)		(x)->os1.ou2.os26.ohas_target
1826 #define	force_target(x)		(x)->os1.ou2.os26.oforce_target
1827 #define	has_body(x)		(x)->os1.ou2.os26.ohas_body
1828 #define	indefinite(x)		(x)->os1.ou2.os26.oindefinite
1829 #define	recursive(x)		(x)->os1.ou2.os26.orecursive
1830 #define	uses_extern_target(x)	(x)->os1.ou2.os26.ouses_extern_target
1831 #define	is_extern_target(x)	(x)->os1.ou2.os26.ois_extern_target
1832 #define	is_key(x)		(x)->os1.ou2.os26.ois_key
1833 #define	has_key(x)		(x)->os1.ou2.os26.ohas_key
1834 #define	dirty(x)		(x)->os1.ou2.os26.odirty
1835 #define	visible(x)		(x)->os1.ou2.os26.ovisible
1836 #define	has_mark(x)		(x)->os1.ou2.os26.ohas_mark
1837 #define	has_join(x)		(x)->os1.ou2.os26.ohas_join
1838 #define	has_par(x)		(x)->os1.ou2.os26.ohas_par
1839 #define	uses_galley(x)		(x)->os1.ou2.os26.ouses_galley
1840 #define	horiz_galley(x)		(x)->os1.ou2.os26.ohoriz_galley
1841 #define	imports_encl(x)		(x)->os1.ou2.os26.oimports_encl
1842 
1843 #define	fpos(x)			(x)->os1.ou1.ofpos
1844 #define word_save_mark(x)	(x)->os1.ou1.os11.oword_save_mark
1845 
1846 #define	back(x, dim)		(x)->os1.ou3.os31.oback[dim]
1847 #define	comp_count(x)		back(x, COLM)
1848 #define	fwd(x, dim)		(x)->os1.ou3.os31.ofwd[dim]
1849 #define	size(x, dim)		(back(x, dim) + fwd(x, dim))
1850 #define	db_filep(x)		(x)->os1.ou3.odb_filep
1851 #define	db_lines(x)		(x)->os1.ou3.odb_lines
1852 #define	filter_actual(x)	(x)->os1.ou3.ofilter_actual
1853 #define	db_checksym(x)		filter_actual(x)
1854 
1855 #define	cs_type(x)		(x)->os1.ou3.os33.ocs_type
1856 #define	cs_fnum(x)		(x)->os1.ou3.os33.ocs_fnum
1857 #define	cs_pos(x)		(x)->os1.ou3.os33.ocs_pos
1858 #define	cs_lnum(x)		(x)->os1.ou3.os33.ocs_lnum
1859 
1860 #define line_count(x)		(x)->os1.ou3.os34.oline_count
1861 #define file_number(x)		(x)->os1.ou3.os34.ofile_number
1862 #define type_of_file(x)		(x)->os1.ou3.os34.otype_of_file
1863 #define used_suffix(x)		(x)->os1.ou3.os34.oused_suffix
1864 #define updated(x)		(x)->os1.ou3.os34.oupdated
1865 #define path(x)			(x)->os1.ou3.os34.opath
1866 
1867 #define string(x)		(x)->os1.ostring
1868 
1869 #define	save_style(x)		(x)->os2.ou4.osave_style
1870 #define	constraint(x)		(x)->os2.ou4.oconstraint
1871 #define	shift_type(x)		width(space_gap(save_style(x)))
1872 #define	shift_gap(x)		line_gap(save_style(x))
1873 
1874 #define actual(x)		(x)->os2.oactual
1875 #define whereto(x)		(x)->os2.oux.owhereto
1876 #define pinpoint(x)		(x)->os2.oux.opinpoint
1877 #define save_mark(x)		(x)->os2.oux.osave_mark
1878 #define ready_galls(x)		(x)->os2a.oready_galls
1879 #define opt_components(x)	(x)->os2a.oopt_components
1880 #define opt_constraints(x)	(x)->os2a.oopt_constraints
1881 #define opt_counts(x)		(x)->os2a.oopt_counts
1882 #define limiter(x)		(x)->os2a.olimiter
1883 #define enclose_obj(x)		(x)->os2a.oenclose_obj
1884 #define headers(x, i)		(x)->os2a.oheaders[i]
1885 #define head_next(x)		(x)->os2a.ohead_next
1886 #define opt_comps_permitted(x)	(x)->os2a.oopt_comps_permitted
1887 
1888 #define	number(x)		(x)->os4.onumber
1889 #define	db_targ(x)		(x)->os4.odb_targ
1890 
1891 #define	gap(x)			(x)->os5.ogap
1892 #define	save_badness(x)		(x)->os5.osave_badness
1893 #define	save_space(x)		(x)->os5.osave_space
1894 #define	save_actual_gap(x)	(x)->os5.osave_actual_gap
1895 #define	save_prev(x)		(x)->os5.osave_prev
1896 #define	save_cwid(x)		(x)->os5.osave_cwid
1897 
1898 #define	enclosing(x)		(x)->os6.oenclosing
1899 #define	sym_body(x)		(x)->os6.osym_body
1900 #define	base_uses(x)		(x)->os6.obase_uses
1901 #define	uses(x)			(x)->os6.ouses
1902 #define	marker(x)		(x)->os6.omarker
1903 #define	cross_sym(x)		(x)->os6.ocross_sym
1904 #define	imports(x)		(x)->os6.oimports
1905 #define	filter(x)		(x)->os6.ofilter
1906 #define	use_invocation(x)	(x)->os6.ouse_invocation
1907 #define	predefined(x)		(x)->os6.opredefined
1908 #define	has_compulsory(x)	(x)->os6.ohas_compulsory
1909 #define	uses_count(x)		(x)->os6.ouses_count
1910 #define	npar_code(x)		(x)->os6.onpar_code
1911 #define	is_optimize(x)		(x)->os6.ois_optimize
1912 #define	has_optimize(x)		(x)->os6.ohas_optimize
1913 #define	is_merge(x)		(x)->os6.ois_merge
1914 #define	has_merge(x)		(x)->os6.ohas_merge
1915 #define	is_enclose(x)		(x)->os6.ois_enclose
1916 #define	has_enclose(x)		(x)->os6.ohas_enclose
1917 #define	is_compulsory(x)	(x)->os6.ois_compulsory
1918 
1919 #define	target_state(x)		(x)->os7.otarget_state
1920 #define	target_file(x)		(x)->os7.otarget_file
1921 /* #define cr_file(x)		(x)->os7.ocr_file unused */
1922 #define	target_val(x)		(x)->os7.otarget_val
1923 #define	target_seq(x)		(x)->os7.otarget_seq
1924 #define	target_pos(x)		(x)->os7.otarget_pos
1925 #define	target_lnum(x)		(x)->os7.otarget_lnum
1926 /* #define cr_seq(x)		(x)->os7.ocr_seq unused */
1927 #define	gall_seq(x)		(x)->os7.ogall_seq
1928 #define	symb(x)			(x)->os7.osymb
1929 #define	gall_tag(x)		(x)->os7.ogall_tag
1930 #define	gall_tfile(x)		(x)->os7.ogall_tfile
1931 
1932 #define	eg_fnum(x)		(x)->os8.oeg_fnum
1933 #define	eg_fpos(x)		(x)->os8.oeg_fpos
1934 #define	eg_lnum(x)		(x)->os8.oeg_lnum
1935 #define	eg_cont(x)		(x)->os8.oeg_cont
1936 #define	eg_symbol(x)		(x)->os8.oeg_symbol
1937 
1938 #define	item(x)			(x)->os9.oitem
1939 #define	next(x)			(x)->os9.onext
1940 
1941 #define	font_num(x)		(x)->os1.ou3.os32.ofont_num
1942 #define	font_page(x)		(x)->os1.ou3.os32.ofont_page
1943 #define	font_size(x)		(x)->os1.ou3.os32.ofont_size
1944 #define	font_xheight2(x)	(x)->os1.ou3.os32.ofont_xheight2
1945 #define	font_spacewidth(x)	(x)->os1.ou3.os32.ofont_spacewidth
1946 #define	font_mapping(x)		(x)->os1.ou3.os32.ofont_mapping
1947 #define	font_recoded(x)		(x)->os1.ou3.os32.ofont_recoded
1948 
1949 
1950 /*@::FONT_INFO@***************************************************************/
1951 /*                                                                           */
1952 /*  typedef FONT_INFO - information about font metrics etc.  Really private  */
1953 /*  but shared between z37.c and z24.c                                       */
1954 /*                                                                           */
1955 /*****************************************************************************/
1956 
1957 struct metrics {
1958   FULL_LENGTH up;
1959   FULL_LENGTH down;
1960   FULL_LENGTH left;
1961   FULL_LENGTH right;
1962   FULL_LENGTH last_adjust;
1963 };
1964 
1965 typedef struct composite_rec {
1966   FULL_CHAR char_code;
1967   FULL_LENGTH x_offset;
1968   FULL_LENGTH y_offset;
1969 } COMPOSITE;
1970 
1971 typedef struct font_rec {
1972   struct metrics	*size_table;		/* metrics of sized fonts    */
1973   FULL_CHAR		*lig_table;		/* ligatures                 */
1974   unsigned short	*composite;		/* non-zero means composite  */
1975   COMPOSITE		*cmp_table;		/* composites to build	     */
1976   int			cmp_top;		/* length of cmp_table	     */
1977   OBJECT		font_table;		/* record of sized fonts     */
1978   OBJECT		original_face;		/* face object of this font  */
1979   FULL_LENGTH		underline_pos;		/* position of underline     */
1980   FULL_LENGTH		underline_thick;	/* thickness of underline    */
1981   unsigned short	*kern_table;		/* first kerning chars       */
1982   FULL_CHAR		*kern_chars;		/* second kerning chars      */
1983   unsigned char		*kern_value;		/* points into kern_lengths  */
1984   FULL_LENGTH		*kern_sizes;		/* sizes of kernings         */
1985 } FONT_INFO;
1986 
1987 
1988 /*@::MAP_VEC@*****************************************************************/
1989 /*                                                                           */
1990 /*  typedef MAP_VEC - information about character mappings.  Really private  */
1991 /*  to z38.c but (for efficiency) shared with z37.c and z24.c                */
1992 /*                                                                           */
1993 /*****************************************************************************/
1994 
1995 #define MAX_CHASH       353             /* size of hash table                */
1996 #define MAP_UPPERCASE     0             /* the map to upper case             */
1997 #define MAP_LOWERCASE     1             /* the map to lower case             */
1998 #define MAP_UNACCENTED    2             /* the map to unaccented             */
1999 #define MAP_ACCENT        3             /* the map to the accent character   */
2000 #define MAPS              4             /* the number of maps in each file   */
2001 
2002 typedef struct mapvec {
2003   OBJECT        file_name;              /* name of file containing the vec   */
2004   FILE_NUM      fnum;                   /* the file number of this file      */
2005   BOOLEAN       seen_recoded;           /* TRUE if a font recode was seen    */
2006   int		last_page_printed;	/* most recent page on which printed */
2007   OBJECT        name;                   /* PostScript name of encoding vec   */
2008   OBJECT        vector[MAX_CHARS];      /* character names                   */
2009   FULL_CHAR     hash_table[MAX_CHASH];  /* character hash table for inverse  */
2010   FULL_CHAR     map[MAPS][MAX_CHARS];   /* the mappings                      */
2011 } *MAP_VEC;
2012 
2013 
2014 /*@::BACK_END@****************************************************************/
2015 /*                                                                           */
2016 /*  typedef BACK_END - an OO-like record describing one back end             */
2017 /*                                                                           */
2018 /*****************************************************************************/
2019 
2020 typedef struct back_end_rec {
2021   int code;				/* the code number of the back end   */
2022   FULL_CHAR *name;			/* string name of the back end	     */
2023   BOOLEAN scale_avail;			/* TRUE if @Scale is available	     */
2024   BOOLEAN rotate_avail;			/* TRUE if @Rotate is available	     */
2025   BOOLEAN mirror_avail;			/* TRUE if @HMirror, @VMirror avail  */
2026   BOOLEAN graphic_avail;		/* TRUE if @Graphic is available     */
2027   BOOLEAN incgraphic_avail;		/* TRUE if @IncludeGraphic is avail. */
2028   BOOLEAN plaingraphic_avail;		/* TRUE if @PlainGraphic is avail.   */
2029   BOOLEAN fractional_spacing_avail;	/* TRUE if fractional spacing avail. */
2030   BOOLEAN uses_font_metrics;		/* TRUE if actual font metrics used  */
2031   BOOLEAN colour_avail;			/* TRUE if colour is available       */
2032   void (*PrintInitialize)(FILE *fp, BOOLEAN encapsulated);
2033   void (*PrintLength)(FULL_CHAR *buff, int length, int length_dim);
2034   void (*PrintPageSetupForFont)(OBJECT face, int font_curr_page,
2035     FULL_CHAR *font_name, FULL_CHAR *first_size_str);
2036   void (*PrintPageResourceForFont)(FULL_CHAR *font_name, BOOLEAN first);
2037   void (*PrintMapping)(MAPPING m);
2038   void (*PrintBeforeFirstPage)(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label);
2039   void (*PrintBetweenPages)(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label);
2040   void (*PrintAfterLastPage)(void);
2041   void (*PrintWord)(OBJECT x, int hpos, int vpos);
2042   void (*PrintPlainGraphic)(OBJECT x, FULL_LENGTH xmk,FULL_LENGTH ymk,OBJECT z);
2043   void (*PrintUnderline)(FONT_NUM fnum, COLOUR_NUM col, TEXTURE_NUM pat,
2044     FULL_LENGTH xstart, FULL_LENGTH xstop, FULL_LENGTH ymk);
2045   void (*CoordTranslate)(FULL_LENGTH xdist, FULL_LENGTH ydist);
2046   void (*CoordRotate)(FULL_LENGTH amount);
2047   void (*CoordScale)(float hfactor, float vfactor);
2048   void (*CoordHMirror)(void);
2049   void (*CoordVMirror)(void);
2050   void (*SaveGraphicState)(OBJECT x);
2051   void (*RestoreGraphicState)(void);
2052   void (*PrintGraphicObject)(OBJECT x);
2053   void (*DefineGraphicNames)(OBJECT x);
2054   void (*SaveTranslateDefineSave)(OBJECT x,FULL_LENGTH xdist,FULL_LENGTH ydist);
2055   void (*PrintGraphicInclude)(OBJECT x,FULL_LENGTH colmark,FULL_LENGTH rowmark);
2056   void (*LinkSource)(OBJECT name, FULL_LENGTH llx, FULL_LENGTH lly,
2057     FULL_LENGTH urx, FULL_LENGTH ury);
2058   void (*LinkDest)(OBJECT name, FULL_LENGTH llx, FULL_LENGTH lly,
2059     FULL_LENGTH urx, FULL_LENGTH ury);
2060   void (*LinkURL)(OBJECT url, FULL_LENGTH llx, FULL_LENGTH lly,
2061     FULL_LENGTH urx, FULL_LENGTH ury);
2062   void (*LinkCheck)(void);
2063 } *BACK_END;
2064 
2065 
2066 /*@::object types@************************************************************/
2067 /*                                                                           */
2068 /*  OBJECT, TOKEN AND OTHER TYPES inhabiting type(x) and predefined(x)       */
2069 /*                                                                           */
2070 /*  Key letters in the adjacent comment indicate where the tag is legal:     */
2071 /*                                                                           */
2072 /*    t  a token type, pushed on token stack                                 */
2073 /*    o  an object type (returned by reduce(), inserted by Manifest)         */
2074 /*    i  an index type (a child of a galley header other than an object)     */
2075 /*    s  a predefined symbol (some symbol table entry has this predefined()) */
2076 /*    n  an indefinite object i.e. one which is ignored in catenation ops    */
2077 /*                                                                           */
2078 /*****************************************************************************/
2079 
2080 #define	LINK		     0		/*        a link between objects     */
2081 #define	GAP_OBJ		     1		/*  o     a gap object               */
2082 #define	CLOSURE		     2		/* to  n  a closure of a symbol      */
2083 #define	UNDER_REC	     3		/*  o  n  record of underlining      */
2084 #define	PAGE_LABEL	     4		/* to sn  @PageLabel                 */
2085 #define	NULL_CLOS	     5		/* to sn  @Null                      */
2086 #define	CROSS		     6		/* to sn  && (a cross reference obj) */
2087 #define	FORCE_CROSS	     7		/* to sn  &&& (a forcing cross ref.) */
2088 #define	LINK_DEST_NULL	     8		/* to sn  @LinkDest (null version)   */
2089 #define	HEAD		     9		/*  o  n  a galley header            */
2090 #define	SPLIT		    10		/*  o     @Split                     */
2091 #define	PAR		    11		/*  o     a parameter of a closure   */
2092 #define	WORD		    12		/*  o     a word                     */
2093 #define	QWORD		    13		/*  o     a word (was quoted in i/p) */
2094 #define	HSPANNER	    14		/*  o     a horizontal spanner       */
2095 #define	VSPANNER	    15		/*  o     a vertical spanner         */
2096 #define	ROW_THR		    16		/*  o     a row thread               */
2097 #define	COL_THR		    17		/*  o     a column thread            */
2098 #define	ACAT		    18		/* to s   a sequence of &-ed objs    */
2099 #define	HCAT		    19		/* to s   a sequence of |-ed objs    */
2100 #define	VCAT		    20		/* to s   a sequence of /-ed objs    */
2101 #define	BEGIN_HEADER	    21		/* to s   @BeginHeaderComponent      */
2102 #define	END_HEADER	    22		/* to s   @EndHeaderComponent        */
2103 #define	SET_HEADER	    23		/* to s   @SetHeaderComponent        */
2104 #define	CLEAR_HEADER	    24		/* to s   @ClearHeaderComponent      */
2105 #define	ONE_COL		    25		/* to s   @OneCol                    */
2106 #define	ONE_ROW		    26		/* to s   @OneRow                    */
2107 #define	WIDE		    27		/* to s   @Wide                      */
2108 #define	HIGH		    28		/* to s   @High                      */
2109 #define	HSHIFT		    29		/* to s   @HShift                    */
2110 #define	VSHIFT		    30		/* to s   @VShift                    */
2111 #define	HMIRROR		    31		/* to s   @HScale                    */
2112 #define	VMIRROR		    32		/* to s   @VScale                    */
2113 #define	HSCALE		    33		/* to s   @HScale                    */
2114 #define	VSCALE		    34		/* to s   @VScale                    */
2115 #define	HCOVER		    35		/* to s   @HCover                    */
2116 #define	VCOVER		    36		/* to s   @VCover                    */
2117 #define	SCALE		    37		/* to s   @Scale                     */
2118 #define	KERN_SHRINK	    38		/* to s   @KernShrink                */
2119 #define	HCONTRACT	    39		/* to s   @HContract                 */
2120 #define	VCONTRACT	    40		/* to s   @VContract                 */
2121 #define	HLIMITED	    41		/* to s   @HLimited                  */
2122 #define	VLIMITED	    42		/* to s   @VLimited                  */
2123 #define	HEXPAND		    43		/* to s   @HExpand                   */
2124 #define	VEXPAND		    44		/* to s   @VExpand                   */
2125 #define	START_HSPAN	    45		/* to s   @StartHSpan                */
2126 #define	START_VSPAN 	    46		/* to s   @StartVSpan                */
2127 #define	START_HVSPAN 	    47		/* to s   @StartHVSpan               */
2128 #define	HSPAN  		    48		/* to s   @HSpan                     */
2129 #define	VSPAN  		    49		/* to s   @VSpan                     */
2130 #define	PADJUST		    50		/* to s   @PAdjust                   */
2131 #define	HADJUST		    51		/* to s   @HAdjust                   */
2132 #define	VADJUST		    52		/* to s   @VAdjust                   */
2133 #define	ROTATE		    53		/* to s   @Rotate                    */
2134 #define	BACKGROUND	    54		/* to s   @Background                */
2135 #define	CASE		    55		/* to s   @Case                      */
2136 #define	VERBATIM	    56		/* to s   @Verbatim                  */
2137 #define	RAW_VERBATIM	    57		/* to s   @RawVerbatim               */
2138 #define	YIELD		    58		/* to s   @Yield                     */
2139 #define	BACKEND		    59		/* to s   @BackEnd                   */
2140 #define	FILTERED	    60		/* to s   filtered object (no name)  */
2141 #define	XCHAR		    61		/* to s   @Char                      */
2142 #define	FONT		    62		/* to s   @Font                      */
2143 #define	SPACE		    63		/* to s   @Space                     */
2144 #define	YUNIT		    64		/* to s   @YUnit                     */
2145 #define	ZUNIT		    65		/* to s   @ZUnit                     */
2146 #define	SET_CONTEXT	    66		/* to s   @SetContext                */
2147 #define	GET_CONTEXT	    67		/* to s   @GetContext                */
2148 #define	BREAK		    68		/* to s   @Break                     */
2149 #define	UNDERLINE	    69		/* to s   @Underline                 */
2150 #define	UNDERLINE_COLOUR    70		/* to s   @SetUnderlineColour        */
2151 #define	COLOUR		    71		/* to s   @SetColour and @SetColor   */
2152 #define	TEXTURE		    72		/* to s   @SetTexture                */
2153 #define	OUTLINE		    73		/* to s   @Outline                   */
2154 #define	LANGUAGE	    74		/* to s   @Language                  */
2155 #define	CURR_LANG	    75		/* to s   @CurrLang                  */
2156 #define	CURR_FAMILY	    76		/* to s   @CurrFamily                */
2157 #define	CURR_FACE	    77		/* to s   @CurrFace                  */
2158 #define	CURR_YUNIT	    78		/* to s   @CurrYUnit                 */
2159 #define	CURR_ZUNIT	    79		/* to s   @CurrZUnit                 */
2160 #define	COMMON		    80		/* to s   @Common                    */
2161 #define	RUMP		    81		/* to s   @Rump                      */
2162 #define	MELD		    82		/* to s   @Meld                      */
2163 #define	INSERT		    83		/* to s   @Insert                    */
2164 #define	ONE_OF		    84		/* to s   @OneOf                     */
2165 #define	NEXT		    85		/* to s   @Next                      */
2166 #define	PLUS		    86		/* to s   @Plus                      */
2167 #define	MINUS		    87		/* to s   @Minus                     */
2168 #define	ENV_OBJ		    88		/* to s   object with envt (no name) */
2169 #define	ENV		    89		/* to s   @LEnv                      */
2170 #define	ENVA		    90		/* to s   @LEnvA                     */
2171 #define	ENVB		    91		/* to s   @LEnvB                     */
2172 #define	ENVC		    92		/* to s   @LEnvC                     */
2173 #define	ENVD		    93		/* to s   @LEnvD                     */
2174 #define	CENV		    94		/* to s   @LCEnv                     */
2175 #define	CLOS		    95		/* to s   @LClos                     */
2176 #define	LVIS		    96		/* to s   @LVis                      */
2177 #define	LUSE		    97		/* to s   @LUse                      */
2178 #define	LEO 		    98		/* to s   @LEO                       */
2179 #define	OPEN		    99		/* to s   @Open                      */
2180 #define	TAGGED		   100		/* to s   @Tagged                    */
2181 #define	INCGRAPHIC	   101		/* to s   @IncludeGraphic            */
2182 #define	SINCGRAPHIC	   102		/* to s   @SysIncludeGraphic         */
2183 #define	PLAIN_GRAPHIC	   103		/* to s   @PlainGraphic              */
2184 #define	GRAPHIC		   104		/* to s   @Graphic                   */
2185 #define	LINK_SOURCE	   105		/* to s   @LinkSource                */
2186 #define	LINK_DEST	   106		/* to s   @LinkDest                  */
2187 #define	LINK_URL	   107		/* to s   @URLLink                   */
2188 #define	TSPACE		   108		/* t      a space token, parser only */
2189 #define	TJUXTA		   109		/* t      a juxta token, parser only */
2190 #define	LBR		   110		/* t  s   left brace token           */
2191 #define	RBR		   111		/* t  s   right brace token          */
2192 #define	BEGIN		   112		/* t  s   @Begin token               */
2193 #define	END		   113		/* t  s   @End token                 */
2194 #define	USE		   114		/* t  s   @Use                       */
2195 #define	NOT_REVEALED	   115		/* t  s   @NotRevealed               */
2196 #define	GSTUB_NONE	   116		/* t      a galley stub, no rpar     */
2197 #define	GSTUB_INT	   117		/* t      galley stub internal rpar  */
2198 #define	GSTUB_EXT	   118		/* t      galley stub external rpar  */
2199 #define	UNEXPECTED_EOF	   119		/* t      unexpected end of file     */
2200 #define	INCLUDE		   120		/*    s   @Include                   */
2201 #define	SYS_INCLUDE	   121		/*    s   @SysInclude                */
2202 #define	PREPEND		   122		/*    s   @Prepend                   */
2203 #define	SYS_PREPEND	   123		/*    s   @SysPrepend                */
2204 #define	INCG_REPEATED	   124		/*    s   @IncludeGraphicRepeated    */
2205 #define	SINCG_REPEATED     125		/*    s   @SysIncludeGraphicRepeated */
2206 #define	DATABASE	   126		/*    s   @Database                  */
2207 #define	SYS_DATABASE	   127		/*    s   @SysDatabase               */
2208 #define	DEAD		   128		/*   i    a dead galley              */
2209 #define	UNATTACHED	   129		/*   i    an inner, unsized galley   */
2210 #define	RECEPTIVE	   130		/*   i    a receptive object index   */
2211 #define	RECEIVING	   131		/*   i    a receiving object index   */
2212 #define	RECURSIVE	   132		/*   i    a recursive definite obj.  */
2213 #define	PRECEDES	   133		/*   i    an ordering constraint     */
2214 #define	FOLLOWS		   134		/*   i    other end of ordering c.   */
2215 #define	CROSS_LIT	   135		/*   i    literal word cross-ref     */
2216 #define	CROSS_FOLL	   136		/*   i    following type cross-ref   */
2217 #define	CROSS_FOLL_OR_PREC 137		/*   i    follorprec type cross-ref  */
2218 #define	GALL_FOLL	   138		/*   i    galley with &&following    */
2219 #define	GALL_FOLL_OR_PREC  139		/*   i    galley with &&following    */
2220 #define	CROSS_TARG	   140		/*   i    value of cross-ref         */
2221 #define	GALL_TARG	   141		/*   i    target of these galleys    */
2222 #define	GALL_PREC	   142		/*   i    galley with &&preceding    */
2223 #define	CROSS_PREC	   143		/*   i    preceding type cross-ref   */
2224 #define	PAGE_LABEL_IND	   144		/*   i    index of PAGE_LABEL        */
2225 #define	SCALE_IND	   145		/*   i    index of auto SCALE        */
2226 #define	COVER_IND	   146		/*   i    index of HCOVER or VCOVER  */
2227 #define	EXPAND_IND	   147		/*   i    index of HEXPAND or VEXPD  */
2228 #define	THREAD		   148		/*        a sequence of threads      */
2229 #define	CROSS_SYM	   149		/*        cross-ref info             */
2230 #define	CR_ROOT		   150		/*        RootCross                  */
2231 #define	MACRO	           151		/*        a macro symbol             */
2232 #define	LOCAL	           152		/*        a local symbol             */
2233 #define	LPAR	           153		/*        a left parameter           */
2234 #define	NPAR	           154		/*        a named parameter          */
2235 #define	RPAR	           155		/*        a right parameter          */
2236 #define	EXT_GALL           156		/*        an external galley         */
2237 #define	CR_LIST	           157		/*        a list of cross references */
2238 #define	SCOPE_SNAPSHOT     158		/*        a scope snapshot	     */
2239 #define	DISPOSED           159		/*        a disposed record          */
2240 
2241 #define is_indefinite(x)  ((x) >= CLOSURE && (x) <= HEAD)
2242 #define is_header(x)  ((x) >= BEGIN_HEADER && (x) <= CLEAR_HEADER)
2243 #define is_definite(x) 	 ((x) >= SPLIT && (x) <= LINK_URL)
2244 #define	is_par(x)	((x) >= LPAR   && (x) <= RPAR)
2245 #define	is_index(x)	((x) >= DEAD && (x) <= EXPAND_IND)
2246 #define	is_type(x)	((x) >= LINK && (x) < DISPOSED)
2247 #define	is_word(x)	((x) == WORD || (x) == QWORD)
2248 #define	is_cross(x)	((x) == CROSS || (x) == FORCE_CROSS)
2249 #define is_cat_op(x)    (((x)>=ACAT && (x)<=VCAT) || (x)==TSPACE || (x)<=TJUXTA)
2250 
2251 
2252 /*@::miscellaneous constants@*************************************************/
2253 /*                                                                           */
2254 /*  Miscellaneous globally defined constants                                 */
2255 /*                                                                           */
2256 /*****************************************************************************/
2257 
2258 /* sides of a mark */
2259 #define	BACK	           160		/* means lies to left of mark        */
2260 #define	ON	           161		/* means lies on mark                */
2261 #define	FWD	           162		/* means lies to right of mark       */
2262 
2263 /* constraint statuses */
2264 #define	PROMOTE	           163		/* this component may be promoted    */
2265 #define	CLOSE	           164		/* must close dest before promoting  */
2266 #define	BLOCK	           165		/* cannot promote this component     */
2267 #define	CLEAR	           166		/* this constraint is now satisfied  */
2268 
2269 /* gap increment types */
2270 #define	GAP_ABS	           167		/* absolute,  e.g.  3p               */
2271 #define	GAP_INC	           168		/* increment, e.g. +3p               */
2272 #define	GAP_DEC	           169		/* decrement, e.g. -3p               */
2273 
2274 /* gap modes occupying mode(x) */
2275 #define	NO_MODE		     0		/* for error detection: no mode      */
2276 #define	EDGE_MODE	     1		/* edge-to-edge spacing              */
2277 #define	HYPH_MODE	     2		/* edge-to-edge with hyphenation     */
2278 #define	MARK_MODE	     3		/* mark-to-mark spacing              */
2279 #define	OVER_MODE	     4		/* overstrike spacing                */
2280 #define	KERN_MODE	     5		/* kerning spacing                   */
2281 #define	TAB_MODE	     6		/* tabulation spacing                */
2282 #define	ADD_HYPH	     7		/* temp value used by FillObject     */
2283 
2284 /* hyph_style(style) options                                                 */
2285 #define	HYPH_UNDEF	     0		/* hyphenation option undefined      */
2286 #define	HYPH_OFF	     1		/* hyphenation off                   */
2287 #define	HYPH_ON		     2		/* hyphenation on                    */
2288 
2289 /* fill_style(style) options                                                 */
2290 #define	FILL_UNDEF	     0		/* fill option undefined             */
2291 #define	FILL_OFF	     1		/* no filling of lines               */
2292 #define	FILL_ON		     2		/* fill lines with text              */
2293 
2294 /* underline(obj) options                                                    */
2295 #define	UNDER_UNDEF	     0		/* underline undefined               */
2296 #define	UNDER_OFF	     1		/* no underlining	             */
2297 #define	UNDER_ON	     2		/* underline this                    */
2298 
2299 /* space_style(style) options                                                */
2300 #define	SPACE_LOUT	     0		/* interpret white space Lout's way  */
2301 #define	SPACE_COMPRESS	     1		/* compress multiple white spaces    */
2302 #define	SPACE_SEPARATE	     2		/* compress an separate              */
2303 #define	SPACE_TROFF	     3		/* interpret white space troff's way */
2304 #define	SPACE_TEX	     4		/* interpret white space TeX's way   */
2305 
2306 /* display_style(style) options                                              */
2307 #define	DISPLAY_UNDEF	     0		/* display option undefined          */
2308 #define	DISPLAY_ADJUST	     1		/* adjust lines (except last)        */
2309 #define	DISPLAY_OUTDENT	     2		/* outdent lines (except first)      */
2310 #define	DISPLAY_ORAGGED	     3		/* outdent but don't adjust          */
2311 #define	DISPLAY_LEFT	     4		/* left-justify lines, no adjust     */
2312 #define	DISPLAY_CENTRE	     5		/* centre lines, no adjust           */
2313 #define	DISPLAY_RIGHT	     6		/* right-justify lines, no adjust    */
2314 #define	DO_ADJUST	     7		/* placed in ACATs when adjust need  */
2315 
2316 /* small_caps(style) options                                                 */
2317 #define	SMALL_CAPS_OFF	     0		/* don't want small capitals         */
2318 #define	SMALL_CAPS_ON	     1		/* small capitals                    */
2319 
2320 /* statuses of thread objects */
2321 #define	NOTSIZED	     0		/* this thread object is not sized   */
2322 #define	SIZED		     1		/* thread is sized but not printed   */
2323 #define	FINALSIZE	     2		/* thread object size is now final   */
2324 
2325 /* file types */
2326 #define	SOURCE_FILE	     0		/* input file from command line      */
2327 #define	INCLUDE_FILE	     1		/* @Include file                     */
2328 #define	DATABASE_FILE	     2		/* database file                     */
2329 #define	INDEX_FILE	     3		/* database index file               */
2330 #define	FONT_FILE	     4		/* font file                         */
2331 #define	PREPEND_FILE	     5		/* PostScript prologue file          */
2332 #define	HYPH_FILE	     6		/* hyphenation file                  */
2333 #define	HYPH_PACKED_FILE     7		/* packed hyphenation file           */
2334 #define	MAPPING_FILE	     8		/* character mapping file            */
2335 #define	FILTER_FILE	     9		/* filter output file                */
2336 #define	MAX_TYPES	    10		/* number of file types              */
2337 
2338 /* path types (i.e. sequences of directories for file searching) */
2339 #define	SOURCE_PATH	     0		/* path to search for source files   */
2340 #define	INCLUDE_PATH	     1		/* path for @Include files           */
2341 #define	SYSINCLUDE_PATH	     2		/* path for @SysInclude files        */
2342 #define	DATABASE_PATH	     3		/* path for @Database files          */
2343 #define	SYSDATABASE_PATH     4		/* path for @SysDatabase files       */
2344 #define	FONT_PATH	     5		/* path for font metrics (AFM) files */
2345 #define	HYPH_PATH	     6		/* path for hyphenation files        */
2346 #define	MAPPING_PATH	     7		/* path for mapping (LCM) files      */
2347 #define	MAX_PATHS	     8		/* number of mapping paths           */
2348 
2349 /* units of measurement */
2350 #define	NO_UNIT		     0		/* no unit - for error detection     */
2351 #define	FIXED_UNIT	     1		/* inches, cm, points, ems, y, z     */
2352 #define	FRAME_UNIT	     2		/* b unit (frame widths)             */
2353 #define	AVAIL_UNIT	     3		/* r unit (available spaces)         */
2354 #define	DEG_UNIT	     4		/* d unit (degrees)                  */
2355 #define	NEXT_UNIT	     5		/* w unit (inners)                   */
2356 
2357 /* units of distance as multiples of the basic unit */
2358 #define	CM	           567		/* 1 centimetre                      */
2359 #define	IN	          1440		/* 1 inch                            */
2360 #define	EM	           120		/* 1 em (= 1/12 inch)                */
2361 #define	PT		    20		/* 1 point (= 1/72 inch)             */
2362 #define	FR	          4096		/* virtual unit for frame units      */
2363 #define	DG	           128		/* virtual unit for degrees          */
2364 #define	SF	           256		/* virtual unit for @Scale factors   */
2365                                         /* including blankline scale         */
2366 
2367 /* default size of characters for the PLAINTEXT back end */
2368 #define	PLAIN_WIDTH        144		/* default char width, 10 per inch   */
2369 #define	PLAIN_HEIGHT       240		/* default char height, 6 per inch   */
2370 
2371 /* precedences */
2372 #define	NO_PREC		     0		/* lower than any precedence         */
2373 #define	BEGIN_PREC	     1		/* precedence of @Begin              */
2374 #define	END_PREC	     2		/* precedence of @End                */
2375 #define	LBR_PREC	     3		/* precedence of {                   */
2376 #define	RBR_PREC	     4		/* precedence of }                   */
2377 #define	VCAT_PREC	     5		/* precedence of /                   */
2378 #define	HCAT_PREC	     6		/* precedence of |                   */
2379 #define	ACAT_PREC	     7		/* precedence of & and white space   */
2380 #define	MIN_PREC            10		/* minimum precedence of user ops    */
2381 #define	MAX_PREC           100		/* maximim precedence of user ops    */
2382 #define	DEFAULT_PREC       100		/* default precedence of user ops    */
2383 #define CROSSOP_PREC       101		/* precedence of && and &&& ops      */
2384 #define GAP_PREC           102		/* precedence of gap op after cat op */
2385 #define JUXTA_PREC         103		/* precedence of juxtaposition &     */
2386 #define	FILTER_PREC        104		/* precedence of filter symbol ops   */
2387 #define	FORCE_PREC         105		/* higher than any precedence        */
2388 
2389 /* back ends */
2390 #define POSTSCRIPT           0		/* PostScript back end               */
2391 #define	PDF		     1		/* PDF back end			     */
2392 #define	PLAINTEXT	     2		/* plain text back end               */
2393 
2394 /* error types */
2395 #define	INTERN		     0		/* internal error (i.e. bug)         */
2396 #define	FATAL		     1		/* fatal error, abort now            */
2397 #define	FATAL_WITH_USAGE     2		/* fatal error, abort now + usage    */
2398 #define	WARN		     3		/* warning, non-fatal                */
2399 
2400 /* status values returned by AttachGalley() */
2401 #define	ATTACH_KILLED	     0
2402 #define	ATTACH_INPUT	     1
2403 #define	ATTACH_NOTARGET	     2
2404 #define	ATTACH_SUSPEND	     3
2405 #define	ATTACH_NULL	     4
2406 #define	ATTACH_ACCEPT	     5
2407 
2408 /* kinds of tidying up accepted by ReplaceWithTidy */
2409 #define	ACAT_TIDY	     0
2410 #define	WORD_TIDY	     1
2411 #define	PARA_TIDY	     2
2412 
2413 /* types of memory usage, used to debug memory consumption */
2414 #define	MEM_BINARY	     0		/* the executable binary	     */
2415 #define	MEM_OBJECTS	     1		/* objects currently in free list    */
2416 #define	MEM_FONTS	     2		/* fonts                             */
2417 #define	MEM_LEX		     3		/* lexical analyser file buffers     */
2418 #define	MEM_FILES	     4		/* table of file names               */
2419 #define	MEM_CROSSREF	     5		/* table of file names               */
2420 #define	MEM_PAGES	     6		/* page grids (-p only)              */
2421 #define	MEM_DBCHECK	     7		/* database checks                   */
2422 #define	MEM_DB	             8		/* in_memory database                */
2423 #define	MEM_HYPH_PATS	     9		/* hyphenation patterns              */
2424 #define	MEM_CMAPS	    10		/* character maps                    */
2425 #define	MEM_COLOUR_TAB	    11		/* colour table                      */
2426 #define	MEM_TEXTURE_TAB	    12		/* texture table                     */
2427 #define	MEM_LANG_TAB	    13		/* language table                    */
2428 #define	MEM_USAGE_MAX	    14		/* number of memory usage types      */
2429 
2430 /*@::Keywords@****************************************************************/
2431 /*                                                                           */
2432 /*  Keywords.                                                                */
2433 /*                                                                           */
2434 /*****************************************************************************/
2435 
2436 #define	KW_START		AsciiToFull("\\Start")
2437 #define	KW_PRINT		AsciiToFull("\\Print")
2438 #define	KW_OPTGALL		AsciiToFull("@OptGall")
2439 #define	KW_DEF			AsciiToFull("def")
2440 #define	KW_FONTDEF		AsciiToFull("@FontDef")
2441 #define	KW_FAMILY		AsciiToFull("@Family")
2442 #define	KW_FACE			AsciiToFull("@Face")
2443 #define	KW_NAME			AsciiToFull("@Name")
2444 #define	KW_METRICS		AsciiToFull("@Metrics")
2445 #define	KW_EXTRA_METRICS	AsciiToFull("@ExtraMetrics")
2446 #define	KW_MAPPING		AsciiToFull("@Mapping")
2447 #define	KW_RECODE		AsciiToFull("@Recode")
2448 #define	KW_LANGDEF		AsciiToFull("langdef")
2449 #define	KW_FORCE		AsciiToFull("force")
2450 #define	KW_HORIZ		AsciiToFull("horizontally")
2451 #define	KW_INTO			AsciiToFull("into")
2452 #define	KW_EXTEND		AsciiToFull("extend")
2453 #define	KW_IMPORT		AsciiToFull("import")
2454 #define	KW_EXPORT		AsciiToFull("export")
2455 #define	KW_PRECEDENCE		AsciiToFull("precedence")
2456 #define	KW_ASSOC		AsciiToFull("associativity")
2457 #define	KW_LEFT			AsciiToFull("left")
2458 #define	KW_RIGHT		AsciiToFull("right")
2459 #define	KW_BODY			AsciiToFull("body")
2460 #define	KW_FILTER		AsciiToFull("@Filter")
2461 #define	KW_FILTERIN		AsciiToFull("@FilterIn")
2462 #define	KW_FILTEROUT		AsciiToFull("@FilterOut")
2463 #define	KW_FILTERERR		AsciiToFull("@FilterErr")
2464 #define	KW_MACRO		AsciiToFull("macro")
2465 #define	KW_NAMED		AsciiToFull("named")
2466 #define	KW_COMPULSORY		AsciiToFull("compulsory")
2467 #define	KW_COMMON		AsciiToFull("@Common")
2468 #define	KW_RUMP			AsciiToFull("@Rump")
2469 #define	KW_MELD			AsciiToFull("@Meld")
2470 #define	KW_INSERT		AsciiToFull("@Insert")
2471 #define	KW_ONE_OF		AsciiToFull("@OneOf")
2472 #define	KW_NEXT			AsciiToFull("@Next")
2473 #define	KW_PLUS			AsciiToFull("@Plus")
2474 #define	KW_MINUS		AsciiToFull("@Minus")
2475 #define	KW_WIDE			AsciiToFull("@Wide")
2476 #define	KW_HIGH			AsciiToFull("@High")
2477 #define	KW_HSHIFT		AsciiToFull("@HShift")
2478 #define	KW_VSHIFT		AsciiToFull("@VShift")
2479 #define	KW_BEGIN_HEADER		AsciiToFull("@BeginHeaderComponent")
2480 #define	KW_END_HEADER		AsciiToFull("@EndHeaderComponent")
2481 #define	KW_SET_HEADER		AsciiToFull("@SetHeaderComponent")
2482 #define	KW_CLEAR_HEADER		AsciiToFull("@ClearHeaderComponent")
2483 #define	KW_ONE_COL		AsciiToFull("@OneCol")
2484 #define	KW_ONE_ROW		AsciiToFull("@OneRow")
2485 #define	KW_HMIRROR		AsciiToFull("@HMirror")
2486 #define	KW_VMIRROR		AsciiToFull("@VMirror")
2487 #define	KW_HSCALE		AsciiToFull("@HScale")
2488 #define	KW_VSCALE		AsciiToFull("@VScale")
2489 #define	KW_HCOVER		AsciiToFull("@HCover")
2490 #define	KW_VCOVER		AsciiToFull("@VCover")
2491 #define	KW_SCALE		AsciiToFull("@Scale")
2492 #define	KW_KERN_SHRINK		AsciiToFull("@KernShrink")
2493 #define	KW_HCONTRACT		AsciiToFull("@HContract")
2494 #define	KW_VCONTRACT		AsciiToFull("@VContract")
2495 #define	KW_HLIMITED		AsciiToFull("@HLimited")
2496 #define	KW_VLIMITED		AsciiToFull("@VLimited")
2497 #define	KW_HEXPAND		AsciiToFull("@HExpand")
2498 #define	KW_VEXPAND		AsciiToFull("@VExpand")
2499 #define	KW_STARTHVSPAN		AsciiToFull("@StartHVSpan")
2500 #define	KW_STARTHSPAN		AsciiToFull("@StartHSpan")
2501 #define	KW_STARTVSPAN		AsciiToFull("@StartVSpan")
2502 #define	KW_HSPAN		AsciiToFull("@HSpan")
2503 #define	KW_VSPAN		AsciiToFull("@VSpan")
2504 #define	KW_PADJUST		AsciiToFull("@PAdjust")
2505 #define	KW_HADJUST		AsciiToFull("@HAdjust")
2506 #define	KW_VADJUST		AsciiToFull("@VAdjust")
2507 #define	KW_ROTATE		AsciiToFull("@Rotate")
2508 #define	KW_BACKGROUND		AsciiToFull("@Background")
2509 #define	KW_INCGRAPHIC		AsciiToFull("@IncludeGraphic")
2510 #define	KW_SINCGRAPHIC		AsciiToFull("@SysIncludeGraphic")
2511 #define	KW_GRAPHIC		AsciiToFull("@Graphic")
2512 #define	KW_LINK_SOURCE		AsciiToFull("@LinkSource")
2513 #define	KW_LINK_DEST		AsciiToFull("@LinkDest")
2514 #define	KW_LINK_URL		AsciiToFull("@URLLink")
2515 #define	KW_PLAINGRAPHIC		AsciiToFull("@PlainGraphic")
2516 #define	KW_VERBATIM		AsciiToFull("@Verbatim")
2517 #define	KW_RAWVERBATIM		AsciiToFull("@RawVerbatim")
2518 #define	KW_CASE			AsciiToFull("@Case")
2519 #define	KW_YIELD		AsciiToFull("@Yield")
2520 #define	KW_BACKEND		AsciiToFull("@BackEnd")
2521 #define	KW_XCHAR		AsciiToFull("@Char")
2522 #define	KW_FONT			AsciiToFull("@Font")
2523 #define	KW_SPACE		AsciiToFull("@Space")
2524 #define	KW_YUNIT		AsciiToFull("@YUnit")
2525 #define	KW_ZUNIT		AsciiToFull("@ZUnit")
2526 #define	KW_BREAK		AsciiToFull("@Break")
2527 #define	KW_UNDERLINE		AsciiToFull("@Underline")
2528 #define	KW_COLOUR		AsciiToFull("@SetColour")
2529 #define	KW_COLOR		AsciiToFull("@SetColor")
2530 #define	KW_UNDERLINE_COLOUR	AsciiToFull("@SetUnderlineColour")
2531 #define	KW_UNDERLINE_COLOR	AsciiToFull("@SetUnderlineColor")
2532 #define	KW_TEXTURE		AsciiToFull("@SetTexture")
2533 #define	KW_OUTLINE		AsciiToFull("@Outline")
2534 #define	KW_LANGUAGE		AsciiToFull("@Language")
2535 #define	KW_CURR_LANG		AsciiToFull("@CurrLang")
2536 #define	KW_CURR_FAMILY		AsciiToFull("@CurrFamily")
2537 #define	KW_CURR_FACE		AsciiToFull("@CurrFace")
2538 #define	KW_CURR_YUNIT		AsciiToFull("@CurrYUnit")
2539 #define	KW_CURR_ZUNIT		AsciiToFull("@CurrZUnit")
2540 #define	KW_ENV			AsciiToFull("@LEnv")
2541 #define	KW_ENVA			AsciiToFull("@@A")
2542 #define	KW_ENVB			AsciiToFull("@@B")
2543 #define	KW_ENVC			AsciiToFull("@@C")
2544 #define	KW_ENVD			AsciiToFull("@@D")
2545 #define	KW_CENV			AsciiToFull("@@E")
2546 #define	KW_CLOS			AsciiToFull("@LClos")
2547 #define	KW_LVIS			AsciiToFull("@@V")
2548 #define	KW_LUSE			AsciiToFull("@LUse")
2549 #define	KW_LEO			AsciiToFull("@LEO")
2550 #define	KW_OPEN			AsciiToFull("@Open")
2551 #define	KW_USE			AsciiToFull("@Use")
2552 #define	KW_NOT_REVEALED		AsciiToFull("@NotRevealed")
2553 #define	KW_TAGGED		AsciiToFull("@Tagged")
2554 #define	KW_DATABASE		AsciiToFull("@Database")
2555 #define	KW_SYSDATABASE		AsciiToFull("@SysDatabase")
2556 #define	KW_INCLUDE		AsciiToFull("@Include")
2557 #define	KW_SYSINCLUDE		AsciiToFull("@SysInclude")
2558 #define	KW_INCG_REPEATED	AsciiToFull("@IncludeGraphicRepeated")
2559 #define	KW_SINCG_REPEATED	AsciiToFull("@SysIncludeGraphicRepeated")
2560 #define	KW_PREPEND		AsciiToFull("@PrependGraphic")
2561 #define	KW_SYSPREPEND		AsciiToFull("@SysPrependGraphic")
2562 #define	KW_TARGET		AsciiToFull("@Target")
2563 #define	KW_FOLLOWING		AsciiToFull("following")
2564 #define	KW_PRECEDING		AsciiToFull("preceding")
2565 #define	KW_FOLL_OR_PREC		AsciiToFull("foll_or_prec")
2566 #define	KW_NOW			AsciiToFull("now")
2567 #define	KW_NULL			AsciiToFull("@Null")
2568 #define	KW_PAGE_LABEL		AsciiToFull("@PageLabel")
2569 #define	KW_GALLEY		AsciiToFull("@Galley")
2570 #define	KW_FORCE_GALLEY		AsciiToFull("@ForceGalley")
2571 #define	KW_INPUT		AsciiToFull("@LInput")
2572 #define	KW_SPLIT		AsciiToFull("@Split")
2573 #define	KW_TAG			AsciiToFull("@Tag")
2574 #define	KW_KEY			AsciiToFull("@Key")
2575 #define	KW_OPTIMIZE		AsciiToFull("@Optimize")
2576 #define	KW_MERGE		AsciiToFull("@Merge")
2577 #define	KW_ENCLOSE		AsciiToFull("@Enclose")
2578 #define	KW_CROSS		AsciiToFull("&&")
2579 #define	KW_FORCE_CROSS		AsciiToFull("&&&")
2580 #define	KW_LBR			AsciiToFull("{")
2581 #define	KW_RBR			AsciiToFull("}")
2582 #define	KW_BEGIN		AsciiToFull("@Begin")
2583 #define	KW_END			AsciiToFull("@End")
2584 #define	KW_VCAT_NN		AsciiToFull("//")
2585 #define	KW_VCAT_MN		AsciiToFull("^//")
2586 #define	KW_VCAT_NJ		AsciiToFull("/")
2587 #define	KW_VCAT_MJ		AsciiToFull("^/")
2588 #define	KW_HCAT_NN		AsciiToFull("||")
2589 #define	KW_HCAT_MN		AsciiToFull("^||")
2590 #define	KW_HCAT_NJ		AsciiToFull("|")
2591 #define	KW_HCAT_MJ		AsciiToFull("^|")
2592 #define	KW_ACAT_NJ		AsciiToFull("&")
2593 #define	KW_ACAT_MJ		AsciiToFull("^&")
2594 #define	KW_MOMENT		AsciiToFull("@Moment")
2595 #define	KW_SECOND		AsciiToFull("@Second")
2596 #define	KW_MINUTE		AsciiToFull("@Minute")
2597 #define	KW_HOUR			AsciiToFull("@Hour")
2598 #define	KW_DAY			AsciiToFull("@Day")
2599 #define	KW_MONTH		AsciiToFull("@Month")
2600 #define	KW_YEAR			AsciiToFull("@Year")
2601 #define	KW_CENTURY		AsciiToFull("@Century")
2602 #define	KW_WEEKDAY		AsciiToFull("@WeekDay")
2603 #define	KW_YEARDAY		AsciiToFull("@YearDay")
2604 #define	KW_DAYLIGHTSAVING	AsciiToFull("@DaylightSaving")
2605 #define	KW_SET_CONTEXT		AsciiToFull("@SetContext")
2606 #define	KW_GET_CONTEXT		AsciiToFull("@GetContext")
2607 
2608 /*@::GetMem(), New(), NewWord()@**********************************************/
2609 /*                                                                           */
2610 /*  GetMem(x, siz, pos)                                                      */
2611 /*  New(x, typ)                                                              */
2612 /*  NewWord(x, typ, len, pos)                                                */
2613 /*                                                                           */
2614 /*  Set x to point to a new record, of appropriate length (in ALIGNs).       */
2615 /*  The New and NewWord versions initialise LIST, type and rec_size fields.  */
2616 /*  NewWord must be used for WORD and QWORD objects.                         */
2617 /*                                                                           */
2618 /*****************************************************************************/
2619 
2620 #if DEBUG_ON
2621 #define newcount zz_newcount++
2622 #define freecount zz_listcount--
2623 
2624 #define checknew(typ)							\
2625 { assert1( is_type(typ), "New: type", Image(typ) );			\
2626   assert(  zz_lengths[typ] > 0, "New: zero length!" );			\
2627 }
2628 
2629 #define checkmem(z, typ)						\
2630 { if( (MemCheck != 0) && ( (POINTER) z == MemCheck) )			\
2631     fprintf(stderr, "%ld = New(%s)%s",(long)z,Image(type(z)),STR_NEWLINE); \
2632 }
2633 
2634 #else
2635 #define newcount
2636 #define freecount
2637 #define checknew(typ)
2638 #define checkmem(z, typ)
2639 #endif
2640 
2641 #define	GetMem(x, siz, pos)						\
2642 { newcount;								\
2643   if( (zz_size=(siz)) >= MAX_OBJECT_REC )				\
2644     x = NULL, Error(1, 1, "word is too long", FATAL, pos);		\
2645   else if( zz_free[zz_size] == nilobj )					\
2646     x = GetMemory(zz_size, pos);					\
2647   else									\
2648   { x = zz_free[zz_size];						\
2649     freecount;								\
2650     zz_free[zz_size] = pred(x, CHILD);					\
2651   }									\
2652 }
2653 
2654 #define	New(x, typ)							\
2655 { checknew(typ);							\
2656   GetMem(zz_hold, zz_lengths[typ], no_fpos);				\
2657   type(zz_hold) = typ;							\
2658   checkmem(zz_hold, typ);						\
2659   x = pred(zz_hold, CHILD) = succ(zz_hold, CHILD) =			\
2660   pred(zz_hold, PARENT) = succ(zz_hold, PARENT) = zz_hold;		\
2661 }
2662 
2663 #define NewWord(x, typ, len, pos)					\
2664 { zz_size = sizeof(struct word_type) - 4 + ((len)+1)*sizeof(FULL_CHAR);	\
2665   /* NB the following line RESETS zz_size */				\
2666   GetMem(zz_hold, ceiling(zz_size, sizeof(ALIGN)), pos);		\
2667   checkmem(zz_hold, typ);						\
2668   rec_size(zz_hold) = zz_size;						\
2669   type(zz_hold) = typ;							\
2670   x = pred(zz_hold, CHILD) = succ(zz_hold, CHILD) =			\
2671   pred(zz_hold, PARENT) = succ(zz_hold, PARENT) = zz_hold;		\
2672 }
2673 
2674 /*@::PutMem(), Dispose()@*****************************************************/
2675 /*                                                                           */
2676 /*  PutMem(x, siz)                                                           */
2677 /*  Dispose(x)                                                               */
2678 /*                                                                           */
2679 /*  Dispose x, which is of size siz.  Dispose works out the size itself.     */
2680 /*                                                                           */
2681 /*****************************************************************************/
2682 #if DEBUG_ON
2683 #define disposecount zz_disposecount++; zz_listcount++;
2684 
2685 #define disposecheck							\
2686 { assert( zz_size >= 0 && zz_size < MAX_OBJECT_REC, "Dispose: size" );	\
2687 }
2688 
2689 #define	setdisposed							\
2690 { if( (MemCheck != 0) && ((POINTER) zz_hold == MemCheck) )		\
2691     fprintf(stderr, "Dispose(%ld, %s)%s", (long) zz_hold,		\
2692       Image(type(zz_hold)), STR_NEWLINE);				\
2693   type(zz_hold) = DISPOSED;						\
2694 }
2695 
2696 #else
2697 #define disposecount
2698 #define disposecheck
2699 #define	setdisposed
2700 #endif
2701 
2702 #define PutMem(x, siz)							\
2703 { disposecount;								\
2704   zz_hold = (x);							\
2705   zz_size = (siz);							\
2706   disposecheck;								\
2707   pred(zz_hold, CHILD) = zz_free[zz_size];				\
2708   zz_free[zz_size] = zz_hold;						\
2709 }
2710 
2711 #define Dispose(x)							\
2712 { zz_hold = (x);							\
2713   PutMem(zz_hold, is_word(type(zz_hold)) ?				\
2714     rec_size(zz_hold) : zz_lengths[type(zz_hold)]);			\
2715   setdisposed;								\
2716 }
2717 
2718 /*@::Append(), Delete()@******************************************************/
2719 /*                                                                           */
2720 /*  OBJECT Append(x, y, dir)                                                 */
2721 /*                                                                           */
2722 /*  Return the append of lists x and y (dir is PARENT or CHILD).             */
2723 /*                                                                           */
2724 /*****************************************************************************/
2725 
2726 #define	Append(x, y, dir)						\
2727 ( zz_res = (x),	zz_hold = (y),						\
2728   zz_hold == nilobj ? zz_res  :						\
2729   zz_res  == nilobj ? zz_hold :						\
2730   ( zz_tmp = pred(zz_hold, dir),					\
2731     pred(zz_hold, dir) = pred(zz_res, dir),				\
2732     succ(pred(zz_res, dir), dir) = zz_hold,				\
2733     pred(zz_res, dir) = zz_tmp,						\
2734     succ(zz_tmp, dir) = zz_res						\
2735   )									\
2736 )
2737 
2738 
2739 /*****************************************************************************/
2740 /*                                                                           */
2741 /*  OBJECT Delete(x, dir)                                                    */
2742 /*                                                                           */
2743 /*  Delete x from its dir list, and return succ(x, dir) or nilobj if none.   */
2744 /*                                                                           */
2745 /*****************************************************************************/
2746 
2747 #define Delete(x, dir)							\
2748 ( zz_hold = (x),							\
2749   succ(zz_hold, dir) == zz_hold ? nilobj :				\
2750   ( zz_res = succ(zz_hold, dir),					\
2751     pred(zz_res, dir) = pred(zz_hold, dir),				\
2752     succ(pred(zz_hold, dir), dir) = zz_res,				\
2753     pred(zz_hold, dir) = succ(zz_hold, dir) = zz_hold,			\
2754     zz_res								\
2755   )									\
2756 )
2757 
2758 #define Down(x)		succ(x, CHILD)
2759 #define NextDown(x)	succ(x, CHILD)
2760 #define LastDown(x)	pred(x, CHILD)
2761 #define PrevDown(x)	pred(x, CHILD)
2762 #define	Up(x)		succ(x, PARENT)
2763 #define	NextUp(x)	succ(x, PARENT)
2764 #define	LastUp(x)	pred(x, PARENT)
2765 #define	PrevUp(x)	pred(x, PARENT)
2766 
2767 #define	Child(y, link)							\
2768 for( y = pred(link, PARENT);  type(y) == LINK;  y = pred(y, PARENT) )
2769 
2770 #define CountChild(y, link, i)                                          \
2771 for( y=pred(link, PARENT), i=1; type(y)==LINK;  y = pred(y, PARENT), i++ )
2772 
2773 #define	Parent(y, link)							\
2774 for( y = pred(link, CHILD);   type(y) == LINK;  y = pred(y, CHILD) )
2775 
2776 
2777 /*@::UpDim(), DownDim(), Link(), DeleteLink(), etc.@**************************/
2778 /*                                                                           */
2779 /*  UpDim(x, dim)                                                            */
2780 /*  DownDim(x, dim)                                                          */
2781 /*                                                                           */
2782 /*  Returns the dim child or parent link of node x (dim == COLM or ROWM).    */
2783 /*                                                                           */
2784 /*****************************************************************************/
2785 
2786 #define UpDim(x, dim)	( (dim) == COLM ? succ(x, PARENT) : pred(x, PARENT) )
2787 #define DownDim(x, dim)	( (dim) == COLM ? succ(x, CHILD) : pred(x, CHILD) )
2788 
2789 
2790 /*****************************************************************************/
2791 /*                                                                           */
2792 /*  OBJECT Link(x, y)                                                        */
2793 /*                                                                           */
2794 /*  Make y a child of x in the directed graph, using a new link.             */
2795 /*  The link node is returned.                                               */
2796 /*                                                                           */
2797 /*****************************************************************************/
2798 
2799 #define Link(x, y)							\
2800 { New(xx_link, LINK);							\
2801   Append(xx_link, (x), CHILD);						\
2802   Append(xx_link, (y), PARENT);						\
2803 }
2804 
2805 
2806 /*****************************************************************************/
2807 /*                                                                           */
2808 /*  DeleteLink(link)                                                         */
2809 /*                                                                           */
2810 /*  Cut the link between nodes x and y of the directed graph.                */
2811 /*  Returns the link node of the next child of x, or x if none.              */
2812 /*                                                                           */
2813 /*****************************************************************************/
2814 
2815 #define DeleteLink(link)						\
2816 { xx_link = (link);							\
2817   Delete(xx_link, PARENT);						\
2818   Delete(xx_link, CHILD);						\
2819   Dispose(xx_link);							\
2820 }
2821 
2822 
2823 /*****************************************************************************/
2824 /*                                                                           */
2825 /*  DisposeChild(link)                                                       */
2826 /*                                                                           */
2827 /*  Delete link, and if its child is thereby unattached, dispose it.         */
2828 /*                                                                           */
2829 /*****************************************************************************/
2830 
2831 #define DisposeChild(link)						\
2832 { xx_link = (link);							\
2833   xx_tmp = Delete(xx_link, PARENT);					\
2834   Delete(xx_link, CHILD);						\
2835   Dispose(xx_link);							\
2836   if( succ(xx_tmp, PARENT) == xx_tmp )  DisposeObject(xx_tmp);		\
2837 } /* end DisposeChild */
2838 
2839 
2840 /*****************************************************************************/
2841 /*                                                                           */
2842 /*  MoveLink(link, x, dir)                                                   */
2843 /*                                                                           */
2844 /*  Move the dir end of link from wherever it is now to node x.              */
2845 /*                                                                           */
2846 /*****************************************************************************/
2847 
2848 #define MoveLink(link, x, dir)						\
2849 ( xx_link = (link),							\
2850   Delete(xx_link, 1 - (dir) ),						\
2851   Append(xx_link, (x), 1 - (dir) )					\
2852 ) /* end MoveLink */
2853 
2854 
2855 /*@::TransferLinks(), DeleteNode(), etc.@*************************************/
2856 /*                                                                           */
2857 /*  TransferLinks(start_link, stop_link, dest_link)                          */
2858 /*                                                                           */
2859 /*  Move parent end of links start_link (inclusive) to stop_link (exclusive) */
2860 /*  to just before dest_link.                                                */
2861 /*                                                                           */
2862 /*****************************************************************************/
2863 
2864 #define TransferLinks(start_link, stop_link, dest_link)			\
2865 { OBJECT xxstart = start_link, xxstop = stop_link, xxdest = dest_link;	\
2866   if( xxstart != xxstop )						\
2867   {	assert( type(xxstart) == LINK, "TransferLinks: start_link!" );	\
2868 	Append(xxstart, xxstop, CHILD); /* actually a split */		\
2869 	Append(xxstart, xxdest, CHILD);					\
2870   }									\
2871 }
2872 
2873 
2874 /*****************************************************************************/
2875 /*                                                                           */
2876 /*  DeleteNode(x)                                                            */
2877 /*                                                                           */
2878 /*  Delete node x and every edge attaching to x.                             */
2879 /*                                                                           */
2880 /*****************************************************************************/
2881 
2882 #define DeleteNode(x)							\
2883 { xx_hold = (x);							\
2884   while( Up(xx_hold)   != xx_hold ) DeleteLink( Up(xx_hold) );		\
2885   while( Down(xx_hold) != xx_hold ) DeleteLink( Down(xx_hold) );	\
2886   Dispose(xx_hold);							\
2887 }
2888 
2889 
2890 /*****************************************************************************/
2891 /*                                                                           */
2892 /*  MergeNode(x, y)                                                          */
2893 /*                                                                           */
2894 /*  Take all the children of y and make them children of x.                  */
2895 /*  Take all the parents of y and make them parents of x.  Dispose y.        */
2896 /*                                                                           */
2897 /*****************************************************************************/
2898 
2899 #define MergeNode(x, y)							\
2900 { xx_res = (x); xx_hold = (y);						\
2901   xx_tmp = Delete(xx_hold, PARENT);					\
2902   Append(xx_res, xx_tmp, PARENT);					\
2903   xx_tmp = Delete(xx_hold, CHILD);					\
2904   Append(xx_res, xx_tmp, CHILD);					\
2905   Dispose(xx_hold);							\
2906 }  /* end MergeNode */
2907 
2908 
2909 /*****************************************************************************/
2910 /*                                                                           */
2911 /*  ReplaceNode(x, y)                                                        */
2912 /*                                                                           */
2913 /*  Move all the parent links of y to x.                                     */
2914 /*                                                                           */
2915 /*****************************************************************************/
2916 
2917 #define ReplaceNode(x, y)						\
2918 ( xx_tmp = Delete((y), PARENT),						\
2919   Append((x), xx_tmp, PARENT)						\
2920 ) /* end ReplaceNode */
2921 
2922 
2923 /*@::FirstDefinite(), NextDefinite(), etc.@***********************************/
2924 /*                                                                           */
2925 /*  FirstDefinite(x, link, y, jn)                                            */
2926 /*                                                                           */
2927 /*  On input, x is an object and link and y are undefined.  On output there  */
2928 /*  are two cases:                                                           */
2929 /*                                                                           */
2930 /*  link != x.  Then y is first definite child of x and link is its link;    */
2931 /*              jn is TRUE iff all gaps on the way to link were joined.      */
2932 /*                                                                           */
2933 /*  link == x.  Then x has no definite child and y is undefined.             */
2934 /*                                                                           */
2935 /*  A SPLIT object is considered to be definite if both its children are     */
2936 /*  definite.  This condition is returned by SplitIsDefinite.                */
2937 /*                                                                           */
2938 /*****************************************************************************/
2939 
2940 #define FirstDefinite(x, link, y, jn)					\
2941 { jn = TRUE;								\
2942   for( link = Down(x);  link != x;  link = NextDown(link) )		\
2943   { Child(y, link);							\
2944     if( type(y) == GAP_OBJ )  jn = jn && join(gap(y));			\
2945     else if( type(y)==SPLIT ? SplitIsDefinite(y) : is_definite(type(y)))\
2946       break;								\
2947   }									\
2948 } /* end FirstDefinite */
2949 
2950 
2951 /*****************************************************************************/
2952 /*                                                                           */
2953 /*  NextDefinite(x, link, y)                                                 */
2954 /*                                                                           */
2955 /*  On input, x is an object and link is a link to one of its children; y    */
2956 /*  is undefined.  On output there are two cases:                            */
2957 /*                                                                           */
2958 /*  link != x.  Then y is the first definite child of x following link, and  */
2959 /*              link is changed to be the link of y.                         */
2960 /*                                                                           */
2961 /*  link == x.  Then x has no definite child following link, and y remains   */
2962 /*              undefined.                                                   */
2963 /*                                                                           */
2964 /*****************************************************************************/
2965 
2966 #define NextDefinite(x, link, y)					\
2967 { for( link = NextDown(link);  link != x;  link = NextDown(link) )	\
2968   { Child(y, link);							\
2969     if( type(y) == SPLIT ? SplitIsDefinite(y) : is_definite(type(y)) )	\
2970 	break;								\
2971   }									\
2972 } /* end NextDefinite */
2973 
2974 
2975 /*****************************************************************************/
2976 /*                                                                           */
2977 /*  NextDefiniteWithGap(x, link, y, g, jn)                                   */
2978 /*                                                                           */
2979 /*  On input, x is an object and link is a link to one of its children; y    */
2980 /*  and g are undefined.  On output there are two cases:                     */
2981 /*                                                                           */
2982 /*  link != x.  Then y is the first definite child of x following link, and  */
2983 /*              link is changed to be the link of y.  Also, g is defined     */
2984 /*              to be the gap just before y; this must exist and is tested   */
2985 /*              by an assert test; and jn is true iff all of the gaps on     */
2986 /*              the way from old link to new link are join gaps.             */
2987 /*                                                                           */
2988 /*  link == x.  Then x has no definite child following link, and y and g     */
2989 /*              remain undefined.                                            */
2990 /*                                                                           */
2991 /*****************************************************************************/
2992 
2993 #define NextDefiniteWithGap(x, link, y, g, jn)				\
2994 { g = nilobj;  jn = TRUE;						\
2995   for( link = NextDown(link);  link != x;  link = NextDown(link) )	\
2996   { Child(y, link);							\
2997     if( type(y) == GAP_OBJ )  g = y, jn = jn && join(gap(y));		\
2998     else if( type(y)==SPLIT ? SplitIsDefinite(y):is_definite(type(y)) )	\
2999     {									\
3000       debug2(DFS, DD, "  NextDefiniteWithGap at %s %s",			\
3001 	Image(type(y)), EchoObject(y));					\
3002       assert( g != nilobj, "NextDefiniteWithGap: g == nilobj!" );	\
3003       break;								\
3004     }									\
3005   }									\
3006 } /* end NextDefiniteWithGap */
3007 
3008 /*@@**************************************************************************/
3009 /*                                                                           */
3010 /*  LastDefinite(x, link, y)                                                 */
3011 /*                                                                           */
3012 /*  On input, x is an object and link and y are undefined.  On output there  */
3013 /*  are two cases:                                                           */
3014 /*                                                                           */
3015 /*  link != x.  Then y is the last definite child of x and link is its link. */
3016 /*                                                                           */
3017 /*  link == x.  Then x has no definite child and y is undefined.             */
3018 /*                                                                           */
3019 /*  A SPLIT object is considered to be definite if both its children are     */
3020 /*  definite.  This condition is returned by SplitIsDefinite.                */
3021 /*                                                                           */
3022 /*****************************************************************************/
3023 
3024 #define LastDefinite(x, link, y)					\
3025 { for( link = LastDown(x);  link != x;  link = PrevDown(link) )		\
3026   { Child(y, link);							\
3027     if( type(y) == SPLIT ? SplitIsDefinite(y) : is_definite(type(y)) )	\
3028 	break;								\
3029   }									\
3030 } /* end LastDefinite */
3031 
3032 
3033 /*****************************************************************************/
3034 /*                                                                           */
3035 /*  PrevDefinite(x, link, y)                                                 */
3036 /*                                                                           */
3037 /*  On input, x is an object and link is a link to one of its children; y    */
3038 /*  is undefined.  On output there are two cases:                            */
3039 /*                                                                           */
3040 /*  link != x.  Then y is the first definite child of x preceding link, and  */
3041 /*              link is changed to be the link of y.                         */
3042 /*                                                                           */
3043 /*  link == x.  Then x has no definite child preceding link, and y remains   */
3044 /*              undefined.                                                   */
3045 /*                                                                           */
3046 /*****************************************************************************/
3047 
3048 #define PrevDefinite(x, link, y)					\
3049 { for( link = PrevDown(link);  link != x;  link = PrevDown(link) )	\
3050   { Child(y, link);							\
3051     if( type(y) == SPLIT ? SplitIsDefinite(y) : is_definite(type(y)) )	\
3052 	break;								\
3053   }									\
3054 } /* end PrevDefinite */
3055 
3056 
3057 /*@::Module Declarations@*****************************************************/
3058 /*                                                                           */
3059 /*  MODULE DECLARATIONS                                                      */
3060 /*                                                                           */
3061 /*****************************************************************************/
3062 
3063 /*****  z01.c	  Supervise		**************************************/
3064 extern	void	  PrintUsage(FILE *fp);
3065 extern	int	  main(int argc, char *argv[]);
3066 extern	POINTER	  MemCheck;
3067 extern	OBJECT	  StartSym;
3068 extern	OBJECT	  GalleySym;
3069 extern	OBJECT	  ForceGalleySym;
3070 extern	OBJECT	  InputSym;
3071 extern	OBJECT	  PrintSym;
3072 extern	OBJECT	  FilterInSym;
3073 extern	OBJECT	  FilterOutSym;
3074 extern	OBJECT	  FilterErrSym;
3075 extern	OBJECT	  VerbatimSym;
3076 extern	OBJECT	  RawVerbatimSym;
3077 extern	OBJECT	  OptGallSym;
3078 extern	BACK_END  BackEnd;
3079 extern	OBJECT	  CommandOptions;
3080 extern	BOOLEAN	  AllowCrossDb;
3081 extern	BOOLEAN	  UseCollate;
3082 extern	BOOLEAN	  InMemoryDbIndexes;
3083 extern	BOOLEAN	  Kern;
3084 extern	BOOLEAN	  SafeExecution;
3085 extern	BOOLEAN   AltErrorFormat;
3086 extern	int	  TotalWordCount;
3087 extern	BOOLEAN	  InitializeAll;
3088 #if LOCALE_ON
3089 extern	nl_catd	  MsgCat;
3090 #endif
3091 
3092 /*****  z02.c	  Lexical Analyser	**************************************/
3093 extern	BOOLEAN	  LexLegalName(FULL_CHAR *str);
3094 extern	void	  LexInit(void);
3095 extern	void	  LexPush(FILE_NUM x, int offs, int ftyp, int lnum, BOOLEAN same);
3096 extern	void	  LexPop(void);
3097 extern	long	  LexNextTokenPos(void);
3098 extern	OBJECT	  LexGetToken(void);
3099 extern	OBJECT	  LexScanVerbatim(FILE *fp, BOOLEAN end_stop, FILE_POS *err_pos,
3100 		    BOOLEAN lessskip);
3101 
3102 /*****  z03.c	  File Service	        **************************************/
3103 extern	FILE_POS  *no_fpos;
3104 extern	void	  InitFiles(void);
3105 extern	void	  AddToPath(int fpath, OBJECT dirname);
3106 extern	FILE_NUM  DefineFile(FULL_CHAR *str, FULL_CHAR *suffix,
3107 		    FILE_POS *xfpos, int ftype, int fpath);
3108 extern	FILE_NUM  FirstFile(int ftype);
3109 extern	FILE_NUM  NextFile(FILE_NUM i);
3110 extern	FILE_NUM  FileNum(FULL_CHAR *str, FULL_CHAR *suffix);
3111 extern	FILE_NUM  DatabaseFileNum(FILE_POS *xfpos);
3112 extern	FULL_CHAR *FileName(FILE_NUM fnum);
3113 extern	FULL_CHAR *FullFileName(FILE_NUM fnum);
3114 extern	int	  FileType(FILE_NUM fnum);
3115 extern	FULL_CHAR *EchoFilePos(FILE_POS *pos);
3116 extern	FULL_CHAR *EchoAltFilePos(FILE_POS *pos);
3117 extern	FULL_CHAR *EchoFileSource(FILE_NUM fnum);
3118 extern	FULL_CHAR *EchoFileLine(FILE_POS *pos);
3119 extern	FILE_POS  *PosOfFile(FILE_NUM fnum);
3120 extern	FILE	  *OpenFile(FILE_NUM fnum, BOOLEAN check_ld, BOOLEAN check_lt);
3121 extern	FILE	  *OpenIncGraphicFile(FULL_CHAR *str, unsigned char typ,
3122 		    OBJECT *full_name, FILE_POS *xfpos, BOOLEAN *compressed);
3123 extern	void	  FileSetUpdated(FILE_NUM fnum, int newlines);
3124 extern	int	  FileGetLineCount(FILE_NUM fnum);
3125 extern	BOOLEAN	  FileTestUpdated(FILE_NUM fnum);
3126 
3127 /*****  z04.c	  Token Service	        **************************************/
3128 extern	OBJECT	  NewToken(unsigned char xtype, FILE_POS *xfpos,
3129 		    unsigned char xvspace, unsigned char xhspace,
3130 		    unsigned char xprec, OBJECT xactual);
3131 extern	OBJECT	  CopyTokenList(OBJECT x, FILE_POS *pos);
3132 extern	FULL_CHAR *EchoCatOp(unsigned xtype, BOOLEAN xmark, BOOLEAN xjoin);
3133 extern	FULL_CHAR *EchoToken(OBJECT x);
3134 
3135 /*****  z05.c	  Read Definitions  	**************************************/
3136 extern	void	  ReadPrependDef(unsigned typ, OBJECT encl);
3137 extern	void	  ReadIncGRepeatedDef(unsigned typ, OBJECT encl);
3138 extern	void	  ReadDatabaseDef(unsigned typ, OBJECT encl);
3139 extern	void	  ReadDefinitions(OBJECT *token, OBJECT encl,
3140 		    unsigned char res_type);
3141 
3142 /*****  z06.c	  Object Parser	        **************************************/
3143 extern	BOOLEAN	  InDefinitions;
3144 extern	void	  SetScope(OBJECT env, int *count, BOOLEAN vis_only);
3145 extern	void	  InitParser(FULL_CHAR *cross_db);
3146 extern	OBJECT	  Parse(OBJECT *token, OBJECT encl, BOOLEAN defs_allowed,
3147 		    BOOLEAN transfer_allowed);
3148 
3149 /*****  z07.c	  Object Service	**************************************/
3150 extern	BOOLEAN	  SplitIsDefinite(OBJECT x);
3151 extern	int	  DisposeObject(OBJECT x);
3152 extern	OBJECT	  MakeWord(unsigned typ, FULL_CHAR *str, FILE_POS *pos);
3153 extern	OBJECT	  MakeWordTwo(unsigned typ, FULL_CHAR *str1, FULL_CHAR *str2,
3154 		    FILE_POS *pos);
3155 extern	OBJECT	  MakeWordThree(FULL_CHAR *s1, FULL_CHAR *s2, FULL_CHAR *s3);
3156 extern	OBJECT	  CopyObject(OBJECT x, FILE_POS *pos);
3157 extern	OBJECT	  InsertObject(OBJECT x, OBJECT *ins, STYLE *style);
3158 extern	OBJECT	  Meld(OBJECT x, OBJECT y);
3159 extern	BOOLEAN	  EqualManifested(OBJECT x, OBJECT y);
3160 
3161 /*****  z08.c	  Object Manifest	**************************************/
3162 extern	OBJECT	  ReplaceWithTidy(OBJECT x, int one_word);
3163 extern	float	  GetScaleFactor(OBJECT x);
3164 extern	OBJECT	  Manifest(OBJECT x, OBJECT env, STYLE *style, OBJECT bthr[2],
3165 		    OBJECT fthr[2], OBJECT *target, OBJECT *crs, BOOLEAN ok,
3166 		    BOOLEAN need_expand, OBJECT *enclose, BOOLEAN fcr);
3167 
3168 /*****  z09.c	  Closure Expansion	**************************************/
3169 extern	OBJECT	  SearchEnv(OBJECT env, OBJECT sym);
3170 extern	OBJECT	  SetEnv(OBJECT x, OBJECT y);
3171 extern	void	  AttachEnv(OBJECT env, OBJECT x);
3172 extern	OBJECT	  GetEnv(OBJECT x);
3173 extern	OBJECT	  DetachEnv(OBJECT x);
3174 extern	OBJECT	  ClosureExpand(OBJECT x, OBJECT env, BOOLEAN crs_wanted,
3175 		    OBJECT *crs, OBJECT *res_env);
3176 extern	OBJECT	  ParameterCheck(OBJECT x, OBJECT env);
3177 
3178 /*****  z10.c	  Cross References	**************************************/
3179 extern	void	  CrossInitModule(void);
3180 extern	void	  CrossInit(OBJECT sym);
3181 extern	OBJECT	  CrossMake(OBJECT sym, OBJECT val, int ctype);
3182 extern	OBJECT	  GallTargEval(OBJECT sym, FILE_POS *dfpos);
3183 extern	void	  CrossAddTag(OBJECT x);
3184 extern	OBJECT	  CrossExpand(OBJECT x, OBJECT env, STYLE *style,
3185 		    OBJECT *crs, OBJECT *res_env);
3186 extern	void	  CrossSequence(OBJECT x);
3187 extern	void	  CrossClose(void);
3188 
3189 /*****  z11.c	  Style Service		**************************************/
3190 extern	FULL_CHAR *EchoStyle(STYLE *style);
3191 extern	void	  SpaceChange(STYLE *style, OBJECT x);
3192 extern	void	  BreakChange(STYLE *style, OBJECT x);
3193 extern	void	  YUnitChange(STYLE *style, OBJECT x);
3194 extern	void	  ZUnitChange(STYLE *style, OBJECT x);
3195 
3196 /*****  z12.c	  Size Finder		**************************************/
3197 extern	void	  SpannerAvailableSpace(OBJECT y, int dim, FULL_LENGTH *resb,
3198 		     FULL_LENGTH *resf);
3199 extern	OBJECT	  MinSize(OBJECT x, int dim, OBJECT *extras);
3200 
3201 /*****  z13.c	  Object Breaking	**************************************/
3202 extern	OBJECT	  BreakObject(OBJECT x, CONSTRAINT *c);
3203 
3204 /*****  z14.c	  Object Filling        **************************************/
3205 extern	OBJECT	  FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi,
3206 		     BOOLEAN can_hyphenate, BOOLEAN allow_shrink,
3207 		     BOOLEAN extend_unbreakable, BOOLEAN *hyph_used);
3208 
3209 /*****  z15.c	  Size Constraints	**************************************/
3210 extern	void	  MinConstraint(CONSTRAINT *xc, CONSTRAINT *yc);
3211 extern	void	  SetSizeToMaxForwardConstraint(FULL_LENGTH *b, FULL_LENGTH *f,
3212 		    CONSTRAINT *c);
3213 extern	void	  EnlargeToConstraint(FULL_LENGTH *b, FULL_LENGTH *f,
3214 		    CONSTRAINT *c);
3215 extern	int	  ScaleToConstraint(FULL_LENGTH b, FULL_LENGTH f,
3216 		    CONSTRAINT *c);
3217 extern	void	  InvScaleConstraint(CONSTRAINT *yc, FULL_LENGTH sf,
3218 		    CONSTRAINT*xc);
3219 extern	void	  RotateConstraint(CONSTRAINT *c, OBJECT y, FULL_LENGTH angle,
3220 		    CONSTRAINT *hc, CONSTRAINT *vc, int dim);
3221 extern	BOOLEAN	  InsertScale(OBJECT x, CONSTRAINT *c);
3222 extern	void	  Constrained(OBJECT x, CONSTRAINT *xc, int dim, OBJECT *why);
3223 extern	FULL_CHAR *EchoConstraint(CONSTRAINT *c);
3224 extern	void	  DebugConstrained(OBJECT x);
3225 
3226 /*****  z16.c	  Size Adjustments	**************************************/
3227 extern	FULL_LENGTH	  FindShift(OBJECT x, OBJECT y, int dim);
3228 extern	void	  SetNeighbours(OBJECT link, BOOLEAN ratm, OBJECT *pg,
3229 		    OBJECT *pdef, OBJECT *sg, OBJECT *sdef, int *side);
3230 extern	void	  AdjustSize(OBJECT x, FULL_LENGTH b, FULL_LENGTH f, int dim);
3231 
3232 /*****  z17.c	  Gap Widths		**************************************/
3233 extern	int	  GetWidth(OBJECT x, STYLE *style);
3234 extern	void	  GetGap(OBJECT x, STYLE *style, GAP *res_gap,
3235 		    unsigned *res_inc);
3236 extern	FULL_LENGTH  MinGap(FULL_LENGTH a, FULL_LENGTH b, FULL_LENGTH c, GAP *xgap);
3237 extern	FULL_LENGTH  ExtraGap(FULL_LENGTH a, FULL_LENGTH b, GAP *xgap, int dir);
3238 extern	FULL_LENGTH  ActualGap(FULL_LENGTH a, FULL_LENGTH b, FULL_LENGTH c,
3239 		       GAP *xgap, FULL_LENGTH f, FULL_LENGTH mk);
3240 extern	FULL_CHAR *EchoGap(GAP *xgap);
3241 
3242 /*****  z18.c	  Galley Transfer	**************************************/
3243 extern	STYLE	  InitialStyle;
3244 extern	CONTEXT	  InitialContext;
3245 extern	OBJECT	  InitialEnvironment;
3246 extern	void	  TransferInit(OBJECT InitEnv);
3247 extern	OBJECT	  TransferBegin(OBJECT x);
3248 extern	void	  TransferComponent(OBJECT x);
3249 extern	void	  TransferEnd(OBJECT x);
3250 extern	void	  TransferClose(void);
3251 
3252 /*****  z19.c	  Galley Attaching	**************************************/
3253 extern	void	  DetachGalley(OBJECT hd);
3254 extern	OBJECT	  SearchGalley(OBJECT start, OBJECT sym, BOOLEAN forwards,
3255 		    BOOLEAN subgalleys, BOOLEAN closures, BOOLEAN input);
3256 extern	int	  AttachGalley(OBJECT hd, OBJECT *inners, OBJECT *suspend_pt);
3257 
3258 /*****  z20.c	  Galley Flushing	**************************************/
3259 extern	FULL_CHAR *DebugInnersNames(OBJECT inners);
3260 extern	void	  FlushGalley(OBJECT hd);
3261 
3262 /***    z21.c	  Galley Maker		**************************************/
3263 extern	void	  SizeGalley(OBJECT hd, OBJECT env, BOOLEAN rows,
3264 		    BOOLEAN joined, BOOLEAN nonblock, BOOLEAN trig,
3265 		    STYLE *style, CONSTRAINT *c, OBJECT target,
3266 		    OBJECT *dest_index, OBJECT *recs, OBJECT *inners,
3267 		    OBJECT enclose);
3268 
3269 /***    z22.c	  Galley Service	**************************************/
3270 extern	void	  PromoteInit(void);
3271 extern	void	  ClearHeaders(OBJECT hd);
3272 extern	void	  Interpose(OBJECT z, int typ, OBJECT x, OBJECT y);
3273 extern	void	  FlushInners(OBJECT inners, OBJECT hd);
3274 extern	void	  ExpandRecursives(OBJECT recs);
3275 extern	void	  HandleHeader(OBJECT hd, OBJECT header);
3276 extern	void	  Promote(OBJECT hd, OBJECT stop_link, OBJECT dest_index,
3277 		    BOOLEAN join_after);
3278 extern	void	  KillGalley(OBJECT hd, BOOLEAN optimize);
3279 extern	void	  FreeGalley(OBJECT hd, OBJECT stop_link, OBJECT *inners,
3280 		    OBJECT relocate_link, OBJECT sym);
3281 extern	void	  SetTarget(OBJECT hd);
3282 extern	int	  CheckComponentOrder(OBJECT preceder, OBJECT follower);
3283 
3284 /*****  z23.c	  Galley Printer	**************************************/
3285 extern	OBJECT	  FixAndPrintObject(OBJECT x, FULL_LENGTH xmk, FULL_LENGTH xb,
3286 		    FULL_LENGTH xf, int dim, BOOLEAN suppress, FULL_LENGTH pg,
3287 		    int count, FULL_LENGTH *actual_back, FULL_LENGTH *actual_fwd);
3288 
3289 /*****  z24.c	  Print Service         **************************************/
3290 extern	char	  *EightBitToPrintForm[];
3291 
3292 /*****  z25.c	  Object Echo	        **************************************/
3293 extern	FULL_CHAR *EchoObject(OBJECT x);
3294 extern	void	  DebugObject(OBJECT x);
3295 extern	FULL_CHAR *EchoIndex(OBJECT index);
3296 extern	void	  DebugGalley(OBJECT hd, OBJECT pinpt, int indent);
3297 
3298 /*****  z26.c	  Echo Service	        **************************************/
3299 extern	void	  BeginString(void);
3300 extern	void	  AppendString(FULL_CHAR *str);
3301 extern	FULL_CHAR *EndString(void);
3302 extern	FULL_CHAR *EchoLength(int len);
3303 extern	FULL_CHAR *Image(unsigned int c);
3304 extern	void	  SetLengthDim(int dim);
3305 
3306 /*****	z27.c	  Debug Service		**************************************/
3307 #if DEBUG_ON
3308 extern	void	  DebugInit(FULL_CHAR *str);
3309 extern	void	  Debug(int category, int urgency, char *str, ...);
3310 extern	void	  ProfileOn(char *str);
3311 extern	void	  ProfileOff(char *str);
3312 extern	void	  ProfilePrint(void);
3313 #endif
3314 
3315 /*****	z28.c	  Error Service		**************************************/
3316 extern	void	  ErrorInit(void);
3317 extern	void	  ErrorSetFile(FULL_CHAR *str);
3318 extern	BOOLEAN	  ErrorSeen(void);
3319 extern	void	  EnterErrorBlock(BOOLEAN ok_to_print);
3320 extern	void	  LeaveErrorBlock(BOOLEAN commit);
3321 extern	void	  CheckErrorBlocks(void);
3322 extern	POINTER	  Error(int set_num, int msg_num, char *str, int etype,
3323 		    FILE_POS *pos, ...);
3324 
3325 /*****  z29.c	  Symbol Table		**************************************/
3326 extern	void	  InitSym(void);
3327 extern	void	  PushScope(OBJECT x, BOOLEAN npars, BOOLEAN vis);
3328 extern	void	  PopScope(void);
3329 extern	void	  SuppressVisible(void);
3330 extern	void	  UnSuppressVisible(void);
3331 extern	void	  SuppressScope(void);
3332 extern	void	  UnSuppressScope(void);
3333 extern	void	  SwitchScope(OBJECT sym);
3334 extern	void	  UnSwitchScope(OBJECT sym);
3335 extern	void	  BodyParAllowed(void);
3336 extern	void	  BodyParNotAllowed(void);
3337 extern	OBJECT	  GetScopeSnapshot(void);
3338 extern	void	  LoadScopeSnapshot(OBJECT ss);
3339 extern	void	  ClearScopeSnapshot(OBJECT ss);
3340 extern	OBJECT	  InsertSym(FULL_CHAR *str, unsigned char xtype,
3341 		    FILE_POS *xfpos, unsigned char xprecedence,
3342 		    BOOLEAN xindefinite, BOOLEAN xrecursive,
3343 		    unsigned xpredefined, OBJECT xenclosing, OBJECT xbody);
3344 extern	void	  InsertAlternativeName(FULL_CHAR *str, OBJECT s,
3345 		    FILE_POS *xfpos);
3346 extern	OBJECT	  SearchSym(FULL_CHAR *str, int len);
3347 extern	FULL_CHAR *SymName(OBJECT s);
3348 extern	FULL_CHAR *FullSymName(OBJECT x, FULL_CHAR *str);
3349 extern	OBJECT	  ChildSym(OBJECT s, unsigned typ);
3350 extern	OBJECT	  ChildSymWithCode(OBJECT s, unsigned char code);
3351 extern	void	  CheckSymSpread(void);
3352 extern	void	  DeleteEverySym(void);
3353 extern	void	  DebugScope(void);
3354 
3355 /*****  z30.c	  Symbol Uses		**************************************/
3356 extern	void	  InsertUses(OBJECT x, OBJECT y);
3357 extern	void	  FlattenUses(void);
3358 extern	BOOLEAN	  SearchUses(OBJECT x, OBJECT y);
3359 extern	OBJECT	  FirstExternTarget(OBJECT sym, OBJECT *cont);
3360 extern	OBJECT	  NextExternTarget(OBJECT sym, OBJECT *cont);
3361 
3362 /*****  z31.c	  Memory Allocator	**************************************/
3363 extern	void	  DebugRegisterUsage(int typ, int delta_num, int delta_size);
3364 extern	void	  DebugMemory(void);
3365 extern	void	  MemInit(void);
3366 extern	OBJECT	  GetMemory(int siz, FILE_POS *pos);
3367 extern	OBJECT	  zz_free[];
3368 extern	unsigned char	zz_lengths[];
3369 extern	int	  zz_newcount;
3370 extern	int	  zz_disposecount;
3371 extern	int	  zz_listcount;
3372 extern	OBJECT	  zz_hold;
3373 extern	OBJECT	  zz_tmp;
3374 extern	OBJECT	  zz_res;
3375 extern	int	  zz_size;
3376 extern	OBJECT	  xx_link, xx_tmp;
3377 extern	OBJECT	  xx_hold, xx_res;
3378 
3379 /*****  z32.c	  Counter Service           **********************************/
3380 extern	OBJECT	  Next(OBJECT x, int inc, BOOLEAN *done);
3381 
3382 /*****  z33.c	  Database Service	**************************************/
3383 extern	OBJECT	  OldCrossDb;
3384 extern	OBJECT	  NewCrossDb;
3385 extern	void	  DbInit(void);
3386 extern	OBJECT	  DbCreate(OBJECT x);
3387 extern	void	  DbInsert(OBJECT db, BOOLEAN gall, OBJECT sym, FULL_CHAR *tag,
3388 		    FILE_POS *tagfpos, FULL_CHAR *seq, FILE_NUM dfnum,
3389 		    long dfpos, int dlnum, BOOLEAN check);
3390 extern	void	  DbConvert(OBJECT db, BOOLEAN full_name);
3391 extern	void	  DbClose(OBJECT db);
3392 extern	OBJECT	  DbLoad(OBJECT stem, int fpath, BOOLEAN create, OBJECT symbs,
3393 		    BOOLEAN in_memory);
3394 extern	BOOLEAN	  DbRetrieve(OBJECT db, BOOLEAN gall, OBJECT sym,
3395 		    FULL_CHAR *tag, FULL_CHAR *seq, FILE_NUM *dfnum,
3396 		    long *dfpos, int *dlnum, long *cont);
3397 extern	BOOLEAN	  DbRetrieveNext(OBJECT db, BOOLEAN *gall, OBJECT *sym,
3398 		    FULL_CHAR *tag, FULL_CHAR *seq, FILE_NUM *dfnum,
3399 		    long *dfpos, int *dlnum, long *cont);
3400 
3401 /*****  z34.c	  Rotation Service    	**************************************/
3402 extern	void	  RotateSize(FULL_LENGTH *xcb, FULL_LENGTH *xcf,
3403 		    FULL_LENGTH *xrb, FULL_LENGTH *xrf, OBJECT y,
3404 		    FULL_LENGTH theta);
3405 
3406 /*****  z35.c	  Time Keeper     	**************************************/
3407 extern	FULL_CHAR *TimeString(void);
3408 extern	void	  InitTime(void);
3409 extern	OBJECT	  MomentSym;
3410 extern	OBJECT	  StartMoment(void);
3411 
3412 /*****  z36.c	  Hyphenation     	**************************************/
3413 extern	void	  HyphInit(void);
3414 extern	BOOLEAN	  ReadHyphTable(LANGUAGE_NUM lnum);
3415 extern	OBJECT	  Hyphenate(OBJECT x);
3416 
3417 /*****  z37.c	  Font Service           *************************************/
3418 extern	OBJECT	  FontDefSym;
3419 extern	FONT_INFO *finfo;
3420 extern	int	  font_curr_page;
3421 extern	void	  FontInit(void);
3422 extern	void	  FontChange(STYLE *style, OBJECT x);
3423 extern	FULL_LENGTH FontKernLength(FONT_NUM fnum, FULL_CHAR *unacc_map,
3424   FULL_CHAR ch1, FULL_CHAR ch2);
3425 extern	void	  FontWordSize(OBJECT x);
3426 extern	FULL_LENGTH  FontSize(FONT_NUM fnum, OBJECT x);
3427 extern	FULL_LENGTH  FontHalfXHeight(FONT_NUM fnum);
3428 extern	MAPPING	  FontMapping(FONT_NUM fnum, FILE_POS *xfpos);
3429 extern	FULL_CHAR *FontName(FONT_NUM fnum);
3430 extern	FULL_CHAR *FontFamily(FONT_NUM fnum);
3431 extern	FULL_CHAR *FontFace(FONT_NUM fnum);
3432 extern	FULL_CHAR *FontFamilyAndFace(FONT_NUM fnum);
3433 extern	void	  FontPrintAll(FILE *fp);
3434 extern	void	  FontPrintPageSetup(FILE *fp);
3435 extern	void	  FontPrintPageResources(FILE *fp);
3436 extern	void	  FontAdvanceCurrentPage(void);
3437 extern	void	  FontPageUsed(OBJECT face);
3438 extern	BOOLEAN	  FontNeeded(FILE *fp);
3439 extern	FULL_LENGTH FontGlyphHeight(FONT_NUM fnum, FULL_CHAR chr);
3440 extern	FULL_LENGTH FontGlyphWidth(FONT_NUM fnum, FULL_CHAR chr);
3441 
3442 /*****  z38.c	  Character Mappings    **************************************/
3443 extern	MAP_VEC	  MapTable[];
3444 extern	void	  MapInit(void);
3445 extern	MAPPING	  MapLoad(OBJECT filename, BOOLEAN recoded);
3446 extern	FULL_CHAR MapCharEncoding(FULL_CHAR *str, MAPPING m);
3447 extern	FULL_CHAR *MapEncodingName(MAPPING m);
3448 extern	void	  MapPrintEncodings(void);
3449 extern	void	  MapEnsurePrinted(MAPPING m, int curr_page);
3450 extern	void	  MapPrintPSResources(FILE *fp);
3451 extern	OBJECT	  MapSmallCaps(OBJECT x, STYLE *style);
3452 extern	BOOLEAN	  MapIsLowerCase(FULL_CHAR ch, MAPPING m);
3453 
3454 
3455 /*****  z39.c	  String Handler        **************************************/
3456 #define		  AsciiToFull(x)	( (FULL_CHAR *) (x) )
3457 #define		  StringEqual(a, b)	(strcmp((char *)(a), (char *)(b))==0)
3458 extern int	  strcollcmp(char *a, char *b);
3459 #define		  TabbedStringLessEqual(a, b) \
3460 		    ( UseCollate ? strcollcmp((char *)(a),(char *)(b)) <= 0 \
3461 				 : strcmp((char *)(a),(char *)(b)) <= 0 )
3462 #define		  StringCat(a, b)	strcat((char *)(a),(char *)(b))
3463 #define		  StringCopy(a, b)	strcpy((char *)(a),(char *)(b))
3464 #define		  StringLength(a)	strlen((char *)(a))
3465 #define		  StringFOpen(a, b)	fopen( (char *) (a), (b) )
3466 #define		  StringFPuts(a, b)	fputs( (char *) (a), (b) )
3467 #define		  StringRemove(a)	remove((char *)(a))
3468 #define		  StringRename(a, b)	rename((char *)(a),(char *)(b))
3469 extern	BOOLEAN	  StringBeginsWith(FULL_CHAR *str, FULL_CHAR *pattern);
3470 extern	BOOLEAN	  StringBeginsWithWord(FULL_CHAR *str, FULL_CHAR *pattern);
3471 extern	BOOLEAN	  StringEndsWith(FULL_CHAR *str, FULL_CHAR *pattern);
3472 extern	BOOLEAN	  StringContains(FULL_CHAR *str, FULL_CHAR *pattern);
3473 extern	FULL_CHAR *StringInt(int i);
3474 extern	FULL_CHAR *StringFiveInt(int i);
3475 extern	FULL_CHAR *StringQuotedWord(OBJECT x);
3476 
3477 /*****  z40.c	  Filter Handler        **************************************/
3478 extern	void	  FilterInit(void);
3479 extern	OBJECT	  FilterCreate(BOOLEAN use_begin, OBJECT act, FILE_POS *xfpos);
3480 extern	void	  FilterSetFileNames(OBJECT x);
3481 extern	OBJECT	  FilterExecute(OBJECT x, FULL_CHAR *command, OBJECT env);
3482 extern	void	  FilterWrite(OBJECT x, FILE *fp, int *linecount);
3483 extern	void	  FilterScavenge(BOOLEAN all);
3484 
3485 /*****  z41.c	  Object Input-Output   **************************************/
3486 extern	void	  ReadFromFileInit(void);
3487 extern	OBJECT	  ReadFromFile(FILE_NUM fnum, long pos, int lnum);
3488 extern	void	  AppendToFile(OBJECT x, FILE_NUM fnum, int *pos, int *lnum);
3489 extern	void	  CloseFiles(void);
3490 
3491 /*****  z42.c	  Colour Service        **************************************/
3492 extern	void	  ColourInit(void);
3493 extern	void	  ColourChange(STYLE *style, OBJECT x);
3494 extern	void	  ColourUnderlineChange(STYLE *style, OBJECT x);
3495 extern	FULL_CHAR *ColourCommand(COLOUR_NUM cnum);
3496 
3497 /*****  z43.c	  Language Service      **************************************/
3498 extern	void	  LanguageInit(void);
3499 extern	BOOLEAN	  LanguageWordEndsSentence(OBJECT wd, BOOLEAN lc_prec);
3500 extern	void	  LanguageDefine(OBJECT names, OBJECT hyph_file);
3501 extern	void	  LanguageChange(STYLE *style, OBJECT x);
3502 extern	FULL_CHAR *LanguageString(LANGUAGE_NUM lnum);
3503 extern	OBJECT	  LanguageHyph(LANGUAGE_NUM lnum);
3504 extern	BOOLEAN	  LanguageSentenceEnds[];
3505 
3506 /*****  z44.c	  Vertical Hyphenation  **************************************/
3507 extern	BOOLEAN	  VerticalHyphenate(OBJECT y);
3508 extern	OBJECT	  ConvertGalleyList(OBJECT x);
3509 extern	OBJECT	  BuildEnclose(OBJECT hd);
3510 
3511 /*****  z45.c	  External Sort         **************************************/
3512 extern	int	  ReadOneLine(FILE *fp, FULL_CHAR *buff, int buff_len);
3513 extern	int	  ReadOneBinaryLine(FILE *fp, FULL_CHAR *buff, int buff_len,
3514                     int *count, long *remaining_len);
3515 extern	LINE	  *ReadLines(FILE *fp, FULL_CHAR *fname, FULL_CHAR *first_line, int *len);
3516 extern	void	  WriteLines(FILE *fp, LINE *lines, int len);
3517 extern	void	  SortLines(LINE *lines, int lines_len);
3518 extern	void	  SortFile(FULL_CHAR *infile, FULL_CHAR *outfile);
3519 
3520 /*****  z46.c	  Optimal Galleys       **************************************/
3521 extern	BOOLEAN	  FindOptimize(OBJECT x, OBJECT env);
3522 extern	void	  SetOptimize(OBJECT hd, STYLE *style);
3523 extern	void	  GazumpOptimize(OBJECT hd, OBJECT dest);
3524 extern	void	  CalculateOptimize(OBJECT hd);
3525 extern	void	  DebugOptimize(OBJECT hd);
3526 
3527 /*****  z47.c	  Environment Table     **************************************/
3528 extern	void	  EnvInit(void);
3529 extern	BOOLEAN	  EnvWriteRetrieve(OBJECT env, FILE_NUM fnum, int *offset,
3530 		    int *lnum);
3531 extern	void	  EnvWriteInsert(OBJECT env, FILE_NUM fnum, int offset,int lnum);
3532 extern	BOOLEAN	  EnvReadRetrieve(FILE_NUM fnum, int offset, OBJECT *env);
3533 extern	void	  EnvReadInsert(FILE_NUM fnum, int offset, OBJECT env);
3534 extern	void	  EnvDebug(void);
3535 
3536 /*****  z48.c	  PDF back end (old)    **************************************/
3537 extern	void      PDFFile_Init(FILE* in_fp, int in_h_bound, int in_v_bound,
3538 				int in_IN, int in_CM, int in_PT, int in_EM);
3539 extern	void      PDFFile_BeginFontEncoding(FILE* in_fp,
3540 				const char* in_encoding_name);
3541 extern	void      PDFFile_EndFontEncoding(FILE* in_fp);
3542 extern	void      PDFFile_Cleanup(FILE* in_fp);
3543 extern	void      PDFPage_Init(FILE* in_fp, float in_scale_factor,
3544 				int in_line_width);
3545 extern	void      PDFPage_Cleanup(FILE* in_fp);
3546 extern	void	  PDFPage_Write(FILE* in_fp, char* in_str);
3547 extern	void      PDFPage_Push(FILE* in_fp);
3548 extern	void      PDFPage_Pop(FILE* in_fp);
3549 extern	void	  PDFPage_Scale(FILE* in_fp, float in_h_scale_factor,
3550 				float in_v_scale_factor);
3551 extern	void	  PDFPage_Translate(FILE* in_fp, float in_delta_h,
3552 				float in_delta_v);
3553 extern	void	  PDFPage_Rotate(FILE* in_fp, float in_angle_in_radians);
3554 extern	void	  PDFPage_SetVars(int xsize, int ysize, int xmark, int ymark,
3555 				int loutf, int loutv, int louts);
3556 extern	void	  PDFPage_WriteGraphic(FILE* in_fp, FULL_CHAR* in_str);
3557 extern	void	  PDFPage_PrintUnderline(FILE* in_fp, int in_x1, int in_x2,
3558 				int in_y, int in_thickness);
3559 
3560 extern	void      PDFFont_AddFont(
3561 				FILE* in_fp,
3562 				const FULL_CHAR* in_short_font_name,
3563 				const FULL_CHAR* in_real_font_name,
3564 				const FULL_CHAR* in_font_encoding_name);
3565 extern	void      PDFFont_Set(FILE* in_fp, FULL_LENGTH in_font_size,
3566 				FULL_CHAR * in_short_font_name);
3567 extern	void    PDFText_OpenXY(FILE* in_fp, int hpos, int vpos);
3568 extern	void    PDFText_OpenX(FILE* in_fp, int hpos);
3569 extern	void    PDFText_Open(FILE* in_fp);
3570 extern	void    PDFText_Kern(FILE* in_fp, int in_kern);
3571 extern	void    PDFText_Close(FILE* in_fp);
3572 extern	BOOLEAN PDFHasValidTextMatrix(void);
3573 
3574 /*****  z49.c	  PostScript back end   **************************************/
3575 extern	BACK_END  PS_BackEnd;
3576 extern	BACK_END  PS_NullBackEnd;
3577 extern	void	  PS_IncGRepeated(OBJECT x);
3578 /* extern	int	  PS_FindIncGRepeated(OBJECT x, int typ); */
3579 /* extern	void	  PS_PrintEPSFile(FILE *fp, FILE_POS *pos); */
3580 extern	BOOLEAN	  PS_FindBoundingBox(FILE *fp, FILE_POS *pos, FULL_LENGTH *llx,
3581 		    FULL_LENGTH *lly, FULL_LENGTH *urx, FULL_LENGTH *ury);
3582 
3583 /*****  z50.c	  PDF back end (new)    **************************************/
3584 extern	BACK_END  PDF_BackEnd;		/* PDF back end record               */
3585 
3586 /*****  z51.c	  Plain text back end   **************************************/
3587 extern	BACK_END  Plain_BackEnd;	/* Plain Text back end record        */
3588 extern	BACK_END  Plain_NullBackEnd;	/* Plain Text null back end record   */
3589 extern	FULL_LENGTH PlainCharWidth;	/* character width                   */
3590 extern	FULL_LENGTH PlainCharHeight;	/* character height		     */
3591 extern	BOOLEAN	  PlainFormFeed;	/* true if using \f		     */
3592 
3593 /*****  z52.c	  Texture Service        **************************************/
3594 extern	BOOLEAN	  UseTexture;
3595 extern	void	  TextureInit(void);
3596 extern	void	  TextureChange(STYLE *style, OBJECT x);
3597 extern	FULL_CHAR *TextureCommand(TEXTURE_NUM pnum);
3598 
3599 /*@::assert(), debug(), debug flags@******************************************/
3600 /*                                                                           */
3601 /*  ASSERT AND DEBUG CODE                                                    */
3602 /*                                                                           */
3603 /*****************************************************************************/
3604 
3605 #if ASSERT_ON
3606 #define assert(c, m)							\
3607    { if( !(c) )  Error(1, 2, "assert failed in %s", INTERN, no_fpos, m); }
3608 #define assert1(c, m, p1)						\
3609    { if( !(c) )  Error(1, 3, "assert failed in %s %s", INTERN,no_fpos,m, p1); }
3610 #else
3611 #define assert(c, m)
3612 #define assert1(c, m, p1)
3613 #endif
3614 
3615 #if DEBUG_ON
3616 
3617 struct dbs
3618 {	char	*flag;			/* external names for debug flags    */
3619 	BOOLEAN	on[3];			/* the debug flags                   */
3620 };
3621 extern	struct dbs 	dbg[];
3622 
3623 /* debug routines */
3624 #define debug0(cat, urg, str)                				\
3625     { if( dbg[cat].on[urg] ) Debug(cat, urg, str); }
3626 #define debug1(cat, urg, str, p1)					\
3627     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1); }
3628 #define debug2(cat, urg, str, p1, p2)					\
3629     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2); }
3630 #define debug3(cat, urg, str, p1, p2, p3)				\
3631     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3); }
3632 #define debug4(cat, urg, str, p1, p2, p3, p4)				\
3633     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4); }
3634 #define debug5(cat, urg, str, p1, p2, p3, p4, p5)			\
3635     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4, p5); }
3636 #define debug6(cat, urg, str, p1, p2, p3, p4, p5, p6)			\
3637     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4, p5, p6); }
3638 #define debug7(cat, urg, str, p1, p2, p3, p4, p5, p6, p7)		\
3639     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4, p5,p6,p7); }
3640 #define debug8(cat, urg, str, p1, p2, p3, p4, p5, p6, p7, p8)		\
3641     { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2,p3,p4,p5,p6,p7,p8); }
3642 #define	ifdebug(cat, urg, x)						\
3643     { if( dbg[cat].on[urg] ) { x; } }
3644 
3645 #define debugcond0(cat, urg, cond, str)                			\
3646     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str); }
3647 #define debugcond1(cat, urg, cond, str, p1)				\
3648     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1); }
3649 #define debugcond2(cat, urg, cond, str, p1, p2)				\
3650     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2); }
3651 #define debugcond3(cat, urg, cond, str, p1, p2, p3)			\
3652     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2, p3); }
3653 #define debugcond4(cat, urg, cond, str, p1, p2, p3, p4)			\
3654     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2, p3, p4); }
3655 #define debugcond5(cat, urg, cond, str, p1, p2, p3, p4, p5)		\
3656     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2, p3, p4, p5);}
3657 #define debugcond6(cat, urg, cond, str, p1, p2, p3, p4, p5, p6)		\
3658     { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2,p3,p4,p5,p6);}
3659 #define	ifdebugcond(cat, urg, cond, x)					\
3660     { if( dbg[cat].on[urg] && cond ) { x; } }
3661 #define	debug_init(str)							\
3662     DebugInit(str)
3663 
3664 /* debug styles */
3665 #define	D	 0
3666 #define	DD	 1
3667 #define	DDD	 2
3668 
3669 /* debug flags */
3670 #define	DSP	 1		/*  z01.c   -dsp   Supervise                 */
3671 #define	DLA	 2		/*  z02.c   -dla   Lexical Analyser          */
3672 #define	DFS	 3		/*  z03.c   -dfs   File Service              */
3673 #define	DTS	 4		/*  z04.c   -dts   Token Service             */
3674 #define	DRD	 5		/*  z05.c   -drd   Read Definitions          */
3675 #define	DOP	 6		/*  z06.c   -dop   Object Parser             */
3676 #define	DOS	 7		/*  z07.c   -dos   Object Service            */
3677 #define	DOM	 8		/*  z08.c   -dom   Object Manifest           */
3678 #define	DCE	 9		/*  z09.c   -dce   Closure Expansion         */
3679 #define	DCR	10		/*  z10.c   -dcr   Cross References	     */
3680 #define	DSS	11		/*  z11.c   -dss   Style Service	     */
3681 #define	DSF	12		/*  z12.c   -dsf   Size Finder               */
3682 #define	DOB	13		/*  z13.c   -dob   Object Breaking	     */
3683 #define	DOF	14		/*  z14.c   -dof   Object Filling	     */
3684 #define	DSC	15		/*  z15.c   -dsc   Size Constraints          */
3685 #define	DSA	16		/*  z16.c   -dsa   Size Adjustments	     */
3686 #define	DGW	17		/*  z17.c   -dgw   Gap Widths                */
3687 #define	DGT	18		/*  z18.c   -dgt   Galley Transfer           */
3688 #define	DGA	19		/*  z19.c   -dgf   Galley Attaching          */
3689 #define	DGF	20		/*  z20.c   -dgf   Galley Flushing           */
3690 #define	DGM	21		/*  z21.c   -dgm   Galley Maker              */
3691 #define	DGS	22		/*  z22.c   -dgs   Galley Service            */
3692 #define	DGP	23		/*  z23.c   -dgp   Galley Printer            */
3693 #define	DPS	24		/*  z24.c   -dps   Print Service             */
3694 #define	DOE	25		/*  z25.c   -doe   Object Echo               */
3695 #define	DES	26		/*  z26.c   -des   Echo Service		     */
3696 #define	DZZ	27		/*  z27.c   -dzz   Debug Service             */
3697 #define	DYY	28		/*  z28.c   -dyy   Error Service             */
3698 #define	DST	29		/*  z29.c   -dst   Symbol Table              */
3699 #define	DSU	30		/*  z30.c   -dsu   Symbol Uses               */
3700 #define	DMA	31		/*  z31.c   -dma   Memory Allocator          */
3701 #define	DCS	32		/*  z32.c   -dcs   Counter Service           */
3702 #define	DBS	33		/*  z33.c   -dbs   Database Service          */
3703 #define	DRS	34		/*  z34.c   -drs   Rotation Service          */
3704 #define	DTK	35		/*  z35.c   -dtk   Time Keeper               */
3705 #define	DHY	36		/*  z36.c   -dhy   Hyphenation               */
3706 #define	DFT	37		/*  z37.c   -dft   Font Service              */
3707 #define	DCM	38		/*  z38.c   -dcm   Character Mapping         */
3708 #define	DSH	39		/*  z39.c   -dsh   String Handler            */
3709 #define	DFH	40		/*  z40.c   -dsh   Filter Handler            */
3710 #define	DIO	41		/*  z41.c   -dio   Object Input-Output       */
3711 #define	DCO	42		/*  z42.c   -dco   Colour Service            */
3712 #define	DLS	43		/*  z43.c   -dls   Language Service          */
3713 #define	DVH	44		/*  z44.c   -dvh   Vertical Hyphenation      */
3714 #define	DEX	45		/*  z45.c   -dex   External Sort             */
3715 #define	DOG	46		/*  z46.c   -dex   Optimal Galleys           */
3716 #define	DET	47		/*  z47.c   -det   Environment Table         */
3717 #define	DPD	48		/*  z48.c   -dpd   PDF Back End (old)        */
3718 #define	DPO	49		/*  z49.c   -dpo   PostScript Back End       */
3719 #define	DPF	50		/*  z50.c   -dpf   PDF Back End              */
3720 #define	DPT	51		/*  z51.c   -dpt   Plain Text Back End       */
3721 #define	DTX	52		/*  z52.c   -dtx   Texture Service           */
3722 #define	DPP	53		/*          -dpp   Profiling                 */
3723 #define	ANY	54		/*          -d     any                       */
3724 
3725 #else
3726 #define ifdebug(cat, urg, x)
3727 #define debug0(cat, urg, str)
3728 #define debug1(cat, urg, str, p1)
3729 #define debug2(cat, urg, str, p1, p2)
3730 #define debug3(cat, urg, str, p1, p2, p3)
3731 #define debug4(cat, urg, str, p1, p2, p3, p4)
3732 #define debug5(cat, urg, str, p1, p2, p3, p4, p5)
3733 #define debug6(cat, urg, str, p1, p2, p3, p4, p5, p6)
3734 #define debug7(cat, urg, str, p1, p2, p3, p4, p5, p6, p7)
3735 #define debug8(cat, urg, str, p1, p2, p3, p4, p5, p6, p7, p8)
3736 
3737 #define debugcond0(cat, urg, cond, str)
3738 #define debugcond1(cat, urg, cond, str, p1)
3739 #define debugcond2(cat, urg, cond, str, p1, p2)
3740 #define debugcond3(cat, urg, cond, str, p1, p2, p3)
3741 #define debugcond4(cat, urg, cond, str, p1, p2, p3, p4)
3742 #define debugcond5(cat, urg, cond, str, p1, p2, p3, p4, p5)
3743 #define debugcond6(cat, urg, cond, str, p1, p2, p3, p4, p5, p6)
3744 #define	ifdebugcond(cat, urg, cond, x)
3745 #define	debug_init(str)	Error(1, 4, "%s - debug flags not implemented", \
3746 	FATAL, no_fpos, str)
3747 #endif
3748