Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Macros | Functions | Variables
dvirle1.c File Reference
#include "rle_config.h"
#include <stdio.h>
#include "types.h"
#include "conv.h"
#include "dviclass.h"
#include "dvicodes.h"
#include "error.h"
#include "fio.h"
#include "font.h"
#include "gripes.h"
#include "dvistate.h"
#include "dvirle.h"
Include dependency graph for dvirle1.c:

Go to the source code of this file.

Macros

#define InitialChars   4000 /* initial number of chars to allocate */
 
#define ABS(n)   ((n) >= 0 ? (n) : -(n))
 
#define maxysize   min(MaxCharHeight, 255)
 
#define CHECK(cond, msg, flag)
 

Functions

void ComputeCWidths (struct font *f)
 
void ExpandArrays ()
 
void SortPage ()
 
struct font * DefineFont (char *name, i32 dvimag, i32 dvidsz)
 
void BeginPage (i32 *count)
 
void EndPage ()
 
void DoSpecial (i32 len)
 
void SetRule (int h, int w)
 
int CheckChar (i32 c)
 
int PageLoop ()
 
void main (int argc, char **argv)
 

Variables

static char rcsid [] = "$Id: dvirle1.c,v 3.0.1.3 1992/02/28 22:12:53 spencer Exp $"
 
char * ProgName
 
char * optarg
 
int optind
 
char serrbuf [ 8192 ]
 
const char * DVIFileName
 
const char * TeXFontDesc
 
int Chars
 
int MaxChars
 
intyx
 
intfcp
 
intnextyx
 
intnextfcp
 
int TopEMsg
 
int BottomEMsg
 
int LeftEMsg
 
int RightEMsg
 
int RuleEMsg
 
int CFlag
 
int HFlag
 
int SFlag
 
int Debug
 
int BottomMargin
 
int TopMargin
 
int WidestPageWidth
 
int TallestPageHeight
 
int PageWidth
 
int PageHeight
 

Macro Definition Documentation

#define ABS (   n)    ((n) >= 0 ? (n) : -(n))

Definition at line 89 of file dvirle1.c.

#define CHECK (   cond,
  msg,
  flag 
)
Value:
if (cond) { \
if (!flag) { \
error(0, 0, warn, msg); \
flag = 1; \
} \
goto ignore; \
}
static void error(int)
Definition: aliastorle.c:559
if(tfd)
Definition: getami.c:852
#define InitialChars   4000 /* initial number of chars to allocate */

Definition at line 62 of file dvirle1.c.

#define maxysize   min(MaxCharHeight, 255)

Definition at line 320 of file dvirle1.c.

Function Documentation

void BeginPage ( i32 *  count)

Definition at line 221 of file dvirle1.c.

223 {
224 
225  if (!SFlag) {
226  if (nextyx)
227  (void) putc(' ', stderr);
228  (void) fprintf(stderr, "[%d", (int)count[0]);
229  (void) fflush(stderr);
230  }
231 
232  /* Chars now becomes "number of characters left" */
233  Chars = MaxChars; /* empty the arrays */
234  nextyx = yx;
235  nextfcp = fcp;
236 
237  TopEMsg = 0;
238  BottomEMsg = 0;
239  LeftEMsg = 0;
240  RightEMsg = 0;
241  RuleEMsg = 0;
242 }
int RuleEMsg
Definition: dvirle1.c:73
int RightEMsg
Definition: dvirle1.c:72
int BottomEMsg
Definition: dvirle1.c:70
int * nextyx
Definition: dvirle1.c:53
int LeftEMsg
Definition: dvirle1.c:71
int SFlag
Definition: dvirle1.c:77
int Chars
Definition: dvirle1.c:49
int MaxChars
Definition: dvirle1.c:50
int * fcp
Definition: dvirle1.c:52
int * nextfcp
Definition: dvirle1.c:54
int TopEMsg
Definition: dvirle1.c:69
int * yx
Definition: dvirle1.c:51
int CheckChar ( i32  c)

Definition at line 386 of file dvirle1.c.

