w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dt2dv.c
Go to the documentation of this file.
1 /* dt2dv - convert human-readable "DTL" file to DVI format
2  - this is intended to invert dv2dt version 0.6.0
3 
4  This file is public domain.
5  Originally written 1995, Geoffrey Tobin.
6  The author has expressed the hope that any modification will retain
7  enough content to remain useful. He would also appreciate being
8  acknowledged as the original author in the documentation.
9  This declaration added 2008/11/14 by Clea F. Rees with the permission
10  of Geoffrey Tobin.
11 
12  - version 0.6.1 - 14:38 GMT +11 Thu 9 March 1995
13  - Geoffrey Tobin G.Tobin@ee.latrobe.edu.au
14  - fixes: Michal Tomczak-Jaegermann ntomczak@vm.ucs.ualberta.ca
15  Nelson H. F. Beebe beebe@math.utah.edu
16  - Reference: "The DVI Driver Standard, Level 0",
17  by The TUG DVI Driver Standards Committee.
18  Appendix A, "Device-Independent File Format".
19 */
20 
21 /* unix version; read from stdin, write to stdout, by default. */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <ctype.h>
28 #include <errno.h>
29 #include <signal.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 
34 #ifdef HAVE_UNISTD_H
35 #include <unistd.h>
36 #endif
37 
38 #ifdef KPATHSEA
39 #include <kpathsea/config.h>
40 #include <kpathsea/c-fopen.h>
41 #include <kpathsea/progname.h>
42 #endif
43 
44 #include "dtl.h"
45 
46 /* by default, read and write regular files */
47 int rd_stdin = 0;
48 int wr_stdout = 0;
49 
50 /* maximum number of characters in a DTL input line */
51 #define MAXLINE 8192
52 
53 /* input line */
54 typedef struct
55 {
56  COUNT num; /* current line number */
57  size_t max; /* capacity of buf */
58  S4 wrote; /* number of characters written into buf */
59  size_t read; /* position in buf of next character to read from buf */
60  char * buf; /* line buffer */
61 } Line;
62 
63 char linebuf[MAXLINE+1];
64 
65 Line dtl_line = {0, 0, 0, MAXLINE, linebuf};
66 
67 /* a DTL token either is:
68  a quoted string (admitting an escape character),
69  or BCOM (if that is a nonempty string),
70  or ECOM (if that is a nonempty string),
71  or a string _not_ including ECOM_CHAR or space.
72 */
73 
74 /* maximum expected length of a DTL token */
75 #define MAXTOKLEN 255
76 typedef char Token[MAXTOKLEN+2];
77 
78 typedef unsigned char Byte;
79 typedef char Boolean;
80 
81 #ifndef true
82 #define true 1
83 #endif
84 #ifndef false
85 #define false 0
86 #endif
87 
88 /* command prefixes */
89 typedef struct
90 {
92  const char * name;
94  Byte first_suffix, last_suffix;
95 } CmdPrefix;
96 
98 {
99  {0, SETCHAR, true, 0, 127},
100  {128, SET, true, 1, 4},
101  {132, SETRULE, false, 0, 0},
102  {133, PUT, true, 1, 4},
103  {137, PUTRULE, false, 0, 0},
104  {138, NOP, false, 0, 0},
105  {139, BOP, false, 0, 0},
106  {140, EOP, false, 0, 0},
107  {141, PUSH, false, 0, 0},
108  {142, POP, false, 0, 0},
109  {143, RIGHT, true, 1, 4},
110  {147, W, true, 0, 4},
111  {152, X, true, 0, 4},
112  {157, DOWN, true, 1, 4},
113  {161, Y, true, 0, 4},
114  {166, Z, true, 0, 4},
115  {171, FONTNUM, true, 0, 63},
116  {235, FONT, true, 1, 4},
117  {239, SPECIAL, true, 1, 4},
118  {243, FONTDEF, true, 1, 4},
119  {247, PRE, false, 0, 0},
120  {248, POST, false, 0, 0},
121  {249, POSTPOST, false, 0, 0},
122  {250, OPCODE, true, 250, 255}
123 };
124 /* cmd_prefixes[] */
125 
126 /* Number of DVI commands, including those officially undefined */
127 #define NCMDS 256
128 
129 /* table of command name (string) pointers */
130 typedef char * CmdTable [NCMDS];
131 
132 /* initially all command name pointers are NULL */
134 
135 /* operation's opcode, name, number of args, string of arguments. */
136 typedef struct
137 {
138  int code;
139  const char * name;
140  int nargs;
141  const char * args;
142 } op_info;
143 
144 /* name of table, first opcode, last opcode, pointer to opcode info. */
145 typedef struct
146 {
147  const char * name;
148  int first;
149  int last;
151 } op_table;
152 
153 /* Table for opcodes 128 to 170 inclusive. */
154 
156 {
157  {128, SET1, 1, "1"},
158  {129, SET2, 1, "2"},
159  {130, SET3, 1, "3"},
160  {131, SET4, 1, "-4"},
161  {132, SETRULE, 2, "-4 -4"},
162  {133, PUT1, 1, "1"},
163  {134, PUT2, 1, "2"},
164  {135, PUT3, 1, "3"},
165  {136, PUT4, 1, "-4"},
166  {137, PUTRULE, 2, "-4 -4"},
167  {138, NOP, 0, ""},
168  /* bop: not counting last argument, a signed address: */
169  {139, BOP, 10, "-4 -4 -4 -4 -4 -4 -4 -4 -4 -4"},
170  {140, EOP, 0, ""},
171  {141, PUSH, 0, ""},
172  {142, POP, 0, ""},
173  {143, RIGHT1, 1, "-1"},
174  {144, RIGHT2, 1, "-2"},
175  {145, RIGHT3, 1, "-3"},
176  {146, RIGHT4, 1, "-4"},
177  {147, W0, 0, ""},
178  {148, W1, 1, "-1"},
179  {149, W2, 1, "-2"},
180  {150, W3, 1, "-3"},
181  {151, W4, 1, "-4"},
182  {152, X0, 0, ""},
183  {153, X1, 1, "-1"},
184  {154, X2, 1, "-2"},
185  {155, X3, 1, "-3"},
186  {156, X4, 1, "-4"},
187  {157, DOWN1, 1, "-1"},
188  {158, DOWN2, 1, "-2"},
189  {159, DOWN3, 1, "-3"},
190  {160, DOWN4, 1, "-4"},
191  {161, Y0, 0, ""},
192  {162, Y1, 1, "-1"},
193  {163, Y2, 1, "-2"},
194  {164, Y3, 1, "-3"},
195  {165, Y4, 1, "-4"},
196  {166, Z0, 0, ""},
197  {167, Z1, 1, "-1"},
198  {168, Z2, 1, "-2"},
199  {169, Z3, 1, "-3"},
200  {170, Z4, 1, "-4"}
201 };
202 /* op_info op_info_128_170 [] */
203 
204 op_table op_128_170 = {"op_128_170", 128, 170, op_info_128_170};
205 
206 /* Table for fnt1 to fnt4 (opcodes 235 to 238) inclusive. */
207 
209 {
210  {235, FONT1, 1, "1"},
211  {236, FONT2, 1, "2"},
212  {237, FONT3, 1, "3"},
213  {238, FONT4, 1, "-4"}
214 };
215 /* op_info fnt_n [] */
216 
217 op_table fnt = {FONT, 235, 238, fnt_n};
218 
219 
220 /* Function prototypes */
221 
222 Void mem_viol ARGS((int sig));
224 int parse ARGS((const char * s));
225 Void process ARGS((const char * s));
226 
227 Void no_op (VOID);
230 
231 int open_dtl ARGS((const char * dtl_file, FILE ** pdtl));
232 int open_dvi ARGS((const char * dvi_file, FILE ** pdvi));
233 
234 int dt2dv ARGS((FILE * dtl, FILE * dvi));
235 
236 Void * gmalloc ARGS((long int size));
237 
238 Void dinfo (VOID);
239 Void dexit ARGS((int n));
240 
241 int cons_cmds ARGS((int nprefixes, CmdPrefix * prefix, CmdTable cmds));
243 
244 int get_line ARGS((FILE * fp, Line * line, int max));
245 int read_line_char ARGS((FILE * fp, int * ch));
246 int read_char ARGS((FILE * fp, int * ch));
247 int unread_char (VOID);
248 int read_string_char ARGS((FILE * fp, int * ch));
249 
251 COUNT read_token ARGS((FILE * dtl, char * token));
255 
256 int find_command ARGS((char * command, int * opcode));
257 int xfer_args ARGS((FILE * dtl, FILE * dvi, int opcode));
258 
259 int set_seq ARGS((FILE * dtl, FILE * dvi));
260 
261 int check_byte ARGS((int byte));
262 int put_byte ARGS((int onebyte, FILE * dvi));
263 
264 U4 xfer_hex ARGS((int n, FILE * dtl, FILE * dvi));
265 U4 xfer_oct ARGS((int n, FILE * dtl, FILE * dvi));
266 U4 xfer_unsigned ARGS((int n, FILE * dtl, FILE * dvi));
267 S4 xfer_signed ARGS((int n, FILE * dtl, FILE * dvi));
268 
269 int check_bmes ARGS((FILE * dtl));
270 int check_emes ARGS((FILE * dtl));
271 
272 Void init_Lstring ARGS((Lstring * lsp, long int n));
274 Lstring * alloc_Lstring ARGS((long int n));
276 Void ls_putb ARGS((int ch, Lstring * lstr));
277 
278 S4 get_Lstring ARGS((FILE * dtl, Lstring * lstr));
279 Void put_Lstring ARGS((const Lstring * lstr, FILE * dvi));
280 U4 xfer_len_string ARGS((int n, FILE * dtl, FILE * dvi));
281 
284 
285 int put_unsigned ARGS((int n, U4 unum, FILE * dvi));
286 int put_signed ARGS((int n, S4 snum, FILE * dvi));
287 
290 
291 int put_table ARGS((op_table table, int opcode, FILE * dtl, FILE * dvi));
292 
293 U4 special ARGS((FILE * dtl, FILE * dvi, int n));
294 int fontdef ARGS((FILE * dtl, FILE * dvi, int n));
295 
296 U4 preamble ARGS((FILE * dtl, FILE * dvi));
297 int postamble ARGS((FILE * dtl, FILE * dvi));
298 int post_post ARGS((FILE * dtl, FILE * dvi));
299 
300 
301 typedef struct
302 {
303  const char * keyword; /* command line option keyword */
304  int * p_var; /* pointer to option variable */
305  const char * desc; /* description of keyword and value */
306  Void (* p_fn) (VOID); /* pointer to function called when option is set */
307 } Options;
308 
310 {
311  {"-debug", &debug, "detailed debugging", no_op},
312  {"-group", &group, "each DTL command is in parentheses", no_op},
313  {"-si", &rd_stdin, "read all DTL commands from standard input", dtl_stdin},
314  {"-so", &wr_stdout, "write all DVI commands to standard output", dvi_stdout},
315  {NULL, NULL, NULL, NULL}
316 };
317 /* opts[] */
318 
319 const char * progname; /* intended for name of this program */
320 int nfile; /* number of filename arguments on the command line */
321 
322 #define PRINT_PROGNAME fprintf (stderr, "%s ", progname)
323 
324 /* Harbison & Steele (1991) warn that some C implementations */
325 /* of free() do not treat NULL pointers correctly. */
326 #define gfree(p) {if (p) free (p);}
327 
328 
331 
332 const char * dtl_filename;
333 const char * dvi_filename;
334 
335 
336 int
338 #ifdef STDC
339  (int argc, char * argv[])
340 #else
341  (argc, argv)
342  int argc;
343  char * argv[];
344 #endif
345 {
346  int i;
347 
348 #ifdef KPATHSEA
349  kpse_set_program_name(argv[0], "dt2dv");
351 #else
352  progname = argv[0]; /* name of this program */
353 #endif
354 
355  /* memory violation signal handler */
356  /* Not supported under Win32 */
357 #ifndef WIN32
358  signal (SIGSEGV, mem_viol);
359 #endif
360 
361 #ifndef __DATE__
362 #define __DATE__ ""
363 #endif
364 
365 #ifndef __TIME__
366 #define __TIME__ ""
367 #endif
368 
369 #if STDC
370 #define C_LEVEL ""
371 #else /* NOT STDC */
372 #define C_LEVEL "non-"
373 #endif /* NOT STDC */
374 
375  /* message about program and compiler */
376  /* NB: LTU EE's Sun/OS library is BSD, even though gcc 2.2.2 is ANSI */
377 
378  fprintf (stderr, "\n");
379  fprintf (stderr,
380  "Program \"%s\" version %s (%s) compiled in %sstandard C.\n",
382 
383  /* interpret command line arguments */
384 
385  nfile = 0;
386  dtl_fp = dvi_fp = NULL;
387  dtl_filename = dvi_filename = "";
388 
389  for (i=1; i < argc; i++)
390  {
391  /* parse options, followed by any explicit filenames */
392  parse (argv[i]);
393  }
394 
395  if (nfile != 2) /* not exactly two files specified, so give help */
396  give_help();
397  else
398  /* the real works */
399  dt2dv (dtl_fp, dvi_fp);
400 
401  return 0; /* OK */
402 }
403 /* end main */
404 
405 #ifndef WIN32
406 Void
408 #ifdef STDC
409  (int sig)
410 #else
411  (sig)
412  int sig;
413 #endif
414 {
415  signal (SIGSEGV, mem_viol);
416  if (sig != SIGSEGV)
417  {
419  fprintf (stderr,
420  "(mem_viol) : called with wrong signal!\n");
421  }
423  fprintf (stderr, "(mem_viol) : RUNTIME MEMORY ERROR : memory violation, ");
424  fprintf (stderr, "dtl line >= ");
425  fprintf (stderr, WF, dtl_line.num);
426  fprintf (stderr, "\n");
427  dexit (1);
428 }
429 /* mem_viol */
430 #endif
431 
432 Void
434 {
435  int i;
436  const char * keyword;
437  fprintf (stderr, "usage: ");
439  fprintf (stderr, "[options] dtl_file dvi_file");
440  fprintf (stderr, "\n");
441  for (i=0; (keyword = opts[i].keyword) != NULL; i++)
442  {
443  fprintf (stderr, " ");
444  fprintf (stderr, "[%s]", keyword);
445  fprintf (stderr, " ");
446  fprintf (stderr, "%s", opts[i].desc);
447  fprintf (stderr, "\n");
448  }
449  fprintf (stderr, "Messages, like this one, go to stderr.\n");
450  fprintf (stderr, "\nEmail bug reports to %s.\n", PACKAGE_BUGREPORT);
451 }
452 /* give_help */
453 
454 
456 /* do nothing */
457 {
458 }
459 
461 {
462  dtl_fp = stdin;
463  dtl_filename = "Standard Input";
464  ++ nfile;
465 }
466 
468 {
469  /* ! Perilous to monitors! */
470  dvi_fp = stdout;
471  dvi_filename = "Standard Output";
472  ++ nfile;
473  if (!isatty(fileno(dvi_fp)))
475 }
476 
477 
478 int
480 #ifdef STDC
481  (const char * s)
482 #else
483  (s)
484  const char * s;
485 #endif
486 /* parse one command-line argument, `s' */
487 {
488  int i;
489  const char * keyword;
490  for (i=0; (keyword = opts[i].keyword) != NULL; i++)
491  {
492  if (strncmp (s, keyword, strlen (keyword)) == 0)
493  {
494  Void (*pfn) (VOID);
495  (*(opts[i].p_var)) = 1; /* turn option on */
496  if ((pfn = opts[i].p_fn) != NULL)
497  (*pfn) (); /* call option function */
498  return i;
499  }
500  }
501  /* reached here, so not an option: assume it's a filename */
502  process (s);
503  return i;
504 }
505 /* parse */
506 
507 
508 int
510 #ifdef STDC
511  (const char * dtl_file, FILE ** pdtl)
512 #else
513  (dtl_file, pdtl)
514  const char * dtl_file;
515  FILE ** pdtl;
516 #endif
517 /* I: dtl_file; I: pdtl; O: *pdtl. */
518 {
519  dtl_filename = dtl_file;
520 
521  if (dtl_filename == NULL)
522  {
524  fprintf (stderr,
525  "(open_dtl) : INTERNAL ERROR : dtl file's name is NULL.\n");
526  dexit (1);
527  }
528 
529  if (pdtl == NULL)
530  {
532  fprintf (stderr,
533  "(open_dtl) : INTERNAL ERROR : address of dtl variable is NULL.\n");
534  dexit (1);
535  }
536 
537  *pdtl = fopen (dtl_file, "r");
538 
539  if (*pdtl == NULL)
540  {
542  fprintf (stderr,
543  "(open_dtl) : DTL FILE ERROR : Cannot open \"%s\" for text reading.\n",
544  dtl_file);
545  dexit (1);
546  }
547 
548  return 1; /* OK */
549 }
550 /* open_dtl */
551 
552 
553 int
555 #ifdef STDC
556  (const char * dvi_file, FILE ** pdvi)
557 #else
558  (dvi_file, pdvi)
559  const char * dvi_file;
560  FILE ** pdvi;
561 #endif
562 /* I: dvi_file; I: pdvi; O: *pdvi. */
563 {
565 
566  if (dvi_filename == NULL)
567  {
569  fprintf (stderr,
570  "(open_dvi) : INTERNAL ERROR : dvi file's name is NULL.\n");
571  dexit (1);
572  }
573 
574  if (pdvi == NULL)
575  {
577  fprintf (stderr,
578  "(open_dvi) : INTERNAL ERROR : address of dvi variable is NULL.\n");
579  dexit (1);
580  }
581 
582  *pdvi = fopen (dvi_file, "wb");
583 
584  if (*pdvi == NULL)
585  {
587  fprintf (stderr,
588  "(open_dvi) : DVI FILE ERROR : Cannot open \"%s\" for binary writing.\n",
589  dvi_file);
590  dexit (1);
591  }
592 
593  return 1; /* OK */
594 }
595 /* open_dvi */
596 
597 
598 Void
600 #ifdef STDC
601  (const char * s)
602 #else
603  (s)
604  const char * s;
605 #endif
606 {
607  if (dtl_fp == NULL) /* first filename assumed to be DTL input */
608  {
609  open_dtl (s, &dtl_fp);
610  }
611  else if (dvi_fp == NULL) /* second filename assumed to be DVI output */
612  {
613  open_dvi (s, &dvi_fp);
614  }
615  else
616  {
618  fprintf (stderr, "(process) : at most two filenames allowed.\n");
619  exit (1);
620  }
621  ++ nfile;
622 }
623 /* process */
624 
625 
626 COUNT dtl_read = 0; /* bytes read from dtl file */
627 COUNT dvi_written = 0; /* bytes written to dvi file */
628 word_t last_bop_address = -1; /* byte address of last bop; first bop uses -1 */
629 word_t postamble_address = -1; /* byte address of postamble */
630 COUNT ncom = 0; /* commands successfully read and interpreted from dtl file */
631 COUNT com_read = 0; /* bytes read in current (command and arguments), */
632  /* since and including the opening BCOM_CHAR, if any */
633 
634 
635 int
637 #ifdef STDC
638  (int byte, FILE * dvi)
639 #else
640  (byte, dvi)
641  int byte;
642  FILE * dvi;
643 #endif
644 /* write byte into dvi file */
645 {
646  check_byte (byte);
647 /* if (fprintf (dvi, "%c", byte) != 1) */
648  if (fprintf (dvi, "%c", byte) < 0)
649  {
651  fprintf (stderr,
652  "(put_byte) : DVI FILE ERROR (%s) : cannot write to dvi file.\n",
653  dtl_filename);
654  dexit (1);
655  }
656  ++ dvi_written;
657  return 1; /* OK */
658 }
659 /* put_byte */
660 
661 
662 int
664 #ifdef STDC
665  (FILE * dtl, FILE * dvi)
666 #else
667  (dtl, dvi)
668  FILE * dtl;
669  FILE * dvi;
670 #endif
671 {
672  int nprefixes = 0; /* number of prefixes in cmd_prefixes[] list. */
673  static Token dtl_cmd = ""; /* DTL command name */
674 
675  nprefixes = sizeof (cmd_prefixes) / sizeof (CmdPrefix);
676 
677  /* Construct array of all NCMDS == 256 DTL commands */
678 
679  (Void) cons_cmds (nprefixes, cmd_prefixes, cmd_table);
680 
681  /* DTL commands have the form "[ ]*command arg ... arg[ ]*", */
682  /* possibly enclosed in a BCOM, ECOM pair, */
683  /* and are separated by optional whitespace, typically newlines. */
684  /* That is, each command and its arguments are parenthesised, */
685  /* with optional spaces after the BCOM and before the ECOM, if any. */
686 
687  /* dt2dv is now at the very start of the DTL file */
688 
689  dtl_line.num = 0;
690  dtl_read = 0;
691 
692  /* The very first thing should be the "variety" signature */
693 
694  read_variety (dtl);
695 
696  /* while not end of dtl file or reading error, */
697  /* read, interpret, and write commands */
698 
699  while (!feof (dtl))
700  {
701  int opcode;
702 
703  com_read = 0;
704 
705  if (group)
706  {
707  /* BCOM check */
708  static Token token = ""; /* DTL token */
709  read_token (dtl, token);
710  /* test for end of input, or reading error */
711  if (strlen (token) == 0)
712  {
713  if (debug)
714  {
716  fprintf (stderr, "(dt2dv) : end of input, or reading error.\n");
717  }
718  break;
719  }
720  /* test whether this command begins correctly */
721  else if (strcmp (token, BCOM) != 0)
722  {
724  fprintf (stderr, "(dt2dv) : DTL FILE ERROR (%s) : ", dtl_filename);
725  fprintf (stderr, "command must begin with \"%s\", ", BCOM);
726  fprintf (stderr, "not `%c' (char %d).\n", token[0], token[0]);
727  dexit (1);
728  }
729  /* end BCOM check */
730  }
731 
732  /* read the command name */
733  read_token (dtl, dtl_cmd);
734  /* test for end of input, or reading error */
735  if (strlen (dtl_cmd) == 0)
736  {
737  if (debug)
738  {
740  fprintf (stderr,
741  "(dt2dv) : end of input, or reading error.\n");
742  }
743  break;
744  }
745  else
746  {
747  if (debug)
748  {
750  fprintf (stderr, "(dt2dv) : command ");
751  fprintf (stderr, WF, ncom);
752  fprintf (stderr, " = \"%s\".\n", dtl_cmd);
753  }
754 
755  /* find opcode for this command */
756  if (find_command (dtl_cmd, &opcode) == 1)
757  {
758  /* write the opcode, if we can */
759  put_byte (opcode, dvi);
760 
761  /* treat the arguments, if any */
762  xfer_args (dtl, dvi, opcode);
763  }
764  else if (dtl_cmd[0] == BSEQ_CHAR)
765  {
766  /* sequence of font characters for SETCHAR */
767  set_seq (dtl, dvi);
768  }
769  else
770  {
772  fprintf (stderr,
773  "(dt2dv) : DTL FILE ERROR (%s) : unknown command \"%s\".\n",
774  dtl_filename, dtl_cmd);
775  dexit (1);
776  }
777  }
778 
779  if (group)
780  {
781  /* seek ECOM after command's last argument and optional whitespace */
782  static Token token = ""; /* DTL token */
783  read_token (dtl, token);
784  /* test for end of input, or reading error */
785  if (strlen (token) == 0)
786  {
787  if (debug)
788  {
790  fprintf (stderr,
791  "(dt2dv) : end of input, or reading error.\n");
792  }
793  break;
794  }
795  if (strcmp (token, ECOM) != 0)
796  {
798  fprintf (stderr, "(dt2dv) : DTL FILE ERROR (%s) : ", dtl_filename);
799  fprintf (stderr, "ECOM (\"%s\") expected, not `%c' (char %d).\n",
800  ECOM, token[0], token[0]);
801  dexit (1);
802  }
803  /* end ECOM check */
804  }
805 
806  ++ ncom; /* one more command successfully read and interpreted */
807  }
808  /* end while */
809 
811  fprintf (stderr, "(dt2dv) :\n");
812  fprintf (stderr, "Read (from file \"%s\") ", dtl_filename);
813  fprintf (stderr, WF, dtl_read);
814  fprintf (stderr, " DTL bytes (");
815  fprintf (stderr, UF4, dtl_line.num);
816  fprintf (stderr, " lines);\n");
817  fprintf (stderr, "wrote (to file \"%s\") ", dvi_filename);
818  fprintf (stderr, WF, dvi_written);
819  fprintf (stderr, " DVI bytes;\n");
820  fprintf (stderr, "completely interpreted ");
821  fprintf (stderr, WF, ncom);
822  fprintf (stderr, " DVI command%s.\n", (ncom == 1 ? "" : "s"));
823  fprintf (stderr, "\n");
824 
826 
827  return 1; /* OK */
828 }
829 /* dt2dv */
830 
831 
832 Void *
834 #ifdef STDC
835  (long int size)
836 #else
837  (size)
838  long int size;
839 #endif
840 {
841  Void * p = NULL;
842  if (size < 1)
843  {
845  fprintf (stderr, "(gmalloc) : INTERNAL ERROR : ");
846  fprintf (stderr,
847  "unreasonable request to malloc %ld bytes\n",
848  size);
849  dexit (1);
850  }
851  p = (Void *) malloc ((size_t) size);
852  if (p == NULL)
853  {
855  fprintf (stderr, "(gmalloc) : MEMORY ALLOCATION ERROR : ");
856  fprintf (stderr,
857  "operating system failed to malloc %ld bytes\n",
858  size);
859  dexit (1);
860  }
861  return (p);
862 }
863 /* gmalloc */
864 
865 
866 Void
868 {
870  fprintf (stderr, "(dinfo) : ");
871  fprintf (stderr, "Current DTL input line ");
872  fprintf (stderr, UF4, dtl_line.num);
873  fprintf (stderr, " :\n");
874  fprintf (stderr, "\"%s\"\n", dtl_line.buf);
875  fprintf (stderr, "Read ");
876  fprintf (stderr, WF, dtl_read);
877  fprintf (stderr, " DTL bytes (");
878  fprintf (stderr, WF, com_read);
879  fprintf (stderr, " in current command), wrote ");
880  fprintf (stderr, WF, dvi_written);
881  fprintf (stderr, " DVI bytes.\n");
882  fprintf (stderr, "Successfully interpreted ");
883  fprintf (stderr, WF, ncom);
884  fprintf (stderr, " DVI command%s.\n", (ncom == 1 ? "" : "s"));
885 }
886 /* dinfo */
887 
888 
889 Void
891 #ifdef STDC
892  (int n)
893 #else
894  (n)
895  int n;
896 #endif
897 {
898  dinfo();
900  fprintf (stderr, "(dexit) : exiting with status %d.\n", n);
901  exit (n);
902 }
903 /* dexit */
904 
905 
906 int
908 #ifdef STDC
909  (int nprefixes, CmdPrefix * prefix, CmdTable cmds)
910 #else
911  (nprefixes, prefix, cmds)
912  int nprefixes;
913  CmdPrefix * prefix;
914  CmdTable cmds;
915 #endif
916 {
917  int code; /* first opcode for a given command prefix */
918  int opcode; /* command's opcode */
919  int nsuffixes; /* number of commands with a given prefix */
920  int isuffix; /**** integer suffix, of at most three digits ****/
921  String suffix; /* suffix string generated from integer suffix */
922  size_t plen = 0; /* prefix length */
923  size_t slen; /* suffix length */
924  size_t clen; /* whole command name length */
925  int i, j; /* loop indices */
926 
927  for (i=0; i < nprefixes; prefix++, i++)
928  {
929  code = prefix->first_code;
930  if (code < 0 || code > 255)
931  {
933  fprintf (stderr, "(cons_cmds) : INTERNAL ERROR : ");
934  fprintf (stderr,
935  "prefix listed internally with code = %d, must be 0 to 255\n",
936  code);
937  dexit (1);
938  }
939  if (prefix->has_suffix)
940  {
941  plen = strlen (prefix->name);
942  /**** Suffixes in DTL are Integers, in Sequence */
943  if (prefix->last_suffix < prefix->first_suffix)
944  {
946  fprintf (stderr, "(cons_cmds) : INTERNAL ERROR : ");
947  fprintf (stderr,
948  "prefix's last suffix %d < first suffix (%d)\n",
949  prefix->last_suffix, prefix->first_suffix);
950  dexit (1);
951  }
952  nsuffixes = prefix->last_suffix - prefix->first_suffix + 1;
953  opcode = prefix->first_code;
954  for (j=0; j < nsuffixes; j++, opcode++)
955  {
956  isuffix = prefix->first_suffix + j;
957  if (0 <= code && code <= 127) /* SETCHAR */
958  {
959  /* SETCHAR's suffix is written in uppercase hexadecimal */
960  sprintf (suffix, "%02X", isuffix);
961  }
962  else /* 128 <= code && code <= 255 */ /* other DTL commands */
963  {
964  /* other commands' suffices are written in decimal */
965  sprintf (suffix, "%d", isuffix);
966  }
967  slen = strlen (suffix);
968  clen = plen + slen;
969  cmds[opcode] = (char *) gmalloc (clen+1);
970  strcpy (cmds[opcode], prefix->name);
971  strcat (cmds[opcode], suffix);
972  }
973  }
974  else /* command name = prefix */
975  {
976  plen = strlen (prefix->name);
977  clen = plen;
978  opcode = prefix->first_code;
979  cmds[opcode] = (char *) gmalloc (clen+1);
980  strcpy (cmds[opcode], prefix->name);
981  }
982  }
983 
984  return 1; /* OK */
985 }
986 /* cons_cmds */
987 
988 
989 Void
991 #ifdef STDC
992  (CmdTable cmds)
993 #else
994  (cmds)
995  CmdTable cmds;
996 #endif
997 {
998  int i;
999  for (i=0; i < NCMDS; i++)
1000  gfree (cmds[i]);
1001 }
1002 /* free_cmds */
1003 
1004 
1005 int
1007 #ifdef STDC
1008  (FILE * fp, Line * line, int max)
1009 #else
1010  (fp, line, max)
1011  FILE * fp;
1012  Line * line;
1013  int max;
1014 #endif
1015 /* read a (Line *) line from fp, return length */
1016 /* adapted from K&R (second, alias ANSI C, edition, 1988), page 165 */
1017 {
1018  if (fgets (line->buf, max, fp) == NULL)
1019  return 0;
1020  else
1021  {
1022  ++ line->num;
1023  line->wrote = strlen (line->buf);
1024  line->read = 0;
1025  return 1;
1026  }
1027 }
1028 /* get_line */
1029 
1030 
1031 int
1033 #ifdef STDC
1034  (FILE * fp, int * ch)
1035 #else
1036  (fp, ch)
1037  FILE * fp;
1038  int * ch;
1039 #endif
1040 /* read one character from dtl_line if possible, */
1041 /* otherwise read another dtl_line from fp */
1042 /* return 1 if a character is read, 0 if at end of fp file */
1043 {
1044  if (dtl_line.wrote == 0 || dtl_line.read >= dtl_line.wrote)
1045  {
1046  int line_status;
1047  /* refill line buffer */
1049  if (line_status == 0)
1050  {
1051  /* at end of DTL file */
1052  if (debug)
1053  {
1055  fprintf (stderr, "(read_line_char) : end of DTL file\n");
1056  dinfo();
1057  }
1058  return 0;
1059  }
1060  else
1061  {
1062  /* new DTL line was read */
1063  if (debug)
1064  {
1066  fprintf (stderr, "(read_line_char) : new DTL input line:\n");
1067  fprintf (stderr, "\"%s\"\n", dtl_line.buf);
1068  }
1069  }
1070  }
1071  *ch = dtl_line.buf [dtl_line.read ++];
1072  ++ dtl_read;
1073  ++ com_read; /* count another DTL command character */
1074  return 1;
1075 }
1076 /* read_line_char */
1077 
1078 
1079 int
1081 #ifdef STDC
1082  (FILE * fp, int * ch)
1083 #else
1084  (fp, ch)
1085  FILE * fp;
1086  int * ch;
1087 #endif
1088 /* Read next character, if any, from file fp. */
1089 /* Write it into *ch. */
1090 /* If no character is read, then *ch value < 0. */
1091 /* Return 1 if OK, 0 if EOF or error. */
1092 {
1093  int status = 1;
1094  int c; /* in case ch points awry, we still have something in c. */
1095 
1096  c = EOF;
1097  if (read_line_char (fp, &c) == 0)
1098  {
1099  /* end of fp file, or error reading it */
1100  status = 0;
1101  }
1102  else
1103  {
1104  if (c > 255)
1105  {
1107  fprintf (stderr,
1108  "(read_char) : character %d not in range 0 to 255\n",
1109  c);
1110  dinfo();
1111  status = 0;
1112  }
1113  else if ( ! isprint (c) && ! isspace (c)
1114 #ifdef WIN32
1115  && ! isknj (c) && ! isknj2 (c)
1116 #endif
1117  )
1118  {
1120  fprintf (stderr,
1121  "(read_char) : character %d not printable and not white space.\n",
1122  c);
1123  dinfo();
1124  status = 0;
1125  }
1126  }
1127  *ch = c;
1128 
1129  return status;
1130 }
1131 /* read_char */
1132 
1133 
1134 COUNT
1136 #ifdef STDC
1137  (FILE * dtl)
1138 #else
1139  (dtl)
1140  FILE * dtl;
1141 #endif
1142 /* read and check DTL variety signature */
1143 /* return number of DTL bytes written */
1144 /* DTL variety is _NEVER_ grouped by BCOM and ECOM. */
1145 /* Uniformity here enables the program easily to modify its behavior. */
1146 {
1147  COUNT vread = 0; /* number of DTL bytes read by read_variety */
1148  static Token token = "";
1149 
1150  /* read the DTL VARIETY keyword */
1151  vread += read_token (dtl, token);
1152  /* test whether signature begins correctly */
1153  if (strcmp (token, "variety") != 0)
1154  {
1156  fprintf (stderr, "(read_variety) : DTL FILE ERROR (%s) : ", dtl_filename);
1157  fprintf (stderr, "DTL signature must begin with \"variety\", not \"%s\".\n",
1158  token);
1159  dexit (1);
1160  }
1161 
1162  /* read the DTL variety */
1163  vread += read_token (dtl, token);
1164  /* test whether variety is correct */
1165  if (strcmp (token, VARIETY) != 0)
1166  {
1168  fprintf (stderr, "(read_variety) : DTL FILE ERROR (%s) : ", dtl_filename);
1169  fprintf (stderr, "DTL variety must be \"%s\", not \"%s\".\n",
1170  VARIETY, token);
1171  dexit (1);
1172  }
1173 
1175  fprintf (stderr, "(read_variety) : DTL variety %s is OK.\n", VARIETY);
1176 
1177  return vread; /* OK */
1178 }
1179 /* read_variety */
1180 
1181 
1182 COUNT
1184 #ifdef STDC
1185  (FILE * fp, int * ch)
1186 #else
1187  (fp, ch)
1188  FILE * fp;
1189  int * ch;
1190 #endif
1191 /* Skip whitespace characters in file fp. */
1192 /* Write in *ch the last character read from fp, */
1193 /* or < 0 if fp could not be read. */
1194 /* Return number of characters read from fp. */
1195 {
1196  int c; /* character read (if any) */
1197  COUNT count; /* number (0 or more) of whitespace characters read */
1198  int nchar; /* number (0 or 1) of characters read by read_char */
1199 
1200  /* loop ends at: end of fp file, or reading error, or not a white space */
1201  for (count=0; ((nchar = read_char (fp, &c)) == 1 && isspace (c)); ++count)
1202  {
1203  /* otherwise, more white spaces to skip */
1204  if (debug)
1205  {
1206  /* report when each DTL end of line is reached */
1207  if (c == '\n')
1208  {
1210  fprintf (stderr, "(skip_space) : ");
1211  fprintf (stderr, "end of DTL line (at least) ");
1212  fprintf (stderr, WF, dtl_line.num);
1213  fprintf (stderr, "\n");
1214  }
1215  }
1216  }
1217 
1218  if (nchar == 0)
1219  {
1220  c = -1;
1221  }
1222 
1223  *ch = c; /* c will be < 0 if read_char could not read fp */
1224  return (count + nchar);
1225 }
1226 /* skip_space */
1227 
1228 
1229 COUNT
1231 #ifdef STDC
1232  (FILE * dtl, char * token)
1233 #else
1234  (dtl, token)
1235  FILE * dtl;
1236  char * token;
1237 #endif
1238 /* read next token from dtl file. */
1239 /* return number of DTL bytes read. */
1240 /* A token is one of:
1241  a string from BMES_CHAR to the next unescaped EMES_CHAR, inclusive;
1242  BCOM or ECOM, unless these are empty strings;
1243  BSEQ or ESEQ;
1244  any other sequence of non-whitespace characters.
1245 */
1246 {
1247  COUNT nread; /* number of DTL bytes read by read_token */
1248  int ch; /* most recent character read */
1249 
1250  nread = 0;
1251 
1252  /* obtain first non-space character */
1253  /* add to nread the number of characters read from dtl by skip_space */
1254  nread += skip_space (dtl, &ch);
1255 
1256  if (ch < 0)
1257  {
1258  /* end of dtl file */
1259  /* write an empty token */
1260  strcpy (token, "");
1261  if (debug)
1262  {
1264  fprintf (stderr, "(read_token) : end of dtl file.\n");
1265  }
1266  }
1267  else if (group && ch == BCOM_CHAR)
1268  {
1269  strcpy (token, BCOM);
1270  }
1271  else if (group && ch == ECOM_CHAR)
1272  {
1273  strcpy (token, ECOM);
1274  }
1275  else
1276  {
1277  token[0] = ch;
1278  token[1] = '\0';
1279  if (ch == BMES_CHAR) /* string token; read until unescaped EMES_CHAR */
1280  {
1281  nread += read_mes (dtl, token+1);
1282  }
1283  else if (ch == BSEQ_CHAR || ch == ESEQ_CHAR)
1284  {
1285  /* token is complete */
1286  }
1287  else /* any other string not containing (ECOM_CHAR or) whitespace */
1288  {
1289  nread += read_misc (dtl, token+1);
1290  }
1291  }
1292 
1293  if (debug)
1294  {
1296  fprintf (stderr, "(read_token) : token = \"%s\"\n", token);
1297  }
1298 
1299  return (nread); /* number of bytes read from dtl file */
1300 }
1301 /* read_token */
1302 
1303 
1304 #define CHAR_OK 1
1305 #define CHAR_FAIL 0
1306 #define CHAR_EOS (-1)
1307 
1308 int
1310 #ifdef STDC
1311  (FILE * fp, int * ch)
1312 #else
1313  (fp, ch)
1314  FILE * fp;
1315  int * ch;
1316 #endif
1317 {
1318  int status = CHAR_OK; /* OK so far */
1319  int c;
1320 
1321  if (read_char (fp, &c) == 0)
1322  status = CHAR_FAIL; /* fail */
1323 
1324  if (c == EMES_CHAR) /* end-of-string char */
1325  {
1326  status = CHAR_EOS; /* end of string */
1327  }
1328  else if (c == ESC_CHAR) /* escape character */
1329  {
1330  /* accept the next character literally, even ESC_CHAR and EMES_CHAR */
1331  if (read_char (fp, &c) == 0)
1332  status = CHAR_FAIL; /* fail */
1333  }
1334 
1335  *ch = c;
1336  return status;
1337 }
1338 /* read_string_char */
1339 
1340 
1341 COUNT
1343 #ifdef STDC
1344  (FILE * fp, Token token)
1345 #else
1346  (fp, token)
1347  FILE * fp;
1348  Token token;
1349 #endif
1350 {
1351  int c;
1352  int count;
1353  /* loop ends at: end of fp file, or reading error, or a space */
1354  for (count=0; count <= MAXTOKLEN; ++count)
1355  {
1356  if (read_char (fp, &c) == 0 || isspace (c))
1357  break;
1358  if (group && c == ECOM_CHAR)
1359  {
1360  (Void) unread_char ();
1361  break;
1362  }
1363 
1364  token[count] = c;
1365  }
1366  token[count] = '\0';
1367  return count;
1368 }
1369 /* read_misc */
1370 
1371 
1372 COUNT
1374 #ifdef STDC
1375  (FILE * fp, char * token)
1376 #else
1377  (fp, token)
1378  FILE * fp;
1379  char * token;
1380 #endif
1381 /* called **AFTER** a BMES_CHAR has been read */
1382 /* read file fp for characters up to next unescaped EMES_CHAR */
1383 /* this is called a "string token" */
1384 /* write string, including EMES_CHAR, into token[] */
1385 /* return number of characters read from fp */
1386 {
1387  COUNT dtl_count; /* number of DTL characters read by read_mes from fp */
1388  int more; /* flag more == 0 to terminate loop */
1389  int escape; /* flag escape == 1 if previous character was ESC_CHAR */
1390  int ch; /* current DTL character */
1391 
1392  escape = 0;
1393  more = 1;
1394  dtl_count = 0;
1395  while (more)
1396  {
1397  if (read_char (fp, &ch) == 0)
1398  {
1399  /* end of fp file, or reading error */
1400  more = 0;
1401  }
1402  else /* error checking passed */
1403  {
1404  ++ dtl_count;
1405  if (ch == EMES_CHAR && escape == 0) /* end of string */
1406  {
1407  /* include final EMES_CHAR */
1408  * token ++ = ch;
1409  more = 0;
1410  }
1411  else if (ch == ESC_CHAR && escape == 0)
1412  {
1413  /* next character is not end of string */
1414  escape = 1;
1415  }
1416  else
1417  {
1418  /* store any other character, */
1419  /* including escaped EMES_CHAR and ESC_CHAR*/
1420  * token ++ = ch;
1421  escape = 0;
1422  }
1423  }
1424  }
1425  * token = '\0';
1426  return dtl_count;
1427 }
1428 /* read_mes */
1429 
1430 
1431 int
1433 /* wind input back, to allow rereading of one character */
1434 /* return 1 if this works, 0 on error */
1435 {
1436  int status;
1437  if (dtl_line.read > 0)
1438  {
1439  -- dtl_line.read; /* back up one character in dtl_line */
1440  -- dtl_read; /* correct the count of DTL characters */
1441  -- com_read; /* count another DTL command character */
1442  status = 1; /* OK */
1443  }
1444  else /* current DTL line is empty */
1445  {
1446  status = 0; /* error */
1447  }
1448  return status;
1449 }
1450 /* unread_char */
1451 
1452 
1453 int
1455 #ifdef STDC
1456  (char * command, int * opcode)
1457 #else
1458  (command, opcode)
1459  char * command;
1460  int * opcode;
1461 #endif
1462 {
1463  int found;
1464  int i;
1465 
1466  found = 0;
1467  for (i=0; i < NCMDS; i++)
1468  {
1469  if ((cmd_table[i] != 0) && (strcmp (command, cmd_table[i]) == 0))
1470  {
1471  found = 1;
1472  break;
1473  }
1474  }
1475 
1476  *opcode = i;
1477 
1478  return found;
1479 }
1480 /* find_command */
1481 
1482 
1483 int
1485 #ifdef STDC
1486  (int byte)
1487 #else
1488  (byte)
1489  int byte;
1490 #endif
1491 {
1492  if (byte < 0 || byte > 255)
1493  {
1495  fprintf (stderr, "(check_byte) : INTERNAL ERROR : ");
1496  fprintf (stderr, "byte %d not in the range of 0 to 255.\n", byte);
1497  dexit (1);
1498  }
1499  return 1; /* OK */
1500 }
1501 /* check_byte */
1502 
1503 
1504 int
1506 #ifdef STDC
1507  (FILE * dtl, FILE * dvi, int opcode)
1508 #else
1509  (dtl, dvi, opcode)
1510  FILE * dtl;
1511  FILE * dvi;
1512  int opcode;
1513 #endif
1514 {
1515  int n;
1516 
1517  if (opcode >= 0 && opcode <= 127)
1518  ; /* SETCHAR uses no data */
1519  else if (opcode >= 128 && opcode <= 170)
1520  {
1521  word_t this_bop_address = last_bop_address;
1522 
1523  if (opcode == 139) /* BOP */
1524  {
1525  this_bop_address = dvi_written - 1;
1526  }
1527  put_table (op_128_170, opcode, dtl, dvi);
1528  if (opcode == 139) /* BOP */
1529  {
1530  xfer_bop_address (dtl, dvi);
1531  last_bop_address = this_bop_address;
1532  }
1533  }
1534  else if (opcode >= 171 && opcode <= 234)
1535  ; /* FONTNUM uses no data */
1536  else if (opcode >= 235 && opcode <= 238)
1537  put_table (fnt, opcode, dtl, dvi);
1538  else if (opcode >= 239 && opcode <= 242)
1539  {
1540  n = opcode - 238;
1541  special (dtl, dvi, n);
1542  }
1543  else if (opcode >= 243 && opcode <= 246)
1544  {
1545  n = opcode - 242;
1546  fontdef (dtl, dvi, n);
1547  }
1548  else if (opcode == 247)
1549  preamble (dtl, dvi);
1550  else if (opcode == 248)
1551  postamble (dtl, dvi);
1552  else if (opcode == 249)
1553  post_post (dtl, dvi);
1554  else if (opcode >= 250 && opcode <= 255)
1555  ; /* these, undefined, opcodes use no data */
1556  else
1557  {
1559  fprintf (stderr,
1560  "(xfer_args) : opcode %d not handled.\n",
1561  opcode);
1562  }
1563 
1564  return 1; /* OK */
1565 }
1566 /* xfer_args */
1567 
1568 
1569 int
1571 #ifdef STDC
1572  (FILE * dtl, FILE * dvi)
1573 #else
1574  (dtl, dvi)
1575  FILE * dtl;
1576  FILE * dvi;
1577 #endif
1578 /* Called _after_ a BSEQ_CHAR command */
1579 /* Read bytes from dtl file, */
1580 /* writing corresponding SETCHAR or SET1 commands to DVI file, */
1581 /* _until_ unescaped ESEQ_CHAR is found */
1582 /* Return 1 if OK, 0 on error */
1583 /**** dt2dv assumes 8 bit characters, ****/
1584 /**** but some day one might change that. ****/
1585 {
1586  int status = 1; /* status = 1 if OK, 0 if error */
1587  int more; /* sequence of font characters continuing? */
1588  int escape = 0; /* flag set if previous character was an escape */
1589  int ch; /* character read from DTL file */
1590  more = 1;
1591  while (more)
1592  {
1593  /* ignore read_char status, to allow unprintable characters */
1594  (Void) read_char (dtl, &ch);
1595  /* but check for end of dtl file, or serious file reading error */
1596  if (ch < 0)
1597  {
1599  fprintf (stderr, "(set_seq) : ");
1600  fprintf (stderr, "end of dtl file, ");
1601  fprintf (stderr, "or serious dtl file reading error\n");
1602  dinfo();
1603  more = 0;
1604  status = 0; /* bad news */
1605  }
1606  else /* read dtl file, okay */
1607  {
1608  if (ch == ESC_CHAR && escape == 0) /* escape next character */
1609  {
1610  escape = 1;
1611  }
1612  else
1613  {
1614  if (ch == ESEQ_CHAR && escape == 0) /* end of sequence */
1615  {
1616  more = 0;
1617  }
1618  else if (ch <= 127) /* can use SETCHAR */
1619  {
1620  put_byte (ch, dvi);
1621  }
1622  else if (ch <= 255) /* can use SET1 */
1623  {
1624  put_byte (128, dvi); /* SET1 opcode */
1625  put_unsigned (1, (U4) ch, dvi);
1626  }
1627  else
1628  {
1630  fprintf (stderr, "(set_seq) : ");
1631  fprintf (stderr,
1632  "ERROR : DTL character %d is not in range 0 to 255\n",
1633  ch);
1634  dexit (1);
1635  more = 0;
1636  status = 0; /* Error, because dt2dv assumes 8 bit characters */
1637  }
1638  escape = 0; /* current ch is not an escape character */
1639  }
1640  }
1641  }
1642  return status;
1643 }
1644 /* set_seq */
1645 
1646 
1647 U4
1649 #ifdef STDC
1650  (int n, FILE * dtl, FILE * dvi)
1651 #else
1652  (n, dtl, dvi)
1653  int n;
1654  FILE * dtl;
1655  FILE * dvi;
1656 #endif
1657 /* translate unsigned n-byte hexadecimal number from dtl to dvi file. */
1658 /* return value of hexadecimal number */
1659 {
1660  U4 unum = 0; /* at most this space needed */
1661  int nconv = 0; /* number of arguments converted by sscanf */
1662  static Token token = ""; /* DTL token */
1663 
1664  if (n < 1 || n > 4)
1665  {
1667  fprintf (stderr,
1668  "(xfer_hex) : INTERNAL ERROR : asked for %d bytes. Must be 1 to 4.\n",
1669  n);
1670  dexit (1);
1671  }
1672 
1673  read_token (dtl, token);
1674 
1675  nconv = sscanf (token, XF4, &unum);
1676 
1677  if (nconv < 1)
1678  {
1680  fprintf (stderr, "(xfer_hex) : DTL FILE ERROR (%s) : %s \"%s\".\n",
1681  dtl_filename, "hexadecimal number expected, not", token);
1682  dexit (1);
1683  }
1684 
1685  put_unsigned (n, unum, dvi);
1686 
1687  return unum;
1688 }
1689 /* xfer_hex */
1690 
1691 
1692 U4
1694 #ifdef STDC
1695  (int n, FILE * dtl, FILE * dvi)
1696 #else
1697  (n, dtl, dvi)
1698  int n;
1699  FILE * dtl;
1700  FILE * dvi;
1701 #endif
1702 /* translate unsigned n-byte octal number from dtl to dvi file. */
1703 /* return value of octal number */
1704 {
1705  U4 unum = 0; /* at most this space needed */
1706  int nconv = 0; /* number of arguments converted by sscanf */
1707  static Token token = ""; /* DTL token */
1708 
1709  if (n < 1 || n > 4)
1710  {
1712  fprintf (stderr,
1713  "(xfer_oct) : INTERNAL ERROR : asked for %d bytes. Must be 1 to 4.\n",
1714  n);
1715  dexit (1);
1716  }
1717 
1718  read_token (dtl, token);
1719 
1720  nconv = sscanf (token, OF4, &unum);
1721 
1722  if (nconv < 1)
1723  {
1725  fprintf (stderr, "(xfer_oct) : DTL FILE ERROR (%s) : %s \"%s\".\n",
1726  dtl_filename, "octal number expected, not", token);
1727  dexit (1);
1728  }
1729 
1730  put_unsigned (n, unum, dvi);
1731 
1732  return unum;
1733 }
1734 /* xfer_oct */
1735 
1736 
1737 U4
1739 #ifdef STDC
1740  (int n, FILE * dtl, FILE * dvi)
1741 #else
1742  (n, dtl, dvi)
1743  int n;
1744  FILE * dtl;
1745  FILE * dvi;
1746 #endif
1747 /* translate unsigned n-byte number from dtl to dvi file. */
1748 /* return value of unsigned number */
1749 {
1750  U4 unum = 0; /* at most this space needed */
1751 
1752  unum = get_unsigned (dtl);
1753  put_unsigned (n, unum, dvi);
1754 
1755  return unum;
1756 }
1757 /* xfer_unsigned */
1758 
1759 
1760 S4
1762 #ifdef STDC
1763  (int n, FILE * dtl, FILE * dvi)
1764 #else
1765  (n, dtl, dvi)
1766  int n;
1767  FILE * dtl;
1768  FILE * dvi;
1769 #endif
1770 /* translate signed n-byte number from dtl to dvi file. */
1771 /* return value of signed number */
1772 {
1773  S4 snum = 0;
1774 
1775  snum = get_signed (dtl);
1776  put_signed (n, snum, dvi);
1777 
1778  return snum;
1779 }
1780 /* xfer_signed */
1781 
1782 
1783 U4
1785 #ifdef STDC
1786  (FILE * dtl)
1787 #else
1788  (dtl)
1789  FILE * dtl;
1790 #endif
1791 /* read unsigned number from dtl file. */
1792 /* return value of unsigned number */
1793 {
1794  U4 unum = 0; /* at most this space needed */
1795  int nconv = 0; /* number of arguments converted by sscanf */
1796  static Token token = ""; /* DTL token */
1797 
1798  read_token (dtl, token);
1799 
1800  nconv = sscanf (token, UF4, &unum);
1801 
1802  if (nconv < 1)
1803  {
1805  fprintf (stderr, "(get_unsigned) : DTL FILE ERROR (%s) : %s \"%s\".\n",
1806  dtl_filename, "unsigned number expected, not", token);
1807  dexit (1);
1808  }
1809 
1810  return unum;
1811 }
1812 /* get_unsigned */
1813 
1814 
1815 S4
1817 #ifdef STDC
1818  (FILE * dtl)
1819 #else
1820  (dtl)
1821  FILE * dtl;
1822 #endif
1823 /* read signed number from dtl file. */
1824 /* return value of signed number */
1825 {
1826  S4 snum = 0;
1827  int nconv = 0; /* number of sscanf arguments converted and assigned */
1828  static Token token = "";
1829 
1830  read_token (dtl, token);
1831 
1832  nconv = sscanf (token, SF4, &snum);
1833 
1834  if (nconv < 1)
1835  {
1837  fprintf (stderr, "(get_signed) : DTL FILE ERROR (%s) : %s \"%s\".\n",
1838  dtl_filename, "signed number expected, not", token);
1839  dexit (1);
1840  }
1841 
1842  return snum;
1843 }
1844 /* get_signed */
1845 
1846 
1847 int
1849 #ifdef STDC
1850  (int n, U4 unum, FILE * dvi)
1851 #else
1852  (n, unum, dvi)
1853  int n;
1854  U4 unum;
1855  FILE * dvi;
1856 #endif
1857 /* put unsigned in-byte integer to dvi file */
1858 /* DVI format uses Big-endian storage of numbers: */
1859 /* most significant byte is first. */
1860 /* return number of bytes written. */
1861 {
1862  Byte ubyte[4]; /* at most 4 bytes needed in DVI format */
1863  int i;
1864 
1865  if (n < 1 || n > 4)
1866  {
1868  fprintf (stderr,
1869  "(put_unsigned) : INTERNAL ERROR : asked for %d bytes. Must be 1 to 4.\n",
1870  n);
1871  dexit (1);
1872  }
1873 
1874  /* Big-endian storage. */
1875  for (i = 0; i < n; i++)
1876  {
1877  ubyte[i] = (Byte) (unum % 256);
1878  unum /= 256;
1879  }
1880  /* Reverse order for big-endian representation. */
1881  for (i = n-1; i >= 0; i--)
1882  {
1883  put_byte ((int) ubyte[i], dvi);
1884  }
1885 
1886  return n;
1887 }
1888 /* put_unsigned */
1889 
1890 
1891 int
1893 #ifdef STDC
1894  (int n, S4 snum, FILE * dvi)
1895 #else
1896  (n, snum, dvi)
1897  int n;
1898  S4 snum;
1899  FILE * dvi;
1900 #endif
1901 /* put signed in-byte integer to dvi file */
1902 /* DVI format uses 2's complement Big-endian storage of signed numbers: */
1903 /* most significant byte is first. */
1904 /* return number of bytes written. */
1905 {
1906  /* Will this deal properly with the sign? */
1907 
1908  if (n < 1 || n > 4)
1909  {
1911  fprintf (stderr,
1912  "(put_signed) : INTERNAL ERROR : asked for %d bytes. Must be 1 to 4.\n",
1913  n);
1914  dexit (1);
1915  }
1916 
1917  /* How do we ensure 2's complement representation? */
1918  /* Here's a trick that I hope is portable, given ANSI C. */
1919  /* See K&R (2nd edition), Appendix A6.2 "Integral Conversions". */
1920 
1921  /* Convert snum to U4 data type */
1922  put_unsigned (n, (U4) snum, dvi);
1923 
1924  return n;
1925 }
1926 /* put_signed */
1927 
1928 
1929 int
1931 #ifdef STDC
1932  (FILE * dtl)
1933 #else
1934  (dtl)
1935  FILE * dtl;
1936 #endif
1937 /* check that a BMES_CHAR is the next non-whitespace character in dtl */
1938 {
1939  int ch; /* next non-whitespace character in dtl */
1940 
1941  /* `(Void)' because we ignore the number of spaces skipped */
1942  (Void) skip_space (dtl, &ch);
1943 
1944  if (ch < 0)
1945  {
1947  fprintf (stderr, "(check_bmes) : DTL FILE ERROR (%s) : ",
1948  dtl_filename);
1949  fprintf (stderr, "end of dtl file, or reading error\n");
1950  dexit (1);
1951  }
1952 
1953  if (ch != BMES_CHAR)
1954  {
1956  fprintf (stderr, "(check_bmes) : DTL FILE ERROR (%s) : ",
1957  dtl_filename);
1958  fprintf (stderr, "BMES_CHAR (`%c') expected before string, not `%c' (char %d).\n",
1959  BMES_CHAR, ch, ch);
1960  dexit (1);
1961  }
1962 
1963  return 1; /* OK */
1964 }
1965 /* check_bmes */
1966 
1967 
1968 int
1970 #ifdef STDC
1971  (FILE * dtl)
1972 #else
1973  (dtl)
1974  FILE * dtl;
1975 #endif
1976 /* check that an EMES_CHAR is the next character in dtl */
1977 {
1978  int ch; /* dtl character */
1979 
1980  if (read_char (dtl, &ch) == 0)
1981  {
1983  fprintf (stderr, "(check_emes) : DTL FILE ERROR (%s) : ",
1984  dtl_filename);
1985  fprintf (stderr, "end of dtl file, or reading error\n");
1986  dexit (1);
1987  }
1988 
1989  if (ch != EMES_CHAR)
1990  {
1992  fprintf (stderr, "(check_emes) : DTL FILE ERROR (%s) : ",
1993  dtl_filename);
1994  fprintf (stderr, "EMES_CHAR (`%c') expected to follow string, not `%c' (char %d).\n",
1995  EMES_CHAR, ch, ch);
1996  dexit (1);
1997  }
1998 
1999  return 1; /* OK */
2000 }
2001 /* check_emes */
2002 
2003 
2004 /* Size typically used in this program for Lstring variables */
2005 #define LSIZE 16384
2006 
2007 
2008 Void
2010 #ifdef STDC
2011  (Lstring * lsp, long int n)
2012 #else
2013  (lsp, n)
2014  Lstring * lsp;
2015  long int n;
2016 #endif
2017 {
2018  lsp->l = 0;
2019  lsp->m = n;
2020  lsp->s = (char *) gmalloc (n);
2021 }
2022 /* init_Lstring */
2023 
2024 
2025 Void
2027 #ifdef STDC
2028  (Lstring * lsp)
2029 #else
2030  (lsp)
2031  Lstring * lsp;
2032 #endif
2033 {
2034  lsp->l = 0;
2035  lsp->m = 0;
2036  free (lsp->s);
2037  lsp->s = NULL; /* to be sure */
2038 }
2039 /* de_init_Lstring */
2040 
2041 
2042 Lstring *
2044 #ifdef STDC
2045  (long int n)
2046 #else
2047  (n)
2048  long int n;
2049 #endif
2050 {
2051  Lstring * lsp;
2052  lsp = (Lstring *) gmalloc (sizeof (Lstring));
2053  init_Lstring (lsp, n);
2054  return (lsp);
2055 }
2056 /* alloc_Lstring */
2057 
2058 
2059 Void
2061 #ifdef STDC
2062  (Lstring * lstr)
2063 #else
2064  (lstr)
2065  Lstring * lstr;
2066 #endif
2067 {
2068  free (lstr->s);
2069  free (lstr);
2070 }
2071 /* free_Lstring */
2072 
2073 
2074 Void
2076 #ifdef STDC
2077  (int ch, Lstring * lstr)
2078 #else
2079  (ch, lstr)
2080  int ch;
2081  Lstring * lstr;
2082 #endif
2083 /* write byte ch into Lstring *lstr */
2084 {
2085  if (lstr->l >= lstr->m)
2086  {
2088  fprintf (stderr, "(ls_putb) : ERROR : No more room in Lstring.\n");
2089  dexit (1);
2090  }
2091  else
2092  {
2093  lstr->s [(lstr->l)++] = ch;
2094  }
2095 }
2096 /* ls_putb */
2097 
2098 
2099 long int
2101 #ifdef STDC
2102  (FILE * dtl, Lstring * lstr)
2103 #else
2104  (dtl, lstr)
2105  FILE * dtl;
2106  Lstring * lstr;
2107 #endif
2108 /* get a string from dtl file, store as an Lstring in *lstr. */
2109 /* lstr must already be allocated and initialised. */
2110 /* return length of Lstring *lstr */
2111 {
2112  U4 nch;
2113  int char_status = CHAR_OK; /* OK so far */
2114 
2115  if (debug)
2116  {
2118  fprintf (stderr, "(get_Lstring) : entering get_Lstring.\n");
2119  }
2120 
2121  check_bmes (dtl);
2122 
2123  if (debug)
2124  {
2126  fprintf (stderr,
2127  "(get_Lstring) : string is: \"");
2128  }
2129 
2130  for (nch=0; ; nch++)
2131  {
2132  int ch;
2133 
2134  char_status = read_string_char (dtl, &ch);
2135 
2136  if (char_status == CHAR_FAIL)
2137  {
2138  /* end of dtl file, or reading error */
2139  fprintf (stderr, "\n");
2141  fprintf (stderr, "(get_Lstring) : DTL FILE ERROR (%s) : ",
2142  dtl_filename);
2143  fprintf (stderr, "cannot read string[");
2144  fprintf (stderr, UF4, nch);
2145  fprintf (stderr, "] from dtl file.\n");
2146  dexit (1);
2147  }
2148 
2149  if (debug)
2150  {
2151  fprintf (stderr, "%c", ch);
2152  }
2153 
2154  if (char_status == CHAR_EOS)
2155  {
2156  if (ch != EMES_CHAR)
2157  {
2159  fprintf (stderr, "(get_Lstring) : INTERNAL ERROR : ");
2160  fprintf (stderr, "char_status = CHAR_FAIL,\n");
2161  fprintf (stderr,
2162  "but ch = %c (char %d) is not EMES_CHAR = %c (char %d)\n",
2163  ch, ch, EMES_CHAR, EMES_CHAR);
2164  dexit (1);
2165  }
2166  (Void) unread_char ();
2167  break; /* end of string */
2168  }
2169  else if (char_status == CHAR_OK)
2170  {
2171  ls_putb (ch, lstr);
2172  }
2173  else
2174  {
2176  fprintf (stderr, "(get_Lstring) : INTERNAL ERROR : ");
2177  fprintf (stderr, "char_status = %d is unfamiliar!\n", char_status);
2178  dexit (1);
2179  }
2180  }
2181  /* end for */
2182 
2183  if (debug)
2184  {
2185  fprintf (stderr, "\".\n");
2186  }
2187 
2188  check_emes (dtl);
2189 
2190  if (debug)
2191  {
2193  fprintf (stderr, "(get_Lstring) : leaving get_Lstring.\n");
2194  }
2195 
2196  return (lstr->l);
2197 }
2198 /* get_Lstring */
2199 
2200 
2201 Void
2203 #ifdef STDC
2204  (const Lstring * lstr, FILE * dvi)
2205 #else
2206  (str, dvi)
2207  Lstring lstr;
2208  FILE * dvi;
2209 #endif
2210 {
2211  size_t fwret;
2212  fwret = fwrite ((lstr->s), sizeof (char), (size_t) (lstr->l), dvi);
2213 
2214  dvi_written += fwret;
2215 
2216  if (fwret < lstr->l)
2217  {
2219  fprintf (stderr,
2220  "(put_Lstring) : DVI File ERROR : not all bytes written ");
2221  fprintf (stderr, "(%ld of %ld).\n",
2222  (long int) fwret, (long int) (lstr->l));
2223  dexit (1);
2224  }
2225 }
2226 /* put_Lstring */
2227 
2228 
2229 U4
2231 #ifdef STDC
2232  (int n, FILE * dtl, FILE * dvi)
2233 #else
2234  (n, dtl, dvi)
2235  int n;
2236  FILE * dtl;
2237  FILE * dvi;
2238 #endif
2239 /* transfer (length and) quoted string from dtl to dvi file, */
2240 /* return number of bytes written to dvi file. */
2241 {
2242  U4 k, k2;
2243  Lstring lstr;
2244 
2245  if (debug)
2246  {
2248  fprintf (stderr, "(xfer_len_string) : entering xfer_len_string.\n");
2249  }
2250 
2251  init_Lstring (&lstr, LSIZE);
2252 
2253  /* k[n] : length of special string */
2254 
2255  k = get_unsigned (dtl);
2256 
2257  if (debug)
2258  {
2260  fprintf (stderr, "(xfer_len_string) : string's nominal length k = ");
2261  fprintf (stderr, UF4, k);
2262  fprintf (stderr, " characters.\n");
2263  }
2264 
2265  k2 = get_Lstring (dtl, &lstr);
2266 
2267  if (k2 != k)
2268  {
2270  fprintf (stderr, "(xfer_len_string) : WARNING : string length (");
2271  fprintf (stderr, UF4, k);
2272  fprintf (stderr, ") in DTL file is wrong\n");
2273  fprintf (stderr, "Writing correct value (");
2274  fprintf (stderr, UF4, k2);
2275  fprintf (stderr, ") to DVI file\n");
2276  }
2277 
2278  put_unsigned (n, k2, dvi);
2279 
2280  put_Lstring (&lstr, dvi);
2281 
2282  if (debug)
2283  {
2285  fprintf (stderr, "(xfer_len_string) : leaving xfer_len_string.\n");
2286  }
2287 
2288  de_init_Lstring (&lstr);
2289 
2290  return (n + k2);
2291 }
2292 /* xfer_len_string */
2293 
2294 
2295 S4
2297 #ifdef STDC
2298  (FILE * dtl, FILE * dvi)
2299 #else
2300  (dtl, dvi)
2301  FILE * dtl;
2302  FILE * dvi;
2303 #endif
2304 /* translate signed 4-byte bop address from dtl to dvi file. */
2305 /* return value of bop address written to DVI file */
2306 {
2307  S4 snum = 0; /* at most this space needed for byte address */
2308  int nconv = 0; /* number of arguments converted by sscanf */
2309  static Token token = ""; /* DTL token */
2310 
2311  read_token (dtl, token);
2312 
2313  nconv = sscanf (token, SF4, &snum);
2314 
2315  if (nconv != 1)
2316  {
2318  fprintf (stderr, "(xfer_bop_address) : DTL FILE ERROR (%s) : ",
2319  dtl_filename);
2320  fprintf (stderr, "signed number expected, not \"%s\".\n", token);
2321  dexit (1);
2322  }
2323 
2324  if (snum != last_bop_address)
2325  {
2327  fprintf (stderr, "(xfer_bop_address) : WARNING : byte address (");
2328  fprintf (stderr, WF, snum);
2329  fprintf (stderr, ")\n");
2330  fprintf (stderr, "for previous bop in DTL file is wrong\n");
2331  fprintf (stderr, "Writing correct value (");
2332  fprintf (stderr, WF, last_bop_address);
2333  fprintf (stderr, ") to DVI file\n");
2334  }
2335 
2337 
2338  return last_bop_address;
2339 }
2340 /* xfer_bop_address */
2341 
2342 
2343 S4
2345 #ifdef STDC
2346  (FILE * dtl, FILE * dvi)
2347 #else
2348  (dtl, dvi)
2349  FILE * dtl;
2350  FILE * dvi;
2351 #endif
2352 /* translate signed 4-byte postamble address from dtl to dvi file. */
2353 /* return value of postamble address written to DVI file */
2354 {
2355  S4 snum = 0; /* at most this space needed for byte address */
2356  int nconv = 0; /* number of arguments converted by sscanf */
2357  static Token token = ""; /* DTL token */
2358 
2359  read_token (dtl, token);
2360 
2361  nconv = sscanf (token, SF4, &snum);
2362 
2363  if (nconv != 1)
2364  {
2366  fprintf (stderr, "(xfer_postamble_address) : DTL FILE ERROR (%s) : ",
2367  dtl_filename);
2368  fprintf (stderr, "signed number expected, not \"%s\".\n", token);
2369  dexit (1);
2370  }
2371 
2372  if (snum != postamble_address)
2373  {
2375  fprintf (stderr, "(xfer_postamble_address) : WARNING : byte address (");
2376  fprintf (stderr, WF, snum);
2377  fprintf (stderr, ")\n");
2378  fprintf (stderr, "for postamble in DTL file is wrong\n");
2379  fprintf (stderr, "Writing correct value (");
2380  fprintf (stderr, WF, postamble_address);
2381  fprintf (stderr, ") to DVI file\n");
2382  }
2383 
2385 
2386  return postamble_address;
2387 }
2388 /* xfer_postamble_address */
2389 
2390 
2391 int
2393 #ifdef STDC
2394  (op_table table, int opcode, FILE * dtl, FILE * dvi)
2395 #else
2396  (table, opcode, dtl, dvi)
2397  op_table table;
2398  int opcode;
2399  FILE * dtl;
2400  FILE * dvi;
2401 #endif
2402 {
2403  /* table: {char * name; int first, last; op_info * list; }; */
2404  /* op_info: {int code; char * name; int nargs; char * args; }; */
2405 
2406  op_info op; /* entry in table */
2407  int i;
2408  int pos; /* current position in string being scanned */
2409  static String args = "";
2410 
2411  /* Defensive programming. */
2412  if (opcode < table.first || opcode > table.last)
2413  {
2415  fprintf (stderr,
2416  "(put_table) : DTL FILE (OR INTERNAL) ERROR : opcode %d ", opcode);
2417  fprintf (stderr, "is outside table %s [ %d to %d ] !\n",
2418  table.name, table.first, table.last);
2419  dexit (1);
2420  }
2421 
2422  op = table.list [ opcode - table.first ];
2423 
2424  /* More defensive programming. */
2425  if (opcode != op.code)
2426  {
2428  fprintf (stderr,
2429  "(put_table) : INTERNAL ERROR : opcode %d for command \"%s\"",
2430  opcode, op.name);
2431  fprintf (stderr, " faulty in table \"%s\".\n", table.name);
2432  dexit (1);
2433  }
2434 
2435  /* process all the arguments, according to size and sign */
2436 
2438 
2439  pos = 0;
2440  for (i=0; i < op.nargs; i++)
2441  {
2442  int argtype = 0;
2443  int nscan = 0; /* number of bytes read by sscanf */
2444  int nconv = 0; /* number of sscanf arguments converted & assigned */
2445 
2446  /* sscanf() does NOT advance over its input: */
2447  /* C strings lack internal state information, which C files have. */
2448  /* On Sun/OS, sscanf calls ungetc on the string it reads, */
2449  /* which therefore has to be writable. */
2450 
2451  nconv = sscanf (args + pos, "%d%n", &argtype, &nscan);
2452 
2453  if (nconv < 1 || nscan < 1)
2454  {
2456  fprintf (stderr,
2457  "(put_table) : INTERNAL ERROR : internal read of table %s failed!\n",
2458  table.name);
2459  dexit (1);
2460  }
2461 
2462  pos += nscan;
2463 
2464  if (argtype < 0)
2465  xfer_signed (-argtype, dtl, dvi);
2466  else
2467  xfer_unsigned (argtype, dtl, dvi);
2468  }
2469  /* end for */
2470 
2471  return 1; /* OK */
2472 }
2473 /* put_table */
2474 
2475 
2476 /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
2477 
2478 
2479 U4
2481 #ifdef STDC
2482  (FILE * dtl, FILE * dvi, int n)
2483 #else
2484  (dtl, dvi, n)
2485  FILE * dtl;
2486  FILE * dvi;
2487  int n;
2488 #endif
2489 /* read special (1 <= n <= 4 byte) data from dtl, and write in dvi */
2490 /* return number of bytes written */
2491 {
2492  U4 nk;
2493 
2494  if (debug)
2495  {
2497  fprintf (stderr, "(special) : entering special.\n");
2498  }
2499 
2500  if (n < 1 || n > 4)
2501  {
2503  fprintf (stderr, "(special) : DTL FILE ERROR (%s) : special %d, ",
2504  dtl_filename, n);
2505  fprintf (stderr, "range is 1 to 4.\n");
2506  dexit (1);
2507  }
2508 
2509  /* k[n] : length of special string */
2510  /* x[k] : special string */
2511  /* nk = n + k */
2512  nk = xfer_len_string (n, dtl, dvi);
2513 
2514  if (debug)
2515  {
2517  fprintf (stderr, "(special) : leaving special.\n");
2518  }
2519 
2520  return (nk);
2521 }
2522 /* special */
2523 
2524 
2525 int
2527 #ifdef STDC
2528  (FILE * dtl, FILE * dvi, int suffix)
2529 #else
2530  (dtl, dvi, suffix)
2531  FILE * dtl;
2532  FILE * dvi;
2533  int suffix;
2534 #endif
2535 /* read fontdef fnt_def1 .. fnt_def4 from dtl, and write in dvi */
2536 /* suffix is the fontdef suffix : 1 to 4 */
2537 /* return number of bytes written */
2538 {
2539  U4 a, l, a2, l2;
2540  U4 k;
2541  Lstring lstr1, lstr2;
2542 
2543  if (debug)
2544  {
2546  fprintf (stderr, "(fontdef) : entering fontdef.\n");
2547  }
2548 
2549  if (suffix < 1 || suffix > 4)
2550  {
2552  fprintf (stderr, "(fontdef) : DTL FILE ERROR (%s) : ",
2553  dtl_filename);
2554  fprintf (stderr, "font def %d, but range is 1 to 4.\n", suffix);
2555  dexit (1);
2556  }
2557 
2558  init_Lstring (&lstr1, LSIZE);
2559  init_Lstring (&lstr2, LSIZE);
2560 
2561  if (debug)
2562  {
2564  fprintf (stderr, "(fontdef) : about to read font number.\n");
2565  }
2566 
2567  /* k[suffix] : font number */
2568  if (suffix == 4)
2569  k = xfer_signed (suffix, dtl, dvi);
2570  else
2571  k = xfer_unsigned (suffix, dtl, dvi);
2572 
2573  if (debug)
2574  {
2576  fprintf (stderr, "(fontdef) : font ");
2577  fprintf (stderr, UF4, k);
2578  fprintf (stderr, ".\n");
2579  }
2580 
2581 #ifdef HEX_CHECKSUM
2582  /* c[4] : (hexadecimal) checksum : I (gt) would prefer this */
2583  xfer_hex (4, dtl, dvi);
2584 #else /* NOT HEX_CHECKSUM */
2585  /* c[4] : checksum (octal, for comparison with tftopl's .pl file) */
2586  xfer_oct (4, dtl, dvi);
2587 #endif
2588 
2589  /* s[4] */
2590  xfer_unsigned (4, dtl, dvi);
2591 
2592  /* d[4] */
2593  xfer_unsigned (4, dtl, dvi);
2594 
2595  /* If DTL file's edited, a and l may be wrong. */
2596 
2597  /* a[1] : length of font `area' (directory) portion of pathname string */
2598  a = get_unsigned (dtl);
2599 
2600  /* l[1] : length of font portion of pathname string */
2601  l = get_unsigned (dtl);
2602 
2603  /* n[a+l] : font pathname string <= area + font */
2604 
2605  a2 = get_Lstring (dtl, &lstr1);
2606 
2607  if (a2 != a)
2608  {
2610  fprintf (stderr, "(fontdef) : WARNING : font area string's length (");
2611  fprintf (stderr, UF4, a);
2612  fprintf (stderr, ") in DTL file is wrong\n");
2613  fprintf (stderr, "Writing correct value (");
2614  fprintf (stderr, UF4, a2);
2615  fprintf (stderr, ") to DVI file\n");
2616  }
2617 
2618  put_unsigned (1, a2, dvi);
2619 
2620  l2 = get_Lstring (dtl, &lstr2);
2621 
2622  if (l2 != l)
2623  {
2625  fprintf (stderr, "(fontdef) : WARNING : font string's length (");
2626  fprintf (stderr, UF4, l);
2627  fprintf (stderr, ") in DTL file is wrong\n");
2628  fprintf (stderr, "Writing correct value (");
2629  fprintf (stderr, UF4, l2);
2630  fprintf (stderr, ") to DVI file\n");
2631  }
2632 
2633  put_unsigned (1, l2, dvi);
2634 
2635  put_Lstring (&lstr1, dvi);
2636  put_Lstring (&lstr2, dvi);
2637 
2638  de_init_Lstring (&lstr2);
2639  de_init_Lstring (&lstr1);
2640 
2641  if (debug)
2642  {
2644  fprintf (stderr, "(fontdef) : leaving fontdef.\n");
2645  }
2646 
2647  return (suffix + 4*4 + 2*1 + a2 + l2);
2648 }
2649 /* fontdef */
2650 
2651 
2652 U4
2654 #ifdef STDC
2655  (FILE * dtl, FILE * dvi)
2656 #else
2657  (dtl, dvi)
2658  FILE * dtl;
2659  FILE * dvi;
2660 #endif
2661 /* read preamble from dtl, and write in dvi */
2662 /* return number of bytes written */
2663 {
2664  U4 k1;
2665 
2666  if (debug)
2667  {
2669  fprintf (stderr, "(preamble) : entering preamble.\n");
2670  }
2671 
2672  /* i[1] */
2673  xfer_unsigned (1, dtl, dvi);
2674 
2675  /* num[4] */
2676  xfer_unsigned (4, dtl, dvi);
2677 
2678  /* den[4] */
2679  xfer_unsigned (4, dtl, dvi);
2680 
2681  /* mag[4] */
2682  xfer_unsigned (4, dtl, dvi);
2683 
2684  /* k[1] : length of comment */
2685  /* x[k] : comment string */
2686  /* k1 = 1 + k */
2687  k1 = xfer_len_string (1, dtl, dvi);
2688 
2689  if (debug)
2690  {
2692  fprintf (stderr, "(preamble) : leaving preamble.\n");
2693  }
2694 
2695  return (1 + 3*4 + k1);
2696 }
2697 /* preamble */
2698 
2699 
2700 int
2702 #ifdef STDC
2703  (FILE * dtl, FILE * dvi)
2704 #else
2705  (dtl, dvi)
2706  FILE * dtl;
2707  FILE * dvi;
2708 #endif
2709 /* read postamble from dtl, and write in dvi */
2710 /* return number of bytes written */
2711 {
2713 
2714  /* p[4] : DVI address of previous bop command */
2715  /* --- unsigned? --- or signed, as I assume? */
2716  /* For, surely p should be -1 if the DVI file has NO bop? */
2717  xfer_bop_address (dtl, dvi);
2718 
2719  /* num[4] */
2720  xfer_unsigned (4, dtl, dvi);
2721 
2722  /* den[4] */
2723  xfer_unsigned (4, dtl, dvi);
2724 
2725  /* mag[4] */
2726  xfer_unsigned (4, dtl, dvi);
2727 
2728  /* l[4] */
2729  xfer_unsigned (4, dtl, dvi);
2730 
2731  /* u[4] */
2732  xfer_unsigned (4, dtl, dvi);
2733 
2734  /* s[2] */
2735  xfer_unsigned (2, dtl, dvi);
2736 
2737  /* t[2] */
2738  xfer_unsigned (2, dtl, dvi);
2739 
2740  return (6*4 + 2*2);
2741 }
2742 /* postamble */
2743 
2744 
2745 int
2747 #ifdef STDC
2748  (FILE * dtl, FILE * dvi)
2749 #else
2750  (dtl, dvi)
2751  FILE * dtl;
2752  FILE * dvi;
2753 #endif
2754 /* read post_post from dtl, and write in dvi */
2755 /* return number of bytes written */
2756 {
2757  /* hope I'm writing the "223" bytes in an 8-bit clean way */
2758  int n223 = 0; /* number of "223" bytes in final padding */
2759 
2760  /* q[4] : DVI address of post command */
2761  /* --- unsigned? --- or signed, as I assume? */
2762  /* what happens if there is NO postamble command? */
2763  /* shouldn't q be -1 then? */
2764 
2765  xfer_postamble_address (dtl, dvi);
2766 
2767  /* i[1] : DVI identification byte = 2 */
2768  xfer_unsigned (1, dtl, dvi);
2769 
2770  for (n223 = 0; true; n223++)
2771  {
2772  COUNT nread = 0; /* number of DTL bytes read by read_token */
2773  static Token token;
2774 
2775  strcpy (token, "");
2776 
2777  nread = read_token (dtl, token);
2778 
2779  /* check whether end of dtl file */
2780  if (nread == 0)
2781  {
2782  if (group)
2783  {
2784  /* dtl file shouldn't end before an ECOM */
2786  fprintf (stderr, "(post_post) : DTL FILE ERROR (%s) : ",
2787  dtl_filename);
2788  fprintf (stderr, "premature end of DTL file!\n");
2789  fprintf (stderr,
2790  "%d complete iterations of \"padding byte\" loop;\n", n223);
2791  fprintf (stderr, "troublesome token = \"%s\"\n", token);
2792  dexit (1);
2793  }
2794  /* leave the "223" loop */
2795  break;
2796  }
2797  else if (strcmp (token, "223") == 0)
2798  {
2799  /* token is a "223" padding byte */
2800  /* loop again */
2801  }
2802  else
2803  {
2804  /* read a non-empty token that wasn't "223" */
2805  (Void) unread_char ();
2806  if (group)
2807  {
2808  if (strcmp (token, ECOM) == 0)
2809  {
2810  /* end of DTL's post_post command */
2811  }
2812  else
2813  {
2814  /* error : expected end of post_post */
2816  fprintf (stderr, "(post_post) : DTL FILE ERROR (%s) : ",
2817  dtl_filename);
2818  fprintf (stderr, "token \"%s\" should be ECOM (\"%s\")\n",
2819  token, ECOM);
2820  dexit (1);
2821  }
2822  }
2823  /* leave the "223" loop */
2824  break;
2825  }
2826  }
2827  /* end for */
2828 
2829  if (n223 < 4)
2830  {
2832  fprintf (stderr, "(post_post) : DTL FILE ERROR (%s) : \n",
2833  dtl_filename);
2834  fprintf (stderr, "fewer than four `223' padding bytes.\n");
2835  fprintf (stderr, "Will write at least four `223' padding bytes.\n");
2836  }
2837 
2838  /* check whether the DVI file size is a multiple of 4 bytes */
2839  if ((dvi_written + n223) % 4 != 0)
2840  {
2842  fprintf (stderr, "(post_post) : WARNING : \n");
2843  fprintf (stderr, "DVI size ");
2844  fprintf (stderr, WF, dvi_written);
2845  fprintf (stderr, " (bytes) wouldn't be a multiple of 4 !\n");
2846  fprintf (stderr,
2847  "Will write (at least four) `223' padding bytes until it is.\n");
2848  }
2849 
2850  /* final padding of DVI file by "223" bytes to a multiple of 4 bytes, */
2851  /* with at least 4 bytes */
2852 
2853  for (n223 = 0; (n223 < 4) || (dvi_written % 4 != 0); n223++)
2854  {
2855  /* add a "223" padding byte */
2856  put_byte (223, dvi);
2857  }
2858 
2859  return (4 + 1 + n223);
2860 }
2861 /* post_post */
2862 
2863 
2864 /* end of dt2dv.c */
int nk
Definition: afm2tfm.c:885
int code
Definition: aftopl.c:52
struct @88 table[500]
static int isknj2(int c)
Definition: allow5c.c:48
static int isknj(int c)
Definition: allow5c.c:29
#define escape
Definition: aptex-macros.h:341
#define count(a)
Definition: aptex-macros.h:781
void Line(double *)
Definition: axohelp.c:1395
void Void
Definition: cfuncs.h:8
#define n
Definition: t4ht.c:1290
#define nchar(x)
Definition: codegen.c:726
#define free(a)
Definition: decNumber.cpp:310
int dt2dv()
#define gfree(p)
Definition: dt2dv.c:326
int cons_cmds()
int init_Lstring()
int main(int argc, char *argv[])
Definition: dt2dv.c:339
#define CHAR_OK
Definition: dt2dv.c:1304
#define MAXTOKLEN
Definition: dt2dv.c:75
int check_emes()
FILE * dtl_fp
Definition: dt2dv.c:329
COUNT ncom
Definition: dt2dv.c:630
COUNT skip_space()
const char * dtl_filename
Definition: dt2dv.c:332
int fontdef()
op_info op_info_128_170[]
Definition: dt2dv.c:155
int rd_stdin
Definition: dt2dv.c:47
char Boolean
Definition: dt2dv.c:79
word_t last_bop_address
Definition: dt2dv.c:628
int dtl_stdin()
Definition: dt2dv.c:460
int dvi_stdout()
Definition: dt2dv.c:467
int de_init_Lstring()
int open_dvi()
COUNT com_read
Definition: dt2dv.c:631
#define MAXLINE
Definition: dt2dv.c:51
int nfile
Definition: dt2dv.c:320
int dexit()
U4 xfer_oct()
int no_op()
Definition: dt2dv.c:455
op_table fnt
Definition: dt2dv.c:217
int * gmalloc()
int postamble()
Definition: scanst.c:47
int dinfo()
Definition: dt2dv.c:867
word_t postamble_address
Definition: dt2dv.c:629
S4 xfer_postamble_address()
#define C_LEVEL
int parse()
S4 get_Lstring()
COUNT read_mes()
#define PRINT_PROGNAME
Definition: dt2dv.c:322
int open_dtl()
int set_seq()
S4 xfer_bop_address()
U4 xfer_unsigned()
int give_help()
Definition: dt2dv.c:433
int unread_char()
Definition: dt2dv.c:1432
#define CHAR_EOS
Definition: dt2dv.c:1306
#define LSIZE
Definition: dt2dv.c:2005
int put_table()
int put_unsigned()
U4 get_unsigned()
int read_string_char()
int wr_stdout
Definition: dt2dv.c:48
COUNT dvi_written
Definition: dt2dv.c:627
#define CHAR_FAIL
Definition: dt2dv.c:1305
Line dtl_line
Definition: dt2dv.c:65
int post_post()
COUNT read_token()
int put_Lstring()
#define NCMDS
Definition: dt2dv.c:127
int read_line_char()
Lstring * alloc_Lstring()
int put_signed()
U4 xfer_len_string()
char * CmdTable[256]
Definition: dt2dv.c:130
const char * dvi_filename
Definition: dt2dv.c:333
COUNT read_misc()
char linebuf[8192+1]
Definition: dt2dv.c:63
int get_line()
Definition: cwebboot.c:807
Options opts[]
Definition: dt2dv.c:309
int ls_putb()
int free_Lstring()
int xfer_args()
int find_command()
U4 xfer_hex()
int mem_viol()
int read_char()
op_table op_128_170
Definition: dt2dv.c:204
const char * progname
Definition: dt2dv.c:319
int free_cmds()
CmdTable cmd_table
Definition: dt2dv.c:133
int check_byte()
int process()
int put_byte()
COUNT read_variety()
op_info fnt_n[]
Definition: dt2dv.c:208
S4 get_signed()
unsigned char Byte
Definition: dt2dv.c:78
U4 special()
CmdPrefix cmd_prefixes[]
Definition: dt2dv.c:97
U4 preamble()
Definition: scanst.c:46
int check_bmes()
S4 xfer_signed()
FILE * dvi_fp
Definition: dt2dv.c:330
COUNT dtl_read
Definition: dt2dv.c:626
int group
Definition: dtl.h:84
#define POP
Definition: dtl.h:135
#define Y0
Definition: dtl.h:159
#define PUT2
Definition: dtl.h:127
#define X4
Definition: dtl.h:152
#define BMES_CHAR
Definition: dtl.h:100
#define FONTDEF
Definition: dtl.h:175
#define DOWN4
Definition: dtl.h:157
#define BSEQ_CHAR
Definition: dtl.h:108
#define X1
Definition: dtl.h:149
#define BCOM_CHAR
Definition: dtl.h:92
long int word_t
Definition: dtl.h:68
#define ESEQ_CHAR
Definition: dtl.h:109
#define RIGHT4
Definition: dtl.h:140
#define WF
Definition: dtl.h:70
#define FONTNUM
Definition: dtl.h:176
#define Y1
Definition: dtl.h:160
#define EMES_CHAR
Definition: dtl.h:101
#define FONT3
Definition: dtl.h:173
#define PUT
Definition: dtl.h:125
#define Y2
Definition: dtl.h:161
#define Z2
Definition: dtl.h:167
#define W3
Definition: dtl.h:145
#define BCOM
Definition: dtl.h:89
#define DOWN
Definition: dtl.h:153
#define PUSH
Definition: dtl.h:134
#define Z1
Definition: dtl.h:166
#define Z0
Definition: dtl.h:165
#define DOWN3
Definition: dtl.h:156
#define Z3
Definition: dtl.h:168
#define RIGHT2
Definition: dtl.h:138
#define Y4
Definition: dtl.h:163
#define W0
Definition: dtl.h:142
#define W
Definition: dtl.h:141
#define Y3
Definition: dtl.h:162
#define SET3
Definition: dtl.h:122
#define PUT3
Definition: dtl.h:128
#define EOP
Definition: dtl.h:133
#define X2
Definition: dtl.h:150
#define RIGHT1
Definition: dtl.h:137
#define OF4
Definition: dtl.h:61
#define VOID
Definition: dtl.h:47
#define X0
Definition: dtl.h:148
#define SPECIAL
Definition: dtl.h:177
#define BOP
Definition: dtl.h:132
#define ECOM
Definition: dtl.h:90
#define PUTRULE
Definition: dtl.h:130
#define FONT2
Definition: dtl.h:172
unsigned long U4
Definition: dtl.h:53
#define SET4
Definition: dtl.h:123
#define ESC_CHAR
Definition: dtl.h:113
#define ECOM_CHAR
Definition: dtl.h:93
#define SET1
Definition: dtl.h:120
#define RIGHT3
Definition: dtl.h:139
#define FONT4
Definition: dtl.h:174
#define XF4
Definition: dtl.h:59
#define DOWN2
Definition: dtl.h:155
#define PUT4
Definition: dtl.h:129
#define MAXSTRLEN
Definition: dtl.h:74
#define W1
Definition: dtl.h:143
U4 COUNT
Definition: dtl.h:65
#define OPCODE
Definition: dtl.h:181
#define W2
Definition: dtl.h:144
#define PUT1
Definition: dtl.h:126
#define W4
Definition: dtl.h:146
#define DOWN1
Definition: dtl.h:154
#define VARIETY
Definition: dtl.h:19
long S4
Definition: dtl.h:52
#define SET2
Definition: dtl.h:121
#define X3
Definition: dtl.h:151
#define FONT
Definition: dtl.h:170
#define FONT1
Definition: dtl.h:171
#define Z4
Definition: dtl.h:169
#define SF4
Definition: dtl.h:55
#define UF4
Definition: dtl.h:56
struct op_table_st op_table
Definition: dv2dt.c:61
struct op_info_st op_info
Definition: dv2dt.c:50
int command
Definition: t4ht.c:934
#define fopen
Definition: xxstdio.h:21
#define fgets
Definition: xxstdio.h:29
#define SET_BINARY(fd)
Definition: dvips.h:109
char * strncpy()
int strcmp()
Definition: coll.cpp:143
int sscanf()
char * strcpy()
FILE * dvi_file
Definition: dviinfo.c:67
struct dvi_data * dvi
#define WIN32
Definition: ft_conf.h:24
#define a2
#define s
Definition: afcover.h:80
@ VERSION
Definition: genrb.cpp:69
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
#define PRE
Definition: hbf2gf.c:42
#define POSTPOST
Definition: hbf2gf.c:65
#define POST
Definition: hbf2gf.c:60
#define slen
Definition: hpcdtoppm.c:1329
#define byte
Definition: in_pcx.cpp:28
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
sizeof(AF_ModuleRec)
#define SET(n)
Definition: md5.c:86
unsigned char Byte
Definition: ftzconf.h:219
void exit()
#define EOF
Definition: afmparse.c:59
#define PACKAGE_BUGREPORT
Definition: config.h:93
#define TL_VERSION
Definition: config.h:131
int argtype
Definition: cff_dict.c:116
#define debug
Definition: pdfparse.c:41
#define kpse_program_name
Definition: types.h:322
#define fileno
Definition: win32lib.h:72
#define isatty
Definition: win32lib.h:80
#define fprintf
Definition: mendex.h:64
#define prefix
Definition: cwebboot.c:154
Code related to b fwrite(a, sizeof(char), b, stdout) @d C_printf(c
#define malloc
Definition: alloca.c:91
int strncmp()
#define sprintf
Definition: snprintf.c:44
unsigned char byte
Definition: tif_acorn.c:69
#define NOP
Definition: tif_getimage.c:684
const int * pos
Definition: combiners.h:905
int k
Definition: otp-parser.c:70
#define ARGS(alist)
Definition: pbmplus.h:235
#define max(a, b)
Definition: pbmto4425.c:11
int Boolean
Definition: pgmcrater.c:64
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF lsl PF lsl PF endif SIZE macro preload_middle scratch_holds_offset if bpp else PF PF endif endif endif endm macro preload_trailing base if bpp if bpp *pix_per_block PF PF lsl PF PF PF PF PF else PF lsl PF lsl PF PF PF PF PF base if bpp if narrow_case &&bpp<=dst_w_bpp) PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, LSL #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 90f PF pld,[WK1]90:.else PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, lsl #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 92f91:PF add, WK0, WK0, #32 PF cmp, WK0, WK1 PF pld,[WK0] PF bne, 91b92:.endif .endif.endm.macro conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx process_head cond, numbytes, firstreg, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond X, X, #8 *numbytes/dst_w_bpp .endif process_tail cond, numbytes, firstreg .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst cond, numbytes, firstreg, DST .endif.endm.macro conditional_process1 cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_BRANCH_OVER .ifc cond, mi bpl 100f .endif .ifc cond, cs bcc 100f .endif .ifc cond, ne beq 100f .endif conditional_process1_helper, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx100:.else conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .endif.endm.macro conditional_process2 test, cond1, cond2, process_head, process_tail, numbytes1, numbytes2, firstreg1, firstreg2, unaligned_src, unaligned_mask, decrementx .if(flags) &(FLAG_DST_READWRITE|FLAG_BRANCH_OVER|FLAG_PROCESS_CORRUPTS_PSR|FLAG_PROCESS_DOES_STORE) test conditional_process1 cond1, process_head, process_tail, numbytes1, firstreg1, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_PROCESS_CORRUPTS_PSR test .endif conditional_process1 cond2, process_head, process_tail, numbytes2, firstreg2, unaligned_src, unaligned_mask, decrementx .else test process_head cond1, numbytes1, firstreg1, unaligned_src, unaligned_mask, 0 process_head cond2, numbytes2, firstreg2, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond1 X, X, #8 *numbytes1/dst_w_bpp sub &cond2 X, X, #8 *numbytes2/dst_w_bpp .endif process_tail cond1, numbytes1, firstreg1 process_tail cond2, numbytes2, firstreg2 pixst cond1, numbytes1, firstreg1, DST pixst cond2, numbytes2, firstreg2, DST .endif.endm.macro test_bits_1_0_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-1 .else movs SCRATCH, WK0, lsl #32-1 .endif.endm.macro test_bits_3_2_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-3 .else movs SCRATCH, WK0, lsl #32-3 .endif.endm.macro leading_15bytes process_head, process_tail .set DECREMENT_X, 1 .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 .set DECREMENT_X, 0 sub X, X, WK0, lsr #dst_bpp_shift str X,[sp, #LINE_SAVED_REG_COUNT *4] mov X, WK0 .endif .if dst_w_bpp==8 conditional_process2 test_bits_1_0_ptr, mi, cs, process_head, process_tail, 1, 2, 1, 2, 1, 1, DECREMENT_X .elseif dst_w_bpp==16 test_bits_1_0_ptr conditional_process1 cs, process_head, process_tail, 2, 2, 1, 1, DECREMENT_X .endif conditional_process2 test_bits_3_2_ptr, mi, cs, process_head, process_tail, 4, 8, 1, 2, 1, 1, DECREMENT_X .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 ldr X,[sp, #LINE_SAVED_REG_COUNT *4] .endif.endm.macro test_bits_3_2_pix movs SCRATCH, X, lsl #dst_bpp_shift+32-3.endm.macro test_bits_1_0_pix .if dst_w_bpp==8 movs SCRATCH, X, lsl #dst_bpp_shift+32-1 .else movs SCRATCH, X, lsr #1 .endif.endm.macro trailing_15bytes process_head, process_tail, unaligned_src, unaligned_mask conditional_process2 test_bits_3_2_pix, cs, mi, process_head, process_tail, 8, 4, 0, 2, unaligned_src, unaligned_mask, 0 .if dst_w_bpp==16 test_bits_1_0_pix conditional_process1 cs, process_head, process_tail, 2, 0, unaligned_src, unaligned_mask, 0 .elseif dst_w_bpp==8 conditional_process2 test_bits_1_0_pix, cs, mi, process_head, process_tail, 2, 1, 0, 1, unaligned_src, unaligned_mask, 0 .endif.endm.macro wide_case_inner_loop process_head, process_tail, unaligned_src, unaligned_mask, dst_alignment110:.set SUBBLOCK, 0 .rept pix_per_block *dst_w_bpp/128 process_head, 16, 0, unaligned_src, unaligned_mask, 1 .if(src_bpp > 0) &&(mask_bpp==0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle src_bpp, SRC, 1 .elseif(src_bpp==0) &&(mask_bpp > 0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle mask_bpp, MASK, 1 .else preload_middle src_bpp, SRC, 0 preload_middle mask_bpp, MASK, 0 .endif .if(dst_r_bpp > 0) &&((SUBBLOCK % 2)==0) &&(((flags) &FLAG_NO_PRELOAD_DST)==0) PF pld,[DST, #32 *prefetch_distance - dst_alignment] .endif process_tail, 16, 0 .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst, 16, 0, DST .endif .set SUBBLOCK, SUBBLOCK+1 .endr subs X, X, #pix_per_block bhs 110b.endm.macro wide_case_inner_loop_and_trailing_pixels process_head, process_tail, process_inner_loop, exit_label, unaligned_src, unaligned_mask .if dst_r_bpp > tst bne process_inner_loop DST_PRELOAD_BIAS endif preload_trailing SRC preload_trailing MASK DST endif add medium_case_inner_loop_and_trailing_pixels unaligned_mask endm macro medium_case_inner_loop_and_trailing_pixels DST endif subs bhs tst beq exit_label trailing_15bytes unaligned_mask endm macro narrow_case_inner_loop_and_trailing_pixels unaligned_mask tst conditional_process1 trailing_15bytes unaligned_mask endm macro switch_on_alignment exit_label if bne endif if bne endif action if endif if bne endif action if endif endif endm macro end_of_line last_one if vars_spilled word LINE_SAVED_REGS endif subs Y
#define fp
#define k1
const char * suffix
Definition: pkg_icu.cpp:27
const char * desc
Definition: pkgdata.cpp:136
@ SETCHAR
Definition: pl-parser.h:85
@ SETRULE
Definition: pl-parser.h:86
@ RIGHT
Definition: pl-parser.h:49
unsigned char ubyte
Definition: ppmdither.c:23
#define X
Definition: ppmforge.c:73
#define Z
Definition: ppmforge.c:75
static int size
Definition: ppmlabel.c:24
char line[1024]
Definition: process_score.c:29
#define status
#define isspace(ch)
Definition: utype.h:87
static int snum[8]
Definition: renumout.c:145
#define str(s)
Definition: sh6.c:399
token
Definition: strexpr.c:17
Boolean has_suffix
Definition: dt2dv.c:93
const char * name
Definition: dt2dv.c:92
Byte first_code
Definition: dt2dv.c:91
Byte first_suffix
Definition: dt2dv.c:94
Definition: dt2dv.c:55
char * buf
Definition: dt2dv.c:60
COUNT num
Definition: dt2dv.c:56
size_t max
Definition: dt2dv.c:57
S4 wrote
Definition: dt2dv.c:58
size_t read
Definition: dt2dv.c:59
Definition: dtl.h:78
int l
Definition: dtl.h:78
int m
Definition: dtl.h:78
char * s
Definition: dtl.h:78
Definition: dt2dv.c:302
const char * keyword
Definition: dt2dv.c:303
const char * desc
Definition: dt2dv.c:305
int * p_var
Definition: dt2dv.c:304
A string of characters.
Definition: t1part.c:49
Definition: llex.h:50
Definition: usprintf.c:39
Definition: inftrees.h:24
Definition: sd.h:82
Definition: bdf.c:133
Definition: dt2dv.c:137
const char * args
Definition: dt2dv.c:141
int nargs
Definition: dt2dv.c:140
const char * name
Definition: dt2dv.c:139
int code
Definition: dt2dv.c:138
int first
Definition: dt2dv.c:148
op_info * list
Definition: dt2dv.c:150
const char * name
Definition: dt2dv.c:147
int last
Definition: dt2dv.c:149
Definition: sh.h:1226
char ** args
Definition: sh.h:1228
const XML_Char * name
Definition: xmlparse.c:153
Definition: table.h:30
Definition: parser.c:43
def_key keyword[6]
Definition: t1part.c:256
#define FILE
Definition: t1stdio.h:34
#define feof(f)
Definition: t1stdio.h:109
ch
Definition: t4ht.c:1443
int j
Definition: t4ht.c:1589
void signal(SIGFPE, sig_err)
*job_name strlen((char *) job_name) - 4)
found
Definition: tex4ht.c:5000
op
Definition: tex4ht.c:3129
struct line_status line_status
#define argv
Definition: xmain.c:270
#define argc
Definition: xmain.c:269