File: out_routines.c

package info (click to toggle)
texlive-bin 2016.20160513.41080.dfsg-2+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 155,060 kB
  • sloc: ansic: 702,862; cpp: 222,090; perl: 76,014; sh: 23,402; makefile: 8,078; lex: 4,710; pascal: 3,782; python: 3,614; java: 3,569; yacc: 2,905; exp: 2,031; xml: 800; tcl: 670; ruby: 620; lisp: 397; sed: 351; asm: 140; csh: 48; awk: 30
file content (372 lines) | stat: -rw-r--r-- 9,121 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/* out_routines.c: Low-level routines for outputting OPL and OVP files.

This file is part of Omega,
which is based on the web2c distribution of TeX,

Copyright (c) 1994--2001 John Plaice and Yannis Haralambous

Omega is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Omega is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Omega; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

*/

#include "cpascal.h"
#include "list_routines.h"
#include "manifests.h"
#include "omfonts.h"
#include "out_routines.h"
#include "error_routines.h"
#include "header_routines.h"
#include "char_routines.h"

/* Character measures */

const_string character_measures[] =
     { "CHARWD",      "CHARHT",         "CHARDP",        "CHARIC",
       "SECWD",       "SECHT",          "SECDP",         "SECIC",
       "PRIMTOPAXIS", "PRIMTOPAXISBIS", "PRIMBOTAXIS",   "PRIMBOTAXISBIS",
       "PRIMMIDHOR",  "PRIMMIDVERT",    "PRIMBASESLANT", NULL,
       "SECTOPAXIS",  "SECTOPAXISBIS",  "SECBOTAXIS",    "SECBOTAXISBIS",
       "SECMIDHOR",   "SECMIDVERT",     "SECBASESLANT",  NULL};

void
out_character_measure(unsigned measure)
{
    if ((measure < C_MIN) || (measure > C_MAX) ||
        (character_measures[measure]==NULL)) {
	internal_error_1("out_character_measure (measure=%d)", measure);
    }
    out(character_measures[measure]);
}

/* Extensible pieces */

const_string extensible_pieces[] =
     { "TOP", "MID", "BOT", "REP", NULL };

void
out_extensible_piece(unsigned piece)
{
    if ((piece < E_MIN) || (piece > E_MAX)) {
	internal_error_1("out_extensible_piece (piece=%d)", piece);
    }
    out(extensible_pieces[piece]);
}

/* Ligature commands */

const_string ligature_commands[] =
     { "LIG", "LIG/", "/LIG", "/LIG/", NULL,
       "LIG/>", "/LIG>", "/LIG/>", NULL, NULL,
       NULL, "/LIG/>>", NULL };

void
out_ligature_command(unsigned command)
{
    if ((command < L_MIN) || (command > L_MAX) ||
        (ligature_commands[command]==NULL)) {
	internal_error_1("out_ligature_command (command=%d)", command);
    }
    out(ligature_commands[command]);
}

/* Xerox faces */

const_string xerox_faces[] =
    { "MRR", "MIR", "BRR", "BIR", "LRR", "LIR",
      "MRC", "MIC", "BRC", "BIC", "LRC", "LIC",
      "MRE", "MIE", "BRE", "BIE", "LRE", "LIE", NULL };

void
print_xerox_face(int face)
{
    if ((face < F_MIN) || (face > F_MAX)) {
	internal_error_1("print_xerox_face (face=%d)", face);
    }
    out("F "); out(xerox_faces[face]);
}

/* Named parameters */

const_string named_parameters[] =
    { NULL,      "SLANT",      "SPACE",  "STRETCH", "SHRINK",    "XHEIGHT",
      "QUAD",    "EXTRASPACE", NULL };

void
out_named_parameter(unsigned parameter)
{
    if ((parameter < P_MIN) || (parameter > P_MAX)) {
	internal_error_1("out_named_parameter (parameter = %d)", parameter);
    }
    out(named_parameters[parameter]);
}

/* Named math symbol parameters */

const_string named_mathsy_parameters[] =
    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
      "NUM1",   "NUM2",    "NUM3",      "DENOM1",
      "DENOM2",  "SUP1",       "SUP2",   "SUP3",    "SUB1",      "SUB2",
      "SUPDROP", "SUBDROP",    "DELIM1", "DELIM2",  "AXISHEIGHT", NULL };

void
out_named_mathsy_parameter(unsigned parameter)
{
    if ((parameter < P_MATHSY_MIN) || (parameter > P_MATHSY_MAX) ||
        (named_mathsy_parameters[parameter]==NULL)) {
	internal_error_1("out_named_mathsy_parameter (parameter=%d)",parameter);
    }
    out(named_mathsy_parameters[parameter]);
}

/* Named math extension parameters */

const_string named_mathex_parameters[] =
    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
      "DEFAULTRULETHICKNESS", "BIGOPSPACING1",
      "BIGOPSPACING2",        "BIGOPSPACING3",
      "BIGOPSPACING4",        "BIGOPSPACING5", NULL };

void
out_named_mathex_parameter(unsigned parameter)
{
    if ((parameter < P_MATHEX_MIN) || (parameter > P_MATHEX_MAX) ||
        (named_mathex_parameters[parameter]==NULL)) {
	internal_error_1("out_named_mathex_parameter (parameter=%d)",parameter);
    }
    out(named_mathex_parameters[parameter]);
}

/* Typesetting directions */

const_string type_directions[] =
     { "FONTDIR", "NATURALFONTDIR", NULL };

const_string actual_directions[] =
     { "TL", "LT", "TR", "RT", "LB", "BL", "BR", "RB", NULL };