388 {
389  /* this driver needs work for codes > 127 */
390 
391  if ((ui32)c > 127) {
392  error(0, 0, "Warning: character code %ld too big",
393  (long)c);
394  return (1);
395  }
396  return (0);
397 }
static void error(int)
Definition: aliastorle.c:559
void ComputeCWidths ( struct font *  f)

Definition at line 96 of file dvirle1.c.

98 {
99  register struct glyph *g;
100  register int i;
101 
102  for (i = 0; i < 128; i++) {
103  g = GLYPH(f, i);
104  if (GVALID(g))
105  g->g_pixwidth = fromSP(g->g_tfmwidth);
106  }
107 }
static unsigned char g
Definition: getami.c:692
int i
Definition: rletorla.c:82
struct font* DefineFont ( char *  name,
i32  dvimag,
i32  dvidsz 
)

Definition at line 173 of file dvirle1.c.

176 {
177  register struct font *f;
178  char *path;
179  int len;
180  static int next; /* dvirle2 knows that we use sequential indicies */
181 
182  if (next >= NFONTS) /* fix this later */
183  error(1, 0, "too many fonts (%d) used", next);
184 
185  f = GetRasterlessFont(name, dvimag, dvidsz, "versatec", &path);
186  if (f == NULL) {
187  GripeCannotGetFont(name, dvimag, dvidsz, "versatec", path);
188  return (NULL);
189  }
190  if (Debug) {
191  (void) fprintf(stderr, "[%s -> %s]\n", Font_TeXName(f), path);
192  (void) fflush(stderr);
193  }
194  if (next == 0) {
195  /*
196  * dvirle2 also needs the conversion factor,
197  * before the first font.
198  */
199  PutLong(stdout, 300); /* dots per inch */
200  PutLong(stdout, ds.ds_usermag);
201  PutLong(stdout, ds.ds_num);
202  PutLong(stdout, ds.ds_denom);
203  PutLong(stdout, ds.ds_dvimag);
204  }
205  putbyte(stdout, 1); /* signal another font */
206  PutLong(stdout, f->f_checksum);
207  PutLong(stdout, dvimag);
208  PutLong(stdout, dvidsz);
209  len = strlen(name);
210  PutLong(stdout, len);
211  (void) fputs(name, stdout);
212  ComputeCWidths(f);
213  f->f_un.f_int = next++;
214  return (f);
215 }
void ComputeCWidths(struct font *f)
Definition: dvirle1.c:96
int Debug
Definition: dvirle1.c:78
static void error(int)
Definition: aliastorle.c:559
#define NFONTS
Definition: dvirle.h:28
void DoSpecial ( i32  len)

Definition at line 310 of file dvirle1.c.

312 {
313 
314  error(0, 0, "warning: ignoring \\special");
315  (void) fseek(ds.ds_fp, (long) len, 1);
316 }
static void error(int)
Definition: aliastorle.c:559
void EndPage ( )

Definition at line 248 of file dvirle1.c.

References Chars, Debug, fcp, HFlag, MaxChars, PageHeight, PageWidth, SFlag, and yx.

249 {
250  register int i, *y, *f, t, v, oldv;
251 
252  /* Chars now becomes "number of characters on page" */
253  i = Chars = MaxChars - Chars;
254 
255  SortPage();
256 
257  if (!SFlag) {
258  putc(']', stderr);
259  (void) fflush(stderr);
260  }
261  y = yx;
262  f = fcp;
263  if ( HFlag )
264  oldv = PageWidth;
265  else
266  oldv = PageHeight;
267  while (--i >= 0) {
268  if ( Debug > 1 )
269  fprintf( stderr, "oldv: %ld, yx: %lx (%d,%d), fcp: %lx\n",
270  oldv, *y, (*y >> 16), (*y & 0xffff), *f );
271  v = *y >> 16;
272  t = oldv - v;
273  if (*f >= 0) { /* setting a character */
274  t = (t << 16) | (*y++ & 0xffff);
275  PutLong(stdout, t);
276  t = *f++;
277  PutLong(stdout, t); /* move down & place char */
278  } else { /* setting a rule */
279  y++;
280  if (t > 0) { /* need to move down first */
281  t = -t;
282  PutLong(stdout, -1);
283  PutLong(stdout, t);
284  }
285  t = *f++ & 0x7fffffff;
286  PutLong(stdout, -1);
287  PutLong(stdout, t); /* place rule */
288  }
289  oldv = v;
290  }
291 
292  /* Make all pages the same length */
293  if (HFlag)
294  t = -PageWidth;
295  else
296  t = -PageHeight;
297  if (t) {
298  PutLong(stdout, -1); /* move down */
299  PutLong(stdout, t);
300  }
301  PutLong(stdout, -1);
302  PutLong(stdout, 0); /* end of page */
303 }
int SFlag
Definition: dvirle1.c:77
int PageWidth
Definition: dvirle1.c:84
int Debug
Definition: dvirle1.c:78
static int y
Definition: getami.c:691
int Chars
Definition: dvirle1.c:49
int MaxChars
Definition: dvirle1.c:50
int * fcp
Definition: dvirle1.c:52
int HFlag
Definition: dvirle1.c:76
void SortPage()
Definition: dvirle1.c:134
int i
Definition: rletorla.c:82
int PageHeight
Definition: dvirle1.c:85
int * yx
Definition: dvirle1.c:51
void ExpandArrays ( )

