% \iffalse meta-comment
%
% Copyright (C) 1997 University of Hamburg. This file may be distributed
% according to the GNU GPL. See file COPYING for details.
% 
% The Babel package and the file language.skeleton on which this file
% is based is Copyright (C) 1989 -- 1997 by Johannes Braams
%
% This file is part of the Ethiopian language package.
% ----------------------------------------------------
%   This system 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.
% 
%   Please do not request updates from us directly.  Primary
%   distribution is through the CTAN archives.

% The Ethiopian language style for the Babel system was designed
% by a project team at the University of Hamburg.
% 
% Please report errors to ethiop@informatik.uni-hamburg.de by
% email.
%
% Universitaet Hamburg
% FB Informatik, AB TGI
% - Ethiopian Language Project Team -
% Vogt-Koelln-Strasse 30     
% 22527 Hamburg 
% Germany
% 
% \fi
% \CheckSum{1537}
%
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{ethiop.dtx}
%</dtx>
%<code>\ProvidesFile{ethiop.ldf}
%<style>\ProvidesFile{ethiop.sty}
%<etha>\ProvidesFile{uetha.fd}
%<ethb>\ProvidesFile{uethb.fd}
%<etho>\ProvidesFile{uetho.fd}
%<arab>\ProvidesFile{etharab.sty}
        [1998/03/30 v0.7 Ethiopian support for the babel system]
