diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/convert/convert.tex |
Initial commit
Diffstat (limited to 'support/convert/convert.tex')
-rw-r--r-- | support/convert/convert.tex | 283 |
1 files changed, 283 insertions, 0 deletions
diff --git a/support/convert/convert.tex b/support/convert/convert.tex new file mode 100644 index 0000000000..54b52da722 --- /dev/null +++ b/support/convert/convert.tex @@ -0,0 +1,283 @@ +%% +%% This is file `convert.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% convert.dtx +%% +%% Copyright (C) 1991,1999 by Bernd Raichle. +%% +%% IMPORTANT NOTICE: +%% +%% This program can be redistributed and/or modified under the terms +%% of the LaTeX Project Public License Distributed from CTAN +%% archives in directory macros/latex/base/lppl.txt; either +%% version 1 of the License, or any later version. +%% +%% Error Reports (in case of UNCHANGED versions) should be sent to +%% +%% Bernd Raichle <raichle@Informatik.Uni-Stuttgart.DE> +%% +\def\fileversion{1.0b} +\def\filedate{1991/07/08} +\def\docdate{1991/07/08} + +%% \CheckSum{556} +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%% +%% TeX utility `convert' to use with plainTeX or LaTeX v2.09 +%% Copyright (C) 1991 by Bernd Raichle. +\catcode`@=11 +\newwrite\@unused +\def\typeout#1{{\let\protect\string\immediate\write\@unused{#1}}} +\def\@strip#1#2 \@gobble{\def #1{#2}} +\def\@defpar{\par} +\def\@iden#1{#1} +\def\@gobble#1{} +\def\typein[#1]#2{\typeout{#2}\read\sixt@@n to#1% + \ifx #1\@defpar \def#1{}\else + \@iden{\expandafter\@strip\expandafter #1#1\@gobble\@gobble} \@gobble + \fi} +\typeout{TeX Utility `convert' version \fileversion\space <\filedate> (br)} +\typeout{English documentation dated <\docdate> (br)} +\def\endofjob{\csname @@end\endcsname \end} +\everypar{\errhelp{This TeX utility should not produce any dvi output.}% + \errmessage{Internal Error 1. -- Please fix me!}} +\nullfont +\def\sorry{% + \typeout{******************************************} + \typeout{* Sorry, you need TeX 3 for this Utility *} + \typeout{******************************************} + \endofjob} +\newif\iftexthree \texthreetrue +\ifx\undefined\inputlineno + \texthreefalse +\else + \count@=\inputlineno + \ifnum\inputlineno<\z@ + \texthreefalse + \else\ifnum\inputlineno=\count@ + \texthreefalse + \fi\fi +\fi +\iftexthree \else \expandafter\sorry\fi +\errorcontextlines=\m@ne +\catcode`^=12 +\typeout{} +\typeout{********************************************************} +\typeout{ This program converts text-files with 8bit-characters} +\typeout{ into text-files with TeX's ^^xx syntax or TeX macros} +\typeout{ for these characters.} +\typeout{********************************************************} +\typeout{} +\newif\iffehler +\newcount\convtype +\def\getnumber{\afterassignment\gobblerest\count@=} +\def\gobblerest#1\lineend{} +\loop + \typeout{ Should I convert 8bit characters to...}% + \typeout{ \space 1) ^^x notation or}% + \typein[\conversion]% + { \space 2) macros calls (defined in `convert.tbl')}% + \getnumber\conversion \space 0 \lineend + \convtype=\count@ + \fehlertrue + \ifnum\convtype>\z@ \ifnum\convtype<\thr@@ \fehlerfalse \fi\fi + \iffehler + \typeout{ !! Please type 1 or 2 !!}\typeout{}% +\repeat +\typeout{} +\typein[\infilename]{First type the name of your input file:} +\typeout{} +\typein[\outfilename]{Now type the name of your output file:} +\typeout{} +\ifx\infilename\outfilename + \typeout{} + \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!} + \typeout{! Not possible to read from and write to the same file !} + \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!} + \expandafter\endofjob +\fi +\newwrite\outstream +\ifx\outfilename\empty + \typeout{Output to \jobname.log and online.} + \typeout{------------------------------------------------------------} + \chardef\outstream=\sixt@@n +\else + \immediate\openout\outstream \outfilename \relax +\fi +\catcode`~=7 +\catcode`$=\active +\newtoks\currentline \currentline={} +\newcount\lineno +\ifx\outfilename\empty + \def\finish@line{\immediate\write\outstream{\the\currentline}% + \currentline{}\outputpos\z@} +\else + \def\finish@line{\immediate\write\outstream{\the\currentline}% + \currentline{}\outputpos\z@\message{\the\lineno}} +\fi +\newcount\outputpos \outputpos=\z@ +\begingroup\lccode`$=32 +\lowercase{\endgroup +\def\expand@tab{% + \count@\outputpos + \loop \ifnum\count@>7 \advance\count@ -8\repeat + \loop \ifnum\count@<8 \advance\count@\@ne $\repeat +} +} % end of lowercase +\begingroup \catcode`\~~@=\active +\gdef~~@{\currentline\expandafter{\the\currentline ^^@}% + \advance\outputpos\thr@@} +\endgroup +\def\defoutstring#1#2#3{\ifnum#1=\z@ \else + \begingroup \lccode`$=#1\relax + \lowercase{\endgroup\xdef$}% + {\currentline\noexpand\expandafter{\noexpand\the\currentline #2}% + \advance\outputpos\noexpand#3}% + \fi +} +\def\defout#1#2{\lccode`$=#1\relax + \lowercase{\gdef$}{#2}} +\def\letout#1#2{\lccode`$=#1\relax + \lowercase{\global\let$}#2} +\def\hexnum#1{\ifcase#1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or + 8\or 9\or a\or b\or c\or d\or e\or f\fi} +\catcode`*=12 +\count@=32 +\loop + \lccode`*=\count@ + \ifnum\count@<127 + \lowercase{\defoutstring\count@*{\@ne}} + \advance\count@\@ne +\repeat +\defoutstring{127}{^^?}\thr@@ +\count@=\@ne \count\thr@@=`A +\loop + \uccode`*=\count\thr@@ + \ifnum\count@<32 + \uppercase{\defoutstring\count@{^^*}}\thr@@ + \advance\count@\@ne \advance\count\thr@@\@ne +\repeat +\count@=128 +\count\@ne=8 \count\tw@=0 % hex-counter +\loop + \ifnum\count@<\@cclvi + \defoutstring\count@ + {^^\hexnum{\the\count\@ne}\hexnum{\the\count\tw@}}4 + \advance\count@\@ne + \ifnum\count\tw@>14 + \count\tw@\z@ \advance\count\@ne \@ne + \else + \advance\count\tw@ \@ne + \fi +\repeat +\newcount\length +\def\getlength{\afterassignment\lengthloop\let\next= } +\def\lengthloop{% + \ifx\next\empty + \else + \advance\length\@ne + \expandafter\getlength + \fi +} +\def\processline#1 #2\lineend{\length=\z@ + \getlength#2\empty \getnumber#1\space -1 \lineend + \defoutstring\count@{#2}\length +} +\newif\ifmore \moretrue +\def\readfile{\begingroup + \count@=\z@ + \loop + \ifnum\count@<\@cclvi + \ifnum\catcode\count@<9 + \catcode\count@ 12 + \else\ifnum\catcode\count@=\active + \catcode\count@ 12 + \fi\fi + \advance\count@ \@ne + \repeat + \loop + \endlinechar\m@ne + \read\@ne to \curline + \endlinechar`~~M + \ifx\curline\empty % ignore empty lines + \else + \expandafter\processline\curline\lineend + \fi + \ifeof\@ne \morefalse \fi + \ifmore + \repeat +\endgroup} +\ifnum\convtype=\tw@ + \openin\@ne convert.tbl\relax + \ifeof\@ne + \typeout{I can't find file `convert.tbl' -- ignored.}% + \else + \readfile + \closein\@ne + \fi +\fi +\letout{9}\expand@tab +\defout{10}{% + \typeout{!!--> Found ^J in line \the\lineno--I'll ignore all ^J.}% + \letout{10}\relax} +\defout{13}{% + \typeout{!!--> Found ^M in line \the\lineno--I'll ignore all ^M.}% + \letout{13}\relax} +\def\readfile{% + \read\@ne to\next + \ifeof\@ne + \else + \advance\lineno\@ne + \next\relax + \finish@line + \expandafter\readfile + \fi +} +\def\makeactiveandinput{\begingroup + \count@=\z@ + \loop + \ifnum\count@<\@cclvi + \catcode\count@\active + \advance\count@\@ne + \repeat + \endlinechar=-1 + \openin\@ne \infilename\relax + \ifeof\@ne + \typeout{No input file \infilename.}% + \else + \lineno\z@ + \readfile + \closein\@ne + \fi + \endlinechar=`~~M + \ifx\outfilename\empty + \typeout{------------------------------------------------------------} + \else + \immediate\closeout\outstream + \fi + \endgroup + \endofjob +} +\makeactiveandinput +\errhelp{This TeX utility should not reach this point.}% +\errmessage{Internal Error 2. -- Please fix me!} +\endinput +%% +%% End of file `convert.tex'. |