Definition at line 113 of file dvirle1.c.

References Chars, fcp, MaxChars, nextfcp, nextyx, and yx.

114 {
115  register unsigned newsize;
116 
117  MaxChars <<= 1;
118  newsize = MaxChars * sizeof *yx;
119  if ((yx = (int *) realloc((char *) yx, newsize)) == NULL)
120  GripeOutOfMemory(newsize, "yx array");
121  if ((fcp = (int *) realloc((char *) fcp, newsize)) == NULL)
122  GripeOutOfMemory(newsize, "fcp array");
123  Chars = MaxChars >> 1;
124  nextyx = &yx[Chars];
125  nextfcp = &fcp[Chars];
126  --Chars; /* we're about to use one */
127 }
int * nextyx
Definition: dvirle1.c:53
int Chars
Definition: dvirle1.c:49
int MaxChars
Definition: dvirle1.c:50
int * fcp
Definition: dvirle1.c:52
int * nextfcp
Definition: dvirle1.c:54
int * yx
Definition: dvirle1.c:51
void main ( int  argc,
char **  argv 
)

Definition at line 684 of file dvirle1.c.

687 {
688  register int c;
689  register CONST_DECL char *s;
690  int lmargin;
691  FILE *fp = stdin;
692 
693  setbuf(stderr, serrbuf);
694 
695  ProgName = *argv;
696  ds.ds_usermag = 1000;
697  ds.ds_maxdrift = DefaultMaxDrift;
698  DVIFileName = "`stdin'";
699 
700  while ((c = getopt(argc, argv, "cd:hm:sD")) != EOF) {
701  switch (c) {
702 
703  case 'c':
704  CFlag++;/* centered output */
705  break;
706 
707  case 'd': /* max drift value */
708  ds.ds_maxdrift = atoi(optarg);
709  break;
710 
711  case 'h': /* horizontal output */
712  HFlag++;
713  break;
714 
715  case 'm': /* magnification */
716  ds.ds_usermag = atoi(optarg);
717  break;
718 
719  case 's': /* silent */
720  SFlag++;
721  break;
722 
723  case 'D':
724  Debug++;
725  break;
726 
727  case '?':
728  (void) fprintf(stderr, "\
729 Usage: %s [-c] [-h] [-m mag] [-s] [file]\n", ProgName);
730  (void) fflush(stderr);
731  exit(1);
732  }
733  }
734 
735  if (optind < argc)
736  if ((fp = fopen(DVIFileName = argv[optind], "r")) == NULL)
737  error(1, -1, "can't open %s", argv[optind]);
738 
739 #ifdef notdef
740  if (MakeSeekable(stdin))
741  error(1, 0,
742  "unable to copy input to temp file (see the manual)");
743 #endif
744 
745  if ((TeXFontDesc = getenv(CONFENV)) == NULL)
746  TeXFontDesc = "";
747 
748  c = (VERSION << 1) + (HFlag ? 1 : 0);
749  putbyte(stdout, c);
750  c = strlen(s = TeXFontDesc);
751  PutLong(stdout, c);
752  while (--c >= 0)
753  putbyte(stdout, *s++);
754 
755  /* the margin offsets here are 0; margins computed later */
756  DVISetState(fp, DefineFont, 300, 0, 0);
757  putbyte(stdout, 0); /* Signal end of fonts. */
758  TallestPageHeight = fromSP(ds.ds_maxheight);
759  WidestPageWidth = fromSP(ds.ds_maxwidth);
760 
761  /*
762  * The character plotter must check each character to ensure it
763  * is on the page, because the widest and tallest page values from
764  * the DVI file are not always accurate; so these tests do little
765  * save to keep one from finding the offending object. Accordingly,
766  * I have disabled them. 20 May 1984 ACT.
767  */
768 #ifdef notdef
769  if (HFlag) {
771  error(1, 0, "text object too high!");
773  error(1, 0, "text object too wide!");
774  } else { /* page height can be safely ignored */
776  error(1, 0, "text object too wide!");
777  }
778 #endif
779 
780  /* Determine margins */
781  if (CFlag) {
782  lmargin = (MaxPageWidth - WidestPageWidth) >> 1;
783  if (lmargin < MinimumLeftMargin) {
784  lmargin = MinimumLeftMargin;
785  error(0, 0, "\
786 cannot center (page too wide); placing flush left instead");
787  }
788  } else
790 
791  if (HFlag) {
793  if (TopMargin < 0)
794  TopMargin = 0;
796  if (BottomMargin < 0)
797  BottomMargin = 0;
798  } else {
801  }
802 
804  PageWidth = WidestPageWidth + BottomMargin + TopMargin;
805  if ( HFlag )
806  {
807  if ( PageHeight > MaxPageWidth )
808  {
809  fprintf( stderr,
810  "Page too high (%d bits), truncated to %d bits\n",
813  }
814  PutLong(stdout, PageWidth);
815  PutLong(stdout, PageHeight);
816  }
817  else
818  {
819  if ( PageWidth > MaxPageWidth )
820  {
821  fprintf( stderr,
822  "Page too wide (%d bits), truncated to %d bits\n",
825  }
826  PutLong(stdout, PageHeight);
827  PutLong(stdout, PageWidth);
828  }
829 
830  /* set the `fresh page' margins */
831  ds.ds_fresh.hh = lmargin;
832  ds.ds_fresh.vv = TopMargin;
833  ds.ds_fresh.h = toSP(ds.ds_fresh.hh);
834  ds.ds_fresh.v = toSP(ds.ds_fresh.vv);
835 
836  /* Allocate arrays */
838  if ((yx = (int *) malloc(InitialChars * sizeof *yx)) == NULL)
839  GripeOutOfMemory(InitialChars * sizeof *yx, "yx array");
840  if ((fcp = (int *) malloc(InitialChars * sizeof *fcp)) == NULL)
841  GripeOutOfMemory(InitialChars * sizeof *fcp, "fcp array");
842 
843  while (PageLoop())
844  /* void */;
845 
846  exit(0);
847  /* NOTREACHED */
848 }
#define InitialChars
Definition: dvirle1.c:62
char * ProgName
Definition: dvirle1.c:37
int getopt(int argc, argv, char *optstring)
Definition: getopt.c:37
#define MaxPageHeight
Definition: dvirle.h:39
_urt_stack * s
Definition: rleClock.c:919
int SFlag
Definition: dvirle1.c:77
int PageWidth
Definition: dvirle1.c:84
const char * DVIFileName
Definition: dvirle1.c:44
int Debug
Definition: dvirle1.c:78
int BottomMargin
Definition: dvirle1.c:80
#define DefaultMaxDrift
Definition: dvirle.h:42
char serrbuf[ 8192 ]
Definition: dvirle1.c:42
int MaxChars
Definition: dvirle1.c:50
int PageLoop()
Definition: dvirle1.c:404
#define DefaultBottomMargin
Definition: dvirle.h:48
#define MinimumLeftMargin
Definition: dvirle.h:45
int * fcp
Definition: dvirle1.c:52
#define DefaultLeftMargin
Definition: dvirle.h:44
#define CONST_DECL
Definition: rle_config.h:42
int HFlag
Definition: dvirle1.c:76
#define MinimumTopMargin
Definition: dvirle.h:47
int TallestPageHeight
Definition: dvirle1.c:83
static void error(int)
Definition: aliastorle.c:559
#define VERSION
Definition: dvirle.h:26
int optind
Definition: getopt.c:30
char * optarg
Definition: getopt.c:29
FILE * fp
Definition: pgmtorle.c:49
void * malloc()
int PageHeight
Definition: dvirle1.c:85
int CFlag
Definition: dvirle1.c:75
const char * TeXFontDesc
Definition: dvirle1.c:46
int TopMargin
Definition: dvirle1.c:81
struct font * DefineFont(char *name, i32 dvimag, i32 dvidsz)
Definition: dvirle1.c:173
int * yx
Definition: dvirle1.c:51
#define DefaultTopMargin
Definition: dvirle.h:46
int WidestPageWidth
Definition: dvirle1.c:82
#define MaxPageWidth
Definition: dvirle.h:40
int PageLoop ( )

Definition at line 404 of file dvirle1.c.

References BottomEMsg, Chars, HFlag, LeftEMsg, nextyx, and TopEMsg.

405 {
406  static struct font NoFont; /* font with zero pspace, etc */
407  register int c;
408  register i32 p = 0;
409  register struct font *f = &NoFont;
410  register FILE *fp = ds.ds_fp;
411  int doingpage = 0, advance;
412 
413  static char warn[] = "\
414 WARNING: text object(s) run off %s of page; ignored";
415 #define CHECK(cond, msg, flag) \
416  if (cond) { \
417  if (!flag) { \
418  error(0, 0, warn, msg); \
419  flag = 1; \
420  } \
421  goto ignore; \
422  }
423 
424  /*
425  * This would be a `for (;;)', but that makes the function
426  * crawl off the right of the screen.
427  *
428  * We handle ordinary characters early, as they are the
429  * most common opcodes in DVI files, and doing so makes the
430  * loop run faster.
431  */
432 loop:
433  c = fgetbyte(fp);
434  if (DVI_IsChar(c)) {
435  register struct glyph *g;
436  register int ulcx, ulcy, height;
437 
438  p = c;
439  advance = 1;
440 do_char:
441  g = GLYPH(f, p);
442  if (!GVALID(g)) {
443  GripeBadGlyph(p, f);
444  goto loop;
445  }
446  if (!HFlag) {
447  ulcy = dvi_vv + g->g_height - g->g_yorigin;
448  ulcx = dvi_hh - g->g_xorigin;
449  height = g->g_height;
450  CHECK(ulcy < 0, "top", TopEMsg);
451  CHECK(ulcx < 0, "left", LeftEMsg);
452  CHECK(ulcx + g->g_width >= MaxPageWidth,
453  "right", RightEMsg);
454  } else {/* rotate & translate */
455  ulcy = dvi_hh + g->g_width - g->g_xorigin;
456  ulcx = MaxPageWidth -
457  (dvi_vv + g->g_height - g->g_yorigin);
458  height = g->g_width;
459  CHECK(ulcy < 0, "left", LeftEMsg);
460 #ifdef notdef
461  CHECK(ulcy + height >= MaxPageHeight,
462  "right", RightEMsg);
463 #endif
464  CHECK(ulcx < 0, "bottom", BottomEMsg);
465  CHECK(ulcx + g->g_height >= MaxPageWidth,
466  "top", TopEMsg);
467  }
468  for (c = 0; height > 0; c++) {
469  if (--Chars < 0)
470  ExpandArrays();
471  *nextyx++ = (ulcy << 16) | ulcx;
472  *nextfcp++ = (f->f_un.f_int << FONTSHIFT) |
473  ((p & CHARMASK) << CHARSHIFT) | c;
474  height -= MaxCharHeight;
475  ulcy += MaxCharHeight;
476  }
477 ignore:
478  if (advance) {
479  dvi_h += g->g_tfmwidth;
480  dvi_hh += g->g_pixwidth;
481  p = fromSP(dvi_h);
482  FIXDRIFT(dvi_hh, p);
483  }
484  goto loop;
485  }
486 
487  if (c == EOF) /* unexpected end of DVI file */
488  GripeUnexpectedDVIEOF();
489 
490  /*
491  * Gather up a parameter, if known.
492  */
493  switch (DVI_OpLen(c)) {
494 
495  case DPL_NONE:
496  break;
497 
498  case DPL_SGN1:
499  p = fgetbyte(fp);
500  p = Sign8(p);
501  break;
502 
503  case DPL_SGN2:
504  fGetWord(fp, p);
505  p = Sign16(p);
506  break;
507 
508  case DPL_SGN3:
509  fGet3Byte(fp, p);
510  p = Sign24(p);
511  break;
512 
513  case DPL_SGN4:
514  fGetLong(fp, p);
515  break;
516 
517  case DPL_UNS1:
518  p = fgetbyte(fp);
519  p = UnSign8(p);
520  break;
521 
522  case DPL_UNS2:
523  fGetWord(fp, p);
524  p = UnSign16(p);
525  break;
526 
527  case DPL_UNS3:
528  fGet3Byte(fp, p);
529  p = UnSign24(p);
530  break;
531 
532  default:
533  panic("DVI_OpLen(%d) = %d", c, DVI_OpLen(c));
534  /* NOTREACHED */
535  }
536 
537  /*
538  * Now switch on the type.
539  */
540  switch (DVI_DT(c)) {
541 
542  case DT_SET:
543  advance = 1;
544  if (CheckChar(p))
545  goto loop;
546  goto do_char;
547 
548  case DT_PUT:
549  advance = 0;
550  if (CheckChar(p))
551  goto loop;
552  goto do_char;
553 
554  case DT_SETRULE:
555  DVIRule(SetRule, 1);
556  goto loop;
557 
558  case DT_PUTRULE:
559  DVIRule(SetRule, 0);
560  goto loop;
561 
562  case DT_NOP:
563  goto loop;
564 
565  case DT_BOP:
566  if (doingpage)
567  GripeUnexpectedOp("BOP (already in page)");
568  DVIBeginPage(BeginPage);
569  doingpage = 1;
570  goto loop;
571 
572  case DT_EOP:
573  if (!doingpage)
574  GripeUnexpectedOp("EOP (no BOP)");
575  EndPage();
576  return (1);
577 
578  case DT_PUSH:
579  *ds.ds_sp++ = ds.ds_cur;
580  goto loop;
581 
582  case DT_POP:
583  ds.ds_cur = *--ds.ds_sp;
584  goto loop;
585 
586  case DT_W0:
587  p = dvi_w;
588  goto right;
589 
590  case DT_W:
591  dvi_w = p;
592  goto right;
593 
594  case DT_X0:
595  p = dvi_x;
596  goto right;
597 
598  case DT_X:
599  dvi_x = p;
600  goto right;
601 
602  case DT_RIGHT:
603 right:
604  dvi_h += p;
605  if (F_SMALLH(f, p)) {
606  dvi_hh += fromSP(p);
607  p = fromSP(dvi_h);
608  FIXDRIFT(dvi_hh, p);
609  } else
610  dvi_hh = fromSP(dvi_h);
611  goto loop;
612 
613  case DT_Y0:
614  p = dvi_y;
615  goto down;
616 
617  case DT_Y:
618  dvi_y = p;
619  goto down;
620 
621  case DT_Z0:
622  p = dvi_z;
623  goto down;
624 
625  case DT_Z:
626  dvi_z = p;
627  goto down;
628 
629  case DT_DOWN:
630 down:
631  dvi_v += p;
632  if (F_SMALLV(f, p)) {
633  dvi_vv += fromSP(p);
634  p = fromSP(dvi_v);
635  FIXDRIFT(dvi_vv, p);
636  } else
637  dvi_vv = fromSP(dvi_v);
638  goto loop;
639 
640  case DT_FNTNUM:
641  f = DVIFindFont((i32)(c - DVI_FNTNUM0));
642  goto loop;
643 
644  case DT_FNT:
645  f = DVIFindFont(p);
646  goto loop;
647 
648  case DT_XXX:
649  DoSpecial(p);
650  goto loop;
651 
652  case DT_FNTDEF:
653  SkipFontDef(fp);
654  goto loop;
655 
656  case DT_PRE:
657  GripeUnexpectedOp("PRE");
658  /* NOTREACHED */
659 
660  case DT_POST:
661  if (doingpage) {
662  GripeUnexpectedOp("POST (no EOP)");
663  /* NOTREACHED */
664  }
665  return (0);
666 
667  case DT_POSTPOST:
668  GripeUnexpectedOp("POSTPOST");
669  /* NOTREACHED */
670 
671  case DT_UNDEF:
672  GripeUndefinedOp(c);
673  /* NOTREACHED */
674 
675  default:
676  panic("DVI_DT(%d) = %d", c, DVI_DT(c));
677  /* NOTREACHED */
678  }
679  /* NOTREACHED */
680 }
static unsigned char g
Definition: getami.c:692
int RightEMsg
Definition: dvirle1.c:72
int BottomEMsg
Definition: dvirle1.c:70
#define MaxCharHeight
Definition: dvirle.h:38
#define MaxPageHeight
Definition: dvirle.h:39
int * nextyx
Definition: dvirle1.c:53
int LeftEMsg
Definition: dvirle1.c:71
#define CHARSHIFT
Definition: dvirle.h:31
void ExpandArrays()
Definition: dvirle1.c:113
int height
Definition: pgmtorle.c:51
void DoSpecial(i32 len)
Definition: dvirle1.c:310
void SetRule(int h, int w)
Definition: dvirle1.c:331
int Chars
Definition: dvirle1.c:49
#define CHARMASK
Definition: dvirle.h:32
int HFlag
Definition: dvirle1.c:76
#define FONTSHIFT
Definition: dvirle.h:30
void BeginPage(i32 *count)
Definition: dvirle1.c:221
int * nextfcp
Definition: dvirle1.c:54
#define CHECK(cond, msg, flag)
FILE * fp
Definition: pgmtorle.c:49
int TopEMsg
Definition: dvirle1.c:69
void EndPage()
Definition: dvirle1.c:248
int CheckChar(i32 c)
Definition: dvirle1.c:386
#define MaxPageWidth
Definition: dvirle.h:40
void SetRule ( int  h,
int  w 
)

Definition at line 331 of file dvirle1.c.

333 {
334  register int y; /* temporary y value */
335  register int x; /* temporary x value */
336  register int ymax; /* bottommost (versatec-wise) y coord */
337  register int xmax; /* rightmost (versatec-wise) x coord */
338  register int ymin; /* topmost y coord */
339  register int xmin; /* leftmost x coord */
340  int anybad = 0;
341 
342  if (!HFlag) {
343  xmin = dvi_hh;
344  ymax = dvi_vv;
345  ymin = ymax - h;
346  xmax = xmin + w;
347  } else {
348  ymin = dvi_hh;
349  xmin = MaxPageWidth - dvi_vv - 1;/* ???DO I NEED -1 ANYMORE?? */
350  xmax = xmin + h;
351  ymax = ymin + w;
352 #ifdef notdef
353  if (ymax > MaxPageHeight)
354  ymax = MaxPageHeight, anybad++;
355 #endif
356  }
357  if (ymin < 0)
358  ymin = 0, anybad++;
359  if (xmin < 0)
360  xmin = 0, anybad++;
361  if (xmax > MaxPageWidth)
362  xmax = MaxPageWidth, anybad++;
363  if (anybad && !RuleEMsg) {
364  error(0, 0, "WARNING: rule(s) off page edge; clipped to fit");
365  RuleEMsg++;
366  }
367  for (y = ymax; y > ymin; y -= h) {
368  for (x = xmin; x < xmax; x += w) {
369  h = y - ymin;
370  h = min(h, maxysize);
371  w = xmax - x;
372  w = min(w, 255);
373  if (--Chars < 0)
374  ExpandArrays();
375  *nextyx++ = (y << 16) | x;
376  *nextfcp++ = (1 << 31) | (x << 16) | (h << 8) | w;
377  }
378  }
379 }
int RuleEMsg
Definition: dvirle1.c:73
#define MaxPageHeight
Definition: dvirle.h:39
int * nextyx
Definition: dvirle1.c:53
void ExpandArrays()
Definition: dvirle1.c:113
static int y
Definition: getami.c:691
int Chars
Definition: dvirle1.c:49
static int x
Definition: getami.c:691
#define min(a, b)
Definition: dvirle.h:51
int HFlag
Definition: dvirle1.c:76
static void error(int)
Definition: aliastorle.c:559
#define maxysize
Definition: dvirle1.c:320
int * nextfcp
Definition: dvirle1.c:54
#define MaxPageWidth
Definition: dvirle.h:40
void SortPage ( )

Definition at line 134 of file dvirle1.c.

References Chars, fcp, and yx.

135 {
136  register int i, j, k, delta, *y, *f;
137 
138  /*
139  * Chars is currently the number of chars on the page, not the number
140  * of chars left in the array.
141  */
142  y = yx;
143  f = fcp;
144  delta = 1;
145  while (9 * delta + 4 < Chars)
146  delta = 3 * delta + 1;
147  while (delta > 0) {
148  for (i = delta; i < Chars; i++) {
149  if (y[j = i - delta] < y[i]) {
150  register int t1 = y[i];
151  register int t2 = f[i];
152 
153  k = i;
154  do {
155  y[k] = y[j];
156  f[k] = f[j];
157  k = j;
158  j -= delta;
159  } while (j >= 0 && y[j] < t1);
160  y[k] = t1;
161  f[k] = t2;
162  }
163  }
164  delta /= 3;
165  }
166 }
static int y
Definition: getami.c:691
int Chars
Definition: dvirle1.c:49
int * fcp
Definition: dvirle1.c:52
int i
Definition: rletorla.c:82
int * yx
Definition: dvirle1.c:51

Variable Documentation

int BottomEMsg

Definition at line 70 of file dvirle1.c.

Referenced by PageLoop().

int BottomMargin

Definition at line 80 of file dvirle1.c.

int CFlag

Definition at line 75 of file dvirle1.c.

int Chars

Definition at line 49 of file dvirle1.c.

Referenced by EndPage(), ExpandArrays(), PageLoop(), and SortPage().

int Debug

Definition at line 78 of file dvirle1.c.

const char* DVIFileName

Definition at line 44 of file dvirle1.c.

int* fcp

Definition at line 52 of file dvirle1.c.

Referenced by EndPage(), ExpandArrays(), and SortPage().

int HFlag

Definition at line 76 of file dvirle1.c.

int LeftEMsg

Definition at line 71 of file dvirle1.c.

Referenced by PageLoop().

int MaxChars

Definition at line 50 of file dvirle1.c.

Referenced by EndPage(), and ExpandArrays().

int* nextfcp

Definition at line 54 of file dvirle1.c.

Referenced by ExpandArrays().

int* nextyx

Definition at line 53 of file dvirle1.c.

Referenced by ExpandArrays(), and PageLoop().

char* optarg

Definition at line 29 of file getopt.c.

int optind

Definition at line 30 of file getopt.c.

int PageHeight

Definition at line 85 of file dvirle1.c.

int PageWidth

Definition at line 84 of file dvirle1.c.

char* ProgName

Definition at line 37 of file dvirle1.c.

char rcsid[] = "$Id: dvirle1.c,v 3.0.1.3 1992/02/28 22:12:53 spencer Exp $"
static

Definition at line 2 of file dvirle1.c.

int RightEMsg

Definition at line 72 of file dvirle1.c.

int RuleEMsg

Definition at line 73 of file dvirle1.c.

char serrbuf[ 8192 ]

Definition at line 42 of file dvirle1.c.

int SFlag

Definition at line 77 of file dvirle1.c.

int TallestPageHeight

Definition at line 83 of file dvirle1.c.

const char* TeXFontDesc

Definition at line 46 of file dvirle1.c.

int TopEMsg

Definition at line 69 of file dvirle1.c.

Referenced by PageLoop().

int TopMargin

Definition at line 81 of file dvirle1.c.

int WidestPageWidth

Definition at line 82 of file dvirle1.c.

int* yx

Definition at line 51 of file dvirle1.c.

Referenced by EndPage(), ExpandArrays(), and SortPage().