summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipsk/dviinput.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
committerKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
commitad547a6b5986815fda458221149728d9d9ab1d87 (patch)
tree16296910eb3eca724371474ea9aea3994dc69614 /Build/source/texk/dvipsk/dviinput.c
parent947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff)
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipsk/dviinput.c')
-rw-r--r--Build/source/texk/dvipsk/dviinput.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/Build/source/texk/dvipsk/dviinput.c b/Build/source/texk/dvipsk/dviinput.c
new file mode 100644
index 00000000000..f25e110da0f
--- /dev/null
+++ b/Build/source/texk/dvipsk/dviinput.c
@@ -0,0 +1,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();
+}