%
% Ethiopian support for Babel package for LaTeX version 2e
%
%<*filedriver>
\documentclass{ltxdoc}
\usepackage{fontenc}
\newcommand*{\TeXhax}{\TeX hax}
\newcommand*{\babel}{\textsf{babel}}
\newcommand*{\langvar}{$\langle \mathit lang \rangle$}
\newcommand*{\note}[1]{}
\newcommand*{\Lopt}[1]{\textsf{#1}}
\newcommand*{\file}[1]{\texttt{#1}}
\begin{document}
 \DocInput{ethiop.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{ethiop.dtx}
%
% \changes{v0.2}{1997/02/08}{Update for \babel\ release 3.6}
%
% \changes{v0.7}{1998/03/30}{Complete reordering of the code
%    for $\Omega$ compatibility}
%
%  \subsubsection{The Ethiopian language}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate.}  defines all the language definition macros for the
%    Ethiopian language. For this language the characters |~|, |^|,
%    |'|, |_|, |.| and |:| are made active. While this may not be
%    the most robust solution, it allows us to use shorthands
%    that are sufficiently close to the scientific transcription.
%    Especially the activation of~|^| and also~|.|~has some drawbacks.
%    \begin{itemize}
%    \item We cannot use |^||^| for entering special characters.
%      Usually this is done in package files only, so we do not
%      get into real trouble, since \babel\ activates the
%      characters only at the beginning of the document.
%    \item We cannot use |.| in numbers, while Ethiopian text
%      is being typeset. This is definitely a problem, because we
%      have to use a |,| instead of the |.| when entering numbers
%      for \TeX.
%    \end{itemize}
%    One must also remember that the Ethiopian language
%    requires a special font that has been hand-taylored to work
%    with this language definition. The font stretches the ligature
%    mechanism of \TeX\ to the limit and works only in connection
%    with this style.
%
% \StopEventually{}
%
%  \subsubsection*{General Setup}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
%    \begin{macrocode}
%<*code>
\LdfInit{ethiop}{captionsethiop}
%    \end{macrocode}
%
%    There is no hyphenation in the Ethiopian language, so
%    we do not expect a hyphenation table to be loaded.
%    For compatibility we add Ethiopian as a dialect of
%    language~0 and disable hyphenation later. Just in case,
%    we check for the existence of |\l@ethiop|.
%
%    \begin{macrocode}
\ifx\undefined\l@ethiop
  \adddialect\l@ethiop0\fi
%    \end{macrocode}
%
%    The next step consists of defining commands to switch to (and
%    from) the Ethiopian language.
%
%  \begin{macro}{\ethiophyphenmins}
%    This macro is used to store the correct values of the hyphenation
%    parameters |\lefthyphenmin| and |\righthyphenmin|. But because
%    there is no hyphenation, we set it to some arbitrarily high value.
%    \begin{macrocode}
\def\ethiophyphenmins{{99}{99}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\eth@doaltchar}
%    Since the Ethiopian language has more than 256 characters,
%    we need to output characters from an alternate font.
%    This is done by temporarily switching to the alternate font family.
%    This generates a considerable overhead in macro expansion time,
%    but no other possibility is available.
%
%    That last space is needed to get the stuff working
%    with $\Omega$. This seems to be a bug in $\Omega$.
%    But the space is certainly allowed,
%    so I will leave it as it is for the moment and
%    probably for a long time.
%    \begin{macrocode}
\newcommand{\eth@doaltchar}[1]{%
  {\fontfamily{\eth@altfamily}\selectfont\char#1 }%
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\dateethiop}
% \begin{macro}{\eth@modulo}
%    The macro |\dateethiop| redefines the command |\today| to
%    produce Ethiopian dates.
%
%    We define some count registers first. They will hold
%    intermediate results when we calculate the Ethiopian date.
%    \begin{macrocode}
\newcount\ethcnt@temp
\newcount\ethcnt@modtemp
\newcount\ethcnt@leap
\newcount\ethcnt@yminone
\newcount\ethcnt@days
\newcount\ethcnt@jdn
\newcount\ethcnt@cycle
\newcount\ethcnt@ethdays
\newcount\ethcnt@ethyear
\newcount\ethcnt@ethmonth
\newcount\ethcnt@ethday
%    \end{macrocode}
%
%    To ease some calculations we define a macro for the
%    remainder of a division.
%    \begin{macrocode}
\newcommand{\eth@modulo}[2]{%
  \ethcnt@modtemp=#1%
  \divide\ethcnt@modtemp by #2%
  \multiply\ethcnt@modtemp by #2%
  \advance#1 by -\ethcnt@modtemp
}
%    \end{macrocode}
%
%    The Ethiopian calendar is a variant of the Julian calendar.
%    First we compute the day number from the Julian epoch, then
%    we calculate day, month, and year of the Ethiopian calendar.
%    Admittedly, the routine is a bit messy. 
%    \begin{macrocode}
\def\dateethiop{%
  \def\today{{%
%    \end{macrocode}
%    |\ethcnt@yminone| denotes the current year minus one.
%    \[\textit{yminone}=\textit{year}-1\]
%    \begin{macrocode}
    \ethcnt@yminone=\year
    \advance\ethcnt@yminone by -1
%    \end{macrocode}
%    We set |\ethcnt@leap| to $1$ if the current year in the
%    Gregorian calendar is a leap year.
%    \[\textit{leap}=
%       \Big\lfloor\frac{\textit{year}}{4}\Big\rfloor
%      -\Big\lfloor\frac{\textit{year}-1}{4}\Big\rfloor
%      -\Big\lfloor\frac{\textit{year}}{100}\Big\rfloor
%      +\Big\lfloor\frac{\textit{year}-1}{100}\Big\rfloor
%      +\Big\lfloor\frac{\textit{year}}{400}\Big\rfloor
%      -\Big\lfloor\frac{\textit{year}-1}{400}\Big\rfloor\]
%    \begin{macrocode}
    \ethcnt@leap=\year
    \divide\ethcnt@leap by 4
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 4
    \advance\ethcnt@leap by -\ethcnt@temp
    \ethcnt@temp=\year
    \divide\ethcnt@temp by 100
    \advance\ethcnt@leap by -\ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 100
    \advance\ethcnt@leap by \ethcnt@temp
    \ethcnt@temp=\year
    \divide\ethcnt@temp by 400
    \advance\ethcnt@leap by \ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 400
    \advance\ethcnt@leap by -\ethcnt@temp
%    \end{macrocode}
%    |\ethcnt@days| corresponds to the number of days since
%    January 0.
%    \[\textit{days}=
%      \left\{\begin{array}{l@{\quad}l}
%        31(\textit{month}-1)+\textit{day}-1 &
%        \textrm{if }\textit{month}\leq 2\\
%        30(\textit{month}-1)+\textit{day}+\textit{leap}-3+
%          \left\lfloor\frac{3 month-2}{5}\right\rfloor &
%        \textrm{if }\textit{month}\geq 3
%      \end{array}\right.\]
%    \begin{macrocode}
    \ifnum\month<3
      \ethcnt@days=\month
      \advance\ethcnt@days by -1
      \multiply\ethcnt@days by 31
      \advance\ethcnt@days by \day
      \advance\ethcnt@days by -1
    \else
      \ethcnt@days=\month
      \advance\ethcnt@days by -1
      \multiply\ethcnt@days by 30
      \advance\ethcnt@days by \day
      \advance\ethcnt@days by \ethcnt@leap
      \advance\ethcnt@days by -3
      \ethcnt@temp=\month
      \multiply\ethcnt@temp by 3
      \advance\ethcnt@temp by -2
      \divide\ethcnt@temp by 5
      \advance\ethcnt@days by \ethcnt@temp
    \fi
%    \end{macrocode}
%    We can now determine the Julian day number, |\ethcnt@jdn|.
%    \[\textit{jdn}=1721426+\textit{days}+365(\textit{year}-1)
%      +\Big\lfloor\frac{\textit{year}-1}{4}\Big\rfloor
%      -\Big\lfloor\frac{\textit{year}-1}{100}\Big\rfloor
%      +\Big\lfloor\frac{\textit{year}-1}{400}\Big\rfloor\]
%    \begin{macrocode}
    \ethcnt@jdn=\ethcnt@days
    \advance\ethcnt@jdn by 1721426
    \ethcnt@temp=\ethcnt@yminone
    \multiply\ethcnt@temp by 365
    \advance\ethcnt@jdn by \ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 4
    \advance\ethcnt@jdn by \ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 100
    \advance\ethcnt@jdn by -\ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 400
    \advance\ethcnt@jdn by \ethcnt@temp
%    \end{macrocode}
%    The first task to determine the Ethiopian date is to
%    compute the number of the current day in a four
%    year cycle.
%    \[\textit{cycle}=(\textit{jdn}-1723856)\bmod 1461\]
%    \begin{macrocode}
    \ethcnt@cycle=\ethcnt@jdn
    \advance\ethcnt@cycle by -1723856
    \eth@modulo{\ethcnt@cycle}{1461}%
%    \end{macrocode}
%    |\ethcnt@ethdays| contains the number of the current day in the
%    Ethiopian year.
%    \[\textit{ethdays}=
%      365\Big\lfloor\frac{\textit{cycle}}{1460}\Big\rfloor
%      +cycle\bmod 365\]
%    \begin{macrocode}
    \ethcnt@ethdays=\ethcnt@cycle
    \eth@modulo{\ethcnt@ethdays}{365}%
    \ethcnt@temp=\ethcnt@cycle
    \divide\ethcnt@temp by 1460
    \multiply\ethcnt@temp by 365
    \advance\ethcnt@ethdays by \ethcnt@temp
%    \end{macrocode}
%    |\ethcnt@ethyear|, |\ethcnt@ethmonth|, and |\ethcnt@ethday| will denote the
%    Ethiopian year, month, and day.
%    \[\textit{ethyear}=
%      4\Big\lfloor\frac{\textit{jdn}-1723856}{1461}\Big\rfloor
%      +\Big\lfloor\frac{\textit{cycle}}{365}\Big\rfloor
%      -\Big\lfloor\frac{\textit{cycle}}{1460}\Big\rfloor\]
%    \begin{macrocode}
    \ethcnt@ethyear=\ethcnt@jdn
    \advance\ethcnt@ethyear by -1723856
    \divide\ethcnt@ethyear by 1461
    \multiply\ethcnt@ethyear by 4
    \ethcnt@temp=\ethcnt@cycle
    \divide\ethcnt@temp by 365
    \advance\ethcnt@ethyear by \ethcnt@temp
    \divide\ethcnt@cycle by 1460
    \advance\ethcnt@ethyear by -\ethcnt@cycle
%    \end{macrocode}
%    \[\textit{ethmonth}=
%      \Big\lfloor\frac{\textit{ethdays}}{30}\Big\rfloor+1\]
%    \begin{macrocode}
    \ethcnt@ethmonth=\ethcnt@ethdays
    \divide\ethcnt@ethmonth by 30
    \advance\ethcnt@ethmonth by 1
%    \end{macrocode}
%    \[\textit{ethday}=\textit{ethdays}\bmod 30+1\]
%    \begin{macrocode}
    \ethcnt@ethday=\ethcnt@ethdays
    \eth@modulo{\ethcnt@ethday}{30}%
    \advance\ethcnt@ethday by 1
%    \end{macrocode}
%    We are almost finished now. We just need to format
%    the date according to Ethiopian conventions.
%    \begin{macrocode}
    \eth@monthname{\ethcnt@ethmonth}\relax\space
      \number\ethcnt@ethday\relax\space
      \number\ethcnt@ethyear
  }}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    We want to be able to switch to the
%    correct font by simply issuing the appropriate
%    |\selectlanguage| command. The defaults for font encoding and
%    family have to be changed, too, in order to get chapter headings
%    etc.~with the correct font. And we must remember our way back.
%    \begin{macrocode}
\addto\extrasethiop{%
  \let\eth@old@encdef\encodingdefault
  \let\eth@old@famdef\familydefault
  \def\encodingdefault{U}%
  \def\familydefault{\eth@defaultfamily}%
  \fontencoding{\encodingdefault}%
  \fontfamily{\familydefault}%
  \selectfont
}
\addto\noextrasethiop{%
  \let\encodingdefault\eth@old@encdef
  \let\familydefault\eth@old@famdef
  \let\eth@old@encdef\relax
  \let\eth@old@famdef\relax
  \fontencoding{\encodingdefault}%
  \fontfamily{\familydefault}%
  \selectfont
}
%    \end{macrocode}
%
%    In order to provide the dollar sign and the curly braces
%    we redefine the commands |\textdollar|, |\textbraceleft|, and |\textbraceright|.
%    \begin{macrocode}
\addto\extrasethiop{%
  \babel@save\textdollar
  \def\textdollar{\char`\$}%
  \def\textbraceleft{{\fontencoding{OMS}%
    \fontfamily{cmr}%
    \selectfont\char102 }}%
  \def\textbraceright{{\fontencoding{OMS}%
    \fontfamily{cmr}%
    \selectfont\char103 }}%
}
%    \end{macrocode}
%
%    When we use |\-|, we want a
%    possible breakpoint without the insertion of a hyphen.
%    \begin{macrocode}
\addto\extrasethiop{%
  \babel@save\-%
  \def\-{\ethbreak}%
}
%    \end{macrocode}
%
%    Sometimes \LaTeX\ uses |\MakeUppercase| and |\MakeLowercase|
%    to format text for output. However, there is no
%    upper or lower case in the Ethiopian languages,
%    so these macros are not needed. Worse still, the use
%    of |\MakeUppercase| can make a character unprintable, which
%    can lead to black error bars in the output. Hence we simply
%    disable the two commands while Ethiopian text is typeset
%    by replacing them with a command that outputs its
%    single argument without any change.
%
%    We cannot redefine the low level commands |\uppercase|
%    and |lowercase| directly, because \LaTeX\ uses them for
%    some internal conversions. Especially the font selection
%    algorithm would be affected by such a change, so we better
%    do not touch anything.
%
%    \begin{macrocode}
\addto\extrasethiop{%
  \babel@save\MakeUppercase
  \let\MakeUppercase=\@firstofone
  \babel@save\MakeLowercase
  \let\MakeLowercase=\@firstofone
}
%    \end{macrocode}
%
%
% \changes{v0.3}{1997/04/24}{Added support for Ethiopian
%   characters in math mode.}
%
%  \begin{macro}{\ethmath}
%    In Ethiopia it is common to use Ethiopian characters
%    as identifiers in math mode, too. Since our use of
%    \TeX\ ligatures is only applicable in text mode, we will
%    need a special command to temporarily switch to text mode
%    with the proper font size selected with the help of
%    a |\mathchoice|.
%
%    \begin{macrocode}
\addto\extrasethiop{%
  \babel@save\ethmath
  \def\ethmath#1{\mathchoice{\hbox{#1}}{\hbox{#1}}%
    {\hbox{\footnotesize #1}}{\hbox{\tiny #1}}}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\ethnum@err}
%    We can only output Ethiopian numbers from 1 to 999999.
%    \begin{macrocode}
\newcommand{\ethnum@err}[1]{%
  \PackageError{ethiop}{%
    Ethiopian number out of range%
  }{%
    Some Ethiopian number I had to print
    was not in the range 1..999999.\MessageBreak
    Type <return> and I will use an
    Arabic number instead.
  }%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\ifethvariantC}
%    Since there are two glyph variants for the |^C| series,
%    we provide a switch between the two.
%    \begin{macrocode}
\newif\ifethvariantC
\ethvariantCfalse
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\ethglue}
%    The macro |\ethglue| is used to insert a small
%    stretchable space before and after certain punctuation marks.
%    \begin{macrocode}
\def\ethglue{\hskip 0,16667em plus 0,16667em }%
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\ethbreak}
%    The macro |\ethbreak| is used to insert a feasible
%    breakpoint between certain characters.
%    \begin{macrocode}
\def\ethbreak{\penalty 5 }%
%    \end{macrocode}
%  \end{macro}
%
%    Now we need to determine if this file is run on an $\Omega$
%    system. What follows is a long |\if| statement.
%    A \emph{really} long |\if| statement.
%    \begin{macrocode}
\ifx\ocp\undefined
%    \end{macrocode}
%
%  \subsubsection*{\TeX\ Setup}
%
%    Ok, so this is an ordinary \TeX\ system. Here we need
%    to define lots of macros for the translation of our
%    encoding.
%
%  \begin{macro}{\eth@altchar}
%  \begin{macro}{\eth@altchargobble}
%    Whenever a character is output, we put the corresponding code
%    into the macro |\eth@res| which will be expanded later
%    on. 
%    \begin{macrocode}
\newcommand{\eth@altchar}[1]{%
  \def\eth@res{\eth@doaltchar{#1}}%
}
%    \end{macrocode}
% 
%    Sometimes we must output a character and gobble a token.
%    \begin{macrocode}
\newcommand{\eth@altchargobble}[1]{%
  \def\eth@res{\eth@doaltchar{#1}\@gobble}%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\eth@testA}
%  \begin{macro}{\eth@ifnextA}
%    To do some three and four character shorthands we define the
%    following auxiliary macros.
%
%    |\eth@ifnextA| checks if the the next character is \texttt{A} or
%    \texttt{a}. If yes, then we output the compound character given in
%    the first parameter and gobble the \texttt{A}. If no, we output the
%    ordinary character (second parameter) and leave the \texttt{A}
%    where it is. On the fly, |\eth@ifnextA| gobbles its third
%    argument (an already processed character \texttt{u}).
%    \begin{macrocode}
\newcommand{\eth@ifnextA}[3]{%
  \def\eth@res{\eth@ifnextA@eval{#1}{#2}}%
  \futurelet\@let@token\eth@res
}
\newcommand{\eth@ifnextA@eval}[2]{%
       \ifx\@let@token a\eth@altchargobble{#1}%
  \else\ifx\@let@token A\eth@altchargobble{#1}%
  \else\eth@altchar{#2}\fi\fi
  \eth@res
}
%    \end{macrocode}
% 
%    Delay the check for the token \texttt{A} until |\eth@res| has been
%    expanded.
%    \begin{macrocode}
\newcommand{\eth@testA}[2]{%
  \def\eth@res{\eth@ifnextA{#1}{#2}}%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\eth@three@short}
%  \begin{macro}{\eth@three@norm}
%  \begin{macro}{\eth@three@full}
%  \begin{macro}{\eth@three@part}
%    Each of the following macros evaluates the token following
%    one of the shorthands. The token has already been saved in the
%    variable |\@let@token| by the means of a |\futurelet|.
%    Depending on the result of the evaluation an appropriate
%    character from the alternate font is output.
%
%    \begin{macrocode}
\newcommand{\eth@three@short}[7]{%
       \ifx\@let@token a\eth@altchargobble{#1}%
  \else\ifx\@let@token A\eth@altchargobble{#2}%
  \else\ifx\@let@token e\eth@altchargobble{#3}%
  \else\ifx\@let@token E\eth@altchargobble{#4}%
  \else\ifx\@let@token i\eth@altchargobble{#5}%
  \else\ifx\@let@token I\eth@altchargobble{#5}%
  \else\ifx\@let@token o\eth@altchargobble{#6}%
  \else\ifx\@let@token O\eth@altchargobble{#6}%
  \else\ifx\@let@token u\eth@altchargobble{#7}%
  \else\ifx\@let@token U\eth@altchargobble{#7}%
  \else\eth@altchar{#3}\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  \eth@res
}
%    \end{macrocode}
%
%    Usually we expect a single vowel, but if the vowel is
%    \texttt{u} or \texttt{U}, another \texttt{A} might
%    follow to indicate a diphtong.
%
%    \begin{macrocode}
\newcommand{\eth@three@norm}[8]{%
       \ifx\@let@token a\eth@altchargobble{#1}%
  \else\ifx\@let@token A\eth@altchargobble{#2}%
  \else\ifx\@let@token e\eth@altchargobble{#3}%
  \else\ifx\@let@token E\eth@altchargobble{#4}%
  \else\ifx\@let@token i\eth@altchargobble{#5}%
  \else\ifx\@let@token I\eth@altchargobble{#5}%
  \else\ifx\@let@token o\eth@altchargobble{#6}%
  \else\ifx\@let@token O\eth@altchargobble{#6}%
  \else\ifx\@let@token u\eth@testA{#8}{#7}%
  \else\ifx\@let@token U\eth@testA{#8}{#7}%
  \else\eth@altchar{#3}\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  \eth@res
}
%    \end{macrocode}
%
%    At last we must deal with the case where
%    a \texttt{u} might actually be followed by a
%    whole range of different vowels.
%
%    \begin{macrocode}
\newcommand{\eth@three@full}[8]{%
       \ifx\@let@token a\eth@altchargobble{#1}%
  \else\ifx\@let@token A\eth@altchargobble{#2}%
  \else\ifx\@let@token e\eth@altchargobble{#3}%
  \else\ifx\@let@token E\eth@altchargobble{#4}%
  \else\ifx\@let@token i\eth@altchargobble{#5}%
  \else\ifx\@let@token I\eth@altchargobble{#5}%
  \else\ifx\@let@token o\eth@altchargobble{#6}%
  \else\ifx\@let@token O\eth@altchargobble{#6}%
  \else\ifx\@let@token u\def\eth@res{\eth@three@help{#8}{#7}}%
  \else\ifx\@let@token U\def\eth@res{\eth@three@help{#8}{#7}}%
  \else\eth@altchar{#3}\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  \eth@res
}
%    \end{macrocode}
%
%    |\eth@three@help| is called if we need to examine the
%    fourth character. The first argument is supposed
%    to be a list of five character codes, the second
%    is an alternative character code, and the third
%    is an already processed character \texttt{u} which
%    we will gobble on the fly.
%
%    \begin{macrocode}
\newcommand{\eth@three@help}[3]{%
  \def\eth@res{\eth@three@part#1{#2}}%
  \futurelet\@let@token\eth@res
}
\newcommand{\eth@three@part}[6]{%
       \ifx\@let@token a\eth@altchargobble{#1}%
  \else\ifx\@let@token A\eth@altchargobble{#2}%
  \else\ifx\@let@token e\eth@altchargobble{#3}%
  \else\ifx\@let@token E\eth@altchargobble{#4}%
  \else\ifx\@let@token i\eth@altchargobble{#5}%
  \else\ifx\@let@token I\eth@altchargobble{#5}%
  \else\eth@altchar{#6}\fi\fi\fi\fi\fi\fi
  \eth@res
}
%    \end{macrocode}
%
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\eth@hatc}
%  \begin{macro}{\eth@dotc}
%  \begin{macro}{\eth@hatC}
%  \begin{macro}{\eth@barC}
%  \begin{macro}{\eth@dotd}
%  \begin{macro}{\eth@hatg}
%  \begin{macro}{\eth@accg}
%  \begin{macro}{\eth@dotg}
%  \begin{macro}{\eth@acch}
%  \begin{macro}{\eth@barh}
%  \begin{macro}{\eth@doth}
%  \begin{macro}{\eth@acck}
%  \begin{macro}{\eth@bark}
%  \begin{macro}{\eth@tiln}
%  \begin{macro}{\eth@dotp}
%  \begin{macro}{\eth@accq}
%  \begin{macro}{\eth@dotq}
%  \begin{macro}{\eth@hats}
%  \begin{macro}{\eth@accs}
%  \begin{macro}{\eth@dots}
%  \begin{macro}{\eth@dott}
%  \begin{macro}{\eth@hatz}
%    For each of the shorthands |^c|, |.c|, |^C|, |_C|, |.d|,
%    |^g|, |'g|, |_h|, |'h|, |.h|, |k'|, |_k|, |~n|,
%    |.p|, |'q|, |.q|, |^s|, |'s|, |.s|, |.t|, and |^z|
%    we will define macros that
%    handle the check for additional characters.
%    These macros call |\eth@three@norm| or some of the
%    related macros to evaluate the
%    characters following the shorthand. We provide the
%    character codes for the current consonant as
%    arguments to the call of the main macro.
%
%    \begin{macrocode}
\DeclareRobustCommand{\eth@hatc}{%
  \eth@three@norm{104}{107}{109}%
    {108}{106}{110}{105}%
    {111}%
}
\DeclareRobustCommand{\eth@dotc}{%
  \eth@three@short{216}{219}{221}%
    {220}{218}{222}{217}%
}
\DeclareRobustCommand{\eth@hatC}{%
  \ifethvariantC
    \bbl@afterelse
    \eth@three@norm{192}{195}{197}%
      {196}{194}{198}{193}%
      {199}%
  \else
    \bbl@afterfi
    \eth@three@norm{184}{187}{189}%
      {188}{186}{190}{185}%
      {191}%
  \fi
}
\DeclareRobustCommand{\eth@dotd}{%
  \eth@three@norm{152}{155}{157}%
    {156}{154}{158}{153}%
    {159}%
}
\DeclareRobustCommand{\eth@hatg}{%
  \eth@three@norm{160}{163}{165}%
    {164}{162}{166}{161}%
    {167}%
}
\DeclareRobustCommand{\eth@accg}{%
  \eth@three@short{248}{251}{253}%
    {252}{250}{254}{249}%
}
\DeclareRobustCommand{\eth@dotg}{%
  \eth@three@full{168}{171}{173}%
    {172}{170}{174}{169}%
    {{24}{27}{29}%
     {28}{26}}%
}
\DeclareRobustCommand{\eth@acch}{%
  \eth@three@short{240}{243}{245}%
    {244}{242}{246}{241}%
}
\DeclareRobustCommand{\eth@barh}{%
  \eth@three@full{112}{115}{117}%
    {116}{114}{118}{113}%
    {{8}{11}{13}%
     {12}{10}}%
}
\DeclareRobustCommand{\eth@doth}{%
  \eth@three@norm{72}{75}{77}%
    {76}{74}{78}{73}%
    {79}%
}
\DeclareRobustCommand{\eth@acck}{%
  \eth@three@short{232}{235}{237}%
    {236}{234}{238}{233}%
}
\DeclareRobustCommand{\eth@bark}{%
  \eth@three@full{136}{139}{141}%
    {140}{138}{142}{137}%
    {{16}{19}{21}%
     {20}{18}}%
}
\DeclareRobustCommand{\eth@tiln}{%
  \eth@three@norm{120}{123}{125}%
    {124}{122}{126}{121}%
    {127}%
}
\DeclareRobustCommand{\eth@dotp}{%
  \eth@three@norm{200}{203}{205}%
    {204}{202}{206}{201}%
    {207}%
}
\DeclareRobustCommand{\eth@accq}{%
  \eth@three@short{224}{227}{229}%
    {228}{226}{230}{225}%
}
\DeclareRobustCommand{\eth@dotq}{%
  \eth@three@full{96}{99}{101}%
    {100}{98}{102}{97}%
    {{0}{3}{5}%
     {4}{2}}%
}
\DeclareRobustCommand{\eth@hats}{%
  \eth@three@norm{88}{91}{93}%
    {92}{90}{94}{89}%
    {95}%
}
\DeclareRobustCommand{\eth@accs}{%
  \eth@three@norm{80}{83}{85}%
    {84}{82}{86}{81}%
    {87}%
}
\DeclareRobustCommand{\eth@dots}{%
  \eth@three@norm{208}{211}{213}%
    {212}{210}{214}{209}%
    {215}%
}
\DeclareRobustCommand{\eth@dott}{%
  \eth@three@norm{176}{179}{181}%
    {180}{178}{182}{177}%
    {183}%
}
\DeclareRobustCommand{\eth@hatz}{%
  \eth@three@norm{144}{147}{149}%
    {148}{146}{150}{145}%
    {151}%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%    For Ethiopian the characters |~|, |^|, |'|, |_|, |.| and |:|
%    are made active. This is done once, later on their definitions
%    may vary.
%    \begin{macrocode}
\initiate@active@char{~}
\initiate@active@char{^}
\initiate@active@char{'}
\initiate@active@char{_}
\initiate@active@char{.}
\initiate@active@char{:}
%    \end{macrocode}
%
%    The macro |\extrasethiop| will perform all the extra
%    definitions needed for the Ethiopian language, among them
%    the activation of the special characters. The macro
%    |\noextrasethiop| is supposed to cancel the actions of
%    |\extrasethiop|. However, |'| must \emph{not} be deactivated,
%    in order to make it usable in math mode.
%    \begin{macrocode}
\addto\extrasethiop{\languageshorthands{ethiop}}
\addto\extrasethiop{%
  \bbl@activate{~}%
  \bbl@activate{^}%
  \bbl@activate{'}%
  \bbl@activate{_}%
  \bbl@activate{.}%
  \bbl@activate{:}}
\addto\noextrasethiop{%
  \bbl@deactivate{~}%
  \bbl@deactivate{^}%
  \bbl@deactivate{_}%
  \bbl@deactivate{.}%
  \bbl@deactivate{:}}
%    \end{macrocode}
%
%    When the active characters appear in an environment where their
%    special behaviour is not wanted they should give an `expected'
%    result. Therefore we define shorthands at system level first.
%    If this is not done, \TeX\ goes into an infinite loop
%    as soon as an active character is followed by a |{|.
%    This is unexpected.
%    \begin{macrocode}
\declare@shorthand{system}{^}{\csname normal@char\string^\endcsname}
\declare@shorthand{system}{_}{\csname normal@char\string_\endcsname}
\declare@shorthand{system}{.}{\csname normal@char\string.\endcsname}
%    \end{macrocode}
%    The |'| must not be replaced by its normal char, because that
%    is converted to an active char in math mode. Then the
%    shorthand code is again executed and the system goes into an
%    infinite loop.
%    \begin{macrocode}
\declare@shorthand{system}{'}{\textormath
  {\csname normal@char\string'\endcsname}%
  {\sp\bgroup\prim@s}%
}
%    \end{macrocode}
%
%    The shorthand |:| will not simply be replaced by
%    an ordinary character, because the associated
%    character indicates an interword space. Before and after
%    such a space we want to get a little stretchable
%    glue, so we have to insert it by hand. A little macro
%    will do that for us.
%
%    Just in case the user typed the spaces himself, they
%    will be automatically removed in order to catch the most
%    common typing errors. We have to use two different
%    methods: After the |:| we can simply ignore space tokens by
%    invoking |\ignorespaces|. Before the |:| we check if the last
%    skip in the horizontal list matches the skip generated by a space
%    token. We cannot directly check whether the last token was
%    indeed a space token, but this heuristic is sufficiently good.
%  \begin{macro}{\eth@punctglue}
%    \begin{macrocode}
\def\eth@punctglue#1#2{%
  \ifmmode
    #2%
  \else
    \ifhmode
      \ifdim\lastskip=\fontdimen2\font\relax
        \unskip
      \fi
    \fi
    \nobreak
    \ethglue
    #1%
    \allowbreak
    \ethglue
    \expandafter
    \ignorespaces
  \fi
}%
%    \end{macrocode}
%  \end{macro}
%
%    We can now define the shorthand.
%    \begin{macrocode}
\declare@shorthand{system}{:}{%
  \eth@punctglue{\char58 }%
    {\char58 }%
}
%    \end{macrocode}
%
%    The double quote needs some extra treatment in math mode.
%
% \changes{v0.5}{1997/06/18}{Correction for double primes in math mode.}
%    \begin{macrocode}
\declare@shorthand{ethiop}{''}{\textormath
  {\symbol{34}}{\sp\bgroup\prime\prim@s}}
%    \end{macrocode}
%
%    Now we can define the shorthands for Ethiopian. Most of the work
%    is already done by the macros we met earlier on.
%
% \changes{v0.3}{1997/04/24}{Made the shorthands
%   work as expected within mathmode.}
%    \begin{macrocode}
\declare@shorthand{ethiop}{^c}{\textormath
  {\futurelet\@let@token\eth@hatc}{\sp c}}
\declare@shorthand{ethiop}{^C}{\textormath
  {\futurelet\@let@token\eth@hatC}{\sp C}}
\declare@shorthand{ethiop}{.c}{\textormath
  {\futurelet\@let@token\eth@dotc}%
  {\csname normal@char\string.\endcsname c}}
\declare@shorthand{ethiop}{.d}{\textormath
  {\futurelet\@let@token\eth@dotd}%
  {\csname normal@char\string.\endcsname d}}
\declare@shorthand{ethiop}{^g}{\textormath
  {\futurelet\@let@token\eth@hatg}{\sp g}}
\declare@shorthand{ethiop}{'g}{\textormath
  {\futurelet\@let@token\eth@accg}%
  {\csname normal@char\string'\endcsname g}}
\declare@shorthand{ethiop}{.g}{\textormath
  {\futurelet\@let@token\eth@dotg}%
  {\csname normal@char\string.\endcsname g}}
\declare@shorthand{ethiop}{_h}{\textormath
  {\futurelet\@let@token\eth@barh}{\sb h}}
\declare@shorthand{ethiop}{'h}{\textormath
  {\futurelet\@let@token\eth@acch}%
  {\csname normal@char\string'\endcsname h}}
\declare@shorthand{ethiop}{.h}{\textormath
  {\futurelet\@let@token\eth@doth}%
  {\csname normal@char\string.\endcsname g}}
\declare@shorthand{ethiop}{_k}{\textormath
  {\futurelet\@let@token\eth@bark}{\sb k}}
\declare@shorthand{ethiop}{'k}{\textormath
  {\futurelet\@let@token\eth@acck}%
  {\csname normal@char\string'\endcsname k}}
\declare@shorthand{ethiop}{~n}{\textormath
  {\futurelet\@let@token\eth@tiln}%
  {\csname normal@char\string~\endcsname n}}
\declare@shorthand{ethiop}{.p}{\textormath
  {\futurelet\@let@token\eth@dotp}%
  {\csname normal@char\string.\endcsname p}}
\declare@shorthand{ethiop}{'q}{\textormath
  {\futurelet\@let@token\eth@accq}%
  {\csname normal@char\string'\endcsname q}}
\declare@shorthand{ethiop}{.q}{\textormath
  {\futurelet\@let@token\eth@dotq}%
  {\csname normal@char\string.\endcsname q}}
\declare@shorthand{ethiop}{^s}{\textormath
  {\futurelet\@let@token\eth@hats}{\sp s}}
\declare@shorthand{ethiop}{'s}{\textormath
  {\futurelet\@let@token\eth@accs}%
  {\csname normal@char\string'\endcsname s}}
\declare@shorthand{ethiop}{.s}{\textormath
  {\futurelet\@let@token\eth@dots}%
  {\csname normal@char\string.\endcsname s}}
\declare@shorthand{ethiop}{.t}{\textormath
  {\futurelet\@let@token\eth@dott}%
  {\csname normal@char\string.\endcsname t}}
\declare@shorthand{ethiop}{^z}{\textormath
  {\futurelet\@let@token\eth@hatz}{\sp z}}
%    \end{macrocode}
%
% \changes{v0.4}{1997/06/12}{Added three letters to
%   get the complete Unicode character set.}
%
%    Now follow the shorthands |~mA|, |~ri|, and |~fi|.
%    Already the first two characters determine the shorthand,
%    but we need to gobble the third, if if is there.
%    \begin{macrocode}
\declare@shorthand{ethiop}{~m}{%
  \textormath{%
    \eth@doaltchar{40}%
    \@ifnextchar A{\@gobble}{}%
  }{\csname normal@char\string~\endcsname m}%
}
\declare@shorthand{ethiop}{~r}{%
  \textormath{%
    \eth@doaltchar{41}%
    \@ifnextchar i{\@gobble}{}%
  }{\csname normal@char\string~\endcsname r}%
}
\declare@shorthand{ethiop}{~f}{%
  \textormath{%
    \eth@doaltchar{42}%
    \@ifnextchar i{\@gobble}{}%
  }{\csname normal@char\string~\endcsname f}%
}
%    \end{macrocode}
%
%    The following shorthands do not start syllables, but
%    they denote characters in their own right.
%
%    \begin{macrocode}
\declare@shorthand{ethiop}{'A}{\textormath
  {\eth@doaltchar{131}}{\csname normal@char\string'\endcsname A}}
\declare@shorthand{ethiop}{'a}{\textormath
  {\eth@doaltchar{128}}{\csname normal@char\string'\endcsname a}}
\declare@shorthand{ethiop}{'E}{\textormath
  {\eth@doaltchar{132}}{\csname normal@char\string'\endcsname E}}
\declare@shorthand{ethiop}{'e}{\textormath
  {\eth@doaltchar{133}}{\csname normal@char\string'\endcsname e}}
\declare@shorthand{ethiop}{'I}{\textormath
  {\eth@doaltchar{130}}{\csname normal@char\string'\endcsname I}}
\declare@shorthand{ethiop}{'i}{\textormath
  {\eth@doaltchar{130}}{\csname normal@char\string'\endcsname i}}
\declare@shorthand{ethiop}{'O}{\textormath
  {\eth@doaltchar{134}}{\csname normal@char\string'\endcsname O}}
\declare@shorthand{ethiop}{'o}{\textormath
  {\eth@doaltchar{134}}{\csname normal@char\string'\endcsname o}}
\declare@shorthand{ethiop}{'U}{\textormath
  {\eth@ifnextA{135}{129}{U}}{\csname normal@char\string'\endcsname U}}
\declare@shorthand{ethiop}{'u}{\textormath
  {\eth@ifnextA{135}{129}{U}}{\csname normal@char\string'\endcsname u}}
%    \end{macrocode}
%
%    There are some punctuation characters that also
%    require a shorthand. It would be possible to form
%    the characters using ligatures, if |:| were not activated.
%    But |:| must be activated to get the spacing effect we
%    mentioned above. 
%    \begin{macrocode}
\declare@shorthand{ethiop}{:=}{%
  \eth@punctglue{\char42 }%
    {\char58 =}%
}%
\declare@shorthand{ethiop}{:-}{%
  \eth@punctglue{\char123 }%
    {\char58 -}%
}%
\declare@shorthand{ethiop}{::}{%
  \eth@punctglue{\char126 }%
    {\char58 \char58 }%
}%
%    \end{macrocode}
%
% \changes{v0.4}{1997/06/12}{Added the paragraph delimiter
%   character to get the complete Unicode character set.}
%
%    The sequence \texttt{:\char124 :} results in a rare seven dot
%    paragraph delimiter.
%    \begin{macrocode}
\declare@shorthand{ethiop}{:|}{%
  \@ifnextchar:{%
    \eth@punctglue{\char125 }%
      {\char58 |\char58 }%
      \@gobble
  }{%
    \char58 |%
  }%
}%
%    \end{macrocode}
%
%  \begin{macro}{\eth@defaultfamily}
%  \begin{macro}{\eth@altfamily}
%    For the \TeX\ transliteration we must use
%    the font family |etha| as the default. The |ethb|
%    family contains the additional characters.
%    \begin{macrocode}
\def\eth@defaultfamily{etha}%
\def\eth@altfamily{ethb}%
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\ethiop}
%  \begin{macro}{\@ethiop}
%  \begin{macro}{\ethnum}
%  \begin{macro}{\ethnum@one}
%  \begin{macro}{\ethnum@two}
%  \begin{macro}{\ethnum@three}
%  \begin{macro}{\ethnum@four}
%  \begin{macro}{\ethnum@five}
%  \begin{macro}{\ethnum@six}
%    We provide a special macro that outputs a counter as an
%    Ethiopian number, namely |\ethiop|. It is accompanied by some
%    auxiliary macros that are called depending on the range of the
%    number. |\@ethiop| converts its argument (an ordinary number)
%    to the Ethiopian format. The name |\@ethiop| is required
%    so that a user can say |\pagenumbering{ethiop}| and get
%    Ethiopian page numbers. |\ethnum| is provided as a nickname
%    for |\@ethiop|, so that it may be called from user code.
%
%    These macros should work even when the Ethiopian
%    language is not currently selected, because
%    counters might be printed during an output routine
%    where we cannot make any assumptions on the
%    current enviroment.
%    \begin{macrocode}
\def\ethiop#1{\expandafter\@ethiop\csname c@#1\endcsname}
\def\@ethiop#1{{%
  \fontencoding{U}%
  \fontfamily{\eth@altfamily}\selectfont
  \ifnum#1<1\relax\ethnum@err{#1}%
  \else\ifnum#1<10\relax\expandafter\ethnum@one\number #1%
  \else\ifnum#1<100\relax\expandafter\ethnum@two\number #1%
  \else\ifnum#1<1000\relax\expandafter\ethnum@three\number #1%
  \else\ifnum#1<10000\relax\expandafter\ethnum@four\number #1%
  \else\ifnum#1<100000\relax\expandafter\ethnum@five\number #1%
  \else\ifnum#1<1000000\relax\expandafter\ethnum@six\number #1%
  \else
    \fontfamily{\eth@defaultfamily}\selectfont
    \ethnum@err
    \number#1%
  \fi\fi\fi\fi\fi\fi\fi
}}
\let\ethnum\@ethiop
\newcommand{\ethnum@tens}[1]{%
  \ifcase#1\or\char58 \or\char59 \or\char60
           \or\char61 \or\char62 \or\char63
           \or\char64 \or\char65 \or\char66 \fi
  \relax
}
\newcommand{\ethnum@one}[1]{%
  \ifnum#1>0\relax#1\fi
}
\newcommand{\ethnum@two}[1]{%
  \ethnum@tens#1%
  \ethnum@one
}
\newcommand{\ethnum@three}[1]{%
  \ifnum#1>1\relax#1\fi
  \ifnum#1>0\relax\char67\fi
  \ethnum@two
}
\newcommand{\ethnum@four}[1]{%
  \ethnum@tens#1%
  \ifnum#1>0\relax\char67\fi
  \ethnum@three
}
\newcommand{\ethnum@five}[1]{%
  \ifnum#1>1\relax#1\fi
  \ifnum#1>0\relax\char68\fi
  \ethnum@four
}
\newcommand{\ethnum@six}[1]{%
  \ethnum@tens#1%
  \ifnum#1>0\relax\char68\fi
  \ethnum@five
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\captionsethiop}
%    The macro |\captionsethiop| defines all strings used in the
%    four standard documentclasses provided with \LaTeX. The
%    words will probably change in future versions. Hints
%    for improvement are invited.
%
%    We need to call the macro |\eth@doaltchar| to switch to the
%    secondary font for some characters.
%    \begin{macrocode}
\addto\captionsethiop{%
  \def\prefacename{maqedeme}%
  \def\refname{ya\eth@doaltchar{85}na
    \eth@doaltchar{209}hUfe
    mene\eth@doaltchar{189}}%
  \def\abstractname{%
    \eth@doaltchar{128}\eth@doaltchar{117}%
    \eth@doaltchar{213}rota
    \eth@doaltchar{213}huf}%
  \def\bibname{wAbI
    ma\eth@doaltchar{213}hAfete}%
  \def\chaptername{kefele}%
  \def\appendixname{madbal}%
  \def\contentsname{yezate}%
  \def\listfigurename{%
    ya\eth@doaltchar{85}`elo\eth@doaltchar{109}
    mAwe\eth@doaltchar{187}}%
  \def\listtablename{%
    yasane\eth@doaltchar{176}ra\eth@doaltchar{149}
    mAwe\eth@doaltchar{187}}%
  \def\indexname{mehe\eth@doaltchar{211}re
    qAle}%
  \def\figurename{\eth@doaltchar{85}`ele}%
  \def\tablename{%
    sane\eth@doaltchar{176}ra\eth@doaltchar{149}}%
  \def\partname{ne`Use kefele}%
  \def\enclname{%
    \eth@doaltchar{128}bArIwO\eth@doaltchar{109}}%
  \def\ccname{gelebA\eth@doaltchar{189}}%
  \def\headtoname{la}%
  \def\pagename{ga\eth@doaltchar{213}}%
  \def\seename{yemalekatU}%
  \def\alsoname{yeheneme yemalekatU}%
  \def\proofname{mAragAga\eth@doaltchar{187}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\eth@monthname}
%    There are 13 months in the Ethiopian calendar. We
%    make a list of their names here.
%    \begin{macrocode}
\newcommand{\eth@monthname}[1]{\ifcase#1\or
  masekarame\or
  \eth@doaltchar{181}qemete\or
  hedAre\or
  tAhesAse\or
  \eth@doaltchar{181}re\or
  yakAtite\or
  magAbite\or
  mIyAzeyA\or
  genebote\or
  sanE\or
  \eth@doaltchar{72}melE\or
  na\eth@doaltchar{72}sE\or
  \eth@doaltchar{200}gUmEne\fi
}
%    \end{macrocode}
%  \end{macro}
%
%    Ok, that's it for the \TeX part. Do you still remember that we are
%    inside a \emph{large} |\if| construct? Here comes the |\else|.
%    \begin{macrocode}
\else
%    \end{macrocode}
%
%    \subsubsection*{$\Omega$ Setup}
%
%    The setup for the $\Omega$ system is much shorter, because
%    we can assume that the actual input is done in Unicode, so we
%    can skip the handling of shorthands. But we want to install
%    an $\Omega$ translation process that removes unneccessary spaces
%    and adds a little stretchable glue around punctuation marks.
%    \begin{macrocode}
\ocp\eth@spc=ethospc
%    \end{macrocode}
%    The translation in threaded into a translation list.
%    \begin{macrocode}
\ocplist\eth@cpl=
  \addbeforeocplist 10 \eth@spc
  \nullocplist
%    \end{macrocode}
%    The translation list is activated during Ethiopian
%    typesetting.
%    \begin{macrocode}
\addto\extrasethiop{%
  \pushocplist\eth@cpl}
\addto\noextrasethiop{%
  \popocplist}
%    \end{macrocode}
%
%  \begin{macro}{\ethiop}
%  \begin{macro}{\@ethiop}
%  \begin{macro}{\ethnum}
%  \begin{macro}{\ethnum@one}
%  \begin{macro}{\ethnum@two}
%  \begin{macro}{\ethnum@three}
%  \begin{macro}{\ethnum@four}
%  \begin{macro}{\ethnum@five}
%  \begin{macro}{\ethnum@six}
%    The macros for the output of ethiopic numbers
%    need to be changed a little, but no big deal here.
%
%    \begin{macrocode}
\def\ethiop#1{\expandafter\@ethiop\csname c@#1\endcsname}
\def\@ethiop#1{{%
  \fontencoding{U}%
  \fontfamily{\eth@altfamily}\selectfont
  \ifnum#1<1\relax\ethnum@err{#1}%
  \else\ifnum#1<10\relax\expandafter\ethnum@one\number #1%
  \else\ifnum#1<100\relax\expandafter\ethnum@two\number #1%
  \else\ifnum#1<1000\relax\expandafter\ethnum@three\number #1%
  \else\ifnum#1<10000\relax\expandafter\ethnum@four\number #1%
  \else\ifnum#1<100000\relax\expandafter\ethnum@five\number #1%
  \else\ifnum#1<1000000\relax\expandafter\ethnum@six\number #1%
  \else
    \fontfamily{\eth@defaultfamily}\selectfont
    \ethnum@err
    \number#1%
  \fi\fi\fi\fi\fi\fi\fi
}}
\let\ethnum\@ethiop
\newcommand{\ethnum@tens}[1]{%
  \ifcase#1\or^^^^1372\or^^^^1373\or^^^^1374%
           \or^^^^1375\or^^^^1376\or^^^^1377%
           \or^^^^1378\or^^^^1379\or^^^^137a\fi
}%
\newcommand{\ethnum@one}[1]{%
  \ifcase#1\or^^^^1369\or^^^^136a\or^^^^136b%
           \or^^^^136c\or^^^^136d\or^^^^136e%
           \or^^^^136f\or^^^^1370\or^^^^1371\fi
}%
\newcommand{\ethnum@two}[1]{%
  \ethnum@tens#1%
  \ethnum@one
}
\newcommand{\ethnum@three}[1]{%
  \ifnum#1>1\relax\ethnum@one#1\fi
  \ifnum#1>0\relax^^^^137b\fi
  \ethnum@two
}
\newcommand{\ethnum@four}[1]{%
  \ethnum@tens#1%
  \ifnum#1>0\relax^^^^137b\fi
  \ethnum@three
}
\newcommand{\ethnum@five}[1]{%
  \ifnum#1>1\relax\ethnum@one#1\fi
  \ifnum#1>0\relax^^^^137c\fi
  \ethnum@four
}
\newcommand{\ethnum@six}[1]{%
  \ethnum@tens#1%
  \ifnum#1>0\relax^^^^137c\fi
  \ethnum@five
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\eth@defaultfamily}
%  \begin{macro}{\eth@altfamily}
%    For the Unicode input we must use
%    the font family |etho| as the default. We do not
%    really need an alternate font, but for compatibility,
%    We define the appropriate macro.
%    \begin{macrocode}
\def\eth@defaultfamily{etho}
\def\eth@altfamily{etho}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\captionsethiop}
%    For $\Omega$ the macro |\captionsethiop| will use |^^^^| escapes
%    to specify the various characters.
%
%    \begin{macrocode}
\addto\captionsethiop{%
  \def\prefacename{^^^^1218^^^^1245^^^^12f5^^^^121d}%
  \def\refname{^^^^12e8^^^^1225^^^^1290
    ^^^^1339^^^^1201^^^^134d ^^^^121d^^^^1295^^^^132d}%
  \def\abstractname{^^^^12a0^^^^1285^^^^133d^^^^122e^^^^1270
    ^^^^133d^^^^1201^^^^134d}%
  \def\bibname{^^^^12cb^^^^1262
     ^^^^1218^^^^133d^^^^1203^^^^134d^^^^1275}%
  \def\chaptername{^^^^12ad^^^^134d^^^^120d}%
  \def\appendixname{^^^^1218^^^^12f5^^^^1260^^^^120d}%
  \def\contentsname{^^^^12ed^^^^12d8^^^^1275}%
  \def\listfigurename{^^^^12e8^^^^1225^^^^12d5^^^^120e^^^^127d
    ^^^^121b^^^^12cd^^^^132b}%
  \def\listtablename{^^^^12e8^^^^1230^^^^1295^^^^1320^^^^1228^^^^12e5
    ^^^^121b^^^^12cd^^^^132b}%
  \def\indexname{^^^^121d^^^^1205^^^^133b^^^^122d ^^^^1243^^^^120d}%
  \def\figurename{^^^^1225^^^^12d5^^^^120d}%
  \def\tablename{^^^^1230^^^^1295^^^^1320^^^^1228^^^^12e5}%
  \def\partname{^^^^1295^^^^12d1^^^^1235 ^^^^12ad^^^^134d^^^^120d}%
  \def\enclname{^^^^12a0^^^^1263^^^^122a^^^^12ce^^^^127d}%
  \def\ccname{^^^^130d^^^^120d^^^^1263^^^^132d}%
  \def\headtoname{^^^^1208}%
  \def\pagename{^^^^1308^^^^133d}%
  \def\seename{^^^^12ed^^^^1218^^^^120d^^^^12a8^^^^1271}%
  \def\alsoname{^^^^12ed^^^^1205^^^^1295^^^^121d
    ^^^^12ed^^^^1218^^^^120d^^^^12a8^^^^1271}%
  \def\proofname{^^^^121b^^^^1228^^^^130b^^^^1308^^^^132b}%
}%
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\eth@monthname}
%    Here is the table of months for $\Omega$.
%    \begin{macrocode}
\newcommand{\eth@monthname}[1]{\ifcase#1\or
  ^^^^1218^^^^1235^^^^12a8^^^^1228^^^^121d\or
  ^^^^1325^^^^1245^^^^121d^^^^1275\or
  ^^^^1205^^^^12f3^^^^122d\or
  ^^^^1273^^^^1205^^^^1233^^^^1235\or
  ^^^^1325^^^^122d\or
  ^^^^12e8^^^^12ab^^^^1272^^^^1275\or
  ^^^^1218^^^^130b^^^^1262^^^^1275\or
  ^^^^121a^^^^12eb^^^^12dd^^^^12eb\or
  ^^^^130d^^^^1295^^^^1266^^^^1275\or
  ^^^^1230^^^^1294\or
  ^^^^1210^^^^121d^^^^120c\or
  ^^^^1290^^^^1210^^^^1234\or
  ^^^^1330^^^^1309^^^^121c^^^^1295\fi
}
%    \end{macrocode}
%  \end{macro}
%
%    Now we are finished with the \emph{large} |\if| structure.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%
%    \subsubsection*{Final Processing}
%
%    It is possible that a site might need to add some extra code to
%    the \babel\ macros. To enable this we load a local configuration
%    file, \file{ethiop.cfg}, if it is found on \TeX's search path.
%    \begin{macrocode}
\loadlocalcfg{ethiop}
%    \end{macrocode}
%
%    Our last action is to make a note that the commands we have just
%    defined, will be executed by calling the macro |\selectlanguage|
%    at the beginning of the document.
%    \begin{macrocode}
\main@language{ethiop}
%    \end{macrocode}
%    Finally, the category code of \texttt{@} is reset to its original
%    value. The macrospace used by |\atcatcode| is freed.
%    \begin{macrocode}
\catcode`\@=\atcatcode \let\atcatcode\relax
%</code>
%    \end{macrocode}
% 
%    The style file \file{ethiop.sty} is provided to allow
%    |\usepackage{ethiop}| within a document's preamble.
% 
% \changes{v0.7}{1998/03/30}{Removed the use of |\RequirePackage|}
%
%    \begin{macrocode}
%<*style>
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ifx\LdfInit\@undefined
  \def\LdfInit{%
    \chardef\atcatcode=\catcode`\@
    \catcode`\@=11\relax
    \input babel.def\relax
    \catcode`\@=\atcatcode \let\atcatcode\relax
    \LdfInit}
\fi
\input ethiop.ldf\relax
%</style>
%    \end{macrocode}
%
%    We need two new font families for the Ethiopian language,
%    because there are more than 256 different characters.
%    Luckily we do not need a new font encoding, the existing
%    encoding \texttt{U} will do fine.
%
% \changes{v0.3}{1997/04/24}{Added support for 5 point fonts.}
%
%    \begin{macrocode}
%<*etha>
\DeclareFontFamily{U}{etha}{}

% Ethiopic A
\DeclareFontShape{U}{etha}{m}{n}{
  <5> etha6
  <6> <7> <8> gen * etha
  <9> <10> <10.95> <12> <14.4> <17.28> <20.74> <24.88> etha10}{}

% Ethiopic A Slanted
\DeclareFontShape{U}{etha}{m}{sl}{
  <-> ethas10}{}

% Ethiopic A Italics
\DeclareFontShape{U}{etha}{m}{it}{
  <-> ssub * etha/m/sl}{}

% Ethiopic A Bold
\DeclareFontShape{U}{etha}{bx}{n}{
  <5> <6> <7> <8> <9> ethab9
  <10> ethab10
  <10.95> ethab11
  <12> ethab12
  <14.4> ethab14
  <17.28> <20.74> ethab18
  <24.88> ethab24
  <36> ethab36}{}

% Ethiopic A Slanted Bold
\DeclareFontShape{U}{etha}{bx}{sl}{
  <5> <6> <7> <8> <9> ethasb9
  <10> ethasb10
  <10.95> ethasb11
  <12> ethasb12
  <14.4> ethasb14
  <17.28> <20.74> ethasb18
  <24.88> ethasb24
  <36> ethasb36}{}

% Ethiopic A Italics Bold
\DeclareFontShape{U}{etha}{bx}{it}{
  <-> ssub * etha/bx/sl}{}
%</etha>
%    \end{macrocode}
% 
%    That was \file{uetha.fd}, now we have a look at \file{uethb.fd} where
%    only some minor changes are applied.
% 
%    \begin{macrocode}
%<*ethb>
\DeclareFontFamily{U}{ethb}{}

% Ethiopic B
\DeclareFontShape{U}{ethb}{m}{n}{
  <5> ethb6
  <6> <7> <8> gen * ethb
  <9> <10> <10.95> <12> <14.4> <17.28> <20.74> <24.88> ethb10}{}

% Ethiopic B Slanted
\DeclareFontShape{U}{ethb}{m}{sl}{
  <-> ethbs10}{}

% Ethiopic B Italics
\DeclareFontShape{U}{ethb}{m}{it}{
  <-> ssub * ethb/m/sl}{}

% Ethiopic B Bold
\DeclareFontShape{U}{ethb}{bx}{n}{
  <5> <6> <7> <8> <9> ethbb9
  <10> ethbb10
  <10.95> ethbb11
  <12> ethbb12
  <14.4> ethbb14
  <17.28> <20.74> ethbb18
  <24.88> ethbb24
  <36> ethbb36}{}

% Ethiopic B Slanted Bold
\DeclareFontShape{U}{ethb}{bx}{sl}{
  <5> <6> <7> <8> <9> ethbsb9
  <10> ethbsb10
  <10.95> ethbsb11
  <12> ethbsb12
  <14.4> ethbsb14
  <17.28> <20.74> ethbsb18
  <24.88> ethbsb24
  <36> ethbsb36}{}

% Ethiopic B Italics Bold
\DeclareFontShape{U}{ethb}{bx}{it}{
  <-> ssub * ethb/bx/sl}{}
%</ethb>
%    \end{macrocode}
%
%    If we want to use $\Omega$, we need an additional
%    font family for the 16-bit fonts. At the moment
%    we will only provide a rudimentary set of fonts.
%
% \changes{v0.7}{1998/03/30}{Added support for $\Omega$.}
%
%    \begin{macrocode}
%<*etho>
\DeclareFontFamily{U}{etho}{}

% Ethiopic B
\DeclareFontShape{U}{etho}{m}{n}{
  <-> etho10}{}

% Ethiopic B Slanted
\DeclareFontShape{U}{etho}{m}{sl}{
  <-> ethos10}{}

% Ethiopic B Italics
\DeclareFontShape{U}{etho}{m}{it}{
  <-> ssub * etho/m/sl}{}

% Ethiopic B Bold
\DeclareFontShape{U}{etho}{bx}{n}{
  <-> ethob10}{}

% Ethiopic B Slanted Bold
\DeclareFontShape{U}{etho}{bx}{sl}{
  <-> ethosb10}{}

% Ethiopic B Italics Bold
\DeclareFontShape{U}{etho}{bx}{it}{
  <-> ssub * etho/bx/sl}{}
%</etho>
%    \end{macrocode}
%
%    We would like compatibility with Arab\TeX, but Arab\TeX\ cannot
%    handle our active characters.
%    \begin{macrocode}
%<*arab>
\def\noethiop{%
  \catcode`\^=7
  \catcode`\_=8
  \catcode`\.=12
  \catcode`\:=12
  \catcode`\'=12
}
%    \end{macrocode}
%    We save the current category codes of the offending
%    characters before changing them.
%    We might save some time and space by assuming that
%    these characters are always active, but we do not take
%    any chances. 
%    \begin{macrocode}
\def\eth@arab@codes{%
  \chardef\eth@hat@de=\catcode`\^%
  \chardef\eth@bar@de=\catcode`\_%
  \chardef\eth@dot@de=\catcode`\.%
  \chardef\eth@col@de=\catcode`\:%
  \chardef\eth@bkq@de=\catcode`\'%
  \noethiop
}
\def\eth@unarab@codes{%
  \catcode`\^=\eth@hat@de
  \catcode`\_=\eth@bar@de
  \catcode`\.=\eth@dot@de
  \catcode`\:=\eth@col@de
  \catcode`\'=\eth@bkq@de
}
%    \end{macrocode}
%    We must patch the two internal
%    macros |\arab@codes| and |\unarab@codes|.
%
%    The original definitions of the redefined macros are
%    inserted into the new definition by means of the
%    |\expandafter| primitive. This way we are less dependent on
%    the actual definition, so that we might survive a few
%    version changes of Arab\TeX.
%    \begin{macrocode}
\expandafter\def\expandafter\arab@codes\expandafter{%
  \expandafter\eth@arab@codes
  \arab@codes
}
\expandafter\def\expandafter\unarab@codes\expandafter{%
  \unarab@codes
  \eth@unarab@codes
}
%</arab>
%    \end{macrocode}
% \Finale
%\endinput
%% \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         \~}
%%
