summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvi2tty/dvi2tty-src
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-02-23 03:08:53 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-02-23 03:08:53 +0000
commit59405b711ceebf34e6683b2fc748294b993c8a18 (patch)
treeddbc31c509b6c38f371183e214a9d1ade370efe1 /Build/source/texk/dvi2tty/dvi2tty-src
parent5cd6f50be0533a56aa7eccf59d527bc4c2df4e76 (diff)
texk/dvi2tty: New convention
git-svn-id: svn://tug.org/texlive/trunk@39831 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvi2tty/dvi2tty-src')
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/COPYING343
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/Changelog154
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/DVI.format102
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/Makefile40
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/README60
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/README.MAC11
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/README.ORG26
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/README.VMS38
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/TODO50
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/getopt.c124
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/macintosh.h34
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/unix-to-macintosh.c460
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/commands.h97
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/README.Debian17
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/changelog118
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/compat1
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/control13
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/copyright12
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/dirs2
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/docs9
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/jdvi2tty-ascii.patch.header30
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/postinst12
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/prerm12
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/debian/rules80
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/disdvi.127
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/disdvi.c820
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.1172
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.DCL55
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.c866
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.h169
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.lsm16
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.tex271
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c1697
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.dvibin0 -> 780 bytes
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.tex35
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/test/test.dvibin0 -> 2516 bytes
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/test/test.tex122
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-src/test/test_org.dvibin0 -> 748 bytes
38 files changed, 6095 insertions, 0 deletions
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/COPYING b/Build/source/texk/dvi2tty/dvi2tty-src/COPYING
new file mode 100644
index 00000000000..520e7de1d76
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/COPYING
@@ -0,0 +1,343 @@
+dvi2tty
+Copyright (C) 1989-2003 many, including Marcel J.E. Mol <marcel@mesa.nl>
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ 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
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/Changelog b/Build/source/texk/dvi2tty/dvi2tty-src/Changelog
new file mode 100644
index 00000000000..c218d592c5a
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/Changelog
@@ -0,0 +1,154 @@
+/******************************************************************************
+ * Takuji Tanaka: 20111119 (KXD02663@nifty.ne.jp)
+ * Used ptexenc library for Japanese TeX.
+ * Enabled UTF8 output for Japanese TeX with option -Eu.
+ * Added upTeX DVI support with option -U.
+ * Added auto detected Japanese fonts in japanese-otf package.
+ * Marcel Mol: 20101113 (marcel@mesa.nl)
+ * Version 5.3.4
+ * Fix VERSION code
+ * From TeXLive:
+ * - DEFPAGER form /bin/more to more
+ * - kapthsea: fix bbug to handle input filenames without ".dvi".
+ * - kpathsea - use library function instead of duplicated code.
+ * - man page fixes
+ * - const char fixes
+ * Marcel Mol: 20101030 (marcel@mesa.nl)
+ * Version 5.3.3
+ * included patches from TexLive and Joerg Prante, and Kenshi Muto
+ * minor cleanup/readability changes: note changes to -J -u -s options
+ * Kenshi Muto: 25 Nov, 1999
+ * Add auto detect patch.
+ * Fix NTT JTeX DVI japanese patch.
+ * Add ASCII pTeX DVI japanese patch.
+ * From TexLive distribution: october 2010
+ * 'KPATHSEA' support
+ * Fix linspacing calculation bug
+ * Fix compile time warnings/cosmetics
+ * Joerg Prante: 30nov2003 (prante@hbz-nrw.de)
+ * latin1 character handling with option '-u' using code by
+ * Simo Nikula (nikula@lut.fi)
+ * Thomas Sefzick (t.sefzick@fz-juelich.de)
+ * Updated help text according to latin1 patch.
+ * NOTE: this patch changes -u and -s option meanings!
+ * 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
+ * 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
+ * an awfull ligature.
+ * Version 4.0.
+ * Marcel Mol: 1990-02-01 (UUCP: marcel@duteca.tudelft.nl)
+ * Included port to VMS (off Joseph Vasallo and Seppo Rantala)
+ * into latest version. Hope things still work, cannot test it ...
+ * Joseph Vasallo & Seppo Rantala: 1989-09-05 (Internet: rantala@tut.FI)
+ * Ported to work under VAX/VMS V4.4 & VAXC V2.4 or higher.
+ * Fixed bugs in using Swedish/Finnish characters.
+ * Marcel Mol: 1989-02-14 (UUCP: duteca!marcel)
+ * Fixed check for .dvi extension.
+ * Allowed more ligatures.
+ * Fixed side effect bugs (2 gets as function arguments).
+ * Version 3.2.
+ * Marcel Mol: 1989-01-19 (UUCP: duteca!marcel)
+ * Changed in option handling, no change
+ * in user interface (only the undocumented
+ * feature -e).
+ * Version 3.1.
+ * Marcel Mol: 1989-01-11 (UUCP: duteca!marcel)
+ * Changed some longs to ints.
+ * It now also runs on MSDOS Microsoft C 5.1
+ * New version: 3.0
+ * Marcel Mol: 1989-01-03 (UUCP: duteca!marcel)
+ * 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.
+ * 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:
+ * -Fprog Pipe output to prog. Can be used to get a different
+ * 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.
+ * 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' &
+ * tries to pipe through PAGER (environment var) or, if PAGER not
+ * defined, /usr/ucb/more. Some changes for efficency.
+ * bogart:/usr/alla/svante/dvitty/dvitty.p 1985-07-15 20:51:00,
+ * The code for processing dvi-files running on UNIX (UCB-Pascal)
+ * but no argument parsing.
+ * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.140, 30-Mar-85 05:43:56,
+ * Edit: Svante Lindahl
+ * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.136, 15-Jan-85 13:52:59,
+ * Edit: Svante Lindahl, final Twenex version !!!??
+ * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.121, 14-Jan-85 03:10:22,
+ * Edit: Svante Lindahl, cleaned up and fixed a lot of little things
+ * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.25, 15-Dec-84 05:29:56,
+ * Edit: Svante Lindahl, COMND-interface, including command line scanning
+ * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.23, 10-Dec-84 21:24:41,
+ * Edit: Svante Lindahl, added command line scanning with Rscan-JSYS
+ * VERA::<SVANTE-LINDAHL.DVITTY>DVITTY.PAS.48, 8-Oct-84 13:26:30,
+ * Edit: Svante Lindahl, fixed switch-parsing, destroyed by earlier patches
+ * 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
+ */
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/DVI.format b/Build/source/texk/dvi2tty/dvi2tty-src/DVI.format
new file mode 100644
index 00000000000..4ce5d3936a3
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/DVI.format
@@ -0,0 +1,102 @@
+/*
+
+
+================================================================================
+== DVI file format ==
+================================================================================
+no_ops >= 0 bytes (NOP, nops before the preamble)
+preamble_marker 1 ubyte (PRE)
+version_id 1 ubyte (should be version 2)
+numerator 4 ubytes (numerater must equal the one in postamble)
+denominator 4 ubytes (denominator must equal the one in postamble)
+magnification 4 ubytes (magnification must equal the one in postamble)
+id_len 1 ubyte (lenght of identification string)
+id_string id_len ubytes (identification string)
+
+no_ops >= 0 bytes (NOP, nops before a page)
+begin_of_page 1 ubyte (BOP)
+page_nr 4 sbytes (page number)
+do_be_do 36 bytes (filler ????)
+prev_page_offset 4 sbytes (offset in file where previous page starts, -1 for none)
+... PAGE DATA ...
+end_of_page 1 ubyte (EOP)
+
+no_ops ??? >= 0 bytes (NOPS, I think they are allowed here...)
+postamble_marker 1 ubyte (POST)
+last_page_offset 4 sbytes (offset in file where last page starts)
+numerator 4 ubytes (numerater must equal the one in preamble)
+denominator 4 ubytes (denominator must equal the one in preamble)
+magnification 4 ubytes (magnification must equal the one in preamble)
+max_page_height 4 ubytes (maximum page height)
+max_page_width 4 ubytes (maximum page width)
+max_stack 2 ubytes (maximum stack depth needed)
+total_pages 2 ubytes (number of pages in file)
+... FONT DEFINITIONS ...
+
+postamble_offset 4 sbytes (offset in file where postamble starts)
+version_id 1 ubyte (should be version 2)
+trailer >= 4 ubytes (TRAILER)
+<EOF>
+
+
+FONT DEFINITIONS:
+ do {
+ switch (c = getc(dvi_fp) {
+ case FNTDEF1 :
+ case FNTDEF2 :
+ case FNTDEF3 :
+ case FNTDEF4 : define_font(c);
+ case POSTPOST : break;
+ default : error;
+ }
+ } while (c != POSTPOST);
+
+===== A font def looks like:
+
+1,2,3 or 4 ubytes TeXfontnumber for FNTDEF1 .. FNTDEF4
+4 ubytes checksum
+4 ubytes scale
+4 ubytes design size
+1 byte deflen1
+1 byte deflen2
+deflen1 + deflen2 bytes fontname.
+
+===== A special looks like:
+
+1,2,3 or 4 ubytes telling length of special command for XXX1 .. XXX4
+all bytes in the special command are used as defined in the dvi driver.
+
+
+-Marcel Mol
+
+
+*/
+
+From: schrod@iti.informatik.th-darmstadt.de (Joachim Schrod)
+Date: 2 Jan 92 18:26:27 GMT
+
+Since this question comes up often, I post the answer:
+
+The following file format definitions are part of the TUG DVI Driver
+Standards Draft:
+ DVI
+ GF
+ PK
+ TFM
+You can ftp them from ftp.th-darmstadt.de, directory
+pub/tex/dvi-standard/standards.
+
+Take either draft-0.05a.tar.Z (the complete standard) or
+<xxx>.tex+fileform.sty where you have to replace <xxx> by dvi, gf,
+etc.
+ In the latter case -- when you fetch single files -- you'll need
+to add a LaTeX standard frame (\documentstyle{article} +
+\begin{document} + \end{document}) to get a full, LaTeXable document.
+
+--
+Joachim
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+Joachim Schrod Email: schrod@iti.informatik.th-darmstadt.de
+Secretary of TUG DVI Driver Standards Committee
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/Makefile b/Build/source/texk/dvi2tty/dvi2tty-src/Makefile
new file mode 100644
index 00000000000..6f8c5e66f5e
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/Makefile
@@ -0,0 +1,40 @@
+# Makefile for dvi2tty and disdvi 23/01/89 M.J.E. Mol
+#
+# For BSD Unix use the following CFLAGS definition
+# CFLAGS = -Dstrchr=index
+#
+# This Makefile does not work for MSDOS. Make your
+# own one, or compile by hand.
+#
+CC = gcc
+
+CFLAGS = -Wall -O2
+# CFLAGS = -Wall -O2 -fomit-frame-pointer
+LDFLAGS = -s
+
+prefix = ${DESTDIR}/usr
+mandir = $(prefix)/share/man/man1
+bindir = $(prefix)/bin
+
+
+all: dvi2tty disdvi
+
+dvi2tty:dvi2tty.o dvistuff.o
+ $(CC) $(LFLAGS) -o dvi2tty dvi2tty.o dvistuff.o
+
+disdvi:disdvi.o
+ $(CC) $(LFLAGS) -o disdvi disdvi.o
+
+dvi2tty.o: dvi2tty.c dvi2tty.h
+
+dvistuff.o: dvistuff.c dvi2tty.h commands.h
+
+disdvi.o: disdvi.c commands.h
+
+clean:
+ rm -f dvi2tty disdvi *.o
+
+install: all
+ install dvi2tty disdvi $(bindir)
+ install dvi2tty.1 $(mandir)
+ install disdvi.1 $(mandir)
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/README b/Build/source/texk/dvi2tty/dvi2tty-src/README
new file mode 100644
index 00000000000..266aa9de1a7
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/README
@@ -0,0 +1,60 @@
+ DVI2TTY
+
+
+dvi2tty is intended for previewing dvi-files on text-only
+devices (terminals and lineprinters).
+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.
+The program runs under UNIX and MSDOS without problems
+It should also run under VMS.
+(you may need some site dependend redefinitions, see below).
+
+
+ DISDVI
+
+Disdvi is a simple hack that dumps a dvi file in a more readable form.
+It is not a spectacular program but use it and improve as you wish.
+I'd appreciate any enhancements made, bug reports etc. mailed to me.
+
+
+ COMPILING THE PROGRAMS
+
+Disdvi is rather simple and does not need any modifications.
+To compile under VMS, you might need to define an extra macro:
+Add a -DVMS on the command line, or add a line
+ #define VMS
+in the dvi2tty.h file.
+For dvi2tty you may find the following problems:
+
+ function strchr() can not be found:
+ Your are probably a BSD UNIX or alike.
+ Solution: #define strchr index
+ '/usr/bin/pg' program not found.
+ Solution: change the DEFPAGER macro in dvi2tty.c
+
+When set, just type:
+
+ make
+
+to build disdvi and dvi2tty
+
+dvi2tty is licensed under the GPL version 2. It has had a history of many
+authors, I am just one of the latest maintainers.
+
+Thats all, good luck.
+
+
+If you like this code and want to support is feel free to donate
+at Paypal marcel@mesa.nl. Thanks
+
+- Marcel
+#########################################
+# Marcel J.E. Mol #
+# #
+# MESA Consulting +31-(0)6-54724868 #
+# email: marcel@mesa.nl #
+# The Netherlands #
+# #
+#########################################
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/README.MAC b/Build/source/texk/dvi2tty/dvi2tty-src/README.MAC
new file mode 100644
index 00000000000..2aa17b3055b
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/README.MAC
@@ -0,0 +1,11 @@
+Macintosh port for THINK_C
+
+Done by Alex Viskovatoff <av@mixcom.com>
+
+Guess the Makefile (if it is used by Think C)
+must be changed a bit to include the UNIXtoMacLib/
+for include files and some supporting functions.
+
+Cannot test this..
+
+-Marcel Mol
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/README.ORG b/Build/source/texk/dvi2tty/dvi2tty-src/README.ORG
new file mode 100644
index 00000000000..3eeefc4684c
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/README.ORG
@@ -0,0 +1,26 @@
+
+dvitty is intended for previewing dvi-files on text-only devices
+(terminals and lineprinters). The output is not very pretty many
+times, but it still saves quite a lot of work, especially if you
+have a little ways to walk to a laserprinter, for example.
+
+The program was originally written in Hedrick-Pascal, running on
+TOPS-20, and was later ported to UNIX (BSD, Berkeley-pascal).
+
+It is not very smart in all situations, but still serves it pur-
+pose fairly well.
+
+For information on how to use see the man-page.
+
+Before compiling and installing inspect the "compile-time cust-
+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:
+
+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.
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/README.VMS b/Build/source/texk/dvi2tty/dvi2tty-src/README.VMS
new file mode 100644
index 00000000000..1d07f22389c
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/README.VMS
@@ -0,0 +1,38 @@
+README file for using dvi2tty on VAX/VMS using VAXC
+Created and submitted as a saveset by:
+
+ Robert Schneider Internet: robert@perv.pe.utexas.edu
+ Department of Petroleum Engineering BITNET: pefv673@utchpc
+ University of Texas at Austin THEnet: PERV::ROBERT
+
+ Marcel Mol
+----------------------------------
+
+dvi2tty for VAX/VMS
+
+
+This is a version of dvi2tty for VAX/VMS which may be compiled with VAXC
+and used as a filter for converting the device independent output files
+produced by TeX to files which may be printed on ASCII terminals or line
+printers. The original version of dvi2tty was written by Svante Lindahl.
+The improved C version of dvi2tty on which this port was based was done
+by Marcel Mol. Only a few minor modifications were necessary to make
+dvi2tty work under VMS with VAXC. Please see the file README. for further
+information on the authors and capabilities of dvi2tty.
+
+This saveset includes all sources which are necessary to compile and
+link dvi2tty under VMS using VAXC. Also included in the saveset are object
+files and images generated from these sources. The command file for
+building dvi2tty under VMS and the TeX documentation file for dvi2tty were
+done at The University of Texas at Austin. The TeX documentation file
+was derived from the Unix man page by tr2tex and then converted to match
+local documentation styles. Please see the "NOTE ---" comments in the
+documentation file to make the appropriate modifications for your site.
+
+If you need to rebuild the images used, simply execute VMS_VAXC_DVI2TTY.COM.
+
+
+Robert Schneider
+
+
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/TODO b/Build/source/texk/dvi2tty/dvi2tty-src/TODO
new file mode 100644
index 00000000000..56b7facaad0
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/TODO
@@ -0,0 +1,50 @@
+Date: Mon, 9 Mar 92 02:34:22 -0500
+From: rosen@cns.bu.edu (David B. Rosen)
+Subject: suggestion for dvi2tty
+
+Would it be difficult to have an option where enough blanks would be
+inserted between words to make the right edge of a line of text appear
+where it should? This would be wonderful for justified text. In
+other words, wherever there is a line or string of text, would it be
+possible to calculate the correct position of the rightmost character,
+and justify the line so that both the leftmost and rightmost
+characters are correctly positioned, even if some intermediate
+characters are not?
+
+-----------------------------------------------------------------------------
+
+Redo font handling.
+ Bit of spagetti now. Japanes, scandinavian, finxed fonts, symbols, math
+ etc. Is a commandline option necessary for selecting japan? Selecting based
+ font jfontnum should do it, doesn't it?
+
+-----------------------------------------------------------------------------
+
+For character handling 'char' might not be a good type. May need to
+change it to 'unsigned char' or 'int'.
+
+-----------------------------------------------------------------------------
+
+Date: Mon, 29 Jan 96 15:36:31 MET
+From: Erick Branderhorst <branderhorst@fgg.eur.nl>
+
+% Mocht je nog eens naar dvi2tty kijken zou je dan wellicht iets aan dit
+% soort tabular rariteiten kunnen doen? Een optie misschien waarmee alle
+% tabular info wordt weggevaagd? Of bestaat zoiets reeds.
+
+\documentclass{article}
+
+\begin{document}
+\begin{tabular}[h]{|c||c||c|c||}
+\hline
+-11.1 & -22.2 & -33.3 & -44.4 \\
+\hline
+\end{tabular}
+\end{document}
+
+% Output via dvi2tty versie 5.1
+%
+% ____________________________
+% |_-11.1_|-|22.2-|3|3.3-|44.4_| |
+%
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/getopt.c b/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/getopt.c
new file mode 100644
index 00000000000..a0db51e2520
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/getopt.c
@@ -0,0 +1,124 @@
+/* getopt.c
+ * Modified slightly to port to Think C by AV 4.5.1993.
+ */
+
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "getopt.h"
+
+/*
+ * get option letter from argument vector
+ */
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt; /* character checked for validity */
+char *optarg; /* argument associated with option */
+
+#define BADCH (int)'?'
+#define EMSG ""
+
+int
+getopt(nargc, nargv, ostr)
+ int nargc;
+ char * const *nargv;
+ const char *ostr;
+{
+ static char *place = EMSG; /* option letter processing */
+ register char *oli; /* option letter list index */
+ char *p;
+ if (!*place) { /* update scanning pointer */
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ return(EOF);
+ }
+ if (place[1] && *++place == '-') { /* found "--" */
+ ++optind;
+ place = EMSG;
+ return(EOF);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int)*place++) == (int)':' ||
+ !(oli = index(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means EOF.
+ */
+ if (optopt == (int)'-')
+ return(EOF);
+ if (!*place)
+ ++optind;
+ if (opterr) {
+ if (!(p = rindex(*nargv, '/')))
+ p = *nargv;
+ else
+ ++p;
+ (void)fprintf(stderr, "%s: illegal option -- %c\n",
+ p, optopt);
+ }
+ return(BADCH);
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (!(p = rindex(*nargv, '/')))
+ p = *nargv;
+ else
+ ++p;
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ p, optopt);
+ return(BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return(optopt); /* dump back option letter */
+}
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/macintosh.h b/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/macintosh.h
new file mode 100644
index 00000000000..24843f507c7
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/macintosh.h
@@ -0,0 +1,34 @@
+/* macintosh.h 24.2.1996 Alex Viskovatoff
+ *
+ * Header file accompanying unix-to-macintosh.c.
+ *
+ * Written and copyright (c) 1996 by Alex Viskovatoff.
+ * Permission is granted to distribute and modify this file.
+ */
+
+
+#define PATHNAME_LENGTH 256
+
+#define isascii(c) (((unsigned) c) <= 0x7f)
+
+
+/* "DVI2ODVI" is equivalent to an arry of static unsigned long
+ initialized to {'DVI2', 'ODVI'} - Textures and OzTeX
+ type signatures of dvi files, respectively. */
+
+#define process_dvi_command_line(args) \
+ docommand(args,0L,2,(unsigned long*)"DVI2ODVI")
+
+int docommand(char ***,void*,int,unsigned long*);
+void set_creator(const unsigned char *outfilename);
+int getopt(int nargc, char * const *nargv, const char *ostr);
+char *get_home_dir(void);
+char *get_file_from_dialog(void);
+pascal unsigned char not_rtf_file_p(void *parms);
+
+
+/* The following are defined in getopt.c */
+
+#define index strchr
+#define rindex strrchr
+int getopt(int nargc, char * const *nargv, const char *ostr);
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/unix-to-macintosh.c b/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/unix-to-macintosh.c
new file mode 100644
index 00000000000..f29b0334256
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/UNIXtoMacLib/unix-to-macintosh.c
@@ -0,0 +1,460 @@
+/* unix-to-macintosh.c 24.2.1996
+
+ * Macintosh THINK-C file system and user interface
+ * library for use by dvi2tty, disdvi, and rtf2LaTeX.
+ *
+ * Written and copyright (c) 1996 by Alex Viskovatoff
+ * (av@mixcom.com). Permission is granted to distribute
+ * and modify this file.
+ */
+
+#include <MacHeaders>
+#include <string.h>
+#include "macintosh.h"
+
+
+static char home_pathname_buf[PATHNAME_LENGTH];
+
+static char *make_pathname(char *q,long dir_id, int vol_num)
+{
+ CInfoPBRec directory;
+ Str31 dir_name;
+ int n;
+ directory.dirInfo.ioDrDirID = dir_id;
+ directory.dirInfo.ioVRefNum = vol_num;
+ directory.dirInfo.ioFDirIndex = -1;
+ directory.dirInfo.ioNamePtr = dir_name;
+ for (;;directory.dirInfo.ioDrDirID = directory.dirInfo.ioDrParID) {
+ *q-- = ':';
+ PBGetCatInfoSync(&directory);
+ for (n=*dir_name; n; n--) *q-- = (char) dir_name[n];
+ if (directory.dirInfo.ioDrDirID == 2) break;
+ }
+ return q+1;
+}
+
+char *get_home_dir()
+{
+ FCBPBRec home_dir;
+ Str31 dir_name;
+ Str31 apName;
+ int pathRefNum;
+ Handle apParam;
+ char *p = home_pathname_buf+PATHNAME_LENGTH-1;
+ GetAppParms(&apName,&pathRefNum,&apParam);
+ home_dir.ioRefNum = pathRefNum;
+ home_dir.ioFCBIndx = 0;
+ home_dir.ioNamePtr = dir_name;
+ PBGetFCBInfoSync(&home_dir);
+ *p-- = 0;
+ return make_pathname(p,home_dir.ioFCBParID,home_dir.ioFCBVRefNum);
+}
+
+pascal unsigned char not_rtf_file_p(void *parms)
+{
+ StringPtr name = ((IOParam*)parms)->ioNamePtr;
+ char *p, *q;
+ static char extension[] = ".rtf";
+ int i;
+ if (name[0] < 5) return TRUE;
+ for (i=4, p = (char*) name + name[0] - 3, q=extension; i; i--)
+ if (*p++ != *q++) return TRUE;
+ return FALSE;
+}
+
+void set_creator(const unsigned char *outfilename)
+{
+ FInfo finfo;
+ Str255 filename;
+ StringHandle h;
+ strcpy((char*)filename,(char*)outfilename);
+ CtoPstr(filename);
+ if (!GetFInfo(filename,0,&finfo)) {
+ finfo.fdCreator = *((OSType*)*(h=GetString(128)));
+ ReleaseResource(h);
+ SetFInfo(filename,0,&finfo);
+ }
+}
+
+
+
+/* The rest of file is a modification of the file ccomand.c (part of
+ * Think C 5.0), with the function ccommand renamed to "docommand",
+ * and changed to take three more arguments: a filter procedure to use
+ * when displaying files in the open input file dialog, the length of
+ * a list of signatures of file types that should be displayed in that
+ * dialog, and a pointer to this list. Furthermore, the file creator
+ * signature for the output file, which is of type 'TEXT', is now set
+ * by a call to the new function set_creator. The signature is stored
+ * as a string resource, and so can be modified by means of ResEdit.
+ * (In the distribution, the signature used is '*TEX', that of Textures.)
+ */
+
+
+/*
+ * ccommand.c
+ *
+ * Copyright (c) 1991 Symantec Corporation. All rights reserved.
+ *
+ * This routine should be called from "main" as follows:
+ *
+ * main(int argc, char **argv)
+ * {
+ * argc = ccommand(&argv);
+ * ...
+ *
+ * A dialog is presented allowing entry of command line arguments
+ * and redirection of stdin/stdout.
+ *
+ */
+
+#include <MacHeaders>
+
+#include "stdlib.h"
+#include "errno.h"
+#include "console.h"
+#include "ansi_private.h"
+
+#define NARGS 25
+
+static char *argv[NARGS+1];
+static char argbuf[256];
+
+static void create_dialog(void);
+static Handle ditem(int);
+static void radio(int, int, int);
+static pascal void drawRing(DialogPtr, short);
+
+static Point getWhere = { 90, 82 };
+static Point putWhere = { 106, 104 };
+
+static void setfile(char *, SFReply *);
+
+static void init_command_line(char *, char *);
+static int parse(char *, char *);
+
+enum {
+ cmdLine = 3,
+ inCon, inFile,
+ outCon, outFile, outEcho, outPrint,
+ okRing,
+ labelIn, labelOut, labelLine
+};
+
+static struct {
+ short count;
+ struct {
+ Handle h;
+ Rect box;
+ char kind;
+ } item[13];
+} itemList = { 12,
+
+ /* OK */
+ 0, { 176, 115, 196, 175 }, ctrlItem+btnCtrl,
+
+ /* Cancel */
+ 0, { 176, 225, 196, 285 }, ctrlItem+btnCtrl,
+
+ /* command line */
+ 0, { 141, 34, 157, 376 }, editText+itemDisable,
+
+ /* (stdin) console */
+ 0, { 34, 30, 50, 180 }, ctrlItem+radCtrl,
+
+ /* (stdin) file */
+ 0, { 54, 30, 70, 180 }, ctrlItem+radCtrl,
+
+ /* (stdout) console */
+ 0, { 34, 230, 50, 380 }, ctrlItem+radCtrl,
+
+ /* (stdout) file */
+ 0, { 54, 230, 70, 380 }, ctrlItem+radCtrl,
+
+ /* (stdout) console+file */
+ 0, { 74, 230, 90, 380 }, ctrlItem+radCtrl,
+
+ /* (stdout) console+printer */
+ 0, { 94, 230, 110, 380 }, ctrlItem+radCtrl,
+
+ /* ring around OK button */
+ (Handle) drawRing, { 172, 111, 200, 179 }, userItem+itemDisable,
+
+ /* "Standard Input:" */
+ 0, { 10, 20, 26, 170 }, statText+itemDisable,
+
+ /* "Standard Output:" */
+ 0, { 10, 220, 26, 370 }, statText+itemDisable,
+
+ /* "Command Line:" */
+ 0, { 114, 20, 130, 170 }, statText+itemDisable,
+};
+
+static DialogPtr dp;
+static Rect bounds = { 60, 51, 270, 461 };
+static int inChoice = inCon, outChoice = outCon;
+
+
+/*
+ * ccommand - process "command line"
+ *
+ */
+
+int
+docommand(char ***av, ProcPtr file_filter, int num_types, SFTypeList type_list)
+{
+ short i, argc;
+ SFReply input, output, scratch;
+ char buf[256];
+
+ /* present dialog */
+
+ cshow(stdin);
+ create_dialog();
+ init_command_line(buf, argbuf);
+ SetCtlValue(ditem(inCon), 1);
+ SetCtlValue(ditem(outCon), 1);
+ ShowWindow(dp);
+
+ /* engage in dialog */
+
+ do {
+ ModalDialog(0, &i);
+ switch (i) {
+ case cancel:
+ abort();
+ case inFile:
+ SFGetFile(getWhere, "", file_filter, num_types, type_list, NULL, &scratch);
+ if (!scratch.good)
+ break;
+ input = scratch;
+ /* ... */
+ case inCon:
+ radio(inChoice = i, inCon, 2);
+ break;
+ case outFile:
+ case outEcho:
+ SFPutFile(putWhere, "", "", NULL, &scratch);
+ if (!scratch.good)
+ break;
+ output = scratch;
+ /* ... */
+ case outCon:
+ case outPrint:
+ radio(outChoice = i, outCon, 4);
+ break;
+ }
+ } while (i != ok);
+
+ /* parse command line */
+
+ GetIText(ditem(cmdLine), argbuf);
+ sprintf(buf, "%#s", argbuf);
+ argc = parse(buf, argbuf);
+ *av = argv;
+ DisposDialog(dp);
+
+ /* redirect stdout */
+
+ if (outChoice == outPrint)
+ cecho2printer(stdout);
+ else if (outChoice != outCon) {
+ setfile((char *) scratch.fName, &output);
+ if (outChoice == outFile)
+ freopen((char *) scratch.fName, "w", stdout);
+ else cecho2file((char *) scratch.fName, 0, stdout);
+ set_creator(scratch.fName); /*** Added by av ***/
+ }
+
+ /* redirect stdin */
+
+ if (inChoice == inFile) {
+ setfile((char *) scratch.fName, &input);
+ freopen((char *) scratch.fName, "r", stdin);
+ }
+
+ /* done */
+
+ errno = 0;
+ return(argc);
+}
+
+
+/* ---------- dialog utilities ---------- */
+
+
+/*
+ * create_dialog - build dialog in memory
+ *
+ */
+
+static void
+create_dialog(void)
+{
+ Handle items;
+
+ asm {
+ lea itemList,a0
+ move.l #sizeof itemList,d0
+ _PtrToHand
+ move.l a0,items
+ }
+ dp = NewDialog(0, &bounds, "", 0, 1, (Ptr) -1, 0, 0, items);
+ SetCTitle(ditem(ok), "\pOK");
+ SetCTitle(ditem(cancel), "\pCancel");
+ SetCTitle(ditem(inCon), "\pconsole");
+ SetCTitle(ditem(inFile), "\pfile");
+ SetCTitle(ditem(outCon), "\pconsole");
+ SetCTitle(ditem(outFile), "\pfile");
+ SetCTitle(ditem(outEcho), "\pconsole+file");
+ SetCTitle(ditem(outPrint), "\pconsole+printer");
+ SetIText(ditem(labelIn), "\pStandard Input:");
+ SetIText(ditem(labelOut), "\pStandard Output:");
+ SetIText(ditem(labelLine), "\pCommand Line:");
+}
+
+
+/*
+ * ditem - return item handle
+ *
+ */
+
+static Handle
+ditem(int i)
+{
+ short kind;
+ Handle item;
+ Rect box;
+
+ GetDItem(dp, i, &kind, &item, &box);
+ return(item);
+}
+
+
+/*
+ * radio - adjust a cluster of radio buttons
+ *
+ */
+
+static void
+radio(int i, int j, int n)
+{
+ for (; n--; j++)
+ SetCtlValue(ditem(j), i == j);
+}
+
+
+/*
+ * drawRing - (user-item proc) draw ring around OK button
+ *
+ */
+
+static pascal void
+drawRing(DialogPtr dp, short i)
+{
+ PenNormal();
+ PenSize(3, 3);
+ FrameRoundRect(&itemList.item[okRing-1].box, 16, 16);
+ PenNormal();
+}
+
+
+/* ---------- file utilities ---------- */
+
+
+/*
+ * setfile - prepare to open file
+ *
+ */
+
+static void
+setfile(char *buf, SFReply *reply)
+{
+ IOParam pb;
+
+ pb.ioNamePtr = 0;
+ pb.ioVRefNum = reply->vRefNum;
+ PBSetVolSync(&pb);
+ sprintf(buf, "%#s", reply->fName);
+}
+
+
+/* ---------- string utilities ---------- */
+
+
+/*
+ * init_command_line - prepare initial command line
+ *
+ * The command line is preset to show the name of the program.
+ * The program name is quoted as necessary.
+ *
+ */
+
+static void
+init_command_line(char *buf1, char *buf2)
+{
+ register char *s, *t = buf2;
+ int c, space = 0, dquote = 0, squote = 0, quote = 0;
+
+ sprintf(s = buf1, "%#s", CurApName);
+ while (c = *s++) {
+ if (c == ' ')
+ space = 1;
+ else if (c == '"')
+ dquote = 1;
+ else if (c == '\'')
+ squote = 1;
+ }
+ if (space || dquote || squote)
+ *t++ = quote = dquote && !squote ? '\'' : '"';
+ for (s = buf1; c = *s++; *t++ = c) {
+ if (c == quote || c == '\\')
+ *t++ = '\\';
+ }
+ if (quote)
+ *t++ = quote;
+ *t++ = ' ';
+ *t++ = 0;
+ SetIText(ditem(cmdLine), __c2p(buf2, buf1));
+ SelIText(dp, cmdLine, 9999, 9999);
+}
+
+
+/*
+ * parse - divide command line into "words"
+ *
+ * Words are delimited by one or more spaces. Any characters within
+ * matching single (') or double (") quotes are taken literally. Any
+ * character preceded by a backslash (\) is taken literally.
+ *
+ */
+
+static int
+parse(char *s, char *t)
+{
+ int c, quote = 0, argc = 0;
+
+ while (c = *s++) {
+ if (c == ' ')
+ continue;
+ if (argc < NARGS)
+ argv[argc++] = t;
+ do {
+ if (c == '\\' && *s)
+ c = *s++;
+ else if (c == '"' || c == '\'') {
+ if (!quote) {
+ quote = c;
+ continue;
+ }
+ if (c == quote) {
+ quote = 0;
+ continue;
+ }
+ }
+ *t++ = c;
+ } while (*s && ((c = *s++) != ' ' || quote));
+ *t++ = 0;
+ }
+ return(argc);
+}
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/commands.h b/Build/source/texk/dvi2tty/dvi2tty-src/commands.h
new file mode 100644
index 00000000000..46bf84530df
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/commands.h
@@ -0,0 +1,97 @@
+/*
+ * 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 */
+#define SET1 128 /* typeset a character and move right */
+#define SET2 129 /* ??? */
+#define SET3 130 /* ??? */
+#define SET4 131 /* ??? */
+#define SET_RULE 132 /* typeset a rule and move right */
+#define PUT1 133 /* typeset a character */
+#define PUT2 134 /* ??? */
+#define PUT3 135 /* ??? */
+#define PUT4 136 /* ??? */
+#define PUT_RULE 137 /* typeset a rule */
+#define NOP 138 /* no operation */
+#define BOP 139 /* beginning of page */
+#define EOP 140 /* ending of page */
+#define PUSH 141 /* save the current positions */
+#define POP 142 /* restore previous positions */
+#define RIGHT1 143 /* move right */
+#define RIGHT2 144 /* ??? */
+#define RIGHT3 145 /* ??? */
+#define RIGHT4 146 /* ??? */
+#define W0 147 /* move right by |w| */
+#define W1 148 /* move right and set |w| */
+#define W2 149 /* ??? */
+#define W3 150 /* ??? */
+#define W4 151 /* ??? */
+#define X0 152 /* move right by |x| */
+#define X1 153 /* move right and set |x| */
+#define X2 154 /* ??? */
+#define X3 155 /* ??? */
+#define X4 156 /* ??? */
+#define DOWN1 157 /* move down */
+#define DOWN2 158 /* ??? */
+#define DOWN3 159 /* ??? */
+#define DOWN4 160 /* ??? */
+#define Y0 161 /* move down by |y| */
+#define Y1 162 /* move down and set |y| */
+#define Y2 163 /* ??? */
+#define Y3 164 /* ??? */
+#define Y4 165 /* ??? */
+#define Z0 166 /* move down by |z| */
+#define Z1 167 /* move down and set |z| */
+#define Z2 168 /* ??? */
+#define Z3 169 /* ??? */
+#define Z4 170 /* ??? */
+#define FONT_00 171 /* 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 */
+#define FNT4 238 /* Same as FNT1, except that arg is 4 bytes */
+#define XXX1 239 /* extension to \.DVI primitives */
+#define XXX2 240 /* Like XXX1, but 0<=k<65536 */
+#define XXX3 241 /* Like XXX1, but 0<=k<@t$2^{24}$@> */
+#define XXX4 242 /* potentially long extension to \.DVI
+ primitives */
+#define FNT_DEF1 243 /* define the meaning of a font number */
+#define FNT_DEF2 244 /* ??? */
+#define FNT_DEF3 245 /* ??? */
+#define FNT_DEF4 246 /* ??? */
+#define PRE 247 /* preamble */
+#define POST 248 /* postamble beginning */
+#define POST_POST 249 /* postamble ending */
+#define TRAILER 223 /* trailer bytes in dvi file */
+
+/* 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 */
+
+
+ /* undefined_commands 250 */
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/README.Debian b/Build/source/texk/dvi2tty/dvi2tty-src/debian/README.Debian
new file mode 100644
index 00000000000..040c15867c1
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/README.Debian
@@ -0,0 +1,17 @@
+dvi2tty for Debian
+----------------------
+
+ English DVI: Simply type "dvi2tty file.dvi".
+ Latin1 DVI: Try 'dvi2tty -u file.dvi".
+
+ NTT JTeX or ASCII pTeX DVI: Challenge autodetect. Type "dvi2tty -J file.dvi".
+ If automatic detection is failed, specify by hand.
+ NTT JTeX DVI: type "dvi2tty -N file.dvi".
+ ASCII pTeX DVI: type "dvi2tty -A file.dvi".
+
+You can specify option by defining environment variable "DVI2TTY".
+
+Example:
+ DVI2TTY=J; export DVI2TTY
+
+ -- Kenshi Muto <kmuto@debian.org>, Thu, 5 Jun 2003 18:41:33 +0900
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/changelog b/Build/source/texk/dvi2tty/dvi2tty-src/debian/changelog
new file mode 100644
index 00000000000..97488d5927a
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/changelog
@@ -0,0 +1,118 @@
+dvi2tty (5.3.3-1) stable; urgency=low
+
+ * New upstream version
+
+ -- Marcel Mol <marcel@mesa.nl> Sat Oct 30 14:11:52 CEST 2010
+
+dvi2tty (5.3.1-3) unstable; urgency=low
+
+ * Fix gcc-3.4 FTBFS. (closes: Bug#258634)
+
+ -- Kenshi Muto <kmuto@debian.org> Sun, 11 Jul 2004 09:50:06 +0900
+
+dvi2tty (5.3.1-2) unstable; urgency=low
+
+ * Fix copyright file to point to full GPL text.
+
+ -- Kenshi Muto <kmuto@debian.org> Sat, 14 Jun 2003 15:44:37 +0900
+
+dvi2tty (5.3.1-1) unstable; urgency=low
+
+ * New upstream (closes: Bug#195508)
+ * dvi2tty changes its license to GNU GPL! dvi2tty can go main (Thanks your
+ report, John R Lenton).
+ * New upstream version looks support latin-1 by -c option (closes: Bug#101533)
+ * Fix displaying ASCII pTeX DVI (closes: Bug#185982)
+
+ -- Kenshi Muto <kmuto@debian.org> Thu, 5 Jun 2003 18:47:01 +0900
+
+dvi2tty (5.1-14) unstable; urgency=low
+
+ * Rebuild with new libc. Thanks your reminder, tbm.
+
+ -- Kenshi Muto <kmuto@debian.org> Sun, 23 Mar 2003 23:06:18 +0900
+
+dvi2tty (5.1-13) unstable; urgency=low
+
+ * Fix manual and README.debian (closes: #52832).
+
+ -- Kenshi Muto <kmuto@debian.org> Thu, 16 Dec 1999 13:06:52 +0900
+
+dvi2tty (5.1-12) unstable; urgency=low
+
+ * Add auto detect routine for NTT JTeX and ASCII pTeX (closes: #50610).
+ Thanks, Mr. Kohda.
+
+ -- Kenshi Muto <kmuto@debian.org> Thu, 25 Nov 1999 14:19:33 +0900
+
+dvi2tty (5.1-11) unstable; urgency=low
+
+ * Fix control file (This package must be treated as non-free).
+
+ -- Kenshi Muto <kmuto@debian.org> Wed, 17 Nov 1999 10:21:09 +0900
+
+dvi2tty (5.1-10) unstable; urgency=low
+
+ * New maintainer.
+ * Fix NTT JTeX patch.
+ * Add ASCII pTeX patch.
+
+ -- Kenshi Muto <kmuto@debian.org> Tue, 16 Nov 1999 12:01:20 +0900
+
+dvi2tty (5.1-9) non-free; urgency=low
+
+ * Orphaned package
+
+ -- Christian Schwarz <schwarz@debian.org> Tue, 10 Mar 1998 21:07:41 +0100
+
+dvi2tty (5.1-8) non-free; urgency=low
+
+ * Recompiled with libc6.
+ * Upgraded to standards version 2.2.0.0.
+
+ -- Christian Schwarz <schwarz@debian.org> Sun, 13 Jul 1997 21:59:04 +0200
+
+dvi2tty (5.1-7) non-free; urgency=low
+
+ * New maintainer.
+ * Upgraded to new source format.
+ * Changed distribution to non-free.
+
+ -- Christian Schwarz <schwarz@debian.org> Sat, 22 Mar 1997 13:42:13 +0100
+
+Mon Jun 10 12:54:08 1996 Erick Branderhorst <branderh@debian.org>
+
+ * debian.rules (binary): dpkg-name
+ * debian.rules (binary): gzip manpages
+ * applied dvi2tty.patch
+
+Mon Apr 22 15:24:45 1996 root <branderh@debian.org>
+
+ * debian.control (Description): "on" text-only devices (Thanks Dirk)
+
+Wed Apr 17 10:49:11 1996 Erick Branderhorst <branderh@debian.org>
+
+ * debian.rules: minor changes
+ * Makefile (INSTALL_PROGRAM): stripped installation
+ * debian.control (Architecture): added
+ (Version): changed
+ (Maintainer): changed to branderh@debian.org
+ (Section): tex
+ (Priority): optional
+ (Recommends): removed
+
+dvi2tty (5.1-3);
+ * Elf
+dvi2tty (5.1-2);
+ * No default pager (dvi2tty.c)
+ * Depends not on less.
+dvi2tty (5.1-1);
+ * Depends on less in stead of recommending less. <edd@qed.econ.queensu.ca>
+dvi2tty (5.1-0);
+ * First release.
+ * Changed default pager to `/usr/bin/less' (dvi2tty.c).
+
+Local variables:
+mode: debian-changelog
+add-log-mailing-address: "schwarz@debian.org"
+End:
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/compat b/Build/source/texk/dvi2tty/dvi2tty-src/debian/compat
new file mode 100644
index 00000000000..b8626c4cff2
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/compat
@@ -0,0 +1 @@
+4
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/control b/Build/source/texk/dvi2tty/dvi2tty-src/debian/control
new file mode 100644
index 00000000000..df02fc909ef
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/control
@@ -0,0 +1,13 @@
+Source: dvi2tty
+Section: tex
+Priority: optional
+Maintainer: Kenshi Muto <kmuto@debian.org>
+Build-Depends: debhelper (>> 4.0.0)
+Standards-Version: 3.5.8
+
+Package: dvi2tty
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Previewing dvi-files on text-only devices
+ If no options are passed output will be send to the pager defined in
+ PAGER if specified. If no pager specified the output will go to pager.
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/copyright b/Build/source/texk/dvi2tty/dvi2tty-src/debian/copyright
new file mode 100644
index 00000000000..b3277a854cd
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/copyright
@@ -0,0 +1,12 @@
+This package was debianized by Kenshi Muto <kmuto@debian.org> on
+Thu, 5 Jun 2003 17:06:08 +0900.
+
+It was downloaded from http://www.mesa.nl/pub/dvi2tty/dvi2tty-5.3.1.tar.gz
+
+Upstream Author(s): many, including Marcel J.E. Mol <marcel@mesa.nl>
+
+Copyright:
+ GNU General Public License.
+
+ On Debian systems, the complete text of the GNU General Public
+ License can be found in /usr/share/common-licenses/GPL file.
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/dirs b/Build/source/texk/dvi2tty/dvi2tty-src/debian/dirs
new file mode 100644
index 00000000000..98d15831b4c
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/dirs
@@ -0,0 +1,2 @@
+usr/bin
+usr/share/man/man1
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/docs b/Build/source/texk/dvi2tty/dvi2tty-src/debian/docs
new file mode 100644
index 00000000000..e7473667e8b
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/docs
@@ -0,0 +1,9 @@
+Changelog
+README
+README.ORG
+README.VMS
+TODO
+ligtest.tex
+test.tex
+test.dvi
+debian/jdvi2tty-ascii.patch.header
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/jdvi2tty-ascii.patch.header b/Build/source/texk/dvi2tty/dvi2tty-src/debian/jdvi2tty-ascii.patch.header
new file mode 100644
index 00000000000..a3c9752ba49
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/jdvi2tty-ascii.patch.header
@@ -0,0 +1,30 @@
+From: motonori@kutsuda.kuis.kyoto-u.ac.jp (Motonori Nakamura)
+Newsgroups: fj.sources
+Subject: jdvi2tty (patch to dvi2tty)
+Message-ID: <46@boots.kutsuda.kuis.kyoto-u.ac.jp>
+Date: 10 May 90 07:45:29 GMT
+
+$BCfB<!w5~Bg>pJs$G$9!#(B
+
+$B$b$&!"$I$J$?$+$d$C$F$*$i$l$k$+$bCN$l$^$;$s$,!"0JA0(B
+comp.sources.misc $B$KN.$l$F$$$?(B dvi2tty $B$r(B ASCII-JTeX $BBP1~$K(B
+$BF|K\8l2=$7$^$7$?!#(BUNIX $B$G(B TeX $B$r;H$*$&$H$$$&?M$O!"(BX $B$G(B preview
+$B$9$k$G$7$g$&$7!"(B98 $B>e$GF0$/(B previewer $B$b=P$F$$$k$3$H$G$9$+$i!"(B
+$B<{MW$O>/$J$$$H$O;W$$$^$9$,!"(BTTY $BC<Kv$G%A%g%3%A%g%3$H=q$$$F!"(B
+$B%A%i%C$H3NG'$9$k$N$K$O!"$J$+$J$+JXMx$@$H$NI>H=$G$9!#(B
+($B;d$K!"!V$M!"F|K\8l2=$7$h$&$h!#!W$H!"8@$C$??M$NJ[(B :-)
+
+$B=jA'(B TTY $B$J$N$GJ#;($J?^$O8+$K$/$$$G$9$7!"I=$bHyL/$K$:$l$^$9!#(B
+($B$:$l$k$N$O85$N%W%m%0%i%`$N;EMM$G$9!"G0$N$?$a(B :-p )
+
+$B$H$$$&Lu$G!"%Q%C%A$r%]%9%H$7$^$9!#(B
+
+$B$$$A$*$&!"(BJIS,SJIS,EUC $B$K$OBP1~$7$F$"$j$^$9!#(B
+dvistuff.c $B$NCf$N(B JIS, SJIS $B$N(B define $B$rJQ$($k$H(B($B$^$?$O!"(B
+Makefile $B$G(B define $B$9$k$H(B)$B$*K>$_$N4A;z%3!<%I$K$J$k$O$:$G$9!#(B
+
+$B$A$J$_$K!"855-;v$O<!$NDL$j$G$9!#(B
+($B>JN,(B)
+=========
+ $BCfB<(B $BAGE5(B $B!w5~ETBg3X(B $B9)3X8&5f2J(B $B>pJs9)3X@l96(B $BDEED8&5f<<(B
+ motonori@kuis.kyoto-u.ac.jp
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/postinst b/Build/source/texk/dvi2tty/dvi2tty-src/debian/postinst
new file mode 100644
index 00000000000..47877c36f67
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/postinst
@@ -0,0 +1,12 @@
+#! /bin/sh
+# postinst script for dvi2tty
+#
+# see: dh_installdeb(1)
+
+set -e
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/prerm b/Build/source/texk/dvi2tty/dvi2tty-src/debian/prerm
new file mode 100644
index 00000000000..ff3fbe963de
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/prerm
@@ -0,0 +1,12 @@
+#! /bin/sh
+# prerm script for dvi2tty
+#
+# see: dh_installdeb(1)
+
+set -e
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/debian/rules b/Build/source/texk/dvi2tty/dvi2tty-src/debian/rules
new file mode 100644
index 00000000000..5c919f9eebd
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/debian/rules
@@ -0,0 +1,80 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatability version to use.
+export DH_COMPAT=1
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+
+ # Add here commands to compile the package.
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/tmp.
+ # $(MAKE) install DESTDIR=`pwd`/debian/tmp
+ install -o root -g root -m 755 dvi2tty disdvi `pwd`/debian/tmp/usr/bin
+ install -o root -g root -m 644 dvi2tty.1 disdvi.1 `pwd`/debian/tmp/usr/share/man/man1
+
+ touch install-stamp
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+# dh_testversion
+ dh_testdir
+ dh_testroot
+# dh_installdebconf
+ dh_installdocs
+ dh_installexamples
+# dh_installmenu
+# dh_installemacsen
+# dh_installpam
+# dh_installinit
+# dh_installcron
+ dh_installmanpages
+ dh_installinfo
+# dh_undocumented
+ dh_installchangelogs
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ # You may want to make some executables suid here.
+ dh_suidregister
+# dh_makeshlibs
+ dh_installdeb
+# dh_perl
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/disdvi.1 b/Build/source/texk/dvi2tty/dvi2tty-src/disdvi.1
new file mode 100644
index 00000000000..e59ce5ce46b
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/disdvi.1
@@ -0,0 +1,27 @@
+.TH DISDVI 1 "27 October 2010"
+.SH NAME
+disdvi \- `disassemble' a (p)TeX or XeTeX DVI file
+.SH SYNOPSIS
+.B disdvi
+.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
+or
+.IR xdv_file
+printing the DVI commands and text in a human-readable ASCII format on
+the standard output.
+.SH "SEE ALSO"
+.BR dvi2tty (1)
+.SH AUTHOR
+Marcel J.E. Mol, Delft University of Technology, The Netherlands
+.br
+marcel@mesa.nl, MESA Consulting
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/disdvi.c b/Build/source/texk/dvi2tty/dvi2tty-src/disdvi.c
new file mode 100644
index 00000000000..c78800cd130
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/disdvi.c
@@ -0,0 +1,820 @@
+/*****************************************************************************/
+/* */
+/* disdvi --- disassembles TeX dvi files. */
+/* */
+/* */
+/* 2.26 23oct2010 TexLivel support pTex and XeTex */
+/* 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 */
+/* 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.
+ *
+ */
+
+const char *disdvi = "@(#) disdvi.c 2.26 20101027 M.J.E. Mol (c) 1989-2010, marcel@mesa.nl";
+
+/*
+ * Include files
+ */
+
+#if defined(KPATHSEA)
+# define NO_DEBUG 1
+# include <kpathsea/config.h>
+# include <kpathsea/lib.h>
+#if defined(WIN32)
+# include <kpathsea/variable.h>
+#endif
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#if defined(MSDOS) || defined(WIN32)
+# include <fcntl.h>
+#else
+# if !defined(THINK_C) /* Macintosh */
+# include <unistd.h>
+# endif
+#endif
+#include <ctype.h>
+#include <string.h>
+#include "commands.h"
+#if defined(THINK_C)
+# include "macintosh.h"
+#endif
+#if defined(WIN32) && defined(KPATHSEA)
+#undef fopen
+#define fopen fsyscp_fopen
+#endif
+
+
+/*
+ * Constant definitions
+ */
+
+#define LASTCHAR 127 /* max dvi character, above are commands */
+
+#define get1() num(1)
+#define get2() num(2)
+#define get3() num(3)
+#define get4() num(4)
+#define sget1() snum(1)
+#define sget2() snum(2)
+#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(VMS)
+ main (int argc, char ** argv);
+#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;
+ unsigned long fontnum;
+
+#if defined(WIN32) && defined(KPATHSEA)
+ char **av, *enc;
+ int ac;
+ kpse_set_program_name(argv[0], "disdvi");
+ enc = kpse_var_value("command_line_encoding");
+ if (get_command_line_args_utf8(enc, &ac, &av)) {
+ argv = av;
+ argc = ac;
+ }
+#endif
+
+#if defined(THINK_C)
+ argc = process_disdvi_command_line(&argv);
+#endif
+
+ 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();
+ exit(1);
+ }
+
+ if (argc == 2) {
+ if ((i = strlen(*argv)) == 0) {
+ fprintf(stderr, "Illegal empty filename\n");
+ usage();
+ exit(2);
+ }
+ if ((i >= 5) && (!strcmp(*argv+i-4, dvi_ext)))
+ dvi_name = *argv;
+ else {
+ if ((dvi_name = malloc((i+5) * sizeof(char))) == NULL) {
+ perror("dvi_name");
+ exit(1);
+ }
+ strcpy(dvi_name, *argv);
+ strcat(dvi_name, dvi_ext);
+ }
+ if ((dvifp = fopen(dvi_name, "r")) == NULL) {
+ perror(dvi_name);
+ exit(3);
+ }
+ }
+ else
+ dvifp = stdin;
+
+#if defined(MSDOS) || defined(WIN32)
+ setmode(fileno(dvifp), O_BINARY);
+#endif
+
+ while ((opcode = (int) get1()) != EOF) { /* process until end of file */
+ printf("%06ld: ", pc - 1);
+ if ((opcode <= LASTCHAR) && isprint(opcode)) {
+ printf("Char: ");
+ while ((opcode <= LASTCHAR) && isprint(opcode)) {
+ putchar(opcode);
+ opcode = (int) get1();
+ }
+ putchar('\n');
+ printf("%06ld: ", pc - 1);
+ }
+
+ if (opcode <= LASTCHAR)
+ 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));
+ else
+ switch (opcode) {
+ case SET1 :
+ case SET2 :
+ case SET3 :
+ case SET4 : printf("SET%d: %ld\n", opcode - SET1 + 1,
+ num(opcode - SET1 + 1));
+ break;
+ case SET_RULE : printf("SET_RULE: height: %ld\n", sget4());
+ printf("%06ld: ", pc);
+ printf(" length: %ld\n", sget4());
+ break;
+ case PUT1 :
+ case PUT2 :
+ case PUT3 :
+ case PUT4 : printf("PUT%d: %ld\n", opcode - PUT1 + 1,
+ num(opcode - PUT1 + 1));
+ break;
+ case PUT_RULE : printf("PUT_RULE: height: %ld\n", sget4());
+ printf("%06ld: ", pc);
+ printf(" length: %ld\n", sget4());
+ break;
+ case NOP : printf("NOP\n"); break;
+ case BOP : bop(); break;
+ case EOP : printf("EOP\n"); break;
+ case PUSH : printf("PUSH\n"); break;
+ case POP : printf("POP\n"); break;
+ case RIGHT1 :
+ case RIGHT2 :
+ case RIGHT3 :
+ case RIGHT4 : printf("RIGHT%d: %ld\n", opcode - RIGHT1 + 1,
+ snum(opcode - RIGHT1 + 1));
+ break;
+ case W0 : printf("W0\n"); break;
+ case W1 :
+ case W2 :
+ case W3 :
+ case W4 : printf("W%d: %ld\n", opcode - W0,
+ snum(opcode - W0));
+ break;
+ case X0 : printf("X0\n"); break;
+ case X1 :
+ case X2 :
+ case X3 :
+ case X4 : printf("X%d: %ld\n", opcode - X0,
+ snum(opcode - X0));
+ break;
+ case DOWN1 :
+ case DOWN2 :
+ case DOWN3 :
+ case DOWN4 : printf("DOWN%d: %ld\n", opcode - DOWN1 + 1,
+ snum(opcode - DOWN1 + 1));
+ break;
+ case Y0 : printf("Y0\n"); break;
+ case Y1 :
+ case Y2 :
+ case Y3 :
+ case Y4 : printf("Y%d: %ld\n", opcode - Y0,
+ snum(opcode - Y0));
+ break;
+ case Z0 : printf("Z0\n"); break;
+ case Z1 :
+ case Z2 :
+ case Z3 :
+ case Z4 : printf("Z%d: %ld\n", opcode - Z0,
+ snum(opcode - Z0));
+ break;
+ case FNT1 :
+ case FNT2 :
+ case FNT3 :
+ case FNT4 : fontnum = num(opcode -FNT1 + 1);
+ printf("FNT%d: %ld /* %s */\n",
+ opcode - FNT1 + 1, fontnum,
+ fontname(fontnum));
+ break;
+ case XXX1 :
+ case XXX2 :
+ case XXX3 :
+ case XXX4 : special(opcode - XXX1 + 1); break;
+ case FNT_DEF1 :
+ case FNT_DEF2 :
+ case FNT_DEF3 :
+ case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1); break;
+ 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);
+ }
+ }
+
+ exit(0);
+
+} /* main */
+
+
+
+/*
+ * BOP -- Process beginning of page.
+ */
+
+void bop(void)
+{
+ int i;
+
+ printf("BOP page number : %ld", sget4());
+ for (i=9; i > 0; i--) {
+ if (i % 3 == 0)
+ printf("\n%06ld: ", pc);
+ printf(" %6ld", sget4());
+ }
+ printf("\n%06ld: ", pc);
+ printf(" prev page offset : %06ld\n", sget4());
+
+ return;
+
+} /* bop */
+
+
+
+/*
+ * POSTAMBLE -- Process post amble.
+ */
+
+void postamble(void)
+{
+
+ printf("POST last page offset : %06ld\n", sget4());
+ printf("%06ld: ", pc);
+ printf(" numerator : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" denominator : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" magnification : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" max page height : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" max page width : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" stack size needed: %d\n", (int) get2());
+ printf("%06ld: ", pc);
+ printf(" number of pages : %d\n", (int) get2());
+
+ return;
+
+} /* postamble */
+
+
+
+/*
+ * PREAMBLE -- Process pre amble.
+ */
+
+void preamble(void)
+{
+ register int i;
+
+ printf("PRE version : %d\n", (int) get1());
+ printf("%06ld: ", pc);
+ printf(" numerator : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" denominator : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" magnification : %ld\n", get4());
+ printf("%06ld: ", pc);
+ i = (int) get1();
+ printf(" job name (%3d) :", i);
+ while (i-- > 0)
+ putchar((int) get1());
+ putchar('\n');
+
+ return;
+
+} /* preamble */
+
+
+
+/*
+ * POSTPOSTAMBLE -- Process post post amble.
+ */
+
+void postpostamble(void)
+{
+ register int i;
+
+ printf("POSTPOST postamble offset : %06ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" version : %d\n", (int) get1());
+ while ((i = (int) get1()) == TRAILER) {
+ printf("%06ld: ", pc - 1);
+ printf("TRAILER\n");
+ }
+ while (i != EOF) {
+ printf("%06ld: ", pc - 1);
+ printf("BAD DVI FILE END: 0x%02X\n", i);
+ i = (int) get1();
+ }
+
+ return;
+
+} /* postpostamble */
+
+
+
+/*
+ * SPECIAL -- Process special opcode.
+ */
+
+void special(int x)
+{
+ register long len;
+
+ len = num(x);
+ printf("XXX%d: %ld bytes\n", x, len);
+ printf("%06ld: ", pc);
+ for (; len>0; len--) /* a bit dangerous ... */
+ putchar((int) get1()); /* can be non-printables */
+ putchar('\n');
+
+ return;
+
+} /* special */
+
+
+
+/*
+ * FONTDEF -- Process a font definition.
+ */
+
+void fontdef(int x)
+{
+ register int i;
+ char * name;
+ font * fnt;
+ int namelen;
+ unsigned long fntnum;
+ int new = 0;
+
+ fntnum = num(x);
+ printf("FNT_DEF%d: %ld\n", x, fntnum);
+ printf("%06ld: ", pc); /* avoid side-effect on pc in get4() */
+ printf(" checksum : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" scale : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" design : %ld\n", get4());
+ printf("%06ld: ", pc);
+ printf(" name : ");
+ namelen = (int) get1() + (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[i] = '\0';
+ fnt->name = name;
+ if (new) {
+ fnt->next = fonts;
+ fonts = fnt;
+ }
+
+ printf("%s\n", name);
+
+ return;
+
+} /* fontdef */
+
+
+
+/*
+ * FONTNAME -- Return font name.
+ */
+
+const char * fontname(unsigned long fntnum)
+{
+ font * fnt;
+
+ fnt = fonts;
+ while (fnt != NULL && fnt->num != fntnum)
+ fnt = fnt->next;
+ if (fnt != NULL)
+ return fnt->name;
+
+ return "unknown fontname";
+
+} /* fontname */
+
+
+
+/*
+ * PRINTNONPRINT -- Translate non-printable characters.
+ */
+
+void printnonprint(int ch)
+{
+
+ printf("Char: ");
+ switch (ch) {
+ case 11 : printf("ff /* ligature (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 12 : printf("fi /* ligature (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 13 : printf("fl /* ligature (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 14 : printf("ffi /* ligature (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 15 : printf("ffl /* ligature (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 16 : printf("i /* (non-printing) 0x%02X */", ch);
+ break;
+ case 17 : printf("j /* (non-printing) 0x%02X */", ch);
+ break;
+ case 25 : printf("ss /* german (non-printing) 0x%02X */", ch);
+ break;
+ case 26 : printf("ae /* scandinavian (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 27 : printf("oe /* scandinavian (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 28 : printf("o /* scandinavian (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 29 : printf("AE /* scandinavian (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 30 : printf("OE /* scandinavian (non-printing) 0x%02X */",
+ ch);
+ break;
+ case 31 : printf("O /* scandinavian (non-printing) 0x%02X */",
+ ch);
+ break;
+ default : printf("0x%02X", ch); break;
+ }
+ putchar('\n');
+
+ return;
+
+} /* printnonprint */
+
+
+
+/*
+ * NUM --
+ */
+
+unsigned long num(int size)
+{
+ register int i;
+ register unsigned long x = 0;
+
+ pc += size;
+ for (i = size; i > 0; i--)
+ x = (x << 8) + (unsigned) getc(dvifp);
+
+ return x;
+
+} /* num */
+
+
+
+/*
+ * SNUM --
+ */
+
+long snum(int size)
+{
+ register int i;
+ register long x;
+
+ pc += size;
+ x = getc(dvifp);
+ if (x & 0x80)
+ x -= 0x100;
+ for (i = size - 1; i > 0; 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");
+ fprintf(stderr, "\n If you like this code and want to support is feel free\n to donate at Paypal marcel@mesa.nl. Thanks.\n\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-src/dvi2tty.1 b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.1
new file mode 100644
index 00000000000..0c3a7da6177
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.1
@@ -0,0 +1,172 @@
+.TH DVI2TTY 1 "13 November 1990"
+.SH NAME
+dvi2tty \- preview a TeX 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
+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
+document.
+.br
+Since
+.I dvi2tty
+produces output for terminals and line printers 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.
+.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
+just one logical line an asterisk (``*'') in the last position
+means that the logical line is continued on the next physical
+line output by
+.I dvi2tty.
+Such a continuation line is started with a a space and an asterisk
+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
+environment, will override the one from the environment.
+.PP
+.B Options:
+.PP
+.TP
+.B \-o file
+Write output to file ``file''.
+.TP
+.B \-p list
+Print the pages chosen by list.
+Numbers refer to TeX\-page numbers (known as \\count0).
+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''.
+.TP
+.B \-P list
+Like \-p except that page numbers refer to
+the sequential ordering of the pages in the dvi\-file.
+Negative numbers don't make a lot of sense here...
+.TP
+.B \-w n
+Specify terminal width
+.I n.
+Legal range 16\-132.
+Default is 80. If your terminal has the
+ability to display in 132 columns it might
+be a good idea to use \-w132 and toggle the
+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.
+.TP
+.B \-f
+Pipe through a pager, $PAGER if defined, or whatever the installer of
+the program 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.
+.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.
+.TP
+.B \-c
+Do not attempt to translate any characters (like the Scandinavion/latin1 mode)
+except when running in tt-font.
+.TP
+.B \-u
+Toggle option to process certain latin1 characters. Use this if your output
+devices supports latin1 cahracters.
+Note this may interfere with -s. Best not to use -u and -s together.
+.TP
+.B \-s
+Toggle option to process the special Scandinavian characters that on most (?)
+terminals in Scandinavia are mapped to ``{|}[\\]''.
+Note this may interfere with -u. Best not to use -u and -s together.
+.TP
+.B \-J
+Auto detect NTT JTeX, ASCII pTeX, and upTeX dvi format.
+.TP
+.B \-N
+Display NTT JTeX dvi.
+.TP
+.B \-A
+Display ASCII pTeX dvi.
+.TP
+.B \-U
+Display upTeX dvi.
+.TP
+.B \-Eenc
+Set output Japanese encoding. The enc argument 'e', 's', 'j', and 'u'
+denotes EUC-JP, Shift_JIS, ISO-2022-JP, and UTF-8, respectively.
+.TP
+.B \-bdelim
+Print the name of fonts when switching to it (and ending it). The delim
+argument is used to delimit the fontname.
+.SH FILES
+/bin/more \ \ \ \
+probably the default pager.
+.SH ENVIRONMENT
+PAGER \ \ \ \ \ \ \ \ \ \ \ \
+the pager to use.
+.br
+DVI2TTY \ \ \ \ \ \ \ \ \ \ \
+can be set to hold command-line options.
+.SH "SEE ALSO"
+TeX, dvi2ps
+.SH AUTHOR
+Original Pascal verion: Svante Lindahl, Royal Institute of Technology, Stockholm
+.br
+Improved C version: Marcel Mol
+.br
+marcel@mesa.nl, MESA Consulting
+.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.
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.DCL b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.DCL
new file mode 100644
index 00000000000..637a9c2000d
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.DCL
@@ -0,0 +1,55 @@
+$ !
+$ ! Compile dvi2tty for VAX/VMS under VAXC
+$ !
+$ !
+$ ! April 25, 1990
+$ !
+$ ! Robert Schneider
+$ ! Department of Petroleum Engineering
+$ ! The University of Texas at Austin
+$ ! < robert@perv.pe.utexas.edu >
+$ !
+$ SAY = "WRITE SYS$OUTPUT"
+$ ASK = "INQUIRE /NOPUNCTUATION ANSWER"
+$ !
+$ ! You can stick options for the C compiler in CC_DEFINES. As
+$ ! an example you can be redundant and define CC_DEFINES to be
+$ ! "/DEFINE=VMS".
+$ !
+$ CC_DEFINES = ""
+$ !
+$ SAY " "
+$ ASK "Compile sources? "
+$ inquire_test = ANSWER .eqs. "Y"
+$ if .not. inquire_test then goto linkstep
+$ !
+$ SAY " "
+$ SAY "Compiling sources ..."
+$ SAY " "
+$ !
+$ SAY "DVI2TTY.C ..."
+$ CC 'CC_DEFINES DVI2TTY.C
+$ SAY "DVISTUFF.C ..."
+$ CC 'CC_DEFINES DVISTUFF.C
+$ SAY "DISDVI.C ..."
+$ CC 'CC_DEFINES DISDVI.C
+$ !
+$ linkstep:
+$ SAY " "
+$ SAY "Linking dvi2tty ..."
+$ link /exe=dvi2tty.exe dvi2tty,dvistuff,sys$library:vaxcrtl/lib
+$ SAY "Linking disdvi ..."
+$ link /exe=disdvi.exe disdvi,sys$library:vaxcrtl/lib
+$ SAY " "
+$ SAY "Be sure and copy DVI2TTY.EXE to wherever you store your TeX"
+$ SAY "images and define the symbol;"
+$ SAY " "
+$ SAY "$ dvi2tty :== $path:dvi2tty.exe"
+$ SAY " "
+$ SAY "in your TeX setup command file so it may be accessed. 'path'"
+$ SAY "is the directory location where you store your TeX images."
+$ SAY " "
+$ SAY "Done."
+$ SAY " "
+$ exit
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.c b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.c
new file mode 100644
index 00000000000..2868d90f365
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.c
@@ -0,0 +1,866 @@
+/*
+ * 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
+#endif
+#if defined(THINK_C)
+# include <unix.h>
+# include "macintosh.h"
+#endif
+
+#if defined(WIN32) && defined(KPATHSEA)
+#undef fopen
+#define fopen fsyscp_fopen
+#endif
+
+
+/*
+ * Constant definitons
+ */
+ /*-----------------------------------------------------------------------*/
+ /* The following constants may be toggled before compilation to */
+ /* customize the default behaviour of the program for your site. */
+ /* Whichever their settings are, the defaults can be overridden at */
+ /* runtime. */
+ /*-----------------------------------------------------------------------*/
+
+#define DEFSCAND FALSE /* default is not Scandinavian, toggle this if */
+ /* you have terminals with Scand. nat. chars */
+#define DEFLATIN1 FALSE /* default is no latin1, toggle this if you */
+ /* have terminals with latin1 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 */
+
+ /*------------------ end of customization constants ---------------------*/
+
+#if defined(MSDOS) || defined(VMS) || defined(AMIGA)
+#define OPTSET "haJweEpPousltvbcANU" /* legal options */
+#define OPTWARG "weEpPovb" /* options with argument */
+#else
+#define OPTSET "haJweEpPousqlfFtvbcANU" /* legal options */
+#define OPTWARG "weEpPoFvb" /* options with argument */
+#endif
+
+/*
+ * USAGE CODES
+ */
+
+#define wrnge 1 /* width switch arg out of range */
+#define ign 2 /* ignore cause, print 'Usage:..' */
+#define nan 3 /* not a number where one expected */
+#define gae 4 /* garbage at end */
+#define bdlst 5 /* bad page-numberlist */
+#define onef 6 /* only one dvifile allowed */
+#define bdopt 7 /* bad option */
+#define onepp 8 /* only one page list allowed */
+#define noarg 9 /* argument expected */
+#define confl 10 /* -J, -N, -A, and -U conflict */
+#if defined(THINK_C)
+#define nored 11 /* if no input file, redirect stdin */
+#endif
+
+
+/*
+ * Variable definitions
+ */
+
+const char *dvi2tty = "@(#) dvi2tty.c " VERSION " 20101030 M.J.E. Mol (c) 1989-2010";
+
+
+printlisttype * currentpage; /* current page to print */
+printlisttype * firstpage; /* first page selected */
+printlisttype * lastpage; /* last page selected */
+
+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)
+bool pager; /* tells if output is piped to a pager */
+const char * path; /* name of the pager to run */
+#endif
+char * progname; /* our name */
+int Argc;
+char ** Argv;
+char * DVIfilename;
+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);
+#else
+
+# 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);
+#endif
+
+
+/****************************************************************************/
+/* */
+/* M A I N */
+/* */
+/****************************************************************************/
+
+#if defined(VMS)
+main(int argc, char **argv)
+#else
+int main(int argc, char **argv)
+#endif
+{
+#if defined(WIN32) && defined(KPATHSEA)
+ char *enc;
+#endif
+
+#if defined(THINK_C)
+ argc = process_dvi_command_line(&argv);
+#endif
+
+ progname = *argv;
+ Argc = argc;
+ Argv = argv;
+#if defined(WIN32) && defined(KPATHSEA)
+ kpse_set_program_name(argv[0], "dvi2tty");
+ enc = kpse_var_value("command_line_encoding");
+ get_command_line_args_utf8(enc, &Argc, &Argv);
+#endif
+
+#ifdef WIN32
+ set_enc_string ("sjis", "default");
+#else
+ set_enc_string (NULL, "default");
+#endif
+ getargs(); /* read command line arguments */
+#if defined(THINK_C)
+ if (inputfromfile) {
+#endif
+#if defined(MSDOS) || defined(WIN32)
+ 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
+#endif
+ errorexit(filop); /* can't open dvifile */
+#if defined(THINK_C)
+ }
+ else
+ DVIfile = stdin;
+#endif
+
+ 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)
+ 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 ((output = popen(path, "w")) == NULL) /* get pipe to pager */
+ errorexit(pipcr); /* make output to output */
+ }
+ else
+ pager = FALSE;
+#endif
+ }
+
+ dvimain();
+
+#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
+ if (pager)
+ pclose(output); /* close pipe to pager */
+#endif
+
+ exit(0);
+
+} /* main */
+
+
+
+/*
+ * GETARGS -- Process options from command line and from environment.
+ */
+
+void getargs(void)
+{
+ const char *str;
+ 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)
+ 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 */
+ latin1 = DEFLATIN1; /* latin1 support, 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 ((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
+ while (*envp == ' ')
+ envp++;
+ while (*envp) { /* environment var args */
+ if (strchr(OPTSET, optch = *envp++) != NULL) {
+ /*
+ * we always pass one option, and arrange for optarg ourselfes,
+ * so setoption does not mesh up Argv
+ */
+ if (strchr(OPTWARG, optch) != NULL) {
+ while (*envp == ' ')
+ envp++;
+ if (*envp == '\0')
+ usage(noarg);
+ str = envp; /* str points to optarg */
+ while ((*envp != ' ') && (*envp != '\0'))
+ envp++; /* set envp just after optarg */
+ if (*envp != '\0')
+ *envp++ = '\0'; /* end optarg string */
+ }
+ else
+ str = "";
+ setoption(str);
+ }
+ else
+ usage(bdopt);
+ while (*envp == ' ')
+ envp++;
+ }
+ }
+
+ /*
+ * 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) {
+ str++; /* point to rest of argument if any */
+ if ((strchr(OPTWARG, optch) != NULL) && (*str == '\0')) {
+ if (--Argc <= 0)
+ usage(noarg);
+ str = *++Argv;
+ }
+ setoption(str);
+ }
+ else
+ usage(bdopt);
+ }
+
+ 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' : jautodetect = TRUE; break;
+ case 'U' : uptex = TRUE; japan = TRUE; /* upTeX */
+ jautodetect = FALSE;
+ enable_UPTEX(true);
+ set_enc_string (NULL, UPTEX_INTERNAL_ENC);
+ break;
+ case 'A' : asciip = TRUE; japan = TRUE; /* ASCII pTeX */
+ jautodetect = FALSE;
+ set_enc_string (NULL, PTEX_INTERNAL_ENC);
+ break;
+ case 'N' : nttj = TRUE; japan = TRUE; /* NTT jTeX */
+ jautodetect = FALSE;
+ set_enc_string (NULL, JTEX_INTERNAL_ENC);
+ break;
+ case 'E' :
+ switch (optarg[0]) {
+ case 'e' :
+ set_enc_string ("euc", NULL); break;
+ case 's' :
+ set_enc_string ("sjis", NULL); break;
+ case 'j' :
+ set_enc_string ("jis", NULL); break;
+ case 'u' :
+ set_enc_string ("utf8", NULL); break;
+ default :
+ usage(noarg);
+ }
+ j++;
+ break;
+ case 't' : ttfont = TRUE; break;
+ case 'l' : noffd = TRUE; break;
+ case 's' : scascii ^= 1; break;
+ case 'u' : latin1 ^= 1; 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;
+ }
+ }
+
+ /* Option conflict */
+ if ((asciip && uptex) ||
+ (nttj && (asciip || uptex)) ||
+ (jautodetect && (nttj || asciip || uptex))) {
+ usage(confl);
+ }
+
+ return;
+
+} /* setoption */
+
+
+
+/*
+ * GETPAGES -- Getr a list of pages to print.
+ */
+
+void getpages(int j, const char *str)
+{
+ int i, c;
+ int num;
+
+ pageswitchon = TRUE;
+ if ((firstpage = (printlisttype *) malloc(sizeof(printlisttype))) == NULL) {
+ perror("firstpage");
+ exit(1);
+ }
+ firstpage->all = FALSE;
+ firstpage->nxt = nil;
+ firstpage->pag = 0;
+ lastpage = firstpage;
+ currentpage = firstpage;
+ if (getinteger(&num, &j, str))
+ usage(nan);
+ plcnxt((int) num);
+ while (str[j]) {
+ c = str[j];
+ if (c == ',' || c == ':') {
+ j++;
+ if (getinteger(&num, &j, str))
+ usage(nan);
+ }
+ else
+ break;
+ if (c == ',')
+ plcnxt(num);
+ else {
+ if (currentpage->pag < 0) {
+ if (num > 0) {
+ currentpage->all = TRUE;
+ plcnxt(num);
+ }
+ else if (num < currentpage->pag)
+ for (i = currentpage->pag - 1; i >= num; i--)
+ plcnxt(i);
+ else
+ usage(bdlst);
+ }
+ else {
+ if (num < currentpage->pag)
+ usage(bdlst);
+ for (i = currentpage->pag + 1; i <= num; i++)
+ plcnxt(i);
+ }
+ }
+ }
+ if ((str[j] != ' ') && (str[j] != '\0')) {
+ usage(gae);
+ }
+ currentpage = firstpage;
+
+ return;
+
+} /* getpages */
+
+
+
+/*
+ * PLCNXT -- Place page-nr next in list.
+ */
+
+void plcnxt(int pagnr)
+{
+
+ currentpage = lastpage;
+ currentpage->pag = pagnr;
+ if ((lastpage = (printlisttype *) malloc(sizeof(printlisttype))) == NULL) {
+ perror("lastpage");
+ exit(1);
+ }
+ lastpage->all = FALSE;
+ lastpage->nxt = nil;
+ lastpage->pag = 0;
+ currentpage->nxt = lastpage;
+
+ return;
+
+} /* plcnxt */
+
+
+
+/*
+ * GETFNAME -- {Make sure we have a .dvi filename.
+ */
+
+void getfname(const char *str)
+{
+ int i;
+
+ i = strlen(str);
+ if (i == 0)
+ usage(ign);
+ if ((DVIfilename = (char *) malloc(i+5)) == NULL) {
+ perror("DVIfilename");
+ exit(1);
+ }
+ strcpy(DVIfilename, str);
+#ifdef KPATHSEA
+ if (!kpse_readable_file(DVIfilename))
+#else
+ if ((i < 5) || strcmp(str+i-4, ".dvi"))
+#endif
+ strcat(DVIfilename, ".dvi");
+
+ return;
+
+} /* 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)
+{
+ int 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*10 + ch - '0';
+ 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)
+{
+
+ fprintf(stderr, "%s: ", progname);
+ switch (errorcode) {
+ case illop : fprintf(stderr, "Illegal op-code found: %d\n", opcode);
+ break;
+ case stkof : fprintf(stderr, "Stack overflow\n");
+ break;
+ case stkuf : fprintf(stderr, "Stack underflow\n");
+ break;
+ case stkrq : fprintf(stderr, "Cannot create dvi stack\n");
+ break;
+ case lnerq : fprintf(stderr, "Cannot allocate memory\n");
+ break;
+ case badid : fprintf(stderr, "Id-byte is not correct: %d\n ", opcode);
+ break;
+ case bdsgn : fprintf(stderr, "Bad signature: %d (not 223)\n",
+ (int) foo);
+ break;
+ case fwsgn : fprintf(stderr, "%d signature bytes (min. 4)\n",
+ (int) foo);
+ break;
+ case nopre : fprintf(stderr, "Missing preamble\n");
+ break;
+ case nobop : fprintf(stderr, "Missing beginning-of-page command\n");
+ break;
+ case nopp : fprintf(stderr, "Missing post-post command\n");
+ break;
+ case bdpre : fprintf(stderr, "Preamble occured inside a page\n");
+ break;
+ case bdbop : fprintf(stderr, "BOP-command occured inside a page\n");
+ break;
+ case bdpst : fprintf(stderr, "Postamble occured before end-of-page\n");
+ break;
+ case bdpp : fprintf(stderr, "Postpost occured before post-command\n");
+ break;
+ case nopst : fprintf(stderr, "Missing postamble\n");
+ break;
+ case illch : fprintf(stderr, "Character code out of range, 0..127\n");
+ break;
+ case filop : fprintf(stderr, "Cannot open dvifile\n");
+ break;
+ case filcr : fprintf(stderr, "Cannot create outfile\n");
+ break;
+#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
+ case pipcr : fprintf(stderr, "Cannot create pipe to pager\n");
+ break;
+#endif
+ default : fprintf(stderr, "Unkown error code\n");
+ break;
+ };
+ if (outputtofile)
+#if defined(VMS)
+ remove(OUTfilename);
+#else
+ unlink(OUTfilename);
+#endif
+
+ exit(errorcode);
+
+} /* errorexit */
+
+
+
+/*
+ * USAGE -- Print the usage info. Also print a warning/error message
+ * if needed.
+ */
+
+void usage(int uerr)
+{
+
+ if (jautodetect || nttj || asciip || uptex)
+ fprintf(stderr, "%s (%s) %s", Progname, get_enc_string(), Copyright);
+ else
+ fprintf(stderr, "%s %s", Progname, Copyright);
+
+ if (uerr != ign) {
+ fprintf(stderr,"\n%s: ", progname);
+ switch (uerr) {
+ case wrnge : fprintf(stderr, "width arg out of range:16-%d",
+ MAXTERMWIDTH);
+ break;
+ case nan : fprintf(stderr,
+ "numeric argument expected for option %c",
+ optch);
+ break;
+ case gae : fprintf(stderr, "garbage in argument for option %c",
+ optch);
+ break;
+ case bdlst : fprintf(stderr, "mal-formed list of pagenumbers");
+ break;
+ case onef : fprintf(stderr, "only one infile argument allowed");
+ break;
+ 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;
+ case confl : fprintf(stderr, "-J, -N, -A, and -U are mutually exclusive");
+ 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, "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");
+ fprintf(stderr,
+ " -Plist Print pages whose 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)
+ fprintf(stderr, " -f Try to pipe to a pager if output is a tty");
+ if (WANTPAGER)
+ fprintf(stderr, " (default).\n");
+ else
+ fprintf(stderr, ".\n");
+ fprintf(stderr, " -q Don't try to pipe to a pager");
+ if (WANTPAGER)
+ fprintf(stderr, ".\n");
+ else
+ fprintf(stderr, " (default).\n");
+ 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,
+ " -s Toggle National Swedish/Finnish characters printed as aaoAAO (default %s).\n", DEFSCAND ? "off" : "on");
+ fprintf(stderr,
+ " -u Toggle latin1 support (default %s).\n", DEFLATIN1 ? "on" : "off");
+ fprintf(stderr,
+ " -J Enable auto detect for NTT JTeX, ASCII pTeX, and upTeX (japanese fonts).\n");
+ fprintf(stderr,
+ " -N Support NTT JTeX dvi.\n");
+ fprintf(stderr,
+ " -A Support ASCII pTeX dvi.\n");
+ fprintf(stderr,
+ " -U Support upTeX dvi.\n");
+ fprintf(stderr,
+ " -Eenc Output Japanese encoding. e:EUC s:SJIS j:JIS, u:UTF8.\n");
+ fprintf(stderr,
+ " -c Override -a -u -s and print all characters 0-255.\n");
+ fprintf(stderr,
+ " -bdelim Print font switch as text: delimcmr10miled\n");
+ fprintf(stderr, " -h This help message.\n");
+ fprintf(stderr, "\n If you like this code and want to support is feel free\n to donate at Paypal marcel@mesa.nl. Thanks.\n\n");
+
+
+ exit(uerr);
+
+} /* usage */
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.h b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.h
new file mode 100644
index 00000000000..e905156300e
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.h
@@ -0,0 +1,169 @@
+/*
+ * 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 VERSION "5.3.4"
+
+#define Progname "dvi2tty"
+#define Copyright "Copyright (C) 1984, 1985, 1986 Svante Lindahl.\n\
+Copyright (C) 1989-2010 M.J.E. Mol, MESA Consulting B.V."
+
+
+#if defined(KPATHSEA)
+# define NO_DEBUG 1
+# include <kpathsea/config.h>
+# include <kpathsea/readable.h>
+#if defined(WIN32)
+# include <kpathsea/variable.h>
+#endif
+# include <sys/types.h>
+# include <sys/stat.h>
+#else
+# define TRUE 1
+# define FALSE 0
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#if defined(MSDOS) || (defined(WIN32) && !defined(__MINGW32__))
+# include <malloc.h>
+#else
+# if !defined(THINK_C)
+# include <unistd.h>
+# endif
+#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
+
+#include <ptexenc/ptexenc.h>
+#include <ptexenc/unicode.h>
+
+/* internal encoding for NTT JTeX : "euc" */
+#define JTEX_INTERNAL_ENC "euc"
+
+/* internal encoding for ASCII pTeX : "euc" or "sjis" */
+#define PTEX_INTERNAL_ENC "euc"
+
+/* internal encoding for upTeX : "uptex" */
+#define UPTEX_INTERNAL_ENC "uptex"
+
+/*
+ * ERROR CODES , don't start with 0
+ */
+
+#define illop 1 /* illegal op-code */
+#define stkof 2 /* stack over-flow */
+#define stkuf 3 /* stack under-flow */
+#define stkrq 4 /* stack requirement */
+#define lnerq 5 /* line allocation */
+#define badid 6 /* id is not right */
+#define bdsgn 7 /* signature is wrong */
+#define fwsgn 8 /* too few signatures */
+#define nopre 9 /* no pre-amble where expected */
+#define nobop 10 /* no bop-command where expected */
+#define nopp 11 /* no postpost where expected */
+#define bdpre 12 /* unexpected preamble occured */
+#define bdbop 13 /* unexpected bop-command occured */
+#define bdpst 14 /* unexpected post-command occured */
+#define bdpp 15 /* unexpected postpost */
+#define nopst 16 /* no post-amble where expected */
+#define illch 17 /* character code out of range */
+#define filop 18 /* cannot access file */
+#define filcr 19 /* cannot creat file */
+#if !defined(MSDOS)
+#define pipcr 20 /* cannot creat pipe */
+#endif
+
+
+
+/*
+ * Type definitions
+ */
+
+typedef char bool;
+
+typedef struct prlistptr { /* list of pages selected for output */
+ int pag; /* number of pages */
+ bool all; /* pages in interval selected */
+ struct prlistptr *prv; /* previous item in list */
+ 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 latin1; /* latin1 chars (dvistuff.c) */
+extern bool accent; /* Output accent stuff(dvistuff.c) */
+extern bool ttfont; /* tt font assumed (dvistuff.c) */
+extern bool jautodetect; /* Autodetect NTT jTeX, ASCII pTeX and upTeX (dvistuff.c) */
+extern bool nttj; /* NTT jTeX font support (dvistuff.c) */
+extern bool asciip; /* ASCII pTeX font support (dvistuff.c) */
+extern bool uptex; /* upTeX font support (dvistuff.c) */
+extern bool japan; /* japanized TeX 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) */
+extern printlisttype *lastpage; /* last page selected (dvi2tty.c) */
+
+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 const 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 --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.lsm b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.lsm
new file mode 100644
index 00000000000..1fe3c431d07
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.lsm
@@ -0,0 +1,16 @@
+Begin2
+Title = dvi2tty convert TeX dvi output to ascii.
+Author = Svante Lindahl / Marcel Mol
+Maintainer = Marcel Mol
+Site1 = ftp.mesa.nl
+Location = /pub/dvi2tty/...
+File1 = dvi2tty-5.3.3.tgz
+FileSize1 =
+CopyPolicy1 = Permision to distribute archive only
+CopyPolicy2 = with (c) notice intact
+Keywords = TeX dvi ascii tty printing
+Entered = 23jun95
+EnteredBy = Marcel Mol
+Company = MESA Consulting
+CheckedEmail = marcel@@mesa.nl
+End
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.tex b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.tex
new file mode 100644
index 00000000000..5687d5e013c
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvi2tty.tex
@@ -0,0 +1,271 @@
+%
+% By: Robert Schneider
+%
+% LaTeX input file which describes how dvi2tty works under
+% VMS with VAXC. When using this file as a source for documentation
+% of dvi2tty on your system, look for the string "NOTE ---" to
+% see what local variables need to be set.
+%
+% This file was created by modifying the original Unix man page.
+% The majority of the conversion from troff to TeX was done by
+% tr2tex.
+%
+\documentstyle{article}
+%
+% Set the page margins.
+%
+\parindent 0pt
+\marginparpush 5pt
+\headheight 5pt
+\headsep 0pt
+\footheight 5pt
+\footskip 15pt
+\columnsep 10pt
+\columnseprule 0pt
+\marginparwidth 0pt
+\oddsidemargin 0pt
+\evensidemargin 0pt
+\marginparsep 0pt
+\topmargin 0pt
+\textwidth 6.5in
+\textheight 9.0in
+%
+\newcommand{\bs}{$\backslash$}
+%
+\title{{\bf DVI2TTY for VAX/VMS}}
+\author{}
+\date{April 25, 1990}
+%
+\begin{document}
+\maketitle
+%
+% NOTE --- We like to describe what something is and how to get it
+% at the top of our files. You will probably want to
+% delete from here to the next \section.
+%
+This document describes the use of {\bf dvi2tty}\/, a filter for converting
+the device independent output files created by \TeX\/ to files which may
+be printed on any ASCII terminal or line printer.
+This document may be printed on the line printer in CPE-3.102 by entering
+the command;
+\\[1ex]
+{\em DOCPRINT SYS\$DOCUMENT:DVI2TTY.DOC}
+\\[1ex]
+Copies of this document may be printed on the laser printer in CPE-3.159
+by entering the command;
+\\[1ex]
+{\em PSPRINT SYS\$DOCUMENT:DVI2TTY.PS}
+\\[1ex]
+You may view copies of this document on workstations or personal computers
+which recognize the {\it X}\/ window system protocol by entering the command;
+\\[1ex]
+{\em XDVI SYS\$DOCUMENT:DVI2TTY.DVI}
+\section*{Description}
+{\bf 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
+preliminary proofreading of \TeX-ed documents.
+By default the output is directed to the terminal.
+%
+% NOTE --- VMS can't pipe output to a pager. Maybe you are lucky
+% and your system can.
+%
+%,possibly through a pager (depending on how the program was installed),
+%but it can be directed to a file or a pipe.
+\par\vspace{1.0\baselineskip}
+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
+document.
+\par\vspace{1.0\baselineskip}
+Since {\bf dvi2tty}\/ produces output for terminals and line printers the
+representation of documents is naturally quite primitive.
+Font changes 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.
+\par\vspace{1.0\baselineskip}
+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
+{\bf 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
+just one logical line an asterisk (``*'') in the last position
+means that the logical line is continued on the next physical
+line output by {\bf dvi2tty.}
+Such a continuation line is started with a space and an asterisk
+in the first two columns.
+\section*{Format}
+{\bf dvi2tty}
+[
+{\bf -o}
+{\it file}
+]
+[
+{\bf -p}
+{\it list}
+]
+[
+{\bf -P}
+{\it list}
+]
+[
+{\bf -w}
+{\it n}
+]
+[
+{\bf -l}
+]
+[
+{\bf -u}
+]
+[
+{\bf -s}
+]
+{\it file\rm[\it.dvi\rm]}
+\par\vspace{1.0\baselineskip}
+{\bf dvi2tty}\/ is compiled with VAXC which converts uppercase command line
+arguments to lowercase. To pass an uppercase argument to {\bf dvi2tty},
+the argument must be enclosed in quotation marks ( i.e. ``-P'' ). Arguments
+enclosed in brackets ( [ ] ) are optional.
+\section*{Options}
+The {\it file}\/ [{\it .dvi}] argument is optional.
+Options may be specified in either a symbol or logical which is named
+%
+% NOTE --- The definition of the following environment variable
+% is implementation dependent.
+%
+DVI\$DVI2TTY or on the command line.
+Any option on the command line, conflicting with one in the
+environment, will override the one from the environment.
+\begin{list}{}{\setlength{\leftmargin}{0.6in}\labelwidth 0.6in}
+\item[{{\bf -o} {\it name}}]
+Write output to file {\it name}.
+\item[{{\bf -p} {\it list}}]
+Print the pages chosen by {\it list}.
+Numbers refer to \TeX-page numbers (known as \bs count0).
+An example of format for {\it 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''.
+\item[{{\bf -P} {\it list}}]
+Like -p except that page numbers refer to
+the sequential ordering of the pages in the dvi-file.
+Negative numbers don't make a lot of sense here...
+\item[{{\bf -w} {\it n}}]
+Specify terminal width {\it n.}\/ The legal range is 16-132 with a
+default of 80. If your terminal has the
+ability to display in 132 columns it might
+be a good idea to use -w132 and toggle the
+terminal into this mode as output will probably look somewhat better.
+%
+% NOTE --- The ability to pipe to a pager is operating system dependent.
+%
+%\item[{{\bf -q}}]
+%Don't pipe the output through a pager.
+%This may be the default on some systems
+%(depending on the whims of the SA installing the program).
+%\item[{{\bf -f}}]
+%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.
+%\item[{{\bf -F}}]
+%Specify the pager program to be used.
+%This overides the \$PAGER and the default pager.
+%\item[{{\bf -Fprog}}]
+%Use ``prog'' as program to pipe output into. Can be used to choose an
+%alternate pager (e g ``-Fless'').
+\item[{{\bf -l}}]
+Mark page breaks with the two-character sequence ``\^{}L''. The default is
+to mark them with a form feed character.
+\item[{{\bf -c}}]
+Do not attempt to trnaslate any characters (like the Scandinavion mode)
+except when running in tt-font.
+\item[{{\bf -bdelim}}]
+Print the name of fonts when switching to it (and ending it). The delim
+argument is used to delimit the fontname.
+\item[{{\bf -u}}]
+Toggle option to process certain latin1 characters. Use this if your output
+devices supports latin1 cahracters.
+Note this may interfere with -u. Best not to use -u and -s together.
+\item[{{\bf -s}}]
+Toggle option to process the special Scandinavian characters that on most (?)
+terminals in Scandinavia are mapped to ``\{$|$\}[\bs ]''.
+Note this may interfere with -u. Best not to use -u and -s together.
+\item[{{\bf -J}}]
+Auto detect NTT JTeX, ASCII pTeX, and upTeX dvi format.
+\item[{{\bf -N}}]
+Display NTT JTeX dvi.
+\item[{{\bf -A}}]
+Display ASCII pTeX dvi.
+\item[{{\bf -U}}]
+Display upTeX dvi.
+\item[{{\bf -Eenc}}]
+Set output Japanese encoding. The enc argument 'e', 's', 'j', and 'u'
+denotes EUC-JP, Shift\_JIS, ISO-2022-JP, and UTF-8, respectively.
+\end{list}
+%
+% NOTE --- No other files are used under VMS.
+%
+%\section*{FILES}
+%/usr/ucb/more \ \ \ \
+%probably the default pager.
+\section*{Environment}
+%
+% NOTE --- The PAGER variable isn't used under VMS.
+%
+%PAGER \ \ \ \ \ \ \ \ \ \ \ \
+%the pager to use.
+%\nwl
+%
+% NOTE --- The definition of the following environment variable
+% is operating system dependent.
+%
+Either a symbol or logical which is named DVI\$DVI2TTY can be set to hold
+command line options. As an example, if you wish to normally have your
+output written to the file {\it dvi2tty.output}\/ and wish to also have
+the output be 132 columns in width, you may define the logical name
+DVI\$DVI2TTY as in;
+\par\vspace{1.0\baselineskip}
+\begin{center}
+{\bf \$ DEFINE DVI\$DVI2TTY ``{\it o dvi2tty.output w 132}''}
+\end{center}
+\par\vspace{1.0\baselineskip}
+Options set in the environment variable will be overridden by conflicting
+options on the command line.
+\section*{See Also}
+%
+% NOTE --- How do you describe where your help files and manuals are?
+%
+For further information use the DCL command {\bf HELP TeX}\/ to obtain
+information on \TeX\/ and how \TeX\/ may be used on our system.
+You should also read the \LaTeX\/ {\it Local Guide}\/ which may be found
+in SYS\$DOCUMENT:.
+This document may be printed on the line printer in CPE-3.102 by entering
+the command;
+\\[1ex]
+{\em DOCPRINT SYS\$DOCUMENT:LOCAL\_GUIDE.DOC}
+\\[1ex]
+Copies of this document may be printed on the laser printer in CPE-3.159
+by entering the command;
+\\[1ex]
+{\em PSPRINT SYS\$DOCUMENT:LOCAL\_GUIDE.PS}
+\\[1ex]
+You may view copies of this document on workstations or personal computers
+which recognize the {\it X}\/ window system protocol by entering the command;
+\\[1ex]
+{\em XDVI SYS\$DOCUMENT:LOCAL\_GUIDE.DVI}
+\section*{Bugs}
+Blanks between words get lost quite easy. This is less
+likely if you are using a wider output than the default 80.
+\par\vspace{1.0\baselineskip}
+Only one file may be specified on the command line.
+\section*{Author}
+Svante Lindahl, Royal Institute of Technology, Stockholm
+\\[1ex]
+\{seismo, mcvax\}!enea!ttds!zap
+\\[1ex]
+Improved C version: Marcel Mol
+\\[1ex]
+marcel@mesa.nl, MESA Consulting
+\end{document}
+
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c b/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c
new file mode 100644
index 00000000000..91d1f2d4c81
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c
@@ -0,0 +1,1697 @@
+/*
+ * 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 types.h
+# include stat
+#else
+# if defined(THINK_C)
+# include <unix.h>
+# else
+# include <sys/types.h>
+# include <sys/stat.h>
+# endif
+#endif
+
+#if defined(MSDOS) || defined(THINK_C)
+# include <math.h>
+#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) )
+#else
+#define mseek fseek
+#endif
+
+#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 leftmargin -50 /* give some room for negative h-coordinate */
+#define LINELEN rightmargin - leftmargin + 1
+
+#define MOVE TRUE /* if advancing h when outputing a rule */
+#define STAY FALSE /* if not advancing h when outputing a rule */
+
+#define absolute 0 /* for seeking in files */
+#define relative 1
+
+#define FORM 12 /* formfeed */
+#define SPACE 32 /* space */
+#define DEL 127 /* delete */
+
+#define LASTCHAR 127 /* max dvi character, above are commands */
+
+#define IMIN(a, b) (a<b ? a : b)
+#define IMAX(a, b) (a>b ? a : b)
+
+#define get1() num(1)
+#define get2() num(2)
+#define get3() num(3)
+#define get4() num(4)
+#define sget1() snum(1)
+#define sget2() snum(2)
+#define sget3() snum(3)
+#define sget4() snum(4)
+
+
+/*
+ * Structure and variable definitions
+ */
+
+const char *dvistuff = "@(#) dvistuff.c " VERSION " 20101027 M.J.E. Mol (c) 1989-2010";
+
+typedef struct {
+ long hh;
+ long vv;
+ long ww;
+ long xx;
+ long yy;
+ long zz;
+} stackitem;
+
+typedef struct lineptr { /* the lines of text to be output to outfile */
+ long vv; /* vertical position of the line */
+ int charactercount; /* pos of last char on line */
+ struct lineptr *prev; /* preceding line */
+ struct lineptr *next; /* succeeding line */
+ unsigned char text[LINELEN+1]; /* leftmargin...rightmargin */
+} linetype;
+
+typedef struct _font {
+ long num;
+ struct _font * next;
+ char * name;
+ char flags; /* to store font types, to get rid of nttj/asciip/uptex/ttfont/symbolfon/mifont vars */
+ int fontnum; /* helper for japanese fonts */
+} font;
+
+#define SYMFONT 0x01
+#define TTFONT 0x02
+#define MIFONT 0x04
+#define JAPFONT 0x08
+#define JASCFONT 0x10
+
+
+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 latin1; /* if true make latin1 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 nttj = FALSE; /* switch to NTT japanese fonts ... */
+bool asciip = FALSE; /* switch to ASCII japanese fonts ... */
+bool uptex = FALSE; /* switch to upTeX CJK fonts ... */
+bool japan = FALSE; /* switch to NTT/ASCII/.. japanese fonts ... */
+bool jautodetect = FALSE; /* switch if do auto detection of Japanese TeX */
+bool jdetect = FALSE; /* switch if Japanese TeX detection is done */
+bool mifont = FALSE; /* ASCII japanese font ??? */
+bool noffd; /* if true output ^L instead of formfeed */
+const 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 */
+
+long h, v; /* coordinates, horizontal and vertical */
+long w, x, y, z; /* horizontal and vertical amounts */
+
+long pagecounter; /* sequence page number counter */
+long backpointer; /* pointer for offset to previous page */
+long pagenr; /* TeX page number */
+int stackmax; /* stacksize required */
+
+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 */
+linetype * lastline; /* pointer to last line on current page */
+int firstcolumn; /* 1st column with something to print */
+
+stackitem * stack; /* stack for dvi-pushes */
+int sptr; /* stack pointer */
+
+font * fonts = NULL; /* List of fontnames defined */
+font * fnt = NULL; /* Current font */
+
+int kanji1 = 0; /* number of rest of trailer bytes in kanji character */
+
+
+
+/*
+ * Function definitions
+ */
+
+#if defined(MSDOS)
+void postamble (void);
+void preamble (void);
+void walkpages (void);
+void initpage (void);
+void dopage (void);
+void skippage (void);
+void printpage (void);
+bool inlist (long);
+void rule (bool, long, long);
+void ruleaux (long, long, char);
+long horizontalmove (long);
+int skipnops (void);
+linetype * my_getline (void);
+linetype * findline (void);
+unsigned long num (int);
+long snum (int);
+void dochar (unsigned char);
+void symchar (unsigned char);
+void normchar (unsigned char);
+void outchar (unsigned char);
+void putcharacter (long);
+void setchar (long);
+void fontdef (int);
+void setfont (long);
+void jischar (unsigned long);
+int compute_jis (int, unsigned int, unsigned int *, unsigned int *);
+void dokanji (long);
+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 * my_getline (void);
+linetype * findline (void);
+unsigned long num (int size);
+long snum (int size);
+void dochar (unsigned char ch);
+void symchar (unsigned char ch);
+void normchar (unsigned 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 (unsigned long ch);
+void compute_jis (int f, unsigned int c, unsigned int * ku, unsigned int * ten);
+void dokanji (long ch);
+int getjsubfont (char * s);
+#if defined(VMS)
+long vmsseek ();
+long vms_ftell ();
+long vms_ungetc ();
+#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.
+ */
+
+void dvimain(void)
+{
+
+ postamble(); /* seek and process the postamble */
+ preamble(); /* process preamble */
+ /* note that walkpages *must* immediately follow preamble */
+ walkpages(); /* time to do the actual work! */
+
+ return;
+
+} /* dvimain */
+
+
+ /*
+ * POSTAMBLE -- Find and process postamble, use random access
+ */
+
+void postamble(void)
+{
+ register long size;
+ register int count;
+#if !defined (THINK_C) && defined(VMS)
+ struct stat st;
+#endif
+
+#if defined (THINK_C)
+ size = DVIfile->len;
+#elif defined(VMS)
+ fstat (fileno(DVIfile), &st);
+ size = (long) st.st_size; /* get size of file */
+#else
+ fseek (DVIfile, 0L, SEEK_END);
+ size = ftell (DVIfile); /* get size of file */
+#endif
+
+ count = -1;
+ do { /* back file up past signature bytes (223), to id-byte */
+ if (size-- == 0)
+ errorexit(nopst);
+ mseek(DVIfile, size, absolute);
+ opcode = (int) get1();
+ count++;
+ } while (opcode == TRAILER);
+ if (count < 4) { /* must have 4 trailer bytes */
+ foo = count;
+ errorexit(fwsgn);
+ }
+ if (opcode != VERSIONID)
+ errorexit(badid);
+ mseek(DVIfile, size-4, absolute); /* back up to back-pointer */
+ mseek(DVIfile, sget4(), absolute); /* and to start of postamble */
+ if (get1() != POST)
+ errorexit(nopst);
+ mseek(DVIfile, 20L, relative); /* lastpageoffset, numerator, denominator */
+ /* magnification, maxpageheight */
+ maxpagewidth = sget4();
+ charwidth = maxpagewidth / (ttywidth + espace);
+ stackmax = (int) get2();
+ if ((stack = (stackitem *) malloc(stackmax * sizeof(stackitem))) == NULL)
+ errorexit(stkrq);
+
+ /* get2() -- totalpages */
+ /* fontdefs do fontdefs in flight ... */
+
+ return;
+
+} /* postamble */
+
+
+
+/*
+ * PREAMBLE --process preamble, use random access
+ */
+
+void preamble(void)
+{
+
+ mseek(DVIfile, 0L, absolute); /* read the dvifile from the start */
+ if ((opcode = skipnops()) != PRE)
+ errorexit(nopre);
+ opcode = (int) get1(); /* check id in preamble, ignore rest of it */
+ if (opcode != VERSIONID)
+ errorexit(badid);
+ 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)
+{
+ register bool wantpage;
+
+ pagecounter = 0L;
+ while ((opcode = skipnops()) != POST) {
+
+ if (opcode != BOP) /* should be at start of page now */
+ errorexit(nobop);
+
+ 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
+ skippage();
+ }
+
+ return;
+
+} /* walkpages */
+
+
+
+/*
+ * INITPAGE -- Setup a new, empty page.
+ */
+
+void initpage(void)
+{
+
+ h = 0L; v = 0L; /* initialize coordinates */
+ x = 0L; w = 0L; y = 0L; z = 0L; /* initialize amounts */
+ sptr = 0; /* initialize stack */
+ currentline = my_getline(); /* initialize list of lines */
+ currentline->vv = 0L;
+ firstline = currentline;
+ lastline = currentline;
+ firstcolumn = rightmargin;
+ if (pageswitchon) {
+ 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 (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)
+{
+
+ while ((opcode = (int) get1()) != EOP) { /* process page until eop */
+ if (opcode <= LASTCHAR)
+ dochar((unsigned char) opcode);
+ else if ((opcode >= FONT_00) && (opcode <= FONT_63))
+ setfont((long) opcode - FONT_00);
+ else if (opcode > POST_POST)
+ errorexit(illop);
+ else
+ switch (opcode) {
+ case SET1 : nttj ? jischar(get1()) : setchar(get1());break;
+ case SET2 : (asciip || uptex) ? dokanji(get2()) : setchar(get2()); break;
+ case SET3 : uptex ? dokanji(get3()) : setchar(get3()); break;
+ case SET4 : setchar(get4()); break;
+ case SET_RULE : { long height = sget4();
+ rule(MOVE, sget4(), height); break;
+ }
+ case PUT1 : putcharacter(get1()); break;
+ case PUT2 : putcharacter(get2()); break;
+ case PUT3 : putcharacter(get3()); break;
+ case PUT4 : putcharacter(get4()); break;
+ case PUT_RULE : { long height = sget4();
+ rule(STAY, sget4(), height); break;
+ }
+ case NOP : break; /* no-op */
+ case BOP : errorexit(bdbop); break;
+/* case EOP : break; strange place to have EOP */
+ case PUSH : if (sptr >= stackmax) /* push */
+ errorexit(stkof);
+ stack[sptr].hh = h;
+ stack[sptr].vv = v;
+ stack[sptr].ww = w;
+ stack[sptr].xx = x;
+ stack[sptr].yy = y;
+ stack[sptr].zz = z;
+ sptr++;
+ break;
+ case POP : if (sptr-- == 0) /* pop */
+ errorexit(stkuf);
+ h = stack[sptr].hh;
+ v = stack[sptr].vv;
+ w = stack[sptr].ww;
+ x = stack[sptr].xx;
+ y = stack[sptr].yy;
+ z = stack[sptr].zz;
+ break;
+ case RIGHT1 : (void) horizontalmove(sget1()); break;
+ case RIGHT2 : (void) horizontalmove(sget2()); break;
+ case RIGHT3 : (void) horizontalmove(sget3()); break;
+ case RIGHT4 : (void) horizontalmove(sget4()); break;
+ case W0 : h += w; break;
+ case W1 : w = horizontalmove(sget1()); break;
+ case W2 : w = horizontalmove(sget2()); break;
+ case W3 : w = horizontalmove(sget3()); break;
+ case W4 : w = horizontalmove(sget4()); break;
+ case X0 : h += x; break;
+ case X1 : x = horizontalmove(sget1()); break;
+ case X2 : x = horizontalmove(sget2()); break;
+ case X3 : x = horizontalmove(sget3()); break;
+ case X4 : x = horizontalmove(sget4()); break;
+ case DOWN1 : v += sget1(); break;
+ case DOWN2 : v += sget2(); break;
+ case DOWN3 : v += sget3(); break;
+ case DOWN4 : v += sget4(); break;
+ case Y0 : v += y; break;
+ case Y1 : y = sget1(); v += y; break;
+ case Y2 : y = sget2(); v += y; break;
+ case Y3 : y = sget3(); v += y; break;
+ case Y4 : y = sget4(); v += y; break;
+ case Z0 : v += z; break;
+ case Z1 : z = sget1(); v += z; break;
+ case Z2 : z = sget2(); v += z; break;
+ case Z3 : z = sget3(); v += z; break;
+ case Z4 : z = sget4(); v += z; break;
+ case FNT1 :
+ case FNT2 :
+ case FNT3 :
+ case FNT4 : setfont(num(opcode - FNT1 + 1));
+ break;
+ case XXX1 : mseek(DVIfile, get1(), relative); break;
+ case XXX2 : mseek(DVIfile, get2(), relative); break;
+ case XXX3 : mseek(DVIfile, get3(), relative); break;
+ case XXX4 : mseek(DVIfile, get4(), relative); break;
+ case FNT_DEF1 :
+ case FNT_DEF2 :
+ case FNT_DEF3 :
+ case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1);
+ break;
+ case PRE : errorexit(bdpre); break;
+ case POST : errorexit(bdpst); break;
+ case POST_POST: errorexit(bdpp); break;
+ }
+ }
+
+ return;
+
+} /* dopage */
+
+
+
+/*
+ * SKIPPAGE -- Scan the dvi file until an end-off-page.
+ * Skip this page.
+ */
+
+void skippage(void)
+{
+ register int opcode;
+
+ while ((opcode = (int) get1()) != EOP) {
+ if (opcode > POST_POST)
+ errorexit(illop);
+ else
+ switch (opcode) {
+ case SET1 :
+ case PUT1 :
+ case RIGHT1 :
+ case W1 :
+ case X1 :
+ case DOWN1 :
+ case Y1 :
+ case Z1 : /* assume FNT change can also be skipped */
+ case FNT1 : mseek(DVIfile, 1L, relative); break;
+ case SET2 :
+ case PUT2 :
+ case RIGHT2 :
+ case W2 :
+ case X2 :
+ case DOWN2 :
+ case Y2 :
+ case Z2 :
+ case FNT2 : mseek(DVIfile, 2L, relative); break;
+ case SET3 :
+ case PUT3 :
+ case RIGHT3 :
+ case W3 :
+ case X3 :
+ case DOWN3 :
+ case Y3 :
+ case Z3 :
+ case FNT3 : mseek(DVIfile, 3L, relative); break;
+ case SET4 :
+ case PUT4 :
+ case RIGHT4 :
+ case W4 :
+ case X4 :
+ case DOWN4 :
+ case Y4 :
+ case Z4 :
+ case FNT4 : mseek(DVIfile, 4L, relative); break;
+ case SET_RULE :
+ case PUT_RULE : mseek(DVIfile, 8L, relative); break;
+ case BOP : errorexit(bdbop); break;
+ case XXX1 : mseek(DVIfile, get1(), relative); break;
+ case XXX2 : mseek(DVIfile, get2(), relative); break;
+ case XXX3 : mseek(DVIfile, get3(), relative); break;
+ case XXX4 : mseek(DVIfile, get4(), relative); break;
+ case FNT_DEF1 :
+ case FNT_DEF2 :
+ case FNT_DEF3 :
+ case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1); break;
+ case PRE : errorexit(bdpre); break;
+ case POST : errorexit(bdpst); break;
+ case POST_POST: errorexit(bdpp); break;
+ }
+ }
+
+ return;
+
+} /* skippage */
+
+
+
+/*
+ * PRINTPAGE -- 'end of page', writes lines of page to output file
+ */
+
+void printpage(void)
+{
+ register int i, j, k;
+ register unsigned char ch;
+ unsigned char buff[4];
+
+ if (sptr != 0)
+ fprintf(stderr, "dvi2tty: warning - stack not empty at eop.\n");
+ for (currentline = firstline; currentline != nil;
+ currentline = currentline->next) {
+ if (currentline != firstline) {
+ foo = ((currentline->vv - currentline->prev->vv)/lineheight)-1;
+ if (foo > 3)
+ foo = 3; /* linespacings not too large */
+ for (i = 1; i <= (int) foo; i++)
+ putc('\n', output);
+ }
+ if (currentline->charactercount >= leftmargin) {
+ foo = ttywidth - 2;
+ for (i = firstcolumn, j = 1; i <= currentline->charactercount;
+ i++, j++) {
+ ch = currentline->text[i - leftmargin];
+
+ if (japan) {
+ if (ch > 127) {
+ for (k = 0; k < 4; k++) {
+ if (i - leftmargin + k < LINELEN+1)
+ buff[k] = currentline->text[i - leftmargin + k];
+ else buff[k] = '\0';
+ }
+ kanji1 = multistrlen(buff, 4, 0) - 1;
+ }
+ else kanji1 = 0;
+ if (kanji1 && (j + kanji1 > (int) foo) &&
+ (currentline->charactercount > i+1)) {
+ putc2('*', output);
+ putc2('\n', output); /* if line to large */
+ putc2(' ', output);
+ putc2('*', output); /* mark output */
+ j = 2;
+ }
+ }
+
+ if (ch >= SPACE || allchar) {
+ if (japan) {
+ for (k = 0; k < kanji1; k++) {
+ putc2(ch, output);
+ i++; j++;
+ ch = currentline->text[i - leftmargin];
+ }
+ putc2(ch, output);
+ }
+ else
+ putc(ch, output);
+ }
+ if ((j > (int) foo) && (currentline->charactercount > i+1)) {
+ if (japan) {
+ putc2('*', output);
+ putc2('\n', output); /* if line to large */
+ putc2(' ', output);
+ putc2('*', output); /* mark output */
+ }
+ else {
+ fprintf(output, "*\n"); /* if line to large */
+ fprintf(output, " *"); /* mark output */
+ }
+ j = 2;
+ }
+ }
+ }
+ if (japan)
+ putc2('\n', output);
+ else
+ putc('\n', output);
+ }
+
+ currentline = firstline;
+ while (currentline->next != nil) {
+ currentline = currentline->next;
+ free(currentline->prev);
+ }
+ 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)
+{
+
+ while ((currentpage->pag < 0) && (currentpage->pag != pagenr) &&
+ !currentpage->all && (currentpage->nxt != nil))
+ currentpage = currentpage->nxt;
+ if ((currentpage->all && (pagenr < currentpage->pag)) ||
+ (currentpage->pag == pagenr))
+ return TRUE;
+ else if (pagenr > 0) {
+ while ((currentpage->pag < pagenr) && (currentpage->nxt != nil))
+ currentpage = currentpage->nxt;
+ 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)
+{
+
+ register char ch; /* character to set rule with */
+ register long saveh = 0, savev;
+ /* rule -- starts up the recursive routine */
+ if (!moving)
+ saveh = h;
+ if ((ruleht <= 0) || (rulewt <= 0))
+ h += rulewt;
+ else {
+ savev = v;
+ if ((ruleht / rulewt) > 0) /* value < 1 truncates to 0 */
+ ch = '|';
+ else if (ruleht > (lineheight / 2))
+ ch = '=';
+ else
+ ch = '_';
+ ruleaux(rulewt, ruleht, ch);
+ v = savev;
+ }
+ if (!moving)
+ h = saveh;
+
+ return;
+
+} /* rule */
+
+
+
+/*
+ * RULEAUX -- do the actual output for the rule recursively.
+ */
+
+void ruleaux(long rulewt, long ruleht, char ch)
+{
+ register long wt, lmh, rmh;
+
+ wt = rulewt;
+ lmh = h; /* save left margin */
+ if (h < 0) { /* let rules that start at negative h */
+ wt -= h; /* start at coordinate 0, but let it */
+ h = 0; /* have the right length */
+ }
+ while (wt > 0) { /* output the part of the rule that */
+ rmh = h; /* goes on this line */
+ outchar(ch);
+ wt -= (h-rmh); /* decrease the width left on line */
+ }
+ ruleht -= lineheight; /* decrease the height */
+ if (ruleht > lineheight) { /* still more vertical? */
+ rmh = h; /* save current h (right margin) */
+ h = lmh; /* restore left margin */
+ v -= (lineheight + lineheight / 10);
+ ruleaux(rulewt, ruleht, ch);
+ h = rmh; /* restore right margin */
+ }
+
+ return;
+
+} /* ruleaux */
+
+
+
+/*
+ * HORIZONTALMOVE -- Move the h pointer by amount.
+ */
+
+long horizontalmove(long amount)
+{
+
+#if defined(MSDOS) || defined(THINK_C)
+ if (labs(amount) > charwidth / 4L) { /* } to make vi happy */
+#else
+ if (abs(amount) > charwidth / 4L) {
+#endif
+ foo = 3*charwidth / 4;
+ if (amount > 0)
+ amount = ((amount+foo) / charwidth) * charwidth;
+ else
+#if defined(VMS)
+ amount = (ROUND( (float) (amount-foo) / charwidth) + 1)* charwidth;
+#else
+ amount = ((amount-foo) / charwidth) * charwidth;
+#endif
+ h += amount;
+ return amount;
+ }
+ else
+ return 0;
+
+} /* horizontalmove */
+
+
+
+/*
+ * SKIPNOPS -- Return first non NOP opcode.
+ */
+
+int skipnops(void)
+{
+ register int opcode;
+
+ while ((opcode = (int) num(1)) == NOP);
+
+ return opcode;
+
+} /* skipnops */
+
+
+
+/*
+ * GETLINE -- Returns an initialized line-object
+ */
+
+linetype *my_getline(void)
+{
+ register int i;
+ register linetype *temp;
+
+ if ((temp = (linetype *) malloc(sizeof(linetype))) == NULL)
+ errorexit(lnerq);
+ temp->charactercount = leftmargin - 1;
+ temp->prev = nil;
+ temp->next = nil;
+ for (i = 0; i < LINELEN; i++)
+ temp->text[i] = ' ';
+ temp->text[i] = '\0';
+
+ return temp;
+
+} /* my_getline */
+
+
+
+/*
+ * FINDLINE -- Find best fit line were text should go
+ * and generate new line if needed.
+ */
+
+linetype *findline(void)
+{
+ register linetype *temp;
+ register long topd, botd;
+
+ if (v <= firstline->vv) { /* above first line */
+ if (firstline->vv - v > lineheight) {
+ temp = my_getline();
+ temp->next = firstline;
+ firstline->prev = temp;
+ temp->vv = v;
+ firstline = temp;
+ }
+ return firstline;
+ }
+
+ if (v >= lastline->vv) { /* below last line */
+ if (v - lastline->vv > lineheight) {
+ temp = my_getline();
+ temp->prev = lastline;
+ lastline->next = temp;
+ temp->vv = v;
+ lastline = temp;
+ }
+ return lastline;
+ }
+
+ temp = lastline; /* in between two lines */
+ while ((temp->vv > v) && (temp != firstline))
+ temp = temp->prev;
+
+ /* 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 < botd) /* take best fit */
+ return temp;
+ else
+ return temp->next;
+ }
+
+ /* no line fits suitable, generate a new one */
+ currentline = my_getline();
+ currentline->next = temp->next;
+ currentline->prev = temp;
+ temp->next->prev = currentline;
+ temp->next = currentline;
+ currentline->vv = v;
+
+ return currentline;
+
+} /* findline */
+
+
+
+/*
+ * NUM --
+ */
+
+unsigned long num(int size)
+{
+ register int i;
+ register unsigned long x = 0;
+
+ for (i = size; i > 0; i--)
+ x = (x << 8) + (unsigned) getc(DVIfile);
+
+ return x;
+
+} /* num */
+
+
+/*
+ * SNUM --
+ */
+
+long snum(int size)
+{
+ register int i;
+ register long x;
+
+ x = getc(DVIfile);
+ if (x & 0x80)
+ x -= 0x100;
+ for (i = size - 1; i > 0; i--)
+ x = (x << 8) + (unsigned) getc(DVIfile);
+
+ return x;
+
+} /* snum */
+
+
+
+/*
+ * DOKANJI -- Process a kanji character opcode.
+ */
+
+void dokanji(long ch)
+{
+ long i;
+
+ i = toBUFF(fromDVI(ch));
+ kanji1 = 3;
+ if (BYTE1(i) != 0) outchar((unsigned char)BYTE1(i));
+ kanji1 = 2;
+ if (BYTE2(i) != 0) outchar((unsigned char)BYTE2(i));
+ kanji1 = 1;
+ /* always */ outchar((unsigned char)BYTE3(i));
+ kanji1 = 0;
+ /* always */ outchar((unsigned char)BYTE4(i));
+
+ return;
+
+} /* dokanji */
+
+
+
+/*
+ * DOCHAR -- Process a character opcode.
+ */
+
+void dochar(unsigned char ch)
+{
+
+ if (nttj && fnt->fontnum)
+ jischar((long) ch);
+ else if (symbolfont == TRUE)
+ symchar(ch);
+ else
+ normchar(ch);
+
+ return;
+
+} /* dochar */
+
+
+
+/*
+ * SYMCHAR -- Process a character opcode for a symbol font.
+ */
+
+void symchar(unsigned char ch)
+{
+
+ switch (ch) { /* can do a lot more on MSDOS/latin1/unicode machines ... */
+ case 0: ch = '-'; break;
+ case 1: ch = '.'; break;
+ case 2: ch = 'x'; break;
+ case 3: ch = '*'; break;
+ case 13: ch = 'O'; break;
+ case 14: ch = 'O'; break;
+ case 15: ch = 'o'; break;
+ case 24: ch = '~'; break;
+ case 32: ch = nttj ? '<' : 32; break; /* really only for japan? */
+ case 33: ch = nttj ? '>' : 33; break; /* really only for japan? */
+ case 102: ch = '{'; break;
+ case 103: ch = '}'; break;
+ case 104: ch = '<'; break;
+ case 105: ch = '>'; break;
+ case 106: ch = '|'; break;
+ case 110: ch = '\\'; break;
+ }
+
+ outchar(ch);
+
+ return;
+
+} /* symchar */
+
+
+
+/*
+ * NORMCHAR -- Process a character opcode for a normal font.
+ */
+
+void normchar(unsigned char ch)
+{
+
+ 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 */
+ }
+ 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 */
+ }
+ break;
+ case 15 : if (ttfont)
+ ch = '.'; /* spanish ? */
+ else if (!allchar) {
+ outchar('f'); outchar('f');
+ ch = 'l'; /* ligature */
+ }
+ break;
+ case 16 : if (!allchar) ch = 'i'; break;
+ case 17 : if (!allchar) ch = 'j'; break;
+ case 25 : if (!allchar) {
+ if (latin1) {
+ ch = 0xdf;
+ }
+ else {
+ outchar('s');
+ ch = 's';
+ }
+ }
+ break; /* German double s */
+ case 26 : if (!allchar) {
+ if (latin1) {
+ ch = 0xe6;
+ }
+ else {
+ 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 = '|';
+ else if (latin1)
+ ch = 0xf8;
+ else
+ ch = 'o';
+ }
+ break; /* Dane/Norw /o */
+ case 29 : if (!allchar) {
+ if (latin1) {
+ ch = 0xc6;
+ }
+ else {
+ 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 = '\\';
+ else if (latin1)
+ ch = 0xd8;
+ else
+ ch = 'O';
+ }
+ break; /* Dane/Norw /O */
+ 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 \" */
+
+ /*
+ * Should SPACE be useed 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 \. */
+ }
+ outchar(ch);
+
+ return;
+
+} /* normchar */
+
+
+
+/*
+ * OUTCHAR -- Here we put the character into the current page.
+ *
+ * This function includes some code to handle Latin1/Scandinavian
+ * characters. I think that code doesn't belong here. IT
+ * SHOULD BE MOVED OUT.
+ */
+
+void outchar(unsigned char ch)
+{
+ 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)
+#else
+ if (abs(v - currentline->vv) > lineheight / 2L)
+#endif
+ currentline = findline();
+
+#if 0
+ j = (int) (((double) h / (double) maxpagewidth) * (ttywidth-1)) + 1;
+#else
+ j = (int) (h / charwidth);
+#endif
+ if (j > rightmargin) /* leftmargin <= j <= rightmargin */
+ j = rightmargin;
+ else if (j < leftmargin)
+ j = leftmargin;
+ foo = leftmargin - 1;
+
+ /*
+ * 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 *
+ * 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. *
+ */
+ if (!allchar && (scascii || latin1)) {
+ 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++)
+ if ((currentline->text[i - leftmargin] == 127) || /* DEL */
+ (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 " */
+ if (ch == 'a')
+ ch = latin1 ? 0xe4 : '{'; /* } vi */
+ else if (ch == 'A') /* dots ... */
+ ch = latin1 ? 0xc4 : '[';
+ else if (ch == 'o')
+ ch = latin1 ? 0xf6 : '|';
+ else if (ch == 'O')
+ ch = latin1 ? 0xd6 : '\\';
+ else if (ch == 'u')
+ ch = latin1 ? 0xfc : 'u';
+ else if (ch == 'U')
+ ch = latin1 ? 0xdc : 'U';
+ break;
+ case 23 : if (ch == 'a')
+ ch = latin1 ? 0xe5 : '}'; /* { vi */
+ else if (ch == 'A') /* circle */
+ ch = latin1 ? 0xc5 : ']';
+ break;
+ }
+ }
+ }
+ }
+ /*----------------- end of 'latin1 / Scandinavian code' ----------------*/
+
+ if (foo == leftmargin-1) {
+ if (japan) {
+ while (((currentline->text[j - leftmargin] != SPACE) ||
+ (kanji1 && (currentline->text[j+kanji1 - leftmargin] != SPACE)))
+ && (j < rightmargin)) {
+ j++;
+ h += charwidth;
+ }
+ } else {
+ while (j < rightmargin &&
+ ( (currentline->text[j - leftmargin] != SPACE) ||
+ (kanji1 && (currentline->text[j+1 - leftmargin] != SPACE))
+ ) ) {
+ j++;
+ h += charwidth;
+ }
+ }
+ }
+ if ( allchar || ((ch >= SPACE) && (ch != DEL)) ||
+ ((latin1 || scascii) && (ch == 23)) ) {
+ /* ((latin1 || scascii) && (ch == DEL)) ) if VMS ??? */
+ if (j < rightmargin)
+ currentline->text[j - leftmargin] = ch;
+ else
+ currentline->text[rightmargin - leftmargin] = '@';
+ if (j > currentline->charactercount)
+ currentline->charactercount = j;
+ if (j < firstcolumn)
+ firstcolumn = j;
+ }
+ h += charwidth;
+
+ return;
+
+} /* outchar */
+
+
+
+/*
+ * PUTCHARACTER -- Output character, don't change h
+ */
+
+void putcharacter(long charnr)
+{
+ register long saveh;
+
+ saveh = h;
+ if (nttj)
+ dochar((unsigned char) charnr);
+ else if (allchar || ((charnr >= 0) && (charnr <= LASTCHAR)))
+ outchar((unsigned char) charnr);
+ else
+ 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)
+{
+
+ outchar((unsigned char)(allchar ? charnr : '#'));
+
+ return;
+
+} /* setchar */
+
+
+static const char *ptex_fontchk[] = {
+ "min", "goth", "jis",
+ "hmin", "hgoth", "hmgoth", /* japanese-otf package */
+ "nmlmin", "nmlgoth", "nmlmgoth",
+ "hiramin", "hirakaku", "hiramaru",
+ NULL /* end */
+};
+
+static const char *uptex_fontchk[] = {
+ "umin", "ugoth", "ujis",
+ "upjis", "upjpn", "upsch", "uptch", "upkor",
+ "uphmin", "uphgoth", "uphmgoth", /* japanese-otf package */
+ "upnmlmin", "upnmlgoth", "upnmlmgoth",
+ "uphiramin", "uphirakaku", "uphiramaru",
+ NULL /* end */
+};
+
+static const char *jtex_fontchk[] = {
+ "dmj", "dgj",
+ NULL /* end */
+};
+
+static int checkjfont(const char **jfontlist, const char *name)
+{
+ int i, len;
+ const char *tmpfont;
+
+ i=0;
+ while ( (tmpfont=jfontlist[i]) != NULL ) {
+ len=strlen(tmpfont);
+ if ( !strncmp(tmpfont, name, len) ) return 1;
+ i++;
+ }
+ return 0;
+} /* checkjfont */
+
+
+
+/*
+ * FONTDEF -- Process a font definition.
+ */
+
+void fontdef(int x)
+{
+ register int i;
+ char * name;
+ font * fnt;
+ int namelen;
+ long fntnum;
+ int new = 0;
+
+ fntnum = num(x);
+ (void) get4(); /* checksum */
+ (void) get4(); /* scale */
+ (void) get4(); /* design */
+ namelen = (int) get1() + (int) get1();
+ fnt = fonts;
+ while (fnt != NULL && fnt->num != fntnum) /* does fontnum exist */
+ 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[i] = '\0'; /* properly end string */
+ fnt->name = name;
+ if (new) {
+ fnt->next = fonts;
+ fonts = fnt;
+ }
+
+ /*
+ * some magic to learn about font types...
+ */
+ fonts->flags = 0;
+
+ if ((asciip == FALSE && nttj == FALSE && uptex == FALSE)
+ && (!jdetect) && jautodetect) {
+ if ( checkjfont(ptex_fontchk, name) ) {
+ /* Detect as ASCII TeX */
+ asciip = TRUE;
+ nttj = uptex = FALSE;
+ japan = jdetect = TRUE;
+ fonts->flags |= MIFONT;
+ set_enc_string (NULL, PTEX_INTERNAL_ENC);
+ } else if ( checkjfont(uptex_fontchk, name) ) {
+ /* Detect as upTeX */
+ uptex = TRUE;
+ nttj = asciip = FALSE;
+ japan = jdetect = TRUE;
+ fonts->flags |= MIFONT;
+ enable_UPTEX(true);
+ set_enc_string (NULL, UPTEX_INTERNAL_ENC);
+ } else if ( checkjfont(jtex_fontchk, name) ) {
+ /* Detect as NTT JTeX */
+ nttj = TRUE;
+ asciip = uptex = FALSE;
+ japan = jdetect = TRUE;
+ fonts->flags |= JAPFONT;
+ set_enc_string (NULL, JTEX_INTERNAL_ENC);
+ }
+ }
+ if (nttj)
+ fonts->fontnum = getjsubfont(name);
+ else
+ fonts->fontnum = 0;
+
+ if ((strstr(name, "sy")) != NULL)
+ fonts->flags |= SYMFONT;
+ if ((strstr(name, "tt")) != NULL)
+ fonts->flags |= TTFONT;
+ if ((strstr(name, "mi")) != NULL)
+ fonts->flags |= MIFONT;
+
+ return;
+
+} /* fontdef */
+
+
+
+#define NJSUBS 33
+const char *jsf_names[]={
+ "sy", "roma", "hira", "kata", "greek", "russian", "keisen",
+ "ka", "kb", "kc", "kd", "ke", "kf", "kg", "kh", "ki", "kj",
+ "kk", "kl", "km", "kn", "ko", "kp", "kq", "kr", "ks", "kt",
+ "ku", "kv", "kw", "kx", "ky", "kz"
+};
+
+
+int getjsubfont(char *s)
+{
+ int jf;
+
+ if (strlen(s) > 3 && s[0] == 'd' && (s[1] == 'm' || s[1] == 'g') && s[2] == 'j') {
+ for (jf = 0; jf < NJSUBS; jf++) {
+ if (strncmp(&s[3], jsf_names[jf], strlen(jsf_names[jf])) == 0)
+ return jf+1;
+ }
+ }
+
+ return 0;
+
+} /* getjsubfont */
+
+
+
+/*
+ * 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)
+{
+ char * s;
+ const char * d;
+
+ symbolfont = FALSE;
+ ttfont = FALSE;
+ mifont = FALSE;
+ fnt = fonts;
+
+ while (fnt != NULL && fnt->num != fntnum)
+ fnt = fnt->next;
+
+ if (fnt == NULL) {
+ /* error : font not found */
+ return;
+ }
+
+ if (fnt->fontnum == 0) {
+ symbolfont = fnt->flags & SYMFONT;
+ ttfont = fnt->flags & TTFONT;
+ mifont = fnt->flags & MIFONT;
+ }
+
+ s = fnt->name;
+ if (printfont) {
+ d = delim; /* print delim and font name if -b was chosen */
+ while (*d) {putcharacter(*d); d++;}
+ while (*s) {putcharacter(*s); s++;}
+ while (d-- > delim) {putcharacter(*d);}
+ }
+
+ return;
+
+} /* setfont */
+
+
+
+void jischar(unsigned long ch)
+{
+ unsigned int Ku, Ten;
+
+ compute_jis(fnt->fontnum, (unsigned int) ch, &Ku, &Ten);
+ kanji1 = 1;
+ outchar((unsigned char)(Ku+128));
+ kanji1 = 0;
+ outchar((unsigned char)(Ten+128));
+
+ return;
+
+} /* jischar */
+
+#define kushift(c) c+0x20
+#define tenshift(c) c+0x20
+
+void compute_jis(int f, unsigned int c, unsigned int *ku, unsigned 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 */
+
+
+
+/*
+ * VMS CODE
+ */
+
+#if defined(VMS)
+long vmsseek(fp,n,dir)
+FILE *fp;
+long n;
+long dir;
+{
+ long k,m,pos,val,oldpos;
+ struct stat buffer;
+
+ for (;;) { /* loops only once or twice */
+ switch (dir) {
+ case 0: /* from BOF */
+ oldpos = vms_ftell(fp);
+ k = n & 511;
+ m = n >> 9;
+ if (((*fp)->_cnt) && ((oldpos >> 9) == m)) {
+ val = 0; /* still in */
+ (*fp)->_ptr = ((*fp)->_base) + k;
+ (*fp)->_cnt = 512 - k;
+ }
+ else {
+ val = fseek(fp, m << 9, 0);
+ if (val == 0) {
+ (*fp)->_cnt = 0;
+ (void) fgetc(fp);
+ (*fp)->_ptr = ((*fp)->_base) + k;
+ (*fp)->_cnt = 512 - k;
+ }
+ }
+ return(val);
+
+ case 1: pos = vms_ftell(fp);
+ if (pos == EOF)
+ return (EOF);
+ n += pos;
+ dir = 0;
+ break;
+
+ case 2: val = fstat(fileno(fp), &buffer);
+ if (val == EOF)
+ return (EOF);
+ n += buffer.st_size - 1;
+
+ dir = 0;
+ break;
+
+ default : return (EOF);
+ }
+ }
+
+ /* NOTREACHED */
+
+} /* vmsseek */
+
+
+
+long vms_ftell(fp)
+FILE *fp;
+{
+ char c;
+ long pos;
+ long val;
+
+ if ((*fp)->_cnt == 0) {
+ c = fgetc(fp);
+ val = vms_ungetc(c, fp);
+ if (val != c)
+ return (EOF);
+ }
+ pos = ftell(fp);
+ if (pos >= 0)
+ pos += ((*fp)->_ptr) - ((*fp)->_base);
+
+ return (pos);
+
+} /* vms_ftell */
+
+
+
+long vms_ungetc(c,fp)
+char c;
+FILE *fp;
+{
+
+ if ((c == EOF) && feof(fp))
+ return (EOF);
+
+ if ((*fp)->_cnt >= 512)
+ return (EOF);
+
+ (*fp)->_cnt++;
+ (*fp)->_ptr--;
+ *((*fp)->_ptr) = c;
+
+ return (c);
+
+} /*vms_ungetc */
+#endif
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.dvi b/Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.dvi
new file mode 100644
index 00000000000..b715d670d8e
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.dvi
Binary files differ
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.tex b/Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.tex
new file mode 100644
index 00000000000..22bf91dafd9
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/test/ligtest.tex
@@ -0,0 +1,35 @@
+\documentstyle{article}
+
+\begin{document}
+
+hello.
+
+dollar \$
+ampersand \&
+procent \%
+matje \#
+leftbrace \{
+rightbrace \}
+underscore \_
+
+dagger \dag
+ddagger \ddag
+section \S
+paragraph \P
+copyright \copyright
+pound \pounds
+
+\begin{itemize}
+\item item 1
+\item \begin{itemize}
+ \item item 2.1
+ \end{itemize}
+\end{itemize}
+bye.
+
+maths: \[ 1 + 2 = 5 / 3 * 1 - 1 \]
+
+
+
+
+\end{document}
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/test/test.dvi b/Build/source/texk/dvi2tty/dvi2tty-src/test/test.dvi
new file mode 100644
index 00000000000..b1c0c097ab4
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/test/test.dvi
Binary files differ
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/test/test.tex b/Build/source/texk/dvi2tty/dvi2tty-src/test/test.tex
new file mode 100644
index 00000000000..a282f0a8fe7
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/test/test.tex
@@ -0,0 +1,122 @@
+
+\documentstyle{article}
+
+\begin{document}
+
+accents: \'{e}
+
+\LaTeX
+
+now inline: bla\'{e} test
+
+now inline: bla \'{e}test
+
+now inline: bla \'{e} test
+
+real spaces~~~xxx
+
+tildes accent \~o
+
+horizontal 2 - is --
+
+horizontal 3 - is ---
+
+ligatures: ffl fi fl Yp
+
+what about vertical bars |
+
+horizontal bar -
+
+and tildes ~
+
+< funny carrots >
+
+copyright \copyright
+
+pounds \pounds
+
+euro \Euro
+$
+diamond \Diamond
+$
+scandinavian ae \ae AE {\AE} o {\o} O {\O} AA {\AA} aa {\aa} Z {\v z}
+
+
+$
+alpha \alpha
+$
+eta \eta
+
+nu \nu
+
+tau \tau
+
+beta \beta
+
+theta \theta
+
+xi \xi
+
+upsilon \upsilon
+
+gamma \gamma
+
+iota \iota
+
+phi \phi
+
+delta \delta
+
+kappa \kappa
+
+pi \pi
+
+chi \chi
+
+epsilon \epsilon
+
+lambda \lambda
+
+rho \rho
+
+psi \psi
+
+zeta \zeta
+
+mu \mu
+
+sigma \sigma
+
+omega \omega
+
+
+\begin{tabular}{ l | c || r | }
+\hline
+ 1 & 2 & 3 \\
+ 4 & 5 & 6 \\
+ 7 & 8 & 9 \\
+\hline
+\end{tabular}
+
+so far not in verbatim (tt font)
+
+\begin{verbatim}
+now in verbatim (tt font)
+accents: \'{e}
+\LaTeX
+now inline: bla\'{e} test
+now inline: bla \'{e}test
+now inline: bla \'{e} test
+real spaces~~~xxx
+tildes accent \~o
+horizontal 2 - is --
+horizontal 3 - is ---
+ligatures: ffl fi fl Yp
+what about vertical bars |
+horizontal bar -
+and tildes ~
+< funny carrots >
+or other symbols: \\ { } [ ] _ ^ ? = ; / . , + * ( ) ' & % $ # " !
+\end{verbatim}
+
+\end{document}
diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/test/test_org.dvi b/Build/source/texk/dvi2tty/dvi2tty-src/test/test_org.dvi
new file mode 100644
index 00000000000..072ec09acf4
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-src/test/test_org.dvi
Binary files differ