void
out_type_direction(unsigned direction)
{
    if ((direction < DIR_MIN) || (direction > DIR_MAX)) {
	internal_error_1("out_type_direction (direction=%d)", direction);
    }
    out(type_directions[direction/8]); out(" ");
    out(actual_directions[direction%8]);
}

/* Kinds of accents */

const_string accent_kinds[] =
     { NULL, "TOPACCENT", "MIDACCENT", "BOTACCENT", NULL };

void
out_accent_kind(unsigned kind)
{
    if ((kind < ACC_TOP) || (kind > ACC_BOT)) {
	internal_error_1("out_accent_kind (kind=%d)", kind);
    }
    out(accent_kinds[kind]);
}

/* Move directions */

const_string move_directions[] =
     { "MOVERIGHT", "MOVELEFT", "MOVEUP", "MOVEDOWN", NULL };

void
out_move_direction(unsigned direction)
{
    if ((direction < M_MIN) || (direction > M_MAX)) {
	internal_error_1("out_move_direction (direction=%d)", direction);
    }
    out(move_directions[direction]);
}

/* Rule measures */

const_string rule_measures[] =
     { "RULEWD", "RULEHT", "RULEDP", NULL };

void
out_rule_measure(unsigned measure)
{
    if ((measure < RULE_MIN) || (measure > RULE_MAX)) {
	internal_error_1("out_rule_measure (measure=%d)", measure);
    }
    out(rule_measures[measure]);
}

/* Glue shrink or stretch */

const_string glue_shrink_stretch[] =
     { "GLUESHRINK", "GLUESTRETCH", NULL };

void
out_shrink_stretch(unsigned shrink_stretch)
{
    if ((shrink_stretch < GLUE_MIN) || (shrink_stretch > GLUE_MAX)) {
	internal_error_1("out_shrink_stretch (shrink_stretch=%d)",
                         shrink_stretch);
    }
    out(glue_shrink_stretch[shrink_stretch]);
}

/* Glue orders */

const_string glue_orders[] =
     { "UNIT", "FI", "FIL", "FILL", "FILLL", NULL };

void
out_glue_order(unsigned order)
{
    if ((order < O_MIN) || (order > O_MAX)) {
	internal_error_1("out_glue_order (order=%d)", order);
    }
    out(glue_orders[order]);
}

/* Glue kinds */

const_string glue_kinds[] =
     { "NORMAL", "ALEADERS", "CLEADERS", "ALEADERS", "XLEADERS", NULL };

void
out_glue_kind(unsigned kind)
{
    if ((kind < K_MIN) || (kind > K_MAX)) {
	internal_error_1("out_glue_kind (kind=%d)", kind);
    }
    out(glue_kinds[kind]);
}

unsigned parenthesis_level=0;
unsigned digits[12];

/* Basic routines used by everyone */

void
out_ln(void)
{
    unsigned i;
    out("\n");
    for (i = 0; i < parenthesis_level; i++) out("   ");
}

void
left(void)
{
    parenthesis_level++; out("(");
}

void
right(void)
{
    if (parenthesis_level==0) internal_error_0("right");
    parenthesis_level--; out(")"); out_ln();
}

void
out_char(unsigned val)
{
        if (char_format==CHAR_CODE_NUM) out_num(val);
        else if (font_type!=FT_VANILLA) out_num(val);
        else if (((val>='0') && (val<='9')) ||
                 ((val>='A') && (val<='Z')) ||
                 ((val>='a') && (val<='z')))
	    fprintf(file_output, "C %c", val);
        else out_num(val);
}

void
out_num(unsigned val)
{
        if (num_format==NUM_CODE_OCTAL) out_int(val, 8);
        else out_int(val, 16);
}

static void out_digits(unsigned);

void
out_int(unsigned val, unsigned base)
{
	register unsigned j=0, acc=val;
	if (val < 0) internal_error_1("out_int (val=%d)", val);
	if (base==16)      out("H ");
	else if (base==10) out("D ");
	else if (base==8)  out("O ");
	else internal_error_1("out_int (base=%d)", base);
	do {
		digits[j] = acc % base;
		j++;
		acc = acc / base;
	} while (acc > 0);
/*
        if ((base==16) && (ec>=0x100)) {
            while (j<4) { digits[j] = 0; j++; }
        }
*/
	out_digits(j);
}

void
out_fix(fix fval)
{
	register int a = (fval & 0xfff00000) >> 20, f = fval & 0xfffff, j=0;
	register int delta;

	out("R ");
	if (a>0x7ff) {
		out("-"); a = 0x1000 - a;
		if (f>0) {
			f = 0x100000 - f; a--;
		}
	}
	do {
		digits[j] = a % 10;
		j++;
		a = a / 10;
	} while (a > 0);
	out_digits(j);
	out(".");
	f = 10*f + 5; delta = 10;
	do {
		if (delta>0x100000) f = f + 0x80000 - (delta / 2);
		fprintf(file_output, "%c", (f / 0x100000) + '0');
		f = 10 * (f % 0x100000); delta = delta*10;
	} while (f>delta);
}

void
out_hex(unsigned char c)
{
	fprintf(file_output, "%02X", c);
}

static void
out_digits(unsigned counter)
{
	register unsigned j=counter, c;
	while (j>0) {
		c = digits[--j];
		if (c<10) fprintf(file_output, "%c", c+'0');
		else fprintf(file_output, "%c", c+'A'-10);
	}
}

void
out(const_string sval)
{
	fprintf(file_output, "%s", sval);
}