summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES')
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/TL-Changes9
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-01-texk37
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-02-simple-typos24
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-03-ANSI-C59
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-04-pager12
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-05-getline78
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-06-bug-fix22
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-50-kpathsea116
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-60-warnings236
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-70-disdvi-xetex298
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-80-maybe-bug-fix13
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-81-maybe-scand61
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-90-undo-some1668
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-91-undo-rest1630
14 files changed, 4263 insertions, 0 deletions
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/TL-Changes b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/TL-Changes
new file mode 100644
index 00000000000..6adeeebc1c7
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/TL-Changes
@@ -0,0 +1,9 @@
+Changes applied to the dvi2tty-5.3.1 tree as obtained from:
+ http://www.mesa.nl/pub/dvi2tty/dvi2tty-5.3.1.tar.gz.
+
+Removed:
+ dvistuff.c.bak
+
+Renamed:
+ test.dvi.org -> test.org.dvi
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-01-texk b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-01-texk
new file mode 100644
index 00000000000..4639c2823e4
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-01-texk
@@ -0,0 +1,37 @@
+diff -ur dvi2tty-5.3.1.orig/README.ORG dvi2tty-5.3.1/README.ORG
+--- dvi2tty-5.3.1.orig/README.ORG 1990-11-14 23:36:08.000000000 +0100
++++ dvi2tty-5.3.1/README.ORG 2009-06-15 00:59:36.000000000 +0200
+@@ -16,11 +16,8 @@
+ omization constants" and change them to suit your site.
+ These constants configure default pager and a little more.
+
+-Please report complaints, suggestions, bugs and/or fixes to:
+-
++Please report complaints, suggestions, bugs and/or fixes to
++tex-k@tug.org, since this is a modified version of the original, written
++by
+ Svante Lindahl, NADA, KTH Numerical Analysis & Computer Science
+-UUCP: {seismo,mcvax}!enea!ttds!zap Royal Institute of Technology, Sweden
+-ARPA: enea!ttds!zap@seismo.CSS.GOV EAN: zap@cs.kth.sunet
+-
+-The TOPS-20 version of the program can also be obtained from the above
+-address.
++ Royal Institute of Technology, Sweden
+diff -ur dvi2tty-5.3.1.orig/disdvi.1 dvi2tty-5.3.1/disdvi.1
+--- dvi2tty-5.3.1.orig/disdvi.1 1996-03-23 17:07:21.000000000 +0100
++++ dvi2tty-5.3.1/disdvi.1 2010-10-20 14:21:13.000000000 +0200
+@@ -1,4 +1,4 @@
+-.TH DISDVI Local "4 April 1989"
++.TH DISDVI 1 "20 October 2010" "TeX Live"
+ .SH NAME
+ disdvi \- `disassemble' a TeX DVI file
+ .SH SYNOPSIS
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.1 dvi2tty-5.3.1/dvi2tty.1
+--- dvi2tty-5.3.1.orig/dvi2tty.1 1996-03-23 20:45:03.000000000 +0100
++++ dvi2tty-5.3.1/dvi2tty.1 2010-10-20 14:21:13.000000000 +0200
+@@ -1,4 +1,4 @@
+-.TH DVI2TTY Local "13 November 1990"
++.TH DVI2TTY 1 "20 October 2010" "TeX Live"
+ .SH NAME
+ dvi2tty \- preview a TeX DVI\-file on an ordinary ascii terminal
+ .SH SYNOPSIS
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-02-simple-typos b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-02-simple-typos
new file mode 100644
index 00000000000..82863912e0d
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-02-simple-typos
@@ -0,0 +1,24 @@
+diff -ur dvi2tty-5.3.1.orig/README dvi2tty-5.3.1/README
+--- dvi2tty-5.3.1.orig/README 2003-01-23 04:02:43.000000000 +0100
++++ dvi2tty-5.3.1/README 2009-06-15 00:59:36.000000000 +0200
+@@ -3,7 +3,7 @@
+
+ dvi2tty is intended for previewing dvi-files on text-only
+ devices (terminals and lineprinters).
+-The program is basicly an improved C version of the pascal
++The program is basically an improved C version of the pascal
+ program written by Svante Lindahl (see README.ORG).
+ I translated it because I could not find a pascal compiler
+ on our machine that could compile it.
+diff -ur dvi2tty-5.3.1.orig/commands.h dvi2tty-5.3.1/commands.h
+--- dvi2tty-5.3.1.orig/commands.h 2003-01-23 04:00:22.000000000 +0100
++++ dvi2tty-5.3.1/commands.h 2010-10-19 11:34:16.000000000 +0200
+@@ -65,7 +65,7 @@
+ #define Z3 169 /* ??? */
+ #define Z4 170 /* ??? */
+ #define FONT_00 171 /* set current font to 0 */
+-#define FONT_63 234 /* set current font to 0 */
++#define FONT_63 234 /* set current font to 63 */
+ #define FNT1 235 /* set current font */
+ #define FNT2 236 /* Same as FNT1, except that arg is 2 bytes */
+ #define FNT3 237 /* Same as FNT1, except that arg is 3 bytes */
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-03-ANSI-C b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-03-ANSI-C
new file mode 100644
index 00000000000..1833fad4306
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-03-ANSI-C
@@ -0,0 +1,59 @@
+diff -ur dvi2tty-5.3.1.orig/disdvi.c dvi2tty-5.3.1/disdvi.c
+--- dvi2tty-5.3.1.orig/disdvi.c 2003-01-23 11:31:00.000000000 +0100
++++ dvi2tty-5.3.1/disdvi.c 2010-10-21 08:07:43.000000000 +0200
+@@ -113,8 +113,6 @@
+
+ #if defined(VMS)
+ main (int argc, char ** argv);
+-#else
+-void main (int argc, char ** argv);
+ #endif
+ void bop (void);
+ void preamble (void);
+@@ -138,7 +136,7 @@
+ #if defined(VMS)
+ main(int argc, char **argv)
+ #else
+-void main(int argc, char **argv)
++int main(int argc, char **argv)
+ #endif
+ {
+ register int opcode; /* dvi opcode */
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.c dvi2tty-5.3.1/dvi2tty.c
+--- dvi2tty-5.3.1.orig/dvi2tty.c 2003-01-23 11:28:30.000000000 +0100
++++ dvi2tty-5.3.1/dvi2tty.c 2010-10-21 08:31:44.000000000 +0200
+@@ -252,7 +252,6 @@
+ */
+
+ #if defined(MSDOS)
+-void main (int, char **);
+ void setoption (char *);
+ void getargs (void);
+ void getpages (int, char *);
+@@ -265,8 +264,6 @@
+
+ # if defined(VMS)
+ main (int argc, char ** argv);
+-# else
+-void main (int argc, char ** argv);
+ # endif
+ void setoption (char * optarg);
+ void getargs (void);
+@@ -288,7 +285,7 @@
+ #if defined(VMS)
+ main(int argc, char **argv)
+ #else
+-void main(int argc, char **argv)
++int main(int argc, char **argv)
+ #endif
+ {
+
+@@ -361,7 +358,7 @@
+ * GETARGS -- Process options from command line and from environment.
+ */
+
+-void getargs()
++void getargs(void)
+ {
+ char *str, *envp;
+ bool DVIfound; /* if a dvi filename found */
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-04-pager b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-04-pager
new file mode 100644
index 00000000000..81cb872384f
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-04-pager
@@ -0,0 +1,12 @@
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.c dvi2tty-5.3.1/dvi2tty.c
+--- dvi2tty-5.3.1.orig/dvi2tty.c 2010-10-21 08:31:44.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.c 2010-10-21 11:15:43.000000000 +0200
+@@ -180,7 +180,7 @@
+ /* don't have terminals with Scand. nat. chars */
+ #define WANTPAGER TRUE /* default: try to pipe through a pager (like */
+ /* more) if stdout is tty and no -o switch */
+-#define DEFPAGER "/usr/bin/pg" /* CHANGE TO YOUR LOCAL PAGER */
++#define DEFPAGER "more" /* CHANGE TO YOUR LOCAL PAGER */
+
+ /*------------------ end of customization constants ---------------------*/
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-05-getline b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-05-getline
new file mode 100644
index 00000000000..29cf25e2d9e
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-05-getline
@@ -0,0 +1,78 @@
+ Apparently POSIX 2008 has getline and glibc 2.9.90 exports it.
+ Rename our getline to something that a standard won't usurp.
+
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2003-01-23 04:01:12.000000000 +0100
++++ dvi2tty-5.3.1/dvistuff.c 2010-10-22 11:03:32.000000000 +0200
+@@ -179,7 +181,7 @@
+ void ruleaux (long, long, char);
+ long horizontalmove (long);
+ int skipnops (void);
+-linetype * getline (void);
++linetype * texlive_getline (void);
+ linetype * findline (void);
+ unsigned long num (int);
+ long snum (int);
+@@ -208,7 +210,7 @@
+ void ruleaux (long rulewt, long ruleht, char ch);
+ long horizontalmove (long amount);
+ int skipnops (void);
+-linetype * getline (void);
++linetype * texlive_getline (void);
+ linetype * findline (void);
+ unsigned long num (int size);
+ long snum (int size);
+@@ -376,7 +376,7 @@
+ h = 0L; v = 0L; /* initialize coordinates */
+ x = 0L; w = 0L; y = 0L; z = 0L; /* initialize amounts */
+ sptr = 0; /* initialize stack */
+- currentline = getline(); /* initialize list of lines */
++ currentline = texlive_getline(); /* initialize list of lines */
+ currentline->vv = 0L;
+ firstline = currentline;
+ lastline = currentline;
+@@ -777,7 +777,7 @@
+ * GETLINE -- Returns an initialized line-object
+ */
+
+-linetype *getline(void)
++linetype *texlive_getline(void)
+ {
+ register int i;
+ register linetype *temp;
+@@ -793,7 +793,7 @@
+
+ return temp;
+
+-} /* getline */
++} /* texlive_getline */
+
+
+
+@@ -809,7 +809,7 @@
+
+ if (v <= firstline->vv) { /* above first line */
+ if (firstline->vv - v > lineheight) {
+- temp = getline();
++ temp = texlive_getline();
+ temp->next = firstline;
+ firstline->prev = temp;
+ temp->vv = v;
+@@ -820,7 +820,7 @@
+
+ if (v >= lastline->vv) { /* below last line */
+ if (v - lastline->vv > lineheight) {
+- temp = getline();
++ temp = texlive_getline();
+ temp->prev = lastline;
+ lastline->next = temp;
+ temp->vv = v;
+@@ -843,7 +843,7 @@
+ return temp->next;
+
+ /* no line fits suitable, generate a new one */
+- currentline = getline();
++ currentline = texlive_getline();
+ currentline->next = temp->next;
+ currentline->prev = temp;
+ temp->next->prev = currentline;
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-06-bug-fix b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-06-bug-fix
new file mode 100644
index 00000000000..927f20ac1b3
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-06-bug-fix
@@ -0,0 +1,22 @@
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2010-10-22 11:03:32.000000000 +0200
++++ dvi2tty-5.3.1/dvistuff.c 2010-10-22 13:45:27.000000000 +0200
+@@ -596,7 +596,8 @@
+ currentline = currentline->next) {
+ if (currentline != firstline) {
+ foo = ((currentline->vv - currentline->prev->vv)/lineheight)-1;
+- foo &= 3; /* linespacings not too large */
++ if (foo > 3)
++ foo = 3; /* linespacings not too large */
+ for (i = 1; i <= (int) foo; i++)
+ putc('\n', output);
+ }
+@@ -1246,7 +1245,7 @@
+
+ for (i = 0; i < namelen; i++)
+ name[i] = get1();
+- name[i] = '\0'; /* just to be sure */
++ name[i] = '\0'; /* required */
+ fnt->name = name;
+ if (new) {
+ fnt->next = fonts;
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-50-kpathsea b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-50-kpathsea
new file mode 100644
index 00000000000..9ca1eb8f22b
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-50-kpathsea
@@ -0,0 +1,116 @@
+diff -ur dvi2tty-5.3.1.orig/disdvi.c dvi2tty-5.3.1/disdvi.c
+--- dvi2tty-5.3.1.orig/disdvi.c 2010-10-21 08:07:43.000000000 +0200
++++ dvi2tty-5.3.1/disdvi.c 2010-10-22 09:08:02.000000000 +0200
+@@ -60,6 +60,11 @@
+ # include "macintosh.h"
+ #endif
+
++#if defined(KPATHSEA)
++#define NO_DEBUG 1
++#include <kpathsea/config.h>
++#include <kpathsea/lib.h>
++#endif
+
+
+ /*
+@@ -181,7 +150,7 @@
+ else
+ dvifp = stdin;
+
+-#if defined(MSDOS)
++#if defined(MSDOS) || defined(WIN32)
+ setmode(fileno(dvifp), O_BINARY);
+ #endif
+
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.c dvi2tty-5.3.1/dvi2tty.c
+--- dvi2tty-5.3.1.orig/dvi2tty.c 2010-10-21 11:15:43.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.c 2010-10-22 14:10:28.000000000 +0200
+@@ -301,7 +301,7 @@
+ #if defined(THINK_C)
+ if (inputfromfile) {
+ #endif
+-#if defined(MSDOS)
++#if defined(MSDOS) || defined(WIN32)
+ if ((DVIfile = fopen(DVIfilename, "rb")) == NULL)
+ #else
+ # if defined(VMS)
+@@ -648,6 +648,48 @@
+ } /* plcnxt */
+
+
++#ifdef KPATHSEA
++#ifdef __DJGPP__
++/* `stat' is way too expensive for such a simple job. */
++#define READABLE(fn, st) \
++ (access (fn, R_OK) == 0 && access (fn, D_OK) == -1)
++#else
++#define READABLE(fn, st) \
++ (access (fn, R_OK) == 0 && stat (fn, &(st)) == 0 && !S_ISDIR (st.st_mode))
++#endif
++
++static char *
++readable_file(char *name)
++{
++ char *ret;
++
++#ifdef WIN32
++ unsigned int fa;
++
++ fa = GetFileAttributes(name);
++ if (fa == 0xFFFFFFFF) {
++ ret = NULL;
++ }
++ else if ((fa & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
++ ret = NULL;
++ }
++ else {
++ ret = name;
++ }
++#else /* ! WIN32 */
++ struct stat st;
++
++ if (READABLE (name, st)) {
++ ret = name;
++
++ } else { /* Some other error. */
++ ret = NULL;
++ }
++#endif
++ return ret;
++
++}
++#endif
+
+ /*
+ * GETFNAME -- {Make sure we have a .dvi filename.
+@@ -661,7 +704,11 @@
+ if (i == 0)
+ usage(ign);
+ strcpy(DVIfilename, str);
++#ifdef KPATHSEA
++ if (!readable_file(DVIfilename))
++#else
+ if ((i < 5) || strcmp(str+i-4, ".dvi"))
++#endif
+ strcat(DVIfilename, ".dvi");
+
+ return;
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.h dvi2tty-5.3.1/dvi2tty.h
+--- dvi2tty-5.3.1.orig/dvi2tty.h 2003-01-23 04:01:04.000000000 +0100
++++ dvi2tty-5.3.1/dvi2tty.h 2010-10-22 15:08:40.000000000 +0200
+@@ -32,8 +32,15 @@
+ # endif
+ #endif
+
++#if defined(KPATHSEA)
++#define NO_DEBUG 1
++#include <kpathsea/config.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#else
+ #define TRUE 1
+ #define FALSE 0
++#endif
+ #define nil NULL
+
+ /*
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-60-warnings b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-60-warnings
new file mode 100644
index 00000000000..d090508a274
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-60-warnings
@@ -0,0 +1,236 @@
+diff -ur dvi2tty-5.3.1.orig/disdvi.c dvi2tty-5.3.1/disdvi.c
+--- dvi2tty-5.3.1.orig/disdvi.c 2010-10-22 09:08:02.000000000 +0200
++++ dvi2tty-5.3.1/disdvi.c 2010-10-22 09:15:58.000000000 +0200
+@@ -124,7 +124,7 @@
+ void postamble (void);
+ void postpostamble (void);
+ void fontdef (int x);
+-char * fontname (unsigned long fntnum);
++const char * fontname (unsigned long fntnum);
+ void special (int x);
+ void printnonprint (int ch);
+ unsigned long num (int size);
+@@ -493,7 +493,7 @@
+ * FONTNAME -- Return font name.
+ */
+
+-char * fontname(unsigned long fntnum)
++const char * fontname(unsigned long fntnum)
+ {
+ font * fnt;
+
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.c dvi2tty-5.3.1/dvi2tty.c
+--- dvi2tty-5.3.1.orig/dvi2tty.c 2010-10-22 14:10:28.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.c 2010-10-22 14:15:38.000000000 +0200
+@@ -236,13 +236,13 @@
+ long foo; /* utility variable, "register" */
+ #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
+ bool pager; /* tells if output is piped to a pager */
+-char * path; /* name of the pager to run */
++const char * path; /* name of the pager to run */
+ #endif
+ char * progname; /* our name */
+ int Argc;
+ char ** Argv;
+ char DVIfilename[MAXLEN];
+-char * OUTfilename;
++const char * OUTfilename;
+ char optch; /* for option handling */
+
+
+@@ -252,26 +252,26 @@
+ */
+
+ #if defined(MSDOS)
+-void setoption (char *);
++void setoption (const char *);
+ void getargs (void);
+-void getpages (int, char *);
++void getpages (int, const char *);
+ void plcnxt (int);
+-void getfname (char *);
+-int getinteger(int *, int *, char *);
+-int getlong (long *, int *, char *);
++void getfname (const char *);
++int getinteger(int *, int *, const char *);
++int getlong (long *, int *, const char *);
+ void usage (int);
+ #else
+
+ # if defined(VMS)
+ main (int argc, char ** argv);
+ # endif
+-void setoption (char * optarg);
++void setoption (const char * optarg);
+ void getargs (void);
+-void getpages (int j, char * str);
++void getpages (int j, const char * str);
+ void plcnxt (int pagnr);
+-void getfname (char * str);
+-int getinteger(int * dest, int * j, char * str);
+-int getlong (long * dest, int * j, char * str);
++void getfname (const char * str);
++int getinteger(int * dest, int * j, const char * str);
++int getlong (long * dest, int * j, const char * str);
+ void usage (int uerr);
+ #endif
+
+@@ -360,7 +360,8 @@
+
+ void getargs(void)
+ {
+- char *str, *envp;
++ const char *str;
++ char *envp;
+ bool DVIfound; /* if a dvi filename found */
+
+ #if !defined(THINK_C)
+@@ -494,7 +495,7 @@
+ * SETOPTION -- Process an option.
+ */
+
+-void setoption(char *optarg)
++void setoption(const char *optarg)
+ {
+ int j = 0;
+
+@@ -571,7 +572,7 @@
+ * GETPAGES -- Getr a list of pages to print.
+ */
+
+-void getpages(int j, char *str)
++void getpages(int j, const char *str)
+ {
+ int i, c;
+ int num;
+@@ -695,7 +696,7 @@
+ * GETFNAME -- {Make sure we have a .dvi filename.
+ */
+
+-void getfname(char *str)
++void getfname(const char *str)
+ {
+ int i;
+
+@@ -722,7 +723,7 @@
+ * call for it.
+ */
+
+-int getinteger(int *dest, int *j, char *str)
++int getinteger(int *dest, int *j, const char *str)
+ {
+ int cum;
+ int sgn;
+@@ -758,7 +759,7 @@
+ * call for it.
+ */
+
+-int getlong(long *dest, int *j, char *str)
++int getlong(long *dest, int *j, const char *str)
+ {
+ long cum;
+ int sgn;
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2010-10-22 13:45:27.000000000 +0200
++++ dvi2tty-5.3.1/dvistuff.c 2010-10-22 14:07:21.391142887 +0200
+@@ -93,7 +93,9 @@
+ * Structure and variable definitions
+ */
+
++#if 0
+ char *dvistuff = "@(#) dvistuff.c 5.12 27may1996 M.J.E. Mol (c) 1989-1996";
++#endif
+
+ typedef struct {
+ long hh;
+@@ -186,7 +188,7 @@
+ void dochar (char);
+ void symchar (char);
+ void normchar (char);
+-void outchar (char);
++void outchar (unsigned char);
+ void putcharacter (long);
+ void setchar (long);
+ void fontdef (int);
+@@ -215,7 +217,7 @@
+ void dochar (char ch);
+ void symchar (char ch);
+ void normchar (char ch);
+-void outchar (char ch);
++void outchar (unsigned char ch);
+ void putcharacter (long charnr);
+ void setchar (long charnr);
+ void fontdef (int x);
+@@ -382,18 +384,20 @@
+ lastline = currentline;
+ firstcolumn = rightmargin;
+ if (pageswitchon) {
+- if ((sequenceon ? pagecounter : pagenr) != firstpage->pag)
++ if ((sequenceon ? pagecounter : pagenr) != firstpage->pag) {
+ if (noffd)
+ fprintf(output, "^L\n");
+ else
+ putc(FORM, output);
++ }
+ }
+ else
+- if (backpointer != -1) /* not FORM at first page */
++ if (backpointer != -1) { /* not FORM at first page */
+ if (noffd)
+ fprintf(output, "^L\n");
+ else
+ putc(FORM, output);
++ }
+
+ return;
+
+@@ -588,7 +592,7 @@
+ void printpage(void)
+ {
+ register int i, j;
+- register char ch;
++ register unsigned char ch;
+
+ if (sptr != 0)
+ fprintf(stderr, "dvi2tty: warning - stack not empty at eop.\n");
+@@ -667,7 +671,7 @@
+ {
+
+ register char ch; /* character to set rule with */
+- register long saveh, savev;
++ register long saveh = 0, savev;
+ /* rule -- starts up the recursive routine */
+ if (!moving)
+ saveh = h;
+@@ -837,11 +841,12 @@
+ /* temp->vv < v < temp->next->vv --- temp is above, temp->next is below */
+ topd = v - temp->vv;
+ botd = temp->next->vv - v;
+- if ((topd < lineheight) || (botd < lineheight))
++ if ((topd < lineheight) || (botd < lineheight)) {
+ if (topd < botd) /* take best fit */
+ return temp;
+ else
+ return temp->next;
++ }
+
+ /* no line fits suitable, generate a new one */
+ currentline = texlive_getline();
+@@ -1071,7 +1076,7 @@
+ * SHOULD BE MOVED OUT.
+ */
+
+-void outchar(char ch)
++void outchar(unsigned char ch)
+ {
+ register int i, j;
+
+@@ -1201,7 +1206,7 @@
+ void setchar(long charnr)
+ {
+
+- outchar(allchar ? charnr : '#');
++ outchar(allchar ? (unsigned char)charnr : '#');
+
+ return;
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-70-disdvi-xetex b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-70-disdvi-xetex
new file mode 100644
index 00000000000..626051ec381
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-70-disdvi-xetex
@@ -0,0 +1,298 @@
+diff -ur dvi2tty-5.3.1.orig/commands.h dvi2tty-5.3.1/commands.h
+--- dvi2tty-5.3.1.orig/commands.h 2010-10-19 11:34:16.000000000 +0200
++++ dvi2tty-5.3.1/commands.h 2010-10-20 11:34:16.000000000 +0200
+@@ -85,3 +85,12 @@
+ #define TRAILER 223 /* trailer bytes in dvi file */
+
+ /* undefined_commands 250,251,252,253,254,255 */
++
++/* additional DVI commands for XeTeX extensions */
++#define PIC_FILE 251
++#define NAT_FNT 252 /* define a native font */
++#define SET_GL_AR 253
++#define SET_GL_ST 254
++
++/* additional DVI command for pTeX extensions */
++#define DVI_DIR 255 /* set direction */
+diff -ur dvi2tty-5.3.1.orig/disdvi.1 dvi2tty-5.3.1/disdvi.1
+--- dvi2tty-5.3.1.orig/disdvi.1 2010-10-20 14:21:13.000000000 +0200
++++ dvi2tty-5.3.1/disdvi.1 2010-10-23 13:10:17.000000000 +0200
+@@ -1,17 +1,25 @@
+-.TH DISDVI 1 "20 October 2010" "TeX Live"
++.TH DISDVI 1 "23 October 2010" "TeX Live"
+ .SH NAME
+-disdvi \- `disassemble' a TeX DVI file
++disdvi \- `disassemble' a (p)TeX DVI or XeTeX XDV file
+ .SH SYNOPSIS
+ .B disdvi
+-dvi\-file
++.RB [ \-p ]
++.RI [ dvi_file [ \fB.dvi\fP ]]
++.br
++.B disdvi \-x
++.RI [ xdv_file [ \fB.xdv\fP ]]
++.br
++.B disdvi \-h
+ .SH DESCRIPTION
+ .I disdvi
+ interprets the contents of
+-.IR dvi\-file ,
++.IR dvi_file
++or
++.IR xdv_file ,
+ printing the DVI commands and text in a human-readable ASCII format on
+ the standard output.
+ .SH "SEE ALSO"
+-dvi2tty(SIPB)
++.BR dvi2tty (1)
+ .SH AUTHOR
+ Marcel J.E. Mol, Delft University of Technology, The Netherlands
+ .br
+diff -ur dvi2tty-5.3.1.orig/disdvi.c dvi2tty-5.3.1/disdvi.c
+--- dvi2tty-5.3.1.orig/disdvi.c 2010-10-22 09:15:58.000000000 +0200
++++ dvi2tty-5.3.1/disdvi.c 2010-10-22 09:17:28.000000000 +0200
+@@ -107,6 +107,9 @@
+
+ char * progname;
+
++int is_ptex = 0;
++int is_xetex = 0;
++const char * dvi_ext = ".dvi";
+
+ /*
+ * Function declarations
+@@ -130,6 +133,11 @@
+ unsigned long num (int size);
+ long snum (int size);
+ void usage (void);
++void picfile (int opcode);
++void natfontdef (int opcode);
++void glyphs (int opcode);
++void dvidir (int opcode);
++void invalid (int opcode);
+
+
+
+@@ -155,6 +163,25 @@
+
+ progname = *argv++;
+
++ if ((argc > 1) && (*argv[0] == '-')) {
++ if (!strcmp(*argv, "-h")) {
++ usage();
++ exit(0);
++ }
++ if (!strcmp(*argv, "-p"))
++ is_ptex = 1;
++ else if (!strcmp(*argv, "-x")) {
++ is_xetex = 1;
++ dvi_ext = ".xdv";
++ } else {
++ fprintf(stderr, "Invalid option `%s'\n", *argv);
++ usage();
++ exit(3);
++ }
++ argv++;
++ argc--;
++ }
++
+ if (argc > 2) {
+ fprintf(stderr, "To many arguments\n");
+ usage();
+@@ -162,21 +189,17 @@
+ }
+
+ if (argc == 2) {
+- if (!strcmp(*argv, "-h")) {
+- usage();
+- exit(0);
+- }
+ if ((i = strlen(*argv)) == 0) {
+ fprintf(stderr, "Illegal empty filename\n");
+ usage();
+ exit(2);
+ }
+- if ((i >= 5) && (!strcmp(*argv+i-4, ".dvi")))
++ if ((i >= 5) && (!strcmp(*argv+i-4, dvi_ext)))
+ dvi_name = *argv;
+ else {
+ dvi_name = malloc((i+5) * sizeof(char));
+ strcpy(dvi_name, *argv);
+- strcat(dvi_name, ".dvi");
++ strcat(dvi_name, dvi_ext);
+ }
+ if ((dvifp = fopen(dvi_name, "r")) == NULL) {
+ perror(dvi_name);
+@@ -293,6 +316,12 @@
+ case PRE : preamble(); break;
+ case POST : postamble(); break;
+ case POST_POST: postpostamble(); break;
++ case PIC_FILE : picfile(opcode); break;
++ case NAT_FNT : natfontdef(opcode); break;
++ case SET_GL_AR:
++ case SET_GL_ST: glyphs(opcode); break;
++ case DVI_DIR : dvidir(opcode); break;
++ default : invalid(opcode);
+ }
+ }
+
+@@ -616,9 +645,157 @@
+ {
+
+ fprintf(stderr, "\n%s\n\n", disdvi);
+- fprintf(stderr, " disassembles TeX dvi files\n");
+- fprintf(stderr, "Usage: %s [-h | <dvi-file>[.dvi]]\n", progname);
++ fprintf(stderr, " disassembles (p)TeX dvi and XeTeX xdv files\n");
++ fprintf(stderr, "Usage: %s [-h | [-p] [dvi_file[.dvi]]\n", progname);
++ fprintf(stderr, " | -x [xdv_file[.xdv]]]\n");
+
+ return;
+
+ } /* usage */
++
++
++
++void picfile(int opcode)
++{
++ int i;
++
++ if (!is_xetex) {
++ invalid(opcode);
++ return;
++ }
++
++ printf("PIC_FILE flags : %ld\n", get1());
++ printf("%06ld: trans :", pc);
++ for (i=0; i<6; i++)
++ printf(" %ld", sget4());
++ printf("\n%06ld: ", pc);
++ printf(" page : %ld\n", get2());
++ printf("%06ld: ", pc);
++ i = (int) get1();
++ printf(" path name (%3d) :", i);
++ while (i-- > 0)
++ putchar((int) get1());
++ putchar('\n');
++} /* picfile */
++
++
++
++void natfontdef(int opcode)
++{
++ register int i;
++ char * name;
++ font * fnt;
++ int flags, namelen, famlen, stylen;
++ long fntnum;
++ int new = 0;
++
++ if (!is_xetex) {
++ invalid(opcode);
++ return;
++ }
++
++ fntnum = num(4);
++ printf("NAT_FNT: %ld\n", fntnum);
++ printf("%06ld: ", pc);
++ printf(" scale : %ld\n", get4());
++ printf("%06ld: ", pc);
++ flags = get2();
++ printf(" flags : %d\n", flags);
++ printf("%06ld: ", pc);
++ printf(" name : ");
++ namelen = (int) get1();
++ famlen = (int) get1();
++ stylen = (int) get1();
++ fnt = fonts;
++ while (fnt != NULL && fnt->num != fntnum)
++ fnt = fnt->next;
++ if (fnt == NULL) {
++ if ((fnt = (font *) malloc(sizeof(font))) == NULL) {
++ perror("fontdef");
++ exit(1);
++ }
++ fnt->num = fntnum;
++ new = 1;
++ }
++ else
++ free(fnt->name); /* free old name */
++ if ((name = (char *) malloc((namelen+1) * sizeof(char))) == NULL) {
++ perror("fontdef");
++ exit(1);
++ }
++
++ for (i = 0; i < namelen; i++)
++ name[i] = get1();
++ name[namelen] = '\0';
++ fnt->name = name;
++ if (new) {
++ fnt->next = fonts;
++ fonts = fnt;
++ }
++
++ printf("%s\n", name);
++
++ if (famlen) {
++ printf(" family : ");
++ while (famlen-- > 0)
++ putchar((int) get1());
++ putchar('\n');
++ }
++
++ if (stylen) {
++ printf(" style : ");
++ while (stylen-- > 0)
++ putchar((int) get1());
++ putchar('\n');
++ }
++} /* fontdef */
++
++
++
++void glyphs(int opcode)
++{
++ long width;
++ int x, n, i, j;
++ long * xy;
++
++ if (!is_xetex) {
++ invalid(opcode);
++ return;
++ }
++
++ x = SET_GL_ST - opcode + 1;
++ width = sget4();
++ n = get2();
++ printf("GLYPH_%s width : %ld\n", x == 2 ? "ARR" : "STR", width);
++ if ((xy = (long *) malloc(n * x * sizeof(long))) == NULL) {
++ perror("glyphs");
++ exit(1);
++ }
++ for (j=0; j < n * x; j++)
++ xy[j] = sget4();
++ for (i=0, j=0; i < n; i++) {
++ printf(" x: %ld", xy[j++]);
++ if (x == 2)
++ printf(" y: %ld", xy[j++]);
++ printf(" g: %ld\n", get2());
++ }
++} /* glyphs */
++
++
++
++void dvidir(int opcode)
++{
++ if (!is_ptex) {
++ invalid(opcode);
++ return;
++ }
++
++ printf("DVI_DIR: %ld\n", get1());
++} /* dvidir */
++
++
++
++void invalid(int opcode)
++{
++ printf("INVALID %d\n", opcode);
++} /* invalid */
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-80-maybe-bug-fix b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-80-maybe-bug-fix
new file mode 100644
index 00000000000..dc76051abdf
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-80-maybe-bug-fix
@@ -0,0 +1,13 @@
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2010-10-22 14:07:21.000000000 +0200
++++ dvi2tty-5.3.1/dvistuff.c 2010-10-22 14:58:46.000000000 +0200
+@@ -1165,8 +1165,8 @@
+ currentline->charactercount = j;
+ if (j < firstcolumn)
+ firstcolumn = j;
++ h += charwidth;
+ }
+- h += charwidth;
+
+ return;
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-81-maybe-scand b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-81-maybe-scand
new file mode 100644
index 00000000000..39a1c07f4ae
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-81-maybe-scand
@@ -0,0 +1,61 @@
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2010-10-22 14:58:46.000000000 +0200
++++ dvi2tty-5.3.1/dvistuff.c 2010-10-23 19:03:03.000000000 +0200
+@@ -1104,18 +1104,18 @@
+ * This code does not really belong here ...
+ *
+ *-------------------------------------------------------------*
+- * The following is very specialized code, it handles national *
+- * Swe/Fin characters. They are respectively: a and o with two *
+- * dots ("a & "o) and a with a circle (Oa). In Swe/Fin "ASCII" *
+- * these characters replace {}|[] and \. TeX outputs these by *
++ * The following is very specialized code, it handles some eu- *
++ * ropean characters. These are: a, o, u with two dots ("a & *
++ * "o & "u), and a with a circle (Oa). TeX outputs these by *
+ * first issuing the dots or circle and then backspace and set *
+- * the a or o. When dvi2tty finds an a or o it searches in the *
+- * near vicinity for the character codes that represent circle *
+- * or dots and if one is found the corresponding national char *
+- * replaces the special character codes. *
++ * the a, o, or u. When dvitty finds an a, o, or u it sear- *
++ * ches in the near vicinity for the character codes that re- *
++ * present circle or dots and if one is found the correspon- *
++ * ding Latin-1 character replaces the special character code. *
+ *-------------------------------------------------------------*/
+- if (!allchar && scascii) {
+- if ((ch == 'a') || (ch == 'A') || (ch == 'o') || (ch == 'O')) {
++ if (scascii) {
++ if ((ch == 'a') || (ch == 'A') || (ch == 'o') || (ch == 'O') ||
++ (ch == 'u') || (ch == 'U')) {
+ for (i = IMAX(leftmargin, j-2);
+ i <= IMIN(rightmargin, j+2);
+ i++)
+@@ -1129,18 +1129,22 @@
+ case 127 :
+ case 34 : /* DEL or " */
+ if (ch == 'a')
+- ch = '{'; /* } vi */
++ ch = 0xe4;
+ else if (ch == 'A') /* dots ... */
+- ch = '[';
++ ch = 0xc4;
+ else if (ch == 'o')
+- ch = '|';
++ ch = 0xf6;
+ else if (ch == 'O')
+- ch = '\\';
++ ch = 0xd6;
++ else if (ch == 'u')
++ ch = 0xfc;
++ else if (ch == 'U')
++ ch = 0xdc;
+ break;
+ case 23 : if (ch == 'a')
+- ch = /* { vi */ '}';
++ ch = 0xe5;
+ else if (ch == 'A') /* circle */
+- ch = ']';
++ ch = 0xc5;
+ break;
+ }
+ }
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-90-undo-some b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-90-undo-some
new file mode 100644
index 00000000000..61d5d06ba2e
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-90-undo-some
@@ -0,0 +1,1668 @@
+diff -ur dvi2tty-5.3.1.orig/disdvi.c dvi2tty-5.3.1/disdvi.c
+--- dvi2tty-5.3.1.orig/disdvi.c 2010-10-22 09:17:28.000000000 +0200
++++ dvi2tty-5.3.1/disdvi.c 2010-10-24 14:03:20.000000000 +0200
+@@ -154,7 +154,7 @@
+ {
+ register int opcode; /* dvi opcode */
+ register int i;
+- unsigned long fontnum;
++ int fontnum;
+
+ #if defined(THINK_C)
+ argc = process_disdvi_command_line(&argv);
+@@ -229,7 +229,7 @@
+ printnonprint(opcode); /* it must be a non-printable */
+ else if ((opcode >= FONT_00) && (opcode <= FONT_63))
+ printf("FONT_%02d /* %s */\n", opcode - FONT_00,
+- fontname((unsigned long) opcode - FONT_00));
++ fontname(opcode - FONT_00));
+ else
+ switch (opcode) {
+ case SET1 :
+@@ -301,7 +301,7 @@
+ case FNT2 :
+ case FNT3 :
+ case FNT4 : fontnum = num(opcode -FNT1 + 1);
+- printf("FNT%d: %ld /* %s */\n",
++ printf("FNT%d: %d /* %s */\n",
+ opcode - FNT1 + 1, fontnum,
+ fontname(fontnum));
+ break;
+@@ -469,7 +469,7 @@
+ char * name;
+ font * fnt;
+ int namelen;
+- unsigned long fntnum;
++ long fntnum;
+ int new = 0;
+
+ fntnum = num(x);
+@@ -522,7 +522,7 @@
+ * FONTNAME -- Return font name.
+ */
+
+-const char * fontname(unsigned long fntnum)
++const char * fontname(long fntnum)
+ {
+ font * fnt;
+
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.c dvi2tty-5.3.1/dvi2tty.c
+--- dvi2tty-5.3.1.orig/dvi2tty.c 2010-10-22 14:15:38.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.c 2010-10-24 14:28:11.424244541 +0200
+@@ -180,17 +180,17 @@
+ /* don't have terminals with Scand. nat. chars */
+ #define WANTPAGER TRUE /* default: try to pipe through a pager (like */
+ /* more) if stdout is tty and no -o switch */
+-#define DEFPAGER "more" /* CHANGE TO YOUR LOCAL PAGER */
++#define DEFPAGER "more" /* CHANGE TO YOUR LOCAL PAGER */
+
+ /*------------------ end of customization constants ---------------------*/
+
+ #define MAXLEN 100 /* size of char-arrays for strings */
+-#if defined(MSDOS) || defined(VMS) || defined(AMIGA)
+-#define OPTSET "haJwepPousltvbc" /* legal options */
+-#define OPTWARG "wepPovb" /* options with argument */
++#if defined(MSDOS) || defined(VMS)
++#define OPTSET "wepPousl" /* legal options */
++#define OPTWARG "wepPo" /* options with argument */
+ #else
+-#define OPTSET "haJwepPousqlfFtvbc"/* legal options */
+-#define OPTWARG "wepPoFvb" /* options with argument */
++#define OPTSET "wepPousqlfF"/* legal options */
++#define OPTWARG "wepPoF" /* options with argument */
+ #endif
+
+ /*
+@@ -206,19 +206,12 @@
+ #define bdopt 7 /* bad option */
+ #define onepp 8 /* only one page list allowed */
+ #define noarg 9 /* argument expected */
+-#if defined(THINK_C)
+-#define nored 10 /* if no input file, redirect stdin */
+-#endif
+-
+
++#if 0
++char *dvi2tty = "@(#) dvi2tty.c 4.1 27/03/90 M.J.E. Mol (c) 1989, 1990";
++#endif
+
+-/*
+- * Variable definitions
+- */
+-
+-char *dvi2tty = "@(#) dvi2tty.c 5.12 27may1996 M.J.E. Mol (c) 1989-1996";
+-#define VERSION 5.2
+-
++/*---------------------------------------------------------------------------*/
+
+ printlisttype * currentpage; /* current page to print */
+ printlisttype * firstpage; /* first page selected */
+@@ -227,14 +220,11 @@
+ FILE * DVIfile;
+ FILE * output;
+ bool outputtofile; /* tells if output goes to file or stdout */
+-#if defined(THINK_C)
+-bool inputfromfile; /* tells if input comes from file or stdin */
+-#endif
+ int ttywidth; /* max nr of chars per printed line */
+ int espace; /* to fake calcs with ttywidth */
+
+ long foo; /* utility variable, "register" */
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
++#if !defined(MSDOS) && !defined(VMS)
+ bool pager; /* tells if output is piped to a pager */
+ const char * path; /* name of the pager to run */
+ #endif
+@@ -245,94 +235,67 @@
+ const char * OUTfilename;
+ char optch; /* for option handling */
+
++/*---------------------------------------------------------------------------*/
+
+-
+-/*
+- * Function declarations
+- */
+-
+-#if defined(MSDOS)
+-void setoption (const char *);
+-void getargs (void);
+-void getpages (int, const char *);
+-void plcnxt (int);
+-void getfname (const char *);
+-int getinteger(int *, int *, const char *);
+-int getlong (long *, int *, const char *);
+-void usage (int);
++#if defined(KPATHSEA) || defined(MSDOS)
++int main (int, char **);
++void setoption (const char *);
++void getargs (void);
++void getpages (int, const char *);
++void plcnxt (int);
++void getfname (const char *);
++int getinteger (int *, int *, const char *);
++void usage (int);
+ #else
++char * getenv ();
++FILE * popen ();
+
+-# if defined(VMS)
+- main (int argc, char ** argv);
+-# endif
+-void setoption (const char * optarg);
+-void getargs (void);
+-void getpages (int j, const char * str);
+-void plcnxt (int pagnr);
+-void getfname (const char * str);
+-int getinteger(int * dest, int * j, const char * str);
+-int getlong (long * dest, int * j, const char * str);
+-void usage (int uerr);
++int main ();
++void setoption ();
++void getargs ();
++void getpages ();
++void plcnxt ();
++void getfname ();
++int getinteger();
++void usage ();
+ #endif
+
+-
+ /****************************************************************************/
+ /* */
+ /* M A I N */
+ /* */
+ /****************************************************************************/
+
+-#if defined(VMS)
+-main(int argc, char **argv)
+-#else
+ int main(int argc, char **argv)
+-#endif
+ {
+
+-#if defined(THINK_C)
+- argc = process_dvi_command_line(&argv);
+-#endif
+-
+ progname = *argv;
+ Argc = argc;
+ Argv = argv;
+
+ getargs(); /* read command line arguments */
+-#if defined(THINK_C)
+- if (inputfromfile) {
+-#endif
+-#if defined(MSDOS) || defined(WIN32)
+- if ((DVIfile = fopen(DVIfilename, "rb")) == NULL)
++#if defined(DOSISH)
++ if ((DVIfile = fopen(DVIfilename, "rb")) == NULL)
+ #else
+-# if defined(VMS)
+- if ((DVIfile = fopen(DVIfilename, "r","ctx=rec")) == NULL)
+-# else
+- if ((DVIfile = fopen(DVIfilename, "r")) == NULL)
+-# endif
++#if defined(VMS)
++ if ((DVIfile = fopen(DVIfilename, "r","ctx=rec")) == NULL)
++#else
++ if ((DVIfile = fopen(DVIfilename, "r")) == NULL)
+ #endif
+- errorexit(filop); /* can't open dvifile */
+-#if defined(THINK_C)
+- }
+- else
+- DVIfile = stdin;
+ #endif
++ errorexit(filop); /* can't open dvifile */
+
+ if (outputtofile) { /* open the outfile, if needed */
+ if ((output = fopen(OUTfilename, "w")) == NULL)
+ errorexit(filcr);
+-#if defined(THINK_C)
+- else
+- set_creator((unsigned char*) OUTfilename);
+-#endif
+-
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
++#if !defined(MSDOS) && !defined(VMS)
+ pager = FALSE;
+ #endif
+ }
+ else {
+ output = stdout;
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
+- if (pager && isatty(fileno(output))) { /* try to pipe to a pager */
++#if !defined(MSDOS) && !defined(VMS)
++ if (isatty(fileno(output)) && pager) { /* try to pipe to a pager */
+ if ((output = popen(path, "w")) == NULL) /* get pipe to pager */
+ errorexit(pipcr); /* make output to output */
+ }
+@@ -343,20 +306,79 @@
+
+ dvimain();
+
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
++#if !defined(MSDOS) && !defined(VMS)
+ if (pager)
+ pclose(output); /* close pipe to pager */
+ #endif
+
+- exit(0);
++ return 0;
+
+ } /* main */
+
++/*----------------------------------------------------------------------------*/
+
++void setoption(const char *optarg)
++{
++ int j = 0;
++
++ while (strchr(OPTSET, optch) != NULL) {
++ switch (optch) {
++#if !defined(MSDOS) && !defined(VMS)
++ case 'q' : pager = FALSE; break;
++ case 'f' : pager = TRUE; break;
++#endif
++ case 'l' : noffd = TRUE; break;
++ case 's' : scascii = TRUE; break;
++ case 'u' : scascii = FALSE; break;
++ case 'P' :
++ sequenceon = TRUE; /* fall through */
++ case 'p' :
++ if (pageswitchon)
++ usage(onepp);
++ getpages(j, optarg);
++ break;
++ case 'w' :
++ if (getinteger(&ttywidth, &j, optarg))
++ usage(nan);
++ if (optarg[j] != '\0')
++ usage(gae);
++ if ((ttywidth < 16) || (ttywidth > 132))
++ usage(wrnge);
++ break;
++ case 'e' :
++ if (getinteger(&espace, &j, optarg))
++ usage(nan);
++ if (optarg[j] != '\0')
++ usage(gae);
++ break;
++ case 'o' :
++ OUTfilename = optarg;
++ outputtofile = TRUE;
++ j = strlen(optarg);
++ break;
++#if !defined(MSDOS) && !defined(VMS)
++ case 'F' :
++ pager = TRUE;
++ path = optarg;
++ j = strlen(optarg);
++ break;
++#endif
++ default :
++ usage(bdopt);
++ }
++ if ((optch = optarg[j]) == '\0')
++ break;
++ j++;
++ if ((strchr(OPTWARG, optch) != NULL) && (optarg[j]=='\0')) {
++ if (--Argc <= 0)
++ usage(noarg);
++ optarg = *++Argv;
++ j = 0;
++ }
++ }
++} /* setoption */
+
+-/*
+- * GETARGS -- Process options from command line and from environment.
+- */
++/*----------------------------------------------------------------------------*/
+
+ void getargs(void)
+ {
+@@ -364,67 +386,33 @@
+ char *envp;
+ bool DVIfound; /* if a dvi filename found */
+
+-#if !defined(THINK_C)
+ if (Argc <= 1)
+ usage(ign);
+-#endif
+
+ pageswitchon = FALSE; /* show all pages */
+ sequenceon = FALSE; /* selected pages are TeX-numbered */
+ outputtofile = FALSE; /* write to stdout */
+-#if defined(THINK_C)
+- inputfromfile = FALSE; /* read from stdin */
+-#endif
+-#if !defined(MSDOS) && !defined(VMS) && !defined (THINK_C) && !defined(AMIGA)
++#if !defined(MSDOS) && !defined(VMS)
+ pager = WANTPAGER; /* want paging, compile time option */
+ #endif
+- accent = TRUE; /* show all accent etc. as extra char */
+- ttfont = FALSE; /* assume tt font (verbatim mode) */
+ noffd = FALSE; /* print formfeed between pages */
+ scascii = DEFSCAND; /* scandinavian, compile time option */
+ ttywidth = 80; /* default terminal width */
+ espace = 0; /* to fake ttywith calcs */
+ DVIfound = FALSE;
+- printfont = FALSE; /* do not print font switches */
+- allchar = FALSE; /* do not put out all characters */
+
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
++#if !defined(MSDOS) && !defined(VMS)
+ if ((path = getenv("PAGER")) == NULL) /* find default pathname of page */
+ path = DEFPAGER; /* program in case paging is wanted */
+ #endif
+
+- /*
+- *
+- * With VAX-C under VMS getenv normally searches the environment array
+- * looking for the variables HOME, TERM, PATH, and USER. In certain
+- * situations getenv attempts to first perform a logical name translation
+- * if none of the environment array strings are matched and then trying
+- * to translate a CLI symbol. Unfortunately we need a CLI symbol defined
+- * as;
+- *
+- * dvi2tty :== $path:dvi2tty.exe
+- *
+- * to invoke dvi2tty with command line arguments as it would be invoked
+- * under Unix. So we use the logical DVI$DVI2TYY as the environment
+- * variable from which options may be set.
+- *
+- */
+-
+- /*
+- * First process environment variable.
+- */
+-
+-#if defined(VMS)
+- if ((envp = getenv("DVI$DVI2TTY")) != NULL) {
+-#else
+- if ((envp = getenv("DVI2TTY")) != NULL) { /* } keep vi happy */
+-#endif
++ if ((envp = getenv("DVI2TTY")) != NULL) {
+ while (*envp == ' ')
+ envp++;
+ while (*envp) { /* environment var args */
+ if (strchr(OPTSET, optch = *envp++) != NULL) {
+ /*
+- * we always pass one option, and arrange for optarg ourselfes,
++ * we always pass one option, and arrange for optarg ourselfves,
+ * so setoption does not mesh up Argv
+ */
+ if (strchr(OPTWARG, optch) != NULL) {
+@@ -449,19 +437,12 @@
+ }
+ }
+
+- /*
+- * Now process command line options.
+- */
+-
+ while (--Argc > 0) { /* command line args */
+ str = *++Argv;
+ if (*str != '-') { /* argument is not an option */
+ if (DVIfound) /* only one dvi file allowed */
+ usage(onef);
+ getfname(str);
+-#if defined(THINK_C)
+- inputfromfile =
+-#endif
+ DVIfound = TRUE;
+ }
+ else if (strchr(OPTSET, optch = *++str) != NULL) {
+@@ -478,99 +459,11 @@
+ }
+
+ if (!DVIfound)
+-#if defined(THINK_C) /* Allow use of stdin for */
+- if (isatty(fileno(stdin)))
+- usage(nored); /* Mac, if redirected */
+-#else
+ usage(ign);
+-#endif
+-
+- return;
+
+ } /* getargs */
+
+-
+-
+-/*
+- * SETOPTION -- Process an option.
+- */
+-
+-void setoption(const char *optarg)
+-{
+- int j = 0;
+-
+- while (strchr(OPTSET, optch) != NULL) {
+- switch (optch) {
+- case 'h' : usage(ign); break;
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
+- case 'q' : pager = FALSE; break;
+- case 'f' : pager = TRUE; break;
+- case 'F' : pager = TRUE;
+- path = optarg;
+- j = strlen(optarg);
+- break;
+-#endif
+- case 'J' : japan = TRUE; break;
+- case 't' : ttfont = TRUE; break;
+- case 'l' : noffd = TRUE; break;
+- case 's' : scascii = TRUE; break;
+- case 'u' : scascii = FALSE; break;
+- case 'a' : accent = FALSE; break;
+- case 'c' : allchar = TRUE; break;
+- case 'P' : sequenceon = TRUE; /* fall through */
+- case 'p' : if (pageswitchon)
+- usage(onepp);
+- getpages(j, optarg);
+- break;
+- case 'w' : if (getinteger(&ttywidth, &j, optarg))
+- usage(nan);
+- if (optarg[j] != '\0')
+- usage(gae);
+- if ((ttywidth < 16) || (ttywidth > MAXTERMWIDTH))
+- usage(wrnge);
+- break;
+- case 'e' : if (getinteger(&espace, &j, optarg))
+- usage(nan);
+- if (optarg[j] != '\0')
+- usage(gae);
+- break;
+- case 'v' : if (getlong(&lineheight, &j, optarg))
+- usage(nan);
+- if (optarg[j] != '\0')
+- usage(gae);
+- /* lineheight *= 65536L; */
+- /* want to specify in pt, but have no getfloat */
+- break;
+- case 'o' : OUTfilename = optarg;
+- outputtofile = TRUE;
+- j = strlen(optarg);
+- break;
+- case 'b' : printfont = TRUE;
+- delim = optarg;
+- if (!strlen(optarg))
+- printfont = FALSE;
+- break;
+- default : usage(bdopt);
+- }
+- if ((optch = optarg[j++]) == '\0')
+- break;
+- if ( (optarg[j] == '\0') && (strchr(OPTWARG, optch) != NULL) ) {
+- if (--Argc <= 0)
+- usage(noarg);
+- optarg = *++Argv;
+- j = 0;
+- }
+- }
+-
+- return;
+-
+-} /* setoption */
+-
+-
+-
+-/*
+- * GETPAGES -- Getr a list of pages to print.
+- */
++/*---------------------------------------------------------------------------*/
+
+ void getpages(int j, const char *str)
+ {
+@@ -623,19 +516,11 @@
+ }
+ currentpage = firstpage;
+
+- return;
+-
+ } /* getpages */
+
+
+-
+-/*
+- * PLCNXT -- Place page-nr next in list.
+- */
+-
+-void plcnxt(int pagnr)
++void plcnxt(int pagnr) /* place page-nr next in list */
+ {
+-
+ currentpage = lastpage;
+ currentpage->pag = pagnr;
+ lastpage = (printlisttype *) malloc(sizeof(printlisttype));
+@@ -644,10 +529,9 @@
+ lastpage->pag = 0;
+ currentpage->nxt = lastpage;
+
+- return;
+-
+ } /* plcnxt */
+
++/*----------------------------------------------------------------------------*/
+
+ #ifdef KPATHSEA
+ #ifdef __DJGPP__
+@@ -675,13 +559,13 @@
+ ret = NULL;
+ }
+ else {
+- ret = name;
++ ret = (string) name;
+ }
+ #else /* ! WIN32 */
+ struct stat st;
+
+ if (READABLE (name, st)) {
+- ret = name;
++ ret = (string) name;
+
+ } else { /* Some other error. */
+ ret = NULL;
+@@ -692,10 +576,6 @@
+ }
+ #endif
+
+-/*
+- * GETFNAME -- {Make sure we have a .dvi filename.
+- */
+-
+ void getfname(const char *str)
+ {
+ int i;
+@@ -705,23 +585,21 @@
+ usage(ign);
+ strcpy(DVIfilename, str);
+ #ifdef KPATHSEA
+- if (!readable_file(DVIfilename))
++ if (readable_file(DVIfilename))
++ return;
++
++ strcat(DVIfilename, ".dvi");
++
+ #else
+- if ((i < 5) || strcmp(str+i-4, ".dvi"))
+-#endif
++ if (!((i >= 5) && (str[i-1] == 'i') && (str[i-2] == 'v') &&
++ (str[i-3] == 'd') && (str[i-4] == '.'))) {
+ strcat(DVIfilename, ".dvi");
+-
+- return;
++ }
++#endif
+
+ } /* getfname */
+
+-
+-
+-
+-/*
+- * GETINTEGER -- Convert ascii to an integer. I'm sure there is a library
+- * call for it.
+- */
++/*----------------------------------------------------------------------------*/
+
+ int getinteger(int *dest, int *j, const char *str)
+ {
+@@ -736,7 +614,6 @@
+ }
+ else
+ sgn = 1;
+-
+ if ((ch >= '0') && (ch <= '9')) {
+ cum = 0;
+ while ((ch >= '0') && (ch <= '9')) {
+@@ -744,55 +621,13 @@
+ ch = str[++(*j)];
+ }
+ *dest = sgn * cum;
+-
+ return 0; /* return ok */
+ }
+-
+ return 1; /* return error */
+
+ } /* getinteger */
+
+-
+-
+-/*
+- * GETLONG -- Convert ascii to a long. I'm sure there is a library
+- * call for it.
+- */
+-
+-int getlong(long *dest, int *j, const char *str)
+-{
+- long cum;
+- int sgn;
+- char ch;
+-
+- ch = str[*j];
+- if (ch == '-') {
+- sgn = -1;
+- ch = str[++(*j)];
+- }
+- else
+- sgn = 1;
+-
+- if ((ch >= '0') && (ch <= '9')) {
+- cum = 0;
+- while ((ch >= '0') && (ch <= '9')) {
+- cum = cum*10L + ch - '0';
+- ch = str[++(*j)];
+- }
+- *dest = (long) sgn * cum;
+-
+- return 0; /* return ok */
+- }
+-
+- return 1; /* return error */
+-
+-} /* getinteger */
+-
+-
+-
+-/*
+- * ERROREXIT -- Exit program with an erro message.
+- */
++/*----------------------------------------------------------------------------*/
+
+ void errorexit(int errorcode)
+ {
+@@ -839,7 +674,7 @@
+ break;
+ case filcr : fprintf(stderr, "Cannot create outfile\n");
+ break;
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
++#if !defined(MSDOS) && !defined(VMS)
+ case pipcr : fprintf(stderr, "Cannot create pipe to pager\n");
+ break;
+ #endif
+@@ -852,31 +687,23 @@
+ #else
+ unlink(OUTfilename);
+ #endif
+-
+ exit(errorcode);
+
+ } /* errorexit */
+
+-
+-
+-/*
+- * USAGE -- Print the usage info. Also print a warning/error message
+- * if needed.
+- */
++/*----------------------------------------------------------------------------*/
+
+ void usage(int uerr)
+ {
+
+- fprintf(stderr, "%s", Copyright);
+-
+ if (uerr != ign) {
+ fprintf(stderr,"%s: ", progname);
+ switch (uerr) {
+- case wrnge : fprintf(stderr, "width arg out of range:16-%d",
+- MAXTERMWIDTH);
++ case ign : fprintf(stderr, "%s", Copyright);
++ break;
++ case wrnge : fprintf(stderr, "width arg out of range:16-132");
+ break;
+- case nan : fprintf(stderr,
+- "numeric argument expected for option %c",
++ case nan : fprintf(stderr, "numeric argument expected for option %c",
+ optch);
+ break;
+ case gae : fprintf(stderr, "garbage in argument for option %c",
+@@ -886,47 +713,29 @@
+ break;
+ case onef : fprintf(stderr, "only one infile argument allowed");
+ break;
+- case noarg : fprintf(stderr,
+- "option argument expected for option %c",
++ case noarg : fprintf(stderr, "option argument expected for option %c",
+ optch);
+ break;
+ case bdopt : fprintf(stderr, "bad option %c", optch);
+ break;
+ case onepp : fprintf(stderr, "only one pagelist allowed");
+ break;
+-#if defined(THINK_C)
+- case nored : fprintf(stderr, "\nIf no input file is given in\
+- command string,\n\Standard Input must be redirected with the radio button.");
+- break;
+-#endif
+ default : fprintf(stderr, "unknown usage error");
+ break;
+ }
+ fprintf(stderr, "\n");
+ }
+-
+- fprintf(stderr, "\n%s\n\n", dvi2tty);
+-#if defined(THINK_C)
+- fprintf(stderr, "Usage: %s [ options ] [<dvi-file>[.dvi]]\n", progname);
+- fprintf(stderr, "Read input from <dvi-file>, else read from Standard Input,\
+-\nwhich must be redirected by means of the radio button.\n");
+-#else
+- fprintf(stderr, "Usage: %s [ options ] <dvi-file>[.dvi]\n", progname);
+-#endif
++ fprintf(stderr, "Usage: %s [ options ] dvifile[.dvi]\n", progname);
+ fprintf(stderr, "Options are:\n");
+ fprintf(stderr,
+ " -ofile Write output to file, else write to stdout.\n");
+ fprintf(stderr,
+- " -plist Print pages whose TeX-page-number are in list.\n");
++ " -plist Print pages whos TeX-page-number are in list.\n");
+ fprintf(stderr,
+- " -Plist Print pages whose sequential number are in list.\n");
++ " -Plist Print pages whos sequential number are in list.\n");
+ fprintf(stderr,
+ " -wn Print the lines with width n characters, default 80.\n");
+- fprintf(stderr,
+- " -vn Use n for vertical line height, default 450000.\n");
+- fprintf(stderr,
+- " -evalue Add/Substract this value for spacing (-20..20)\n");
+-#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
++#if !defined(MSDOS) && !defined(VMS)
+ fprintf(stderr, " -f Try to pipe to a pager if output is a tty");
+ if (WANTPAGER)
+ fprintf(stderr, " (default).\n");
+@@ -940,23 +749,19 @@
+ fprintf(stderr, " -Fprog Pipe output to pager prog.\n");
+ #endif
+ fprintf(stderr,
+- " -a Remove accents grave etc. from output: \\'{e} -> e.\n");
+- fprintf(stderr,
+- " -t Assuming that document was made with tt fonts\n");
+- fprintf(stderr,
+ " -l Write ''^L'' instead of formfeed between pages.\n");
+ fprintf(stderr,
+- " -u National Swedish/Finnish characters printed as aaoAAO (default %s).\n", DEFSCAND ? "off" : "on");
+- fprintf(stderr,
+- " -s National Swedish/Finnish characters printed as }{|][\\ (default %s).\n", DEFSCAND ? "on" : "off");
+- fprintf(stderr,
+- " -J Allow processing of japanese fonts\n");
+- fprintf(stderr,
+- " -c Override -a -u -s and print all characters 0-255.\n");
++ " -u National Swedish/Finnish characters printed as aaoAAO");
++ if (DEFSCAND)
++ fprintf(stderr, ".\n");
++ else
++ fprintf(stderr, " (default).\n");
+ fprintf(stderr,
+- " -bdelim Print font switch as text: delimcmr10miled\n");
+- fprintf(stderr, " -h This help message.\n");
+-
++ " -s National Swedish/Finnish characters printed as }{|][\\");
++ if (DEFSCAND)
++ fprintf(stderr, " (default).\n");
++ else
++ fprintf(stderr, ".\n");
+ exit(uerr);
+
+ } /* usage */
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.h dvi2tty-5.3.1/dvi2tty.h
+--- dvi2tty-5.3.1.orig/dvi2tty.h 2010-10-22 15:08:40.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.h 2010-10-24 14:29:23.814830452 +0200
+@@ -23,33 +23,28 @@
+
+ #include <stdio.h>
+ #include <string.h>
+-#include <stdlib.h>
++
++#include <sys/types.h>
++#include <sys/stat.h>
++
+ #if defined(MSDOS)
+-# include <malloc.h>
+-#else
+-# if !defined(THINK_C)
+-# include <unistd.h>
+-# endif
++#define DOSISH
++#include <stdlib.h>
++#include <malloc.h>
+ #endif
+
+ #if defined(KPATHSEA)
+ #define NO_DEBUG 1
+ #include <kpathsea/config.h>
+-#include <sys/types.h>
+-#include <sys/stat.h>
+-#else
++#endif
++
++#ifndef KPATHSEA
+ #define TRUE 1
+ #define FALSE 0
+ #endif
+ #define nil NULL
+
+ /*
+- * Define the maximum width of the terminal
+- * (this is also used to define the with of the line structure in dvistuff.c)
+- */
+-#define MAXTERMWIDTH 332
+-
+-/*
+ * ERROR CODES , don't start with 0
+ */
+
+@@ -76,11 +71,7 @@
+ #define pipcr 20 /* cannot creat pipe */
+ #endif
+
+-
+-
+-/*
+- * Type definitions
+- */
++/*---------------------------------------------------------------------------*/
+
+ typedef char bool;
+
+@@ -91,22 +82,13 @@
+ struct prlistptr *nxt; /* next item in list */
+ } printlisttype;
+
+-
+-
+-/*
+- * Variable definitions
+- */
++/*---------------------------------------------------------------------------*/
+
+ extern bool outputtofile; /* output to file or stdout(dvi2tty.c)*/
+ extern bool pageswitchon; /* user-set pages to print(dvistuff.c)*/
+ extern bool sequenceon; /* not TeX pagenrs (dvistuff.c) */
+ extern bool scascii; /* Scand. nat. chars (dvistuff.c) */
+-extern bool accent; /* Output accent stuff(dvistuff.c) */
+-extern bool ttfont; /* tt font assumed (dvistuff.c) */
+-extern bool japan; /* japanes font support (dvistuff.c) */
+ extern bool noffd; /* output ^L or formfeed (dvistuff.c) */
+-extern bool printfont; /* include font switches (dvistuff.c) */
+-extern bool allchar; /* output all characters (dvistuff.c */
+
+ extern printlisttype *currentpage; /* current page to print (dvi2tty.c) */
+ extern printlisttype *firstpage; /* first page selected (dvi2tty.c) */
+@@ -115,29 +97,15 @@
+ extern int ttywidth; /* screen width (dvi2tty.c) */
+ extern int espace; /* extra screen width (dvi2tty.c) */
+ extern long foo; /* temporary 'register' (dvi2tty.c) */
+-extern long lineheight; /* height of a line (dvistuff.c) */
+ extern int opcode; /* dvi opcode (dvistuff.c) */
+-extern char * delim; /* printer font delim (dvistuff.c) */
+
+ extern FILE *DVIfile; /* dvi file (dvi2tty.c) */
+ extern FILE *output; /* output file (dvi2tty.c) */
+
+-
+-
+-/*
+- * Funtion declarations
+- */
++/*---------------------------------------------------------------------------*/
+
+ /* dvi2tty.c */
+-#if defined(MSDOS)
+ void errorexit(int);
+-#else
+-void errorexit(int errorcode);
+-#endif
+
+ /* dvistuff.c */
+-#if defined(MSDOS)
+-void dvimain(void);
+-#else
+ void dvimain(void);
+-#endif
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2010-10-23 19:03:03.000000000 +0200
++++ dvi2tty-5.3.1/dvistuff.c 2010-10-24 15:01:30.719544412 +0200
+@@ -23,23 +23,15 @@
+ */
+
+ #include "dvi2tty.h"
+-
++#include <sys/types.h>
++#include <sys/stat.h>
+ #if defined(VMS)
+-# include types.h
+-# include stat
+-#else
+-# if defined(THINK_C)
+-# include <unix.h>
+-# else
+-# include <sys/types.h>
+-# include <sys/stat.h>
+-# endif
++#include types.h
++#include stat
+ #endif
+-
+-#if defined(MSDOS) || defined(THINK_C)
+-# include <math.h>
++#if defined(MSDOS)
++#include <math.h>
+ #endif
+-
+ #include "commands.h"
+
+
+@@ -58,10 +50,9 @@
+ #define VERSIONID 2 /* dvi version number that pgm handles */
+ #define VERTICALEPSILON 450000L /* crlf when increasing v more than this */
+
+-#define rightmargin MAXTERMWIDTH+20
+- /* nr of columns allowed to the right of h=0*/
++#define rightmargin 152 /* nr of columns allowed to the right of h=0*/
+ #define leftmargin -50 /* give some room for negative h-coordinate */
+-#define LINELEN rightmargin - leftmargin + 1
++#define LINELEN 203 /* rightmargin - leftmargin + 1 */
+
+ #define MOVE TRUE /* if advancing h when outputing a rule */
+ #define STAY FALSE /* if not advancing h when outputing a rule */
+@@ -125,17 +116,7 @@
+ bool pageswitchon; /* true if user-set pages to print */
+ bool sequenceon; /* false if pagesw-nrs refers to TeX-nrs */
+ bool scascii; /* if true make Scand. nat. chars right */
+-bool accent; /* if true output accents etc: \'{e} etc. */
+-bool ttfont = FALSE; /* if true we assumed ttfonts, not cmr */
+-bool symbolfont = FALSE; /* true if font is a symbol font */
+-bool japan = FALSE; /* switch to japanese fonts ... */
+-bool mifont = FALSE;
+-int jfontnum = 0;
+ bool noffd; /* if true output ^L instead of formfeed */
+-char * delim; /* -bdelim for font switch printing */
+-bool printfont; /* true if user wants font switches printed */
+-bool allchar; /* true if user sets all characters */
+- /* overrides sscasci, accent */
+
+ int opcode; /* dvi-opcodes */
+
+@@ -149,8 +130,6 @@
+
+ long maxpagewidth; /* width of widest page in file */
+ long charwidth; /* aprox width of character */
+-long lineheight = VERTICALEPSILON;
+- /* aprox height of a line */
+
+ linetype * currentline; /* pointer to current line on current page */
+ linetype * firstline; /* pointer to first line on current page */
+@@ -161,6 +140,7 @@
+ int sptr; /* stack pointer */
+
+ font * fonts = NULL; /* List of fontnames defined */
++int symbolfont = FALSE; /* true if font is a symbol font */
+
+
+
+@@ -168,7 +148,7 @@
+ * Function definitions
+ */
+
+-#if defined(MSDOS)
++#if defined(KPATHSEA) || defined(MSDOS)
+ void postamble (void);
+ void preamble (void);
+ void walkpages (void);
+@@ -193,38 +173,31 @@
+ void setchar (long);
+ void fontdef (int);
+ void setfont (long);
+-void jischar (long);
+-int compute_jis (int, int, int *, int *);
+-int getjsubfont (char *);
+-
+ #else
+-void postamble (void);
+-void preamble (void);
+-void walkpages (void);
+-void initpage (void);
+-void dopage (void);
+-void skippage (void);
+-void printpage (void);
+-bool inlist (long pagenr);
+-void rule (bool moving, long rulewt, long ruleht);
+-void ruleaux (long rulewt, long ruleht, char ch);
+-long horizontalmove (long amount);
+-int skipnops (void);
+-linetype * texlive_getline (void);
+-linetype * findline (void);
+-unsigned long num (int size);
+-long snum (int size);
+-void dochar (char ch);
+-void symchar (char ch);
+-void normchar (char ch);
+-void outchar (unsigned char ch);
+-void putcharacter (long charnr);
+-void setchar (long charnr);
+-void fontdef (int x);
+-void setfont (long fntnum);
+-void jischar (long charnr);
+-void compute_jis (int f, int c, int * ku, int * ten);
+-int getjsubfont (char * s);
++void postamble ();
++void preamble ();
++void walkpages ();
++void initpage ();
++void dopage ();
++void skippage ();
++void printpage ();
++bool inlist ();
++void rule ();
++void ruleaux ();
++long horizontalmove ();
++int skipnops ();
++linetype * texlive_getline ();
++linetype * findline ();
++unsigned long num ();
++long snum ();
++void dochar ();
++void symchar ();
++void normchar ();
++void outchar ();
++void putcharacter ();
++void setchar ();
++void fontdef ();
++void setfont ();
+ #if defined(VMS)
+ long vmsseek ();
+ long vms_ftell ();
+@@ -249,8 +222,8 @@
+ /* note that walkpages *must* immediately follow preamble */
+ walkpages(); /* time to do the actual work! */
+
+- return;
+-
++- return;
++-
+ } /* dvimain */
+
+
+@@ -340,26 +313,30 @@
+
+ pagecounter = 0L;
+ while ((opcode = skipnops()) != POST) {
+-
+ if (opcode != BOP) /* should be at start of page now */
+ errorexit(nobop);
++ else {
++ pagecounter++;
++ pagenr = sget4(); /* get TeX page number */
++ mseek(DVIfile, 36L, relative); /* skip page header */
++ backpointer = sget4(); /* get previous page offset */
++ if (pageswitchon)
++ if (sequenceon)
++ wantpage = inlist(pagecounter);
++ else
++ wantpage = inlist(pagenr);
++ else
++ wantpage = TRUE;
+
+- pagecounter++;
+- pagenr = sget4(); /* get TeX page number */
+- mseek(DVIfile, 36L, relative); /* skip page header */
+- backpointer = sget4(); /* get previous page offset */
+- if (pageswitchon)
+- wantpage = inlist(sequenceon ? pagecounter : pagenr);
+- else
+- wantpage = TRUE;
+-
+- if (wantpage) {
+- initpage();
+- dopage();
+- printpage();
+- }
+- else
++ if (wantpage) {
++ initpage();
++ dopage();
++ printpage();
++ }
++ else {
+ skippage();
++ }
++ }
+ }
+
+ return;
+@@ -417,12 +394,12 @@
+ if (opcode <= LASTCHAR)
+ dochar((char) opcode);
+ else if ((opcode >= FONT_00) && (opcode <= FONT_63))
+- setfont((long) opcode - FONT_00);
++ setfont(opcode - FONT_00);
+ else if (opcode > POST_POST)
+ errorexit(illop);
+ else
+ switch (opcode) {
+- case SET1 : japan ? jischar(get1()) : setchar(get1());break;
++ case SET1 : setchar(get1()); break;
+ case SET2 : setchar(get2()); break;
+ case SET3 : setchar(get3()); break;
+ case SET4 : setchar(get4()); break;
+@@ -599,9 +576,9 @@
+ for (currentline = firstline; currentline != nil;
+ currentline = currentline->next) {
+ if (currentline != firstline) {
+- foo = ((currentline->vv - currentline->prev->vv)/lineheight)-1;
++ foo = ((currentline->vv - currentline->prev->vv)/VERTICALEPSILON)-1;
+ if (foo > 3)
+- foo = 3; /* linespacings not too large */
++ foo = 3; /* linespacings not too large */
+ for (i = 1; i <= (int) foo; i++)
+ putc('\n', output);
+ }
+@@ -610,7 +587,7 @@
+ for (i = firstcolumn, j = 1; i <= currentline->charactercount;
+ i++, j++) {
+ ch = currentline->text[i - leftmargin];
+- if (ch >= SPACE || allchar)
++ if (ch >= SPACE)
+ putc(ch, output);
+ if ((j > (int) foo) && (currentline->charactercount > i+1)) {
+ fprintf(output, "*\n"); /* if line to large */
+@@ -681,7 +658,7 @@
+ savev = v;
+ if ((ruleht / rulewt) > 0) /* value < 1 truncates to 0 */
+ ch = '|';
+- else if (ruleht > (lineheight / 2))
++ else if (ruleht > (VERTICALEPSILON / 2))
+ ch = '=';
+ else
+ ch = '_';
+@@ -716,11 +693,11 @@
+ outchar(ch);
+ wt -= (h-rmh); /* decrease the width left on line */
+ }
+- ruleht -= lineheight; /* decrease the height */
+- if (ruleht > lineheight) { /* still more vertical? */
++ ruleht -= VERTICALEPSILON; /* decrease the height */
++ if (ruleht > VERTICALEPSILON) { /* still more vertical? */
+ rmh = h; /* save current h (right margin) */
+ h = lmh; /* restore left margin */
+- v -= (lineheight + lineheight / 10);
++ v -= (VERTICALEPSILON + VERTICALEPSILON / 10);
+ ruleaux(rulewt, ruleht, ch);
+ h = rmh; /* restore right margin */
+ }
+@@ -813,7 +790,7 @@
+ register long topd, botd;
+
+ if (v <= firstline->vv) { /* above first line */
+- if (firstline->vv - v > lineheight) {
++ if (firstline->vv - v > VERTICALEPSILON) {
+ temp = texlive_getline();
+ temp->next = firstline;
+ firstline->prev = temp;
+@@ -824,7 +801,7 @@
+ }
+
+ if (v >= lastline->vv) { /* below last line */
+- if (v - lastline->vv > lineheight) {
++ if (v - lastline->vv > VERTICALEPSILON) {
+ temp = texlive_getline();
+ temp->prev = lastline;
+ lastline->next = temp;
+@@ -841,7 +818,7 @@
+ /* temp->vv < v < temp->next->vv --- temp is above, temp->next is below */
+ topd = v - temp->vv;
+ botd = temp->next->vv - v;
+- if ((topd < lineheight) || (botd < lineheight)) {
++ if ((topd < VERTICALEPSILON) || (botd < VERTICALEPSILON)) {
+ if (topd < botd) /* take best fit */
+ return temp;
+ else
+@@ -886,7 +863,7 @@
+ long snum(int size)
+ {
+ register int i;
+- register long x;
++ register long x = 0;
+
+ x = getc(DVIfile);
+ if (x & 0x80)
+@@ -906,10 +883,8 @@
+
+ void dochar(char ch)
+ {
+-
+- if (japan && jfontnum)
+- jischar((long) ch);
+- else if (symbolfont == TRUE)
++
++ if (symbolfont == TRUE)
+ symchar(ch);
+ else
+ normchar(ch);
+@@ -936,8 +911,6 @@
+ case 14: ch = 'O'; break;
+ case 15: ch = 'o'; break;
+ case 24: ch = '~'; break;
+- case 32: ch = japan ? '<' : 32; break; /* really only for japan? */
+- case 33: ch = japan ? '>' : 33; break; /* really only for japan? */
+ case 102: ch = '{'; break;
+ case 103: ch = '}'; break;
+ case 104: ch = '<'; break;
+@@ -962,104 +935,58 @@
+ {
+
+ switch (ch) {
+- case 11 : if (ttfont)
+- ch = '^'; /* up symbol */
+- else if (!allchar) {
+- outchar('f'); ch = 'f'; /* ligature */
+- }
+- break;
+- case 12 : if (ttfont)
+- ch = 'v'; /* low symbol */
+- else if (!allchar) {
+- outchar('f'); ch = 'i'; /* ligature */
+- }
++ case 11 : outchar('f'); ch = 'f'; break; /* ligature */
++ case 12 : outchar('f'); ch = 'i'; break; /* ligature */
++ case 13 : outchar('f'); ch = 'l'; break; /* ligature */
++ case 14 : outchar('f'); outchar('f');
++ ch = 'i'; break; /* ligature */
++ case 15 : outchar('f'); outchar('f');
++ ch = 'l'; break; /* ligature */
++ case 16 : ch = 'i'; break;
++ case 17 : ch = 'j'; break;
++ case 25 : if (scascii) /* German sz ligature */
++ ch = 0xdf;
++ else
++ {outchar('s'); ch = 's';}
+ break;
+- case 13 : if (ttfont)
+- ch = '`';
+- else if (!allchar) {
+- outchar('f'); ch = 'l'; /* ligature */
+- }
+- break;
+- case 14 : if (ttfont)
+- ch = 'i'; /* spanish ! */
+- else if (!allchar) {
+- outchar('f'); outchar('f');
+- ch = 'i'; /* ligature */
+- }
++ case 26 : if (scascii) /* Dane/Norw ae */
++ ch = 0xe6;
++ else
++ {outchar('a'); ch = 'e';}
+ break;
+- case 15 : if (ttfont)
+- ch = '.'; /* spanish ? */
+- else if (!allchar) {
+- outchar('f'); outchar('f');
+- ch = 'l'; /* ligature */
+- }
++ case 27 : outchar('o'); ch = 'e'; break; /* Dane/Norw oe */
++ case 28 : if (scascii) /* Dane/Norw /o */
++ ch = 0xf8;
++ else
++ ch = 'o';
+ break;
+- case 16 : if (!allchar) ch = 'i'; break;
+- case 17 : if (!allchar) ch = 'j'; break;
+- case 25 : if (!allchar) {
+- outchar('s');
+- ch = 's';
+- }
+- break; /* German double s */
+- case 26 : if (!allchar) {
+- outchar('a');
+- ch = 'e';
+- }
+- break; /* Dane/Norw ae */
+- case 27 : if (!allchar) {
+- outchar('o');
+- ch = 'e';
+- }
+- break; /* Dane/Norw oe */
+- case 28 : if (!allchar) {
+- if (scascii)
+- ch = '|'; /* Dane/Norw /o */
+- else
+- ch = 'o';
+- }
++ case 29 : if (scascii) /* Dane/Norw AE */
++ ch = 0xc6;
++ else
++ {outchar('A'); ch = 'E';}
+ break;
+- case 29 : if (!allchar) {
+- outchar('A');
+- ch = 'E';
+- }
+- break; /* Dane/Norw AE */
+- case 30 : if (!allchar) {
+- outchar('O');
+- ch = 'E';
+- }
+- break; /* Dane/Norw OE */
+- case 31 : if (!allchar) {
+- if (scascii)
+- ch = '\\'; /* Dane/Norw /O */
+- else
+- ch = 'O';
+- }
++ case 30 : outchar('O'); ch = 'E'; break; /* Dane/Norw OE */
++ case 31 : if (scascii)
++ ch = 0xd8; /* Dane/Norw /O */
++ else
++ ch = 'O';
+ break;
+- case 32 : ch = allchar || ttfont ? ch : '_'; break;
+- /* underlined blank */
+- case 58 : ch = allchar || !mifont ? ch : '.'; break; /* if japan */
+- case 59 : ch = allchar || !mifont ? ch : ','; break; /* if japan */
+- case 92 : ch = allchar || ttfont ? ch : '"'; break; /* \ from `` */
+- case 123 : ch = allchar || ttfont ? ch : '-'; break; /* { from -- */
+- case 124 : ch = allchar || ttfont ? ch : '_'; break; /* | from --- */
+- case 125 : ch = allchar || ttfont ? ch : '"'; break; /* } from \H */
+- case 126 : ch = allchar || ttfont ? ch : '"'; break; /* ~ from \~ */
+- case 127 : if (!allchar) ch = '"'; break; /* DEL from \" */
+-
+- /*
+- * Or should I use SPACE for non-accents ???
+- * This seems to work ...
+- */
+- case 18 : ch = !allchar && accent ? '`' : ch; break; /* from \` */
+- case 19 : ch = !allchar && accent ? 0x27 : ch; break; /* from \' */
+- case 20 : ch = !allchar && accent ? '~' : ch; break; /* from \v */
+- case 21 : ch = !allchar && accent ? '~' : ch; break; /* from \u */
+- case 22 : ch = !allchar && accent ? '~' : ch; break; /* from \= */
+- case 24 : ch = !allchar && accent ? ',' : ch; break; /* from \c */
+- case 94 : ch = (!allchar && accent && !ttfont) ? '^' : ch; break;
+- /* ^ from \^ */
+- case 95 : ch = (!allchar && accent && !ttfont) ? '`' : ch; break;
+- /* _ from \. */
++ case 92 : ch = '"'; break; /* \ from `` */
++ case 123 : ch = '-'; break; /* { from -- */
++ case 124 : ch = '_'; break; /* | from --- */
++ case 125 : ch = '"'; break; /* } from \H */
++ case 126 : ch = '"'; break; /* ~ from \~ */
++ case 127 : ch = '"'; break; /* DEL from \" */
++#if 0
++ case 18 : ch = '`'; break /* from \` */
++ case 19 : ch = ''''; break /* from \' */
++ case 20 : ch = '~'; break /* from \v */
++ case 21 : ch = '~'; break /* from \u */
++ case 22 : ch = '~'; break /* from \= */
++ case 24 : ch = ','; break /* from \c */
++ case 94 : ch = '^'; break /* ^ from \^ */
++ case 95 : ch = '`'; break /* _ from \. */
++#endif
+ }
+ outchar(ch);
+
+@@ -1080,12 +1007,10 @@
+ {
+ register int i, j;
+
+-/* fprintf(stderr, "hor: %ld, ver: %ld\n", h, v); */
+-
+-#if defined(MSDOS) || defined(THINK_C)
+- if (labs(v - currentline->vv) > lineheight / 2L)
++#if defined(MSDOS)
++ if (labs(v - currentline->vv) > VERTICALEPSILON / 2L)
+ #else
+- if (abs(v - currentline->vv) > lineheight / 2L)
++ if (abs(v - currentline->vv) > VERTICALEPSILON / 2L)
+ #endif
+ currentline = findline();
+
+@@ -1119,15 +1044,14 @@
+ for (i = IMAX(leftmargin, j-2);
+ i <= IMIN(rightmargin, j+2);
+ i++)
+- if ((currentline->text[i - leftmargin] == 127) || /* DEL */
+- (currentline->text[i - leftmargin] == 34) || /* " */
++ if ((currentline->text[i - leftmargin] == 127) ||
++ (currentline->text[i - leftmargin] == 34) ||
+ (currentline->text[i - leftmargin] == 23))
+ foo = i;
+ if (foo >= leftmargin) {
+ j = (int) foo;
+ switch (currentline->text[j - leftmargin]) {
+- case 127 :
+- case 34 : /* DEL or " */
++ case 127 : case 34:
+ if (ch == 'a')
+ ch = 0xe4;
+ else if (ch == 'A') /* dots ... */
+@@ -1151,16 +1075,15 @@
+ }
+ }
+ /*----------------- end of 'Scandinavian code' ----------------*/
+-
+ if (foo == leftmargin-1)
+ while ((currentline->text[j - leftmargin] != SPACE)
+ && (j < rightmargin)) {
+ j++;
+ h += charwidth;
+ }
+- if ( allchar || ((ch >= SPACE) && (ch != DEL)) ||
++ if ( ((ch >= SPACE) && (ch != DEL)) ||
+ (scascii && (ch == 23)) ) {
+- /* (scascii && (ch == DEL)) ) if VMS ??? */
++ /* (scascii && (ch == DEL)) ) { if VMS ??? */
+ if (j < rightmargin)
+ currentline->text[j - leftmargin] = ch;
+ else
+@@ -1187,9 +1110,7 @@
+ register long saveh;
+
+ saveh = h;
+- if (japan)
+- dochar((char) charnr);
+- else if (allchar || ((charnr >= 0) && (charnr <= LASTCHAR)))
++ if ((charnr >= 0) && (charnr <= LASTCHAR))
+ outchar((char) charnr);
+ else
+ setchar(charnr);
+@@ -1210,7 +1131,7 @@
+ void setchar(long charnr)
+ {
+
+- outchar(allchar ? (unsigned char)charnr : '#');
++ outchar((unsigned char)(charnr));
+
+ return;
+
+@@ -1280,147 +1201,29 @@
+ {
+ font * fnt;
+ char * s;
+- char * d;
+
+ fnt = fonts;
+ while (fnt != NULL && fnt->num != fntnum)
+ fnt = fnt->next;
+- symbolfont = FALSE;
+- ttfont = FALSE;
+- mifont = FALSE;
+- jfontnum = 0;
+ if (fnt == NULL) {
+ /* error : font not found */
++ symbolfont = FALSE;
+ return;
+ }
+
+ s = fnt->name;
+- d = delim; /* print delim and font name if -b was chosen */
+- if (printfont) {
+- while (*d !=0) {putcharacter(*d); d++;}
+- d = s;
+- while (*d !=0) {putcharacter(*d); d++;}
+- /* d = strrev(delim); */
+- while (*d !=0) {putcharacter(*d); d++;}
+- }
+-
+- if (japan)
+- jfontnum = getjsubfont(s);
+- if (jfontnum == 0) {
+- while ((s = strchr(s, 's')) != NULL) {
+- if (strncmp("sy", s, 2) == 0) {
+- symbolfont = TRUE;
+- break;
+- }
+- s++; /* New line to fix bug; font names with 's' would hang */
+- }
+-
+- s = fnt->name;
+- while ((s = strchr(s, 't')) != NULL) {
+- if (strncmp("tt", s, 2) == 0) {
+- ttfont = TRUE;
+- break;
+- }
+- s++; /* New line to fix bug; font names with 's' would hang */
+- }
+-
+- s = fnt->name;
+- while ((s = strchr(s, 'm')) != NULL) {
+- if (strncmp("mi", s, 2) == 0) {
+- mifont = TRUE;
+- break;
+- }
+- s++; /* New line to fix bug; font names with 's' would hang */
++ while ((s = strchr(s, 's')) != NULL) {
++ if (strncmp("sy", s, 2) == 0) {
++ symbolfont = TRUE;
++ return;
+ }
++ s++; /* New line to fix bug; font names with 's' would hang */
+ }
+
+-
++ symbolfont = FALSE;
+ return;
+
+ } /* setfont */
+-
+-
+-
+-void jischar(long charnr)
+-{
+- int Ku, Ten;
+-
+- compute_jis(jfontnum, (int) charnr, &Ku, &Ten);
+- outchar(Ku+128);
+- outchar(Ten+128);
+-
+- return;
+-
+-} /* jischar */
+-
+-#define kushift(c) c+0x20
+-#define tenshift(c) c+0x20
+-
+-void compute_jis(int f, int c, int *ku, int *ten)
+-{
+- int n;
+-
+- if (f <= 7) {
+- if (f == 1) {
+- if (c >= 100) {
+- *ku = kushift(2);
+- *ten = tenshift(c-100);
+- }
+- else {
+- *ku = kushift(1);
+- *ten = tenshift(c);
+- }
+- }
+- else if (f == 2) {
+- *ku = kushift(3);
+- *ten = tenshift(c-32);
+- }
+- else {
+- *ku = kushift(f+1);
+- *ten = tenshift(c);
+- }
+- }
+- else if (f <= 19) { /* Daiichi Suijun */
+- n = (f-8)*256+c;
+- *ku = kushift((n/94)+16);
+- *ten = tenshift((n%94)+1);
+- }
+- else { /* Daini Suijun */
+- n = (f-20)*256+c;
+- *ku = kushift((n/94)+48);
+- *ten = tenshift((n%94)+1);
+- }
+-
+- return;
+-
+-} /* compute_jis */
+-
+-
+-#define NJSUBS 33
+-char *jsf_names[]={
+- "jsy", "jroma", "jhira", "jkata", "jgreek", "jrussian", "jkeisen",
+- "jka", "jkb", "jkc", "jkd", "jke", "jkf", "jkg", "jkh", "jki", "jkj",
+- "jkk", "jkl", "jkm", "jkn", "jko", "jkp", "jkq", "jkr", "jks", "jkt",
+- "jku", "jkv", "jkw", "jkx", "jky", "jkz"
+-};
+-
+-
+-int getjsubfont(char *s)
+-{
+- int jf;
+-
+- if (s[0] == 'd' && (s[1] == 'm' || s[1] == 'g')) {
+- for (jf = 0; jf < NJSUBS; jf++) {
+- if (strncmp(&s[2], jsf_names[jf], strlen(jsf_names[jf])) == 0)
+- return jf+1;
+- }
+- return 0;
+- }
+- else
+- return 0;
+-
+-} /* getjsubfont */
+-
+
+
+
+@@ -1429,10 +1232,7 @@
+ */
+
+ #if defined(VMS)
+-long vmsseek(fp,n,dir)
+-FILE *fp;
+-long n;
+-long dir;
++long vmsseek(FILE *fp, long n, long dir)
+ {
+ long k,m,pos,val,oldpos;
+ struct stat buffer;
+@@ -1484,8 +1284,7 @@
+
+
+
+-long vms_ftell(fp)
+-FILE *fp;
++long vms_ftell(FILE *fp)
+ {
+ char c;
+ long pos;
+@@ -1507,9 +1306,7 @@
+
+
+
+-long vms_ungetc(c,fp)
+-char c;
+-FILE *fp;
++long vms_ungetc(char c, FILE *fp)
+ {
+
+ if ((c == EOF) && feof(fp))
diff --git a/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-91-undo-rest b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-91-undo-rest
new file mode 100644
index 00000000000..e79c8251ec2
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-5.3.1-PATCHES/patch-91-undo-rest
@@ -0,0 +1,1630 @@
+diff -ur dvi2tty-5.3.1.orig/commands.h dvi2tty-5.3.1/commands.h
+--- dvi2tty-5.3.1.orig/commands.h 2010-10-20 11:34:16.000000000 +0200
++++ dvi2tty-5.3.1/commands.h 2010-10-15 11:34:23.000000000 +0200
+@@ -1,23 +1,3 @@
+-/*
+- * dvi2tty
+- * Copyright (C) 2003 Marcel J.E. Mol <marcel@mesa.nl>
+- *
+- * This program is free software; you can redistribute it and/or
+- * modify it under the terms of the GNU General Public License
+- * as published by the Free Software Foundation; either version 2
+- * of the License, or (at your option) any later version.
+- *
+- * This program is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with this program; if not, write to the Free Software
+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+- *
+- */
+-
+ /* DVI COMMANDS */
+ #define SETC_000 0 /* typeset character 0 and move right */
+ #define SETC_127 127 /* typeset character 127 and move right */
+diff -ur dvi2tty-5.3.1.orig/disdvi.c dvi2tty-5.3.1/disdvi.c
+--- dvi2tty-5.3.1.orig/disdvi.c 2010-10-24 14:03:20.000000000 +0200
++++ dvi2tty-5.3.1/disdvi.c 2010-10-15 11:36:32.000000000 +0200
+@@ -3,73 +3,34 @@
+ /* disdvi --- disassembles TeX dvi files. */
+ /* */
+ /* */
+-/* 2.25 23jan2003 M.J.E. Mol fixed bug in copying font name (name[i]) */
+-/* 2.24 27may96 M.J.E. Mol A few typecasts added */
+-/* 2.23 23jul95 M.J.E. Mol Cleanups from duz@roxi.ez.fht-mannheim.de */
+-/* 2.22 13dec90 M.J.E. Mol Fixed bug in num(). Cleaned up code. */
+-/* 2.21 03may90 M.J.E. Mol Created usage(). */
+-/* 2.2 02may90 M.J.E. Mol Included port to VAX/VMS VAXC by */
+-/* Robert Schneider. */
+-/* 2.1 19jan90 M.J.E. Mol Maintain a list of fonts and */
++/* 2.0 23/01/89 M.J.E. Mol (c) 1989 marcel@duteca.tudelft.nl */
++/* 2.1 19/01/90 M.J.E. Mol Maintain a list of fonts and */
+ /* show fontnames in font changes. */
+ /* Show character code when printing ligatures */
+-/* 2.0 23jan89 M.J.E. Mol (c) 1989 */
+-/* marcel@mesa.nl */
++/* */
+ /* */
+ /*****************************************************************************/
+
+-/*
+- * dvi2tty
+- * Copyright (C) 2003 Marcel J.E. Mol <marcel@mesa.nl>
+- *
+- * This program is free software; you can redistribute it and/or
+- * modify it under the terms of the GNU General Public License
+- * as published by the Free Software Foundation; either version 2
+- * of the License, or (at your option) any later version.
+- *
+- * This program is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with this program; if not, write to the Free Software
+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+- *
+- */
+-
+-char *disdvi = "@(#) disdvi.c 2.25 23jan2003 M.J.E. Mol (c) 1989-1996, marcel@mesa.nl";
+-
+-/*
+- * Include files
+- */
+
+-#include <stdio.h>
+-#include <stdlib.h>
+-#if defined(MSDOS)
+-# include <fcntl.h>
+-#else
+-# if !defined(THINK_C) /* Macintosh */
+-# include <unistd.h>
+-# endif
++#if 0
++char *disdvi = "@(#) disdvi.c 2.1 19/01/90 M.J.E. Mol (c) 1989, 1990";
+ #endif
++
++#include <stdio.h>
+ #include <ctype.h>
+-#include <string.h>
+ #include "commands.h"
+-#if defined(THINK_C)
+-# include "macintosh.h"
+-#endif
+
+ #if defined(KPATHSEA)
+ #define NO_DEBUG 1
+ #include <kpathsea/config.h>
+ #include <kpathsea/lib.h>
++#else
++#if defined(MSDOS)
++#include <stdlib.h>
++#include <string.h>
++#include <fcntl.h>
++#endif
+ #endif
+-
+-
+-/*
+- * Constant definitions
+- */
+
+ #define LASTCHAR 127 /* max dvi character, above are commands */
+
+@@ -82,100 +43,80 @@
+ #define sget3() snum(3)
+ #define sget4() snum(4)
+
+-
+-
+-/*
+- * Type definitions
+- */
+-
+ typedef struct _font {
+ long num;
+ struct _font * next;
+ char * name;
+ } font;
+
+-
+-
+-/*
+- * Variable declarations
+- */
+-
+ font * fonts = NULL;
+ FILE * dvifp;
+ char * dvi_name;
+ long pc = 0;
+
+-char * progname;
+-
+ int is_ptex = 0;
+ int is_xetex = 0;
+ const char * dvi_ext = ".dvi";
+
+-/*
+- * Function declarations
+- */
+-
+-#if !defined(THINK_C)
++#ifdef KPATHSEA
++extern void bop(void);
++extern void postamble(void);
++extern void preamble(void);
++extern void postpostamble(void);
++extern void special(int x);
++extern void fontdef(int x);
++extern const char *fontname(long fntnum);
++extern void printnonprint(int ch);
++extern unsigned long num(int size);
++extern long snum(int size);
++extern void picfile(int opcode);
++extern void natfontdef(int opcode);
++extern void glyphs(int opcode);
++extern void dvidir(int opcode);
++extern void invalid(int opcode);
++#else
+ char * malloc ();
+-#endif
+
+-#if defined(VMS)
+- main (int argc, char ** argv);
++int main ();
++void bop ();
++void preamble ();
++void postamble ();
++void postpostamble ();
++void fontdef ();
++char * fontname ();
++void special ();
++void printnonprint ();
++unsigned long num ();
++long snum ();
++void picfile ();
++void natfontdef ();
++void glyphs ();
++void dvidir ();
++void invalid ();
+ #endif
+-void bop (void);
+-void preamble (void);
+-void postamble (void);
+-void postpostamble (void);
+-void fontdef (int x);
+-const char * fontname (unsigned long fntnum);
+-void special (int x);
+-void printnonprint (int ch);
+-unsigned long num (int size);
+-long snum (int size);
+-void usage (void);
+-void picfile (int opcode);
+-void natfontdef (int opcode);
+-void glyphs (int opcode);
+-void dvidir (int opcode);
+-void invalid (int opcode);
+-
+
+
+
+-/*
+- * MAIN --
+- */
++/*---------------------------------------------------------------------------*/
+
+-#if defined(VMS)
+- main(int argc, char **argv)
+-#else
+ int main(int argc, char **argv)
+-#endif
+ {
+ register int opcode; /* dvi opcode */
+ register int i;
+ int fontnum;
++ char * progname;
+
+-#if defined(THINK_C)
+- argc = process_disdvi_command_line(&argv);
+-#endif
+-
++ progname = *argv;
+
+- progname = *argv++;
+-
+- if ((argc > 1) && (*argv[0] == '-')) {
+- if (!strcmp(*argv, "-h")) {
+- usage();
+- exit(0);
+- }
+- if (!strcmp(*argv, "-p"))
++ if ((argc > 1) && (argv[1][0] == '-')) {
++ if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "--ptex")) {
+ is_ptex = 1;
+- else if (!strcmp(*argv, "-x")) {
++ } else if (!strcmp(argv[1], "-x") || !strcmp(argv[1], "--xetex")) {
+ is_xetex = 1;
+ dvi_ext = ".xdv";
+ } else {
+- fprintf(stderr, "Invalid option `%s'\n", *argv);
+- usage();
++ fprintf(stderr, "Invalid option `%s'\n", argv[1]);
++ fprintf(stderr, "Usage: %s [-p|--ptex|-x|--xetex] [dvi-file]\n", progname);
+ exit(3);
+ }
+ argv++;
+@@ -184,21 +125,21 @@
+
+ if (argc > 2) {
+ fprintf(stderr, "To many arguments\n");
+- usage();
++ fprintf(stderr, "Usage: %s [-p|--ptex|-x|--xetex] [dvi-file]\n", progname);
+ exit(1);
+ }
+
+ if (argc == 2) {
+- if ((i = strlen(*argv)) == 0) {
++ if ((i = strlen(argv[1])) == 0) {
+ fprintf(stderr, "Illegal empty filename\n");
+- usage();
++ fprintf(stderr, "Usage: %s [-p|--ptex|-x|--xetex] [dvi-file]\n", progname);
+ exit(2);
+ }
+- if ((i >= 5) && (!strcmp(*argv+i-4, dvi_ext)))
+- dvi_name = *argv;
++ if ((i >= 5) && !strcmp(argv[1]+(i-4), dvi_ext))
++ dvi_name = argv[1];
+ else {
+ dvi_name = malloc((i+5) * sizeof(char));
+- strcpy(dvi_name, *argv);
++ strcpy(dvi_name, argv[1]);
+ strcat(dvi_name, dvi_ext);
+ }
+ if ((dvifp = fopen(dvi_name, "r")) == NULL) {
+@@ -325,22 +266,19 @@
+ }
+ }
+
+- exit(0);
+-
++ return 0;
+ } /* main */
+
+
++/*----------------------------------------------------------------------------*/
+
+-/*
+- * BOP -- Process beginning of page.
+- */
+
+ void bop(void)
+ {
+ int i;
+
+ printf("BOP page number : %ld", sget4());
+- for (i=9; i > 0; i--) {
++ for (i=0; i < 9; i++) {
+ if (i % 3 == 0)
+ printf("\n%06ld: ", pc);
+ printf(" %6ld", sget4());
+@@ -348,15 +286,10 @@
+ printf("\n%06ld: ", pc);
+ printf(" prev page offset : %06ld\n", sget4());
+
+- return;
+-
+ } /* bop */
+
+
+-
+-/*
+- * POSTAMBLE -- Process post amble.
+- */
++/*---------------------------------------------------------------------------*/
+
+ void postamble(void)
+ {
+@@ -377,16 +310,8 @@
+ printf("%06ld: ", pc);
+ printf(" number of pages : %d\n", (int) get2());
+
+- return;
+-
+ } /* postamble */
+
+-
+-
+-/*
+- * PREAMBLE -- Process pre amble.
+- */
+-
+ void preamble(void)
+ {
+ register int i;
+@@ -405,16 +330,9 @@
+ putchar((int) get1());
+ putchar('\n');
+
+- return;
+-
+ } /* preamble */
+
+
+-
+-/*
+- * POSTPOSTAMBLE -- Process post post amble.
+- */
+-
+ void postpostamble(void)
+ {
+ register int i;
+@@ -432,38 +350,27 @@
+ i = (int) get1();
+ }
+
+- return;
+-
+ } /* postpostamble */
+
+
+
+-/*
+- * SPECIAL -- Process special opcode.
+- */
+-
+-void special(int x)
++void special(register int x)
+ {
+ register long len;
++ register long i;
+
+ len = num(x);
+ printf("XXX%d: %ld bytes\n", x, len);
+ printf("%06ld: ", pc);
+- for (; len>0; len--) /* a bit dangerous ... */
++ for (i = 0; i < len; i++) /* a bit dangerous ... */
+ putchar((int) get1()); /* can be non-printables */
+ putchar('\n');
+
+- return;
+-
+ } /* special */
+
+
+
+-/*
+- * FONTDEF -- Process a font definition.
+- */
+-
+-void fontdef(int x)
++void fontdef(register int x)
+ {
+ register int i;
+ char * name;
+@@ -503,7 +410,7 @@
+
+ for (i = 0; i < namelen; i++)
+ name[i] = get1();
+- name[i] = '\0';
++ name[namelen] = '\0';
+ fnt->name = name;
+ if (new) {
+ fnt->next = fonts;
+@@ -512,17 +419,12 @@
+
+ printf("%s\n", name);
+
+- return;
+-
+ } /* fontdef */
+
+
+
+-/*
+- * FONTNAME -- Return font name.
+- */
+-
+-const char * fontname(long fntnum)
++const char *
++fontname(long fntnum)
+ {
+ font * fnt;
+
+@@ -531,18 +433,14 @@
+ fnt = fnt->next;
+ if (fnt != NULL)
+ return fnt->name;
+-
+- return "unknown fontname";
++ else
++ return "unknown fontname";
+
+ } /* fontname */
+
+
+
+-/*
+- * PRINTNONPRINT -- Translate non-printable characters.
+- */
+-
+-void printnonprint(int ch)
++void printnonprint(register int ch)
+ {
+
+ printf("Char: ");
+@@ -590,71 +488,41 @@
+ }
+ putchar('\n');
+
+- return;
+-
+-} /* printnonprint */
++}
+
+
+
+-/*
+- * NUM --
+- */
+-
+-unsigned long num(int size)
++unsigned long num(register int size)
+ {
+ register int i;
+- register unsigned long x = 0;
++ register long x = 0;
+
+ pc += size;
+- for (i = size; i > 0; i--)
++ for (i = 0; i < size; i++)
+ x = (x << 8) + (unsigned) getc(dvifp);
+-
+ return x;
+
+ } /* num */
+
+
+
+-/*
+- * SNUM --
+- */
+-
+-long snum(int size)
++long snum(register int size)
+ {
+ register int i;
+- register long x;
++ register long x = 0;
+
+ pc += size;
+ x = getc(dvifp);
+ if (x & 0x80)
+ x -= 0x100;
+- for (i = size - 1; i > 0; i--)
++ for (i = 1; i < size; i++)
+ x = (x << 8) + (unsigned) getc(dvifp);
+-
+ return x;
+
+ } /* snum */
+
+
+
+-/*
+- * USAGE --
+- */
+-
+-void usage(void)
+-{
+-
+- fprintf(stderr, "\n%s\n\n", disdvi);
+- fprintf(stderr, " disassembles (p)TeX dvi and XeTeX xdv files\n");
+- fprintf(stderr, "Usage: %s [-h | [-p] [dvi_file[.dvi]]\n", progname);
+- fprintf(stderr, " | -x [xdv_file[.xdv]]]\n");
+-
+- return;
+-
+-} /* usage */
+-
+-
+-
+ void picfile(int opcode)
+ {
+ int i;
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.1 dvi2tty-5.3.1/dvi2tty.1
+--- dvi2tty-5.3.1.orig/dvi2tty.1 2010-10-20 14:21:13.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.1 2006-01-17 22:41:51.000000000 +0100
+@@ -1,38 +1,36 @@
+-.TH DVI2TTY 1 "20 October 2010" "TeX Live"
++.TH DVI2TTY Local "7 June 1986"
+ .SH NAME
+-dvi2tty \- preview a TeX DVI\-file on an ordinary ascii terminal
++dvi2tty \- preview a dvi\-file on an ordinary ascii terminal
+ .SH SYNOPSIS
+ .B dvi2tty
+ [ options ] dvi\-file
+ .SH DESCRIPTION
+ .I dvi2tty
+-converts a TeX DVI\-file to a format that is appropriate for terminals
+-and line printers. The program is intended to be used for
++converts a TeX DVI\-file to a format that is apprporiate for terminals
++and lineprinters. The program is intended to be used for
+ preliminary proofreading of TeX-ed documents.
+ By default the output is directed to the terminal,
+ possibly through a pager (depending on how the program was installed),
+ but it can be directed to a file or a pipe.
+ .PP
+ The output leaves much to be desired, but is still
+-useful if you want to avoid walking to the
+-laser printer (or whatever) for each iteration of your
++usefull if you want to avoid walking to the
++laserprinter (or whatever) for each iteration of your
+ document.
+ .br
+ Since
+ .I dvi2tty
+-produces output for terminals and line printers the
++produces output for terminals and lineprinters the
+ representation of documents is naturally quite primitive.
+-In principle Font Changes are totally ignored, but
+-.I dvi2tty
+-recognizes
+-a few mathematical and special symbols that can be be displayed on an
+-ordinary ascii terminal, such as the '+' and '-' symbol.
++Fontchanges are totally ignored, which implies that
++special symbols, such as mathematical symbols, get mapped into the
++characters at the corresponding positions in the "standard" fonts.
+ .PP
+ If the width of the output text requires more columns than fits
+ in one line (c.f. the \-w option) it is broken into several lines by
+ .I dvi2tty
+ although they will be printed as one line on regular TeX output
+-devices (e.g. laser printers). To show that a broken line is really
++devices (e.g. laserprinters). To show that a broken line is really
+ just one logical line an asterisk (``*'') in the last position
+ means that the logical line is continued on the next physical
+ line output by
+@@ -41,7 +39,7 @@
+ in the first two columns.
+ .PP
+ Options may be specified in the environment variable DVI2TTY.
+-Any option on the command line, conflicting with one in the
++Any option on the commandline, conflicting with one in the
+ environment, will override the one from the environment.
+ .PP
+ .B Options:
+@@ -56,7 +54,7 @@
+ An example of format for list is ``1,3:6,8''
+ to choose pages 1, 3 through 6 and 8.
+ Negative numbers can be used exactly as in TeX,
+-e g \-1 comes before \-4 as in ``\-p\-1:\-4,17''.
++e g \-1 comes before \-4 as in ``\-p-1:-4,17''.
+ .TP
+ .B \-P list
+ Like \-p except that page numbers refer to
+@@ -73,59 +71,35 @@
+ terminal into this mode as output will
+ probably look somewhat better.
+ .TP
+-.B \-v
+-Specify height of lines. Default value 450000. Allows to adjust linespacing.
+-.TP
+ .B \-q
+ Don't pipe the output through a pager.
+ This may be the default on some systems
+-(depending on the whims of the person installing the program).
+-.TP
+-.B \-e n
+-This option can be used to influence the spacing between words.
+-With a negative value the number of spaces
+-between words becomes less, with a positive value it becomes more.
+-\-e\-11 seems to worked well.
++(depending on the whims of the SA installing the program).
+ .TP
+ .B \-f
+-Pipe through a pager, $PAGER if defined, or whatever the installer of
+-the program compiled
++Pipe through a pager, $PAGER if defined, or whatever your SA compiled
+ in (often ``more''). This may be the default, but it is still okay
+ to redirect output with ``>'', the pager will not be used if output
+ is not going to a terminal.
+ .TP
+ .B \-F
+ Specify the pager program to be used.
+-This overrides the $PAGER and the default pager.
++This overides the $PAGER and the default pager.
+ .TP
+ .B \-Fprog
+ Use ``prog'' as program to pipe output into. Can be used to choose an
+ alternate pager (e g ``-Fless'').
+ .TP
+-.B \-t
+-\\tt fonts were used (instead of cm) to produce dvi file. (screen.sty
+-is a powerfull mean to do that with LaTeX).
+-.TP
+-.B \-a
+-Dvi2tty normally tries to output accented characters. With the -a option,
+-accented characters are output without the accent sign.
+-.TP
+ .B \-l
+-Mark page breaks with the two-character sequence ``^L''. The default is
+-to mark them with a form-feed character.
++Mark pagebreaks with the two-character sequence ``^L''. The default is
++to mark them with a formfeed character.
+ .TP
+-.B \-c
+-Do not attempt to trnaslate any characters (like the Scandinavion mode)
+-except when running in tt-font.
+ .B \-u
+ Don't make any attempts to find special Scandinavian characters.
+ If such characters are in the text they will map to ``a'' and ``o''.
+-This is probably the default outside of Scandinavia. (The installer
+-makes this decision when the program is installed.)
++This is probably the default outside of Scandinavia. (The SA made
++the decision when the program was installed.)
+ .TP
+-.B \-bdelim
+-Print the name of fonts when switching to it (and ending it). The delim
+-argument is used to delimit the fontname.
+ .B \-s
+ Try to find the special Scandinavian characters that on most (?)
+ terminals in Scandinavia are mapped to ``{|}[\\]''.
+@@ -139,7 +113,7 @@
+ the pager to use.
+ .br
+ DVI2TTY \ \ \ \ \ \ \ \ \ \ \
+-can be set to hold command-line options.
++can be set to hold commandline options.
+ .SH "SEE ALSO"
+ TeX, dvi2ps
+ .SH AUTHOR
+@@ -147,10 +121,11 @@
+ .br
+ Improved C version: Marcel Mol
+ .br
+-marcel@mesa.nl, MESA Consulting
++{seismo, mcvax}!enea!ttds!zap
++.br
++marcel@duteca.UUCP
+ .SH BUGS
+ Blanks between words get lost quite easy. This is less
+ likely if you are using a wider output than the default 80.
+ .PP
+-Only one file may be specified on the command line.
+-
++Only one file may be specified on the commandline.
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.c dvi2tty-5.3.1/dvi2tty.c
+--- dvi2tty-5.3.1.orig/dvi2tty.c 2010-10-24 14:28:11.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.c 2010-02-23 13:42:05.000000000 +0100
+@@ -1,60 +1,18 @@
+ /******************************************************************************
+- * Marcel Mol: 22jan2003 (Internet: marcel@mesa.nl)
+- * From: jose@monkey.org: clearly state license (GPL).
+- * Marcel Mol: 27may1996 (Internet: marcel@mesa.nl)
+- * From: mlemos@ua.pt (Manuel Lemos): Port to AMIGA.
+- * Marcel Mol: 24mar1996 (Internet: marcel@mesa.nl)
+- * From: Alex Viskovatoff <av@mixcom.com>: Port to Macintosh
+- * From: Anton vd Repe 1995-6-9 (UUCP: arp@neabbs.uucp):
+- * Added option to skip translation of Scandinavian/Finnish
+- * and skip the constraint to ASCII characters only.
+- * Added option to include font name in output when new font
+- * is chosen.
+- * Limit line width of 132 expanded to 332.
+- * Marcel Mol: 23jun1995 (Internet: marcel@duteca.et.tudelft.nl)
+- * Included patch form Hideki ISOZAKI (isozaki@ntt-20.ntt.jp)
+- * to allow japanese fonts generated by NTT JTeX (March 1992).
+- * Added cleanups (protoize + includes) by D.U. Zoller
+- * (1995-07-17 duz@roxi.rz.fht-mannheim.de)
+- * Version 5.1
+- * Marcel Mol: 09sep1993 (Internet: marcel@duteca.et.tudelft.nl)
+- * In dvistuff.c: added auto detection for 'ttfont'.
+- * This make -t flag unneeded, but it is still left in for
+- * people who like to force 'verbatim' mode.
+- * Thanks to: Diomidis Spinellis <dds@doc.imperial.ac.uk>
+- * Marcel Mol: 05sep1993 (Internet: marcel@duteca.et.tudelft.nl)
+- * In dvistuff.c: put some extra chars arround the 'ttfont'
+- * flag in the 'normchar' function.
+- * Marcel Mol: 01oct1991 (Internet: marcel@duteca.et.tudelft.nl)
+- * (From Igor Romanenko, igor@d245.icyb.kiev.ua.)
+- * Fixed unneccesary * in *envp++.
+- * Marcel Mol: 24jul1991 (Internet: marcel@duteca.et.tudelft.nl)
+- * Suggestion From: peter@julian.uwo.ca [uwo]
+- * vertical bars "|" and the tilde "~" print properly in
+- * typewriter font.
+- * Marcel Mol: 1990-11-29 (UUCP: marcel@duteca.et.tudelft.nl)
+- * Fixed bug in option handling. Cleanup of code.
+- * Other minor changes/optimizations.
+- * Marcel Mol: 1990-11-13 (UUCP: marcel@duteca.et.tudelft.nl)
+- * Included patches of Bernard Gaulle in my version.
+- * Version 4.4
+- * Bernard Gaulle: 1990-10-16 (gaulle@murnau.circe.fr)
+- * Add -t option (assuming tt fonts were used)
+- * (Version 3.3)
+- * Marcel Mol: 1990-05-03 (UUCP: marcel@duteca.tudelft.nl)
+- * Now displays accents etc. on characters again. Added option
+- * (-a) to switch this off. If switched off it now uses proper
+- * spacing.
+- * Cleaned up and show version number in usage();
+- * Version 4.3
+- * Marcel Mol: 1990-05-02 (UUCP: marcel@duteca.tudelft.nl)
+- * Included patches for VAX/VMS VAXC, done by Robert Schneider.
+- * Version 4.2
++ * dvitty - get an ascii representation of a dvi-file, suitable for ttys
++
++This program was originally written in Pascal by
++Svante Lindahl <svante dot lindahl (at) pantor dot com>
++and then converted to C by Marcel Mol <marcel (at) mesa dot nl>.
++Some changes have been made for TeX Live (see ./ChangeLog).
++
++It is released under the GNU GPL, version 2 or any later version.
++(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=424018)
++
+ * Marcel Mol: 1990-03-27 (UUCP: marcel@duteca.tudelft.nl)
+ * Fixed bug that causes the program to hang when it finds a
+ * fontname with an 's' in it not followed by an 'y'.
+ * Thanks to Paul Orgren (orgren@Stars.Reston.Unisys.COM).
+- * Version 4.1
+ * Marcel Mol: 1990-02-04 (UUCP: marcel@duteca.tudelft.nl)
+ * First attempt to recognize symbol fonts, so bullets (in
+ * itemized lists) are translated to a proper character instead
+@@ -84,9 +42,9 @@
+ * Fixed a bugs concerning pager programs
+ * and scanning environment variable DVI2TTY.
+ * Marcel Mol: 1988-10-25 (UUCP: duteca!marcel)
+- * Renamed to dvi2tty and converted to C.
+- * Filenames: dvi2tty.c dvi2tty.h dvistuff.c commands.h
+- * Improved spacing between words/characters.
++ * dvi2tty.c dvi2tty.h dvistuff.c commands.h
++ * Converted program to C.
++ * improved spacing between words/characters.
+ * bogart:/usr/alla/zap/dvitty/dvitty.p 1986-08-15 20:24:31,
+ * Version to be sent to mod.sources ready.
+ * New option since last version:
+@@ -94,6 +52,24 @@
+ * pager than the default.
+ * bogart:/usr/alla/zap/dvitty/dvitty.p 1986-01-13 21:49:31,
+ * Environment variable DVITTY is read and options can be set from it.
++ * These are the currently implemented options:
++ * -ofile Write output to file, else write to stdout,
++ * possibly piped through a pager if stdout is a tty.
++ * -plist Print pages whos TeX-page-number are in list.
++ * List is on the form 1,3:6,8 to choose pages
++ * 1,3-6 and 8. TeX-nrs can be negative: -p-1:-4,4
++ * -Plist Print pages whos sequential number are in list.
++ * -wn Print the lines with width n characters, default is
++ * 80. Wider lines gives better results.
++ * -q Don't try to pipe to a pager.
++ * -f Try to pipe to a pager if output is a tty.
++ * -Fname Specify a pager program.
++ * Default of -q and -f is a compile time option, a constant.
++ * -l Write '^L' instead of formfeed between pages.
++ * -u Don't try to find Scandinavian characters (they will
++ * print as a:s and o:s if this option is choosen).
++ * -s Scandinavian characters printed as }{|][\.
++ * Default of -s and -u is a compile time option, a constant.
+ * bogart:/usr/alla/zap/dvitty/dvitty.p 1986-01-10 18:51:03,
+ * Argument parsing, and random access functions (external, in C)
+ * and other OS-dependent stuff (in C). Removed private 'pager' &
+@@ -117,58 +93,14 @@
+ * VERA::<SVANTE-LINDAHL.DVITTY>DVITTY.PAS.45, 29-Sep-84 18:29:53,
+ * Edit: Svante Lindahl
+ *
+- * dvitty - get an ascii representation of a dvi-file, suitable for ttys
+- *
+- * This program, and any documentation for it, is copyrighted by Svante
+- * Lindahl. It may be copied for non-commercial use only, provided that
+- * any and all copyright notices are preserved.
+- *
+- *
+- * UUCP: {seismo,mcvax,cernvax,diku,ukc,unido}!enea!ttds!zap
+- * ARPA: enea!ttds!zap@seismo.CSS.GOV
+- * or Svante_Lindahl_NADA%QZCOM.MAILNET@MIT-MULTICS.ARPA
+- * EAN: zap@cs.kth.sunet
+ */
+
+
+-/*
+- * dvi2tty
+- * Copyright (C) 2003 Marcel J.E. Mol <marcel@mesa.nl>
+- *
+- * This program is free software; you can redistribute it and/or
+- * modify it under the terms of the GNU General Public License
+- * as published by the Free Software Foundation; either version 2
+- * of the License, or (at your option) any later version.
+- *
+- * This program is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with this program; if not, write to the Free Software
+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+- *
+- */
+-
+-/*
+- * Include files
+- */
+-
+ #include "dvi2tty.h"
+ #if defined(VMS)
+-# include unixio
++#include unixio
+ #endif
+-#if defined(THINK_C)
+-# include <unix.h>
+-# include "macintosh.h"
+-#endif
+-
+
+-
+-/*
+- * Constant definitons
+- */
+ /*-----------------------------------------------------------------------*/
+ /* The following constants may be toggled before compilation to */
+ /* customize the default behaviour of the program for your site. */
+diff -ur dvi2tty-5.3.1.orig/dvi2tty.h dvi2tty-5.3.1/dvi2tty.h
+--- dvi2tty-5.3.1.orig/dvi2tty.h 2010-10-24 14:29:23.000000000 +0200
++++ dvi2tty-5.3.1/dvi2tty.h 2010-02-23 13:41:58.000000000 +0100
+@@ -1,25 +1,5 @@
+-/*
+- * dvi2tty
+- * Copyright (C) 2003 Marcel J.E. Mol <marcel@mesa.nl>
+- *
+- * This program is free software; you can redistribute it and/or
+- * modify it under the terms of the GNU General Public License
+- * as published by the Free Software Foundation; either version 2
+- * of the License, or (at your option) any later version.
+- *
+- * This program is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with this program; if not, write to the Free Software
+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+- *
+- */
+-
+-#define Copyright "dvi2tty Copyright (C) 1984, 1985, 1986 Svante Lindahl.\n\
+-Copyright (C) 1989-1996 M.J.E. Mol"
++#define Copyright "dvi2tty.c Copyright (C) 1984, 1985, 1986 Svante Lindahl.\n\
++Copyright (C) 1988 M.J.E. Mol 1989, 1990"
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ur dvi2tty-5.3.1.orig/dvistuff.c dvi2tty-5.3.1/dvistuff.c
+--- dvi2tty-5.3.1.orig/dvistuff.c 2010-10-24 15:01:30.000000000 +0200
++++ dvi2tty-5.3.1/dvistuff.c 2009-09-01 14:14:47.000000000 +0200
+@@ -1,26 +1,3 @@
+-/*
+- * dvi2tty
+- * Copyright (C) 2003 Marcel J.E. Mol <marcel@mesa.nl>
+- *
+- * This program is free software; you can redistribute it and/or
+- * modify it under the terms of the GNU General Public License
+- * as published by the Free Software Foundation; either version 2
+- * of the License, or (at your option) any later version.
+- *
+- * This program is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with this program; if not, write to the Free Software
+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+- *
+- */
+-
+-/*
+- * Include files
+- */
+
+ #include "dvi2tty.h"
+ #include <sys/types.h>
+@@ -34,12 +11,6 @@
+ #endif
+ #include "commands.h"
+
+-
+-
+-/*
+- * Constant definitions
+- */
+-
+ #if defined(VMS)
+ #define mseek vmsseek
+ #define ROUND(a) (a>=0.0 ? (int) (a + 0.5) : (int) (a - 0.5) )
+@@ -78,16 +49,12 @@
+ #define sget3() snum(3)
+ #define sget4() snum(4)
+
+-
+-
+-/*
+- * Structure and variable definitions
+- */
+-
+ #if 0
+-char *dvistuff = "@(#) dvistuff.c 5.12 27may1996 M.J.E. Mol (c) 1989-1996";
++char *dvistuff = "@(#) dvistuff.c 4.1 27/03/90 M.J.E. Mol (c) 1989, 1990";
+ #endif
+
++/*---------------------------------------------------------------------------*/
++
+ typedef struct {
+ long hh;
+ long vv;
+@@ -112,6 +79,7 @@
+ } font;
+
+
++/*---------------------------------------------------------------------------*/
+
+ bool pageswitchon; /* true if user-set pages to print */
+ bool sequenceon; /* false if pagesw-nrs refers to TeX-nrs */
+@@ -142,11 +110,7 @@
+ font * fonts = NULL; /* List of fontnames defined */
+ int symbolfont = FALSE; /* true if font is a symbol font */
+
+-
+-
+-/*
+- * Function definitions
+- */
++/*---------------------------------------------------------------------------*/
+
+ #if defined(KPATHSEA) || defined(MSDOS)
+ void postamble (void);
+@@ -205,51 +169,41 @@
+ #endif
+ #endif
+
+-
++/*---------------------------------------------------------------------------*/
++/*---------------------------------------------------------------------------*/
+
+ /*
+- * DVIMAIN -- The main function for processing the dvi file.
+- * Here we assume there are to file pointers: DVIfile and output.
+- * Also we have a list of pages pointed to by 'currentpage',
+- * which is only used (in 'inlist()') when a page list is given.
++ * The main function for processing the dvi file.
++ * Here we assume there are to file pointers: DVIfile and output.
++ * Also we have a list of pages pointed to by 'currentpage',
++ * which is only used (in 'inlist()') when a page list is given.
+ */
+
+ void dvimain(void)
+ {
+
+ postamble(); /* seek and process the postamble */
+- preamble(); /* process preamble */
+ /* note that walkpages *must* immediately follow preamble */
++ preamble(); /* process preamble */
+ walkpages(); /* time to do the actual work! */
+
+-- return;
+--
+ } /* dvimain */
+
++/*---------------------------------------------------------------------------*/
+
+- /*
+- * POSTAMBLE -- Find and process postamble, use random access
+- */
+-
+-void postamble(void)
++void postamble(void) /* find and process postamble, use random access */
+ {
+ register long size;
+ register int count;
+-#if !defined (THINK_C)
+ struct stat st;
+-#endif
+
+-#if defined (THINK_C)
+- size = DVIfile->len;
+-#else
+ fstat (fileno(DVIfile), &st);
+ size = (long) st.st_size; /* get size of file */
+-#endif
+-
+ count = -1;
+ do { /* back file up past signature bytes (223), to id-byte */
+- if (size-- == 0)
++ if (size == 0)
+ errorexit(nopst);
++ size--;
+ mseek(DVIfile, size, absolute);
+ opcode = (int) get1();
+ count++;
+@@ -261,7 +215,7 @@
+ if (opcode != VERSIONID)
+ errorexit(badid);
+ mseek(DVIfile, size-4, absolute); /* back up to back-pointer */
+- mseek(DVIfile, sget4(), absolute); /* and to start of postamble */
++ mseek(DVIfile, sget4(), absolute); /* and to start of postamble */
+ if (get1() != POST)
+ errorexit(nopst);
+ mseek(DVIfile, 20L, relative); /* lastpageoffset, numerator, denominator */
+@@ -275,17 +229,11 @@
+ /* get2() -- totalpages */
+ /* fontdefs do fontdefs in flight ... */
+
+- return;
+-
+ } /* postamble */
+
++/*---------------------------------------------------------------------------*/
+
+-
+-/*
+- * PREAMBLE --process preamble, use random access
+- */
+-
+-void preamble(void)
++void preamble(void) /* process preamble, use random access */
+ {
+
+ mseek(DVIfile, 0L, absolute); /* read the dvifile from the start */
+@@ -297,17 +245,11 @@
+ mseek(DVIfile, 12L, relative); /* numerator, denominator, magnification */
+ mseek(DVIfile, get1(), relative); /* skip job identification */
+
+- return;
+-
+ } /* preamble */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * WALKPAGES -- process the pages in the DVI-file
+- */
+-
+-void walkpages(void)
++void walkpages(void) /* process the pages in the DVI-file */
+ {
+ register bool wantpage;
+
+@@ -339,15 +281,9 @@
+ }
+ }
+
+- return;
+-
+ } /* walkpages */
+
+-
+-
+-/*
+- * INITPAGE -- Setup a new, empty page.
+- */
++/*---------------------------------------------------------------------------*/
+
+ void initpage(void)
+ {
+@@ -361,7 +297,8 @@
+ lastline = currentline;
+ firstcolumn = rightmargin;
+ if (pageswitchon) {
+- if ((sequenceon ? pagecounter : pagenr) != firstpage->pag) {
++ if ((sequenceon && (pagecounter != firstpage->pag)) ||
++ (!sequenceon && (pagenr != firstpage->pag))) {
+ if (noffd)
+ fprintf(output, "^L\n");
+ else
+@@ -369,23 +306,16 @@
+ }
+ }
+ else
+- if (backpointer != -1) { /* not FORM at first page */
++ if (backpointer != -1) { /* not FORM at first page */
+ if (noffd)
+ fprintf(output, "^L\n");
+ else
+ putc(FORM, output);
+ }
+
+- return;
+-
+ } /* initpage */
+
+-
+-
+-/*
+- * DOPAGE -- Process the dvi file until an end-off-page.
+- * Build up a page image.
+- */
++/*----------------------------------------------------------------------------*/
+
+ void dopage(void)
+ {
+@@ -426,8 +356,9 @@
+ stack[sptr].zz = z;
+ sptr++;
+ break;
+- case POP : if (sptr-- == 0) /* pop */
++ case POP : if (sptr == 0) /* pop */
+ errorexit(stkuf);
++ sptr--;
+ h = stack[sptr].hh;
+ v = stack[sptr].vv;
+ w = stack[sptr].ww;
+@@ -483,18 +414,11 @@
+ }
+ }
+
+- return;
+-
+ } /* dopage */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * SKIPPAGE -- Scan the dvi file until an end-off-page.
+- * Skip this page.
+- */
+-
+-void skippage(void)
++void skippage(void) /* skip past one page */
+ {
+ register int opcode;
+
+@@ -556,17 +480,11 @@
+ }
+ }
+
+- return;
+-
+ } /* skippage */
+
++/*---------------------------------------------------------------------------*/
+
+-
+-/*
+- * PRINTPAGE -- 'end of page', writes lines of page to output file
+- */
+-
+-void printpage(void)
++void printpage(void) /* 'end of page', writes lines of page to output file */
+ {
+ register int i, j;
+ register unsigned char ch;
+@@ -607,17 +525,11 @@
+ free(currentline); /* free last line */
+ currentline = nil;
+
+- return;
+-
+ } /* printpage */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * INLIST -- return true if pagenr is in the list of pages to be printed.
+- */
+-
+-bool inlist(long pagenr)
++bool inlist(register long pagenr) /* ret true if in list of pages */
+ {
+
+ while ((currentpage->pag < 0) && (currentpage->pag != pagenr) &&
+@@ -632,20 +544,14 @@
+ if (currentpage->pag == pagenr)
+ return TRUE;
+ }
+-
+ return FALSE;
+
+ } /* inlist */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * RULE -- Output a rule (vertical or horizontal).
+- * Increment h if moving is true.
+- */
+-
+ void rule(bool moving, long rulewt, long ruleht)
+-{
++{ /* output a rule (vertical or horizontal), increment h if moving is true */
+
+ register char ch; /* character to set rule with */
+ register long saveh = 0, savev;
+@@ -668,17 +574,11 @@
+ if (!moving)
+ h = saveh;
+
+- return;
+-
+ } /* rule */
+
+
+
+-/*
+- * RULEAUX -- do the actual outtput for the rule recursively.
+- */
+-
+-void ruleaux(long rulewt, long ruleht, char ch)
++void ruleaux(long rulewt, long ruleht, char ch) /* recursive that does the job */
+ {
+ register long wt, lmh, rmh;
+
+@@ -702,21 +602,15 @@
+ h = rmh; /* restore right margin */
+ }
+
+- return;
+-
+ } /* ruleaux */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * HORIZONTALMOVE -- Move the h pointer by amount.
+- */
+-
+-long horizontalmove(long amount)
++long horizontalmove(register long amount)
+ {
+
+-#if defined(MSDOS) || defined(THINK_C)
+- if (labs(amount) > charwidth / 4L) { /* } to make vi happy */
++#if defined(MSDOS)
++ if (labs(amount) > charwidth / 4L) {
+ #else
+ if (abs(amount) > charwidth / 4L) {
+ #endif
+@@ -737,29 +631,20 @@
+
+ } /* horizontalmove */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * SKIPNOPS -- Return first non NOP opcode.
+- */
+-
+-int skipnops(void)
++int skipnops(void) /* skips by no-op commands */
+ {
+ register int opcode;
+
+ while ((opcode = (int) num(1)) == NOP);
+-
+ return opcode;
+
+ } /* skipnops */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * GETLINE -- Returns an initialized line-object
+- */
+-
+-linetype *texlive_getline(void)
++linetype *texlive_getline(void) /* returns an initialized line-object */
+ {
+ register int i;
+ register linetype *temp;
+@@ -772,20 +657,14 @@
+ for (i = 0; i < LINELEN; i++)
+ temp->text[i] = ' ';
+ temp->text[i] = '\0';
+-
+ return temp;
+
+ } /* texlive_getline */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * FINDLINE -- Find best fit line were text should go
+- * and generate new line if needed.
+- */
+-
+-linetype *findline(void)
+-{
++linetype *findline(void) /* find best fit line were text should go */
++{ /* and generate new line if needed */
+ register linetype *temp;
+ register long topd, botd;
+
+@@ -832,35 +711,25 @@
+ temp->next->prev = currentline;
+ temp->next = currentline;
+ currentline->vv = v;
+-
+ return currentline;
+
+ } /* findline */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * NUM --
+- */
+-
+-unsigned long num(int size)
++unsigned long num(register int size)
+ {
+ register int i;
+- register unsigned long x = 0;
++ register long x = 0;
+
+- for (i = size; i > 0; i--)
++ for (i = 0; i < size; i++)
+ x = (x << 8) + (unsigned) getc(DVIfile);
+-
+ return x;
+
+ } /* num */
+
+
+-/*
+- * SNUM --
+- */
+-
+-long snum(int size)
++long snum(register int size)
+ {
+ register int i;
+ register long x = 0;
+@@ -868,18 +737,13 @@
+ x = getc(DVIfile);
+ if (x & 0x80)
+ x -= 0x100;
+- for (i = size - 1; i > 0; i--)
++ for (i = 1; i < size; i++)
+ x = (x << 8) + (unsigned) getc(DVIfile);
+-
+ return x;
+
+ } /* snum */
+
+-
+-
+-/*
+- * DOCHAR -- Process a character opcode.
+- */
++/*----------------------------------------------------------------------------*/
+
+ void dochar(char ch)
+ {
+@@ -895,11 +759,7 @@
+
+
+
+-/*
+- * SYMCHAR -- Process a character opcode for a symbol font.
+- */
+-
+-void symchar(char ch)
++void symchar(char ch) /* output ch to appropriate line */
+ {
+
+ switch (ch) { /* can do a lot more on MSDOS machines ... */
+@@ -918,7 +778,6 @@
+ case 106: ch = '|'; break;
+ case 110: ch = '\\'; break;
+ }
+-
+ outchar(ch);
+
+ return;
+@@ -927,10 +786,6 @@
+
+
+
+-/*
+- * NORMCHAR -- Process a character opcode for a normal font.
+- */
+-
+ void normchar(char ch)
+ {
+
+@@ -992,18 +847,11 @@
+
+ return;
+
+-} /* normchar */
+-
++} /*normchar */
+
+
+-/*
+- * OUTCHAR -- Here we put the character into the current page.
+- * This function includes some code to handle Scandinavian
+- * characters. I think that code doesn't belong here. IT
+- * SHOULD BE MOVED OUT.
+- */
+
+-void outchar(unsigned char ch)
++void outchar(unsigned char ch) /* output ch to appropriate line */
+ {
+ register int i, j;
+
+@@ -1024,7 +872,6 @@
+ else if (j < leftmargin)
+ j = leftmargin;
+ foo = leftmargin - 1;
+-
+ /*
+ * This code does not really belong here ...
+ *
+@@ -1095,17 +942,11 @@
+ h += charwidth;
+ }
+
+- return;
+-
+ } /* outchar */
+
++/*----------------------------------------------------------------------------*/
+
+-
+-/*
+- * PUTCHARACTER -- Output character, don't change h
+- */
+-
+-void putcharacter(long charnr)
++void putcharacter(register long charnr) /* output character, don't change h */
+ {
+ register long saveh;
+
+@@ -1116,34 +957,23 @@
+ setchar(charnr);
+ h = saveh;
+
+- return;
+-
+ } /* putcharacter */
+
+-
+-
+-/*
+- * SETCHAR -- Should print characters with character code>127 from
+- * current font. Note that the parameter is a dummy, since
+- * ascii-chars are<=127.
+- */
++/*----------------------------------------------------------------------------*/
+
+ void setchar(long charnr)
+-{
++{ /* should print characters with character code>127 from current font */
++ /* note that the parameter is a dummy, since ascii-chars are<=127 */
+
+ outchar((unsigned char)(charnr));
+
+- return;
+-
+ } /* setchar */
+
+
++/*----------------------------------------------------------------------------*/
+
+-/*
+- * FONTDEF -- Process a font definition.
+- */
+
+-void fontdef(int x)
++void fontdef(register int x)
+ {
+ register int i;
+ char * name;
+@@ -1177,7 +1007,7 @@
+
+ for (i = 0; i < namelen; i++)
+ name[i] = get1();
+- name[i] = '\0'; /* required */
++ name[namelen] = '\0';
+ fnt->name = name;
+ if (new) {
+ fnt->next = fonts;
+@@ -1190,13 +1020,6 @@
+
+
+
+-/*
+- * SETFONT -- Switch to specific font. Try to find out if it is a symbol
+- * font.
+- * Option -c allchar does not pertain to this portion, so symbols
+- * are still translated.
+- */
+-
+ void setfont(long fntnum)
+ {
+ font * fnt;
+@@ -1227,9 +1050,8 @@
+
+
+
+-/*
+- * VMS CODE
+- */
++/*----------------------------------------------------------------------------*/
++
+
+ #if defined(VMS)
+ long vmsseek(FILE *fp, long n, long dir)
+@@ -1237,9 +1059,9 @@
+ long k,m,pos,val,oldpos;
+ struct stat buffer;
+
+- for (;;) { /* loops only once or twice */
++ for (;;) { /*loops only once or twice*/
+ switch (dir) {
+- case 0: /* from BOF */
++ case 0: /*from BOF*/
+ oldpos = vms_ftell(fp);
+ k = n & 511;
+ m = n >> 9;
+@@ -1278,8 +1100,6 @@
+ }
+ }
+
+- /* NOTREACHED */
+-
+ } /* vmsseek */
+
+
+@@ -1289,7 +1109,6 @@
+ char c;
+ long pos;
+ long val;
+-
+ if ((*fp)->_cnt == 0) {
+ c = fgetc(fp);
+ val = vms_ungetc(c, fp);
+@@ -1299,7 +1118,6 @@
+ pos = ftell(fp);
+ if (pos >= 0)
+ pos += ((*fp)->_ptr) - ((*fp)->_base);
+-
+ return (pos);
+
+ } /* vms_ftell */
+@@ -1308,18 +1126,16 @@
+
+ long vms_ungetc(char c, FILE *fp)
+ {
+-
+ if ((c == EOF) && feof(fp))
+ return (EOF);
+-
+- if ((*fp)->_cnt >= 512)
++ else if ((*fp)->_cnt >= 512)
+ return (EOF);
+-
+- (*fp)->_cnt++;
+- (*fp)->_ptr--;
+- *((*fp)->_ptr) = c;
+-
+- return (c);
++ else {
++ (*fp)->_cnt++;
++ (*fp)->_ptr--;
++ *((*fp)->_ptr) = c;
++ return (c);
++ }
+
+ } /*vms_ungetc */
+ #endif