File: dviinput.c

package info (click to toggle)
texlive-bin 2016.20160513.41080.dfsg-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 155,060 kB
  • sloc: ansic: 702,862; cpp: 222,090; perl: 76,014; sh: 23,402; makefile: 8,078; lex: 4,710; pascal: 3,782; python: 3,614; java: 3,569; yacc: 2,905; exp: 2,031; xml: 800; tcl: 670; ruby: 620; lisp: 397; sed: 351; asm: 140; csh: 48; awk: 30
file content (89 lines) | stat: -rw-r--r-- 1,646 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 *   Input bytes from the dvi file or the current virtual character.
 *   These routines could probably be sped up significantly; but they are
 *   very machine dependent, so I will leave such tuning to the installer.
 *   They simply get and return bytes in batches of one, two, three, and four,
 *   updating the current position as necessary.
 */
#include "dvips.h" /* The copyright notice in that file is included too! */
/*
 *   The external declarations:
 */
#include "protos.h"

static void
abortpage(void)
{
   error("! unexpected eof on DVI file");
}

shalfword  /* the value returned is, however, between 0 and 255 */
dvibyte(void)
{
  register shalfword i;
  if (curpos) {
     if (curpos>=curlim) return((shalfword)140);
     return (*curpos++);
  }
  if ((i=getc(dvifile))==EOF)
    abortpage();
  return(i);
}

halfword
twobytes(void)
{
  register halfword i;
  i = dvibyte();
  return(i*256+dvibyte()); }

integer
threebytes(void)
{
  register integer i;
  i = twobytes();
  return(i*256+dvibyte()); }

shalfword
signedbyte(void)
{
  register shalfword i;
  if (curpos) {
     if (curpos>=curlim)
       error("! unexpected end of virtual packet");
     i = *curpos++;
  } else if ((i=getc(dvifile))==EOF)
    abortpage();
  if (i<128) return(i);
  else return(i-256);
}

shalfword
signedpair(void)
{
  register shalfword i;
  i = signedbyte();
  return(i*256+dvibyte());
}

integer
signedtrio(void)
{
  register integer i;
  i = signedpair();
  return(i*256+dvibyte());
}

integer
signedquad(void)
{
  register integer i;
  i = signedpair();
  return(i*65536+twobytes());
}

void
skipover(int i)
{
  while (i-->0) dvibyte();
}