%%%%%%%%%%%%%%
% hyconfig.tex             Copyright Bernard Gaulle as in french_doc.pdf
%                     
%                  Hyphenation configuration code 
% Updates:
% 02/28/92 language number setting was wrong.
% 03/20/92 allow hyphenation exceptions file (in language.dat) loading.
% 06/23/92 call the appropriate hymltex* file when using MlTeX
% 07/03/92 add \accenthypencodes
% 08/24/92 introduce \l@<language> being the language number
% 08/26/92 suppress absolute font character references normally unneeded
% 03/03/93 add dialect feature via ``='' sign.
% 04/02/93 add \input compatible.tex when \csubinverse undefined.
% 08/19/93 apply \c mods from MJF -- July 14, 92 
% 08/20/93 insert space after \input X for NFSS2 (H. Soulard) 
% 01/13/94 add \j def for non french languages (noted by R. Lemieux).
% 03/22/94 \LANGUAGESinFORMAT now contains all languages names (proposed
%             by Michel Lavaud).
%          \input hyphen replaced by \input ushyphen (sugg. of M.Lavaud).
% 05/05/94 \patterns@loaded replace \LANGUAGESinFORMAT as in Babel.
% 08/10/94 \input replaced by \@@input if already defined.
% 10/18/94 Load compatible.tex only outside MlTeX.
% 12/13/94 Allow nothing else than =name in language.dat
% 12/17/94 Let language counter progress when equal sign after first language.
% 12/22/94 Don't load compatible.tex whith 2e any way.
% 03/02/95 "      "     "             "    any other format not OT1, this
%          was clearly pointed by Thierry Bouche.
% 03/22/95 \encodingdefault may be undefined (as pointed by Loic Prylli).
% switching to yy/mm/dd below:
% 96/09/10 Allow exception file to be blank in language.dat.
% 96/10/29 Messages numbered.
% 96/12/31 TeX 2 no more supported. taking in acount new frhyph.tex, no more
%          usage of compatible.tex.
% 98/04/22 As pointed by T.Esser when reading language.dat file either .tex
%          file loading or error message might occur. Macro \@l@ngu@ge now
%          revisited.
% 98/04/22 ushyph.tex file defaultly loaded (instead of ushyphen).
% 99/01/20 No-blank empty exception file name now checked.
% 99/08/10 Allow exception file to contain accent macros.
% 2000/01/13 \space missing in def of \@lineD.
% 2000/04/21 hypht1.tex loaded if available on each non empty patterns file.
%            hymltex3.tex merged, thus no more loaded, file removed.
% 2001/02/01 4th parm allowed in language.dat to specify font encoding for 
%           hyphen char. Defaultly t1 is assumed while "-" is not provided or 
%           any other. When applying hyph<encoding>.tex is then automatically 
%           loaded.
% 2001/02/02 Message added showing version 2.0 of hyconfig.
%          \hyphenation mods only apply for exceptions file loading.
% 2001/03/30 Again, missing \space in def of \@lineD (due to 
%          new parm).
%
\message{(hyconfig V2.01) languages: patterns and exceptions,}
%%
%%      checksum        = "05353 171 783 7872"
%%
\ifx\@@input\undefined\let\@@input\input\fi%
\language=0
\let\@tempc\defaultlanguage% Save it if any.
%
% ======== Load Patterns as described in language.dat ======
%
{\newcount\l@nguage\newcount\initl@\newcount\workl@%
       % Compatibility with TeX 2: \language count
       \ifx\language\let\language\l@nguage\fi%
% Temporary definition for \hyphenation, allowing to accept accent macros.
\let\h@yphenation\hyphenation%
\expandafter\let\csname cf@encoding\endcsname\f@encoding%
%
\initl@=\language\l@nguage=\initl@\workl@=\l@nguage
\xdef\patterns@loaded{}% will contain all languages names
\def\@newlanguage[#1]#2{\language=#1%
        \workl@=#1\advance\workl@ by -\initl@%
      \message{-38- The #2 language is used as language number \the\workl@}%
      \expandafter\xdef\csname l@#2\endcsname{\the\workl@}%
      \xdef\patterns@loaded{\patterns@loaded\space #2}%
      \expandafter\xdef\csname#2\endcsname{\language=\the\workl@\relax}%2/28/92
\ifx\undefined\defaultlanguage\gdef\defaultlanguage{\csname#2\endcsname}\fi}%
% test if #1 equal ``='' that means same language hyphenation but a dialect.
\edef\test{=}\edef\hyphchar{t1}%
\def\@language#1#2 #3 #4 #5/#6{\def\@tempa{=}\def\@tempb{#1}%
    \ifx\@tempa\@tempb%
                     \ifnum\l@nguage > \initl@ \advance\l@nguage by -1\fi%
                     \@newlanguage[\the\l@nguage]{#2}%
                     \ifnum\l@nguage \test \initl@ \advance\l@nguage by -1\fi%
    \else\edef\test{<}\@l@ngu@ge#1#2 #3 #4 #5/{#6}% 
    \fi}%
\def\@l@ngu@ge#1 #2 #3 #4/#5{\begingroup\@newlanguage[#5]{#1}%
            \global\edef\hyphchar{#4}%
            \edef\@tempf{\space}%
            \ifx\@tempf\hyphchar\edef\hyphchar{t1}\fi%
            \edef\@tempf{\space\space}%
            \ifx\@tempf\hyphchar\edef\hyphchar{t1}%
             \else\def\@tempf##1  {\edef\hyphchar{##1}}%
             \@tempf #4%
            \ifx\empty\hyphchar\edef\hyphchar{t1}\fi%
            \fi%
%---
  \let\patternsORI=\patterns% Bug bypass for hypht1 V0.3 which is looping
  \def\patterns##1{\patternsORI{##1}\xdef\@tempe{##1}% with empty patterns.
%                   \message{/##1/}% will list the loaded patterns.
                   \global% but not the hypht1 ones.
                   \let\patterns\patternsORI}% 
%---
  \def\@tempa{#2}% Get patterns file name and
  \ifx\@tempa\empty\else\expandafter\@@input#2 \relax% load that file if any
%%%
\edef\@tempf{-}%
\ifx\@tempf\hyphchar\let\@tempd\relax\else%
\openin2 = hyph\hyphchar.tex\let\@tempd\relax%
\ifeof2\message{-61- hyph\hyphchar.tex file not found.}%
\else%
     \def\@tempd{%
     \message{-62- additional hyphenation file loading 
              for \hyphchar\space fonts with specific hyphen char}
         \input hyph\hyphchar.tex% load additional hyph file 
                }% for \hyphchar font encoding.
\fi\closein2%
\fi%
%%%
\long\def\hyphenation##1{\bgroup\let\par\space\let\@typeset@protect\protect%
                         \lowercase{\edef\@tempa{##1}}%
                          \h@yphenation{\@tempa}\egroup}%
\ifx\@tempe\empty\else\@tempd\fi% Load addtional file for T1, if any.
  \edef\@tempf{-}\edef\@tempa{#3}% Get exceptions file name.
  \ifx\@tempf\@tempa\else%
    \ifx\@tempa\empty\else% Check if empty, 
    \edef\@tempb{\space\space\space}% else if blanks, three or 
      \ifx\@tempa\@tempb\else\edef\@tempb{\space\space}% two or
         \ifx\@tempa\@tempb\else\edef\@tempb{\space}% just one, otherwise
           \ifx\@tempa\@tempb\else\expandafter\@@input#3 \relax\fi%load file.
         \fi%
      \fi%
    \fi% 
  \fi%
\fi%
                          \endgroup}%
%
\newif\if@more\@moretrue%
\openin1 = language.dat % 
\ifeof1\message{-39- Error: file language.dat not found, trying to load %
                 US-english hyphenation file}\language=0\input ushyph% 
                 \@newlanguage[0]{english}% and let it be english hyphenation
\else\advance\l@nguage by -1%
\loop  \endlinechar=-1  \read1 to \@lineD  \endlinechar`\^^M%
  \ifx\@lineD\empty  \else \advance\l@nguage by 1%
    \edef\@lineD{\@lineD\space\space\space/{\the\l@nguage}}% 
    \expandafter\@language\@lineD%
  \fi%
  \ifeof1 \@morefalse \fi%
  \if@more\repeat%
\fi\closein1%
%
}\defaultlanguage% go to the default language (first defined in language,dat) 
%
% ======= definitions for fast e/f/g hyphenation =====
%
\def\ehyph{\language=\l@english \lccode`\'=0 \nonfrenchspacing}%
\def\fhyph{\language=\l@french  \lccode`\'=`\'  \frenchspacing}%
\def\ghyph{\language=\l@german}%
%
% ======= check if default language is alive =========
%
\ifx\beginlanguage\undefined\else\expandafter% is begining language available?
  \ifx\csname l@\beginlanguage\endcsname\relax% if not error.
   \message{-39- Error: \beginlanguage\space 
                        language is undefined in language.dat file}% 
  \expandafter\stop% then stop immediately
  \fi%
\fi%
%
\endinput%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
