% kbconfig.tex                               An idea of Bernard Gaulle 07/29/92
%                                                                         V3,19
%                                     Copyright Bernard Gaulle as in french.doc
%
% V3,12 \ForceMlTeXtoCork apply also with plain T1.               --bg 98/12/18
% V3,13 Force ^^[ and ^^^ to be chars for Plain OT1 hyphenation.  --bg 98/12/22
%       When substition goes through a cs then end it with {}.    --bg 98/12/24
% V3,14 \fguillemets and \endfguillemets replaced by \guillemotleft
%       and \guillemotright to allow 8bits verbatim.              --bg 99/01/07
%       Applemac hack: Reset ^^df to \ss when pointing to ^^ff.   --bg 99/01/15
%       Not doing it twice when making the format. \fmtname 
%          redefined temporary for testing second pass.           
%       Releasing \dumpORI and \fmtnameORI to \undefined.         
%       As all .kbc files contain cs with ending {}:
%       (it's now assumed to be done everywhere!)
%       i introduce \GobbEmpty to remove empty block after 
%          alphabetic cs when generating lex file (+I added).
%       Accepting LO1 encoding as a default, if usefull...        --bg 99/01/18
%       \fmtname was wrongly set to \undefined at run-time as
%          pointed by Werner Struckmann.                          --bg 99/01/27
% V3,15 Remove any trailing {} when doing \csubinverse. Apply
%       to \i, \I, ...                                            --bg 99/02/01
% V3,16 Arg with \i{} and \j{} in \if tests should be the last.   
%       \IeC now defined as in inputenc.                          
% V3,17 Using \IeC when encoding a char when otherwise it would
%         have pointed to an active char. This should solve pb
%         when using \MlTeXtoCork with LaTeX over any write.      
%       \DEBUGmessage introduced for debugging.                   --bg 99/02/09
%       \IeC usage with plain corrected.                          --bg 99/02/12
% V3,18 Should check again \unusedslot after keyboard.dat loading.--bg 99/02/19
% V3,19 \fmtname no more temporary set to \undefined. (Pb reported
%        by A. Valentin). Now define \InitexTime cmd.
%       \@jobname setting correction (for space in \fmtname).     --bg 99/02/19
%%
%%      checksum        = "15052 1271 3311 55942"
%%
%
% Is supposed to run with \catcode`@=11.
%\ifx\makeatletter\undefined% for plain secnd \dump cs
% \def\makeatletter{\catcode`@=11\relax}%
% \def\makeatother{\catcode`@=12\relax}%
%\fi%
%
\ifx\@gobble\undefined\def\@gobble#1{}\fi%
%\let\DEBUGmessage\message
\ifx\DEBUGmessage\undefined\let\DEBUGmessage\@gobble\fi%
%
\def\@tempc{\let\ifLEX\iffalse\let\ifLEXhic\iftrue}%
\ifx\ifLEX\undefined\message{keyboard (kbconfig V3,19),}\@tempc\fi%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This code is able to read keyboard.dat and do appropriate customisation 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\let\charsubdef\undefined% make MlTeX 3 unkown for tests
%------------------------------------------------------------------
\ifx\message\DEBUGmessage%
\def\tracingall{\tracingonline\@ne\tracingcommands\tw@\tracingstats\tw@
  \tracingpages\@ne\tracingoutput\@ne\tracinglostchars\@ne
  \tracingmacros\tw@\tracingparagraphs\@ne\tracingrestores\@ne
  \showboxbreadth\maxdimen\showboxdepth\maxdimen\errorstopmode}
\fi%
%
%%%% Check if we can output 8bit without translation to ^^codes
%
\edef\GOfrench{`\string ^}% temp def further correctly defined
\ifnum\catcode\GOfrench=12% mods of code proposed by DT that
       \let\resetat\relax% accepts also that ^ were active
  \else\edef\resetat{\noexpand\catcode\GOfrench=\the\catcode\GOfrench}%
\ifx\ifEightBitOutput\undefined% in a second pass non-MlTeX
\edef\GOfrench{^^e9}% this char. which is activated should not be expanded
\fi% because all the LaTeX stuff is not available.
\catcode`\^=12%
\fi%
\def\@tempc#1 #2\null{\def\@jobname{#1}}% \jobname may contain a space 
\expandafter\expandafter%
\expandafter\@tempc% on Mac.set \@jobname with first
\csname jobname\expandafter\endcsname\space\null% non blank chars.
\def\@tempc{\csname newif\endcsname\ifEightBitOutput\EightBitOutputfalse%
\csname newwrite\endcsname\test\immediate\openout\test=\@jobname.tmp%
  \immediate\write\test{\string\def\string\ligne{\GOfrench}}%
  \immediate\closeout\test%
{\catcode`\^=12
\input\@jobname.tmp % If pb, insure you wrote in an inputable directory.
\def\vide{}\def\gobbleIV##1##2##3##4{}
\def\yy^##1^##2^{\def\aa{##1}%
               \ifx\aa\vide\let\next\gobbleIV
               \else\aftergroup\EightBitOutputtrue
\let\next\relax\fi
               \next}
\expandafter\yy\expandafter^\ligne^^
}%\catcode
}%\@tempc
\ifx\EightBitOutputfalse\undefined\expandafter\@tempc\fi%
\resetat\let\GOfrench\undefined%
\let\@tempc=\undefined% so if someone use it...
%%%% Dirty hack to be remove later...
\def\@tempc{\let\ifECM\iffalse}%
\ifx\ifECM\undefined\relax\@tempc\fi%
\ifLEX\else%
\ifx\documentclass\undefined% This is Plain
 \ifx\IeC\undefined\def\IeC#1{\ifx\protect\relax #1%
                               \else\noexpand\IeC\noexpand #1\fi}%
 \fi%
\else% This is LaTeX
 \ifx\IeC\undefined%
   \def\IeC{\ifx\protect\@typeset@protect\expandafter\@firstofone%
             \else\noexpand\IeC\fi}%
 \fi%
\ifx\undefined\@uclclist% is it initex? yes probably
    \ifx\dumpORI\undefined\let\dumpORI=\dump%
\wlog{french-kbconfig: Intercepting the dump control sequence for %
                       eliminating few invalid chars}%
%%%          \let\SetCfgFor\undefined%
          \let\InitexTime\relax%
          \def\dump{\makeatletter%
                    \input kbconfig.tex %
                    \let\dump\dumpORI%
                    \ifECM\relax\else\uccode`\^^Y=`\^^Y%
                                     \uccode`\^^Z=`\^^Z%
\wlog{-35- kbconfig: Redefining \string ^\string ^\string Y uccode}%
\wlog{-35- kbconfig: Redefining \string ^\string ^\string Z uccode}%
                    \fi%
                    \let\InitexTime\undefined%
                    \makeatother\dump}%
    \fi%
\fi% LaTeX2e
\fi% initex
\fi% LEX
%%%%
\ifx\I\undefined\def\I{I}\fi%
\ifx\SS\undefined\def\SS{\hbox{SS}}\fi% new defs
% \" is redefined, look at the accentuation macros
%%% unused slot preliminary processing
{% (testing activation of the unused slot char)
\ifx\unusedslot\undefined\else%
  \def\@tempb{}\def\@tempc{\catcode`}
       \edef\@unusedslot{\unusedslot}%
  \expandafter\ifnum\expandafter\@tempc\@unusedslot=\active\else%
    \def\@tempb{\message{ERROR \string\unusedslot\space character
            (\noexpand\unusedslot) is not activated.}\stop}%  
  \fi%
\expandafter\@tempb%
\fi%
}%
%
\def\newcount{\alloc@0\count\countdef\insc@unt}%....................  \newcount
\def\@tempa{\newcount\@tempcnta\newcount\@tempcntb}%
\ifx\@tempcnta\undefined\expandafter\@tempa\fi% case plain TeX.
\def\reserved@a#1#2{\@tempcnta#1\relax\@tempcntb#2\relax\reserved@b}%
\def\reserved@b{\ifnum\@tempcnta>\@tempcntb\else\reserved@c\@tempcnta%
                 \advance\@tempcnta\@ne\expandafter\reserved@b\fi}%
%
% Go back to default LaTeX catcodes
%
\ifLEX\else% don't activate for kb2lex
\expandafter\ifx\csname ^^63\endcsname\c % 128-255 going \active locally in V3
\catcode`\ =10
\catcode`\#=6
\catcode`\$=3
\catcode`\%=14
\catcode`\&=4
\catcode`\\=0
\catcode`\^=7
\catcode`\_=8
\catcode`\{=1
\catcode`\}=2
\catcode`\~=13
\catcode`\@=11
\catcode`\^^I=10
\catcode`\^^J=12
\catcode`\^^L=13
\catcode`\^^M=5
\def\reserved@c#1{\catcode#1=12\relax}
\reserved@c{`\!}
\reserved@c{`\"}
\reserved@a{`\'}{`\?}
\reserved@c{`\[}
\reserved@c{`\]}
\reserved@c{`\`}
\reserved@c{`\|}
%
\def\reserved@c#1{\catcode#1=11\relax}
\reserved@a{`\A}{`\Z}
\reserved@a{`\a}{`\z}
\def\reserved@c#1{\catcode#1=15\relax}
\reserved@a{0}{`\^^H}
\reserved@c{`\^^K}
\reserved@a{`\^^N}{31}
  \catcode"7F=15
\def\reserved@c#1{\catcode#1=13\relax}%
\reserved@a{"7F}{"FF}% activate all 8-bits chars 
\def\reserved@c#1{%
   \count@=#1\advance\count@ by -"20
   \uccode#1=\count@
   \lccode#1=#1}
\reserved@a{`\a}{`\z}
\ifnum\inputlineno=\m@ne\else
  \reserved@a{"A0}{"BC}
  \reserved@a{"E0}{"FF}
\fi
% hack for applemac ==> \def^^df{\ss{}}
\def\reserved@c{\let\D ^^df% ^^df could have been pointing to ^^ff
                \if ^^df\D\def ^^df{\ss{}}\fi}% if so point to 7bit value.
% Do the following only in over a format, not within the format.
\ifx\fmtname\undefined\else% Initex plain format test.
  \ifx\@uclclist\undefined\else% Initex LaTeX format test.
    \ifx\InitexTime\relax\else% Initex second pas LaTeX format test.
      \ifx\undefined ^^df\else\reserved@c\fi%
    \fi%
  \fi%
\fi%
\def\reserved@c#1{%
   \count@=#1\advance\count@ by "20
   \uccode#1=#1
   \lccode#1=\count@
   \sfcode#1=999
}
\reserved@a{`\A}{`\Z}
\ifnum\inputlineno=\m@ne\else
  \reserved@a{"80}{"9C}
  \reserved@a{"C0}{"DF}
\fi
\uccode`\^^Y=`\I     % dotless i
\lccode`\^^Y=`\^^Y   % dotless i
\uccode`\^^Z=`\J     % dotless j, ae in OT1
\lccode`\^^Z=`\^^Z   % dotless j, ae in OT1
\ifnum\inputlineno=\m@ne\else
  \lccode`\^^9d=`\i    % dotted I
  \uccode`\^^9d=`\^^9d % dotted I
  \lccode`\^^9e=`\^^9e % d-bar
  \uccode`\^^9e=`\^^d0 % d-bar
\fi
% reset macros to initial values
\def\reserved@a#1#2{\@tempcnta#1\relax\@tempcntb#2\relax\reserved@b}%
\def\reserved@b{\ifnum\@tempcnta>\@tempcntb\else\reserved@c\@tempcnta%
                 \advance\@tempcnta\@ne\expandafter\reserved@b\fi}%
%
\ifx\unusedslot\undefined\edef\@unusedslot{\noexpand ^^9c}%
  \else\edef\@unusedslot{\unusedslot}%
\fi%
\expandafter\let \@unusedslot =\undefined%
\fi% ifx TeX V3 
\fi%\ifLEX
\def\ESC{}% no escape char
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------------------------------------------------------
% code coming from compatible.tex (Aug. 1990) of MJF and Justin Bur
\def\csubinverse #1#2#3{\expandafter\xdef\csname #2#3\endcsname{#1}}%
%           #1 -- extended 8bits character to replace accent+letter
%           #2 -- accent macro invocation for...
%           #3 -- this letter (base character)
%------------------------------------------------------------------
\begingroup% to protect all the marmelade done here
\ifLEX\else\let\protect\noexpand\fi%
\catcode`[=13\catcode`@=11%
\catcode`<=13\catcode`>=13% will allow << and >> in keyboard.dat
%%%%%%%%%
% test if ECM can be used (in fact DCM here) 
%
\newif\ifECM% local redefinition for a global expansion.
\global\let\ifECM\ifHB% may be it's already set by \ifHB in lhyphen/plain
\ifx\ifHB\undefined\global\ECMfalse\fi%
\ifECM\else% skip this if already decided
\ifx\encodingdefault\undefined%%%%%%%%%%%% 
  \ifECM\else% if false test (again) if it might be an ec/dc font
  \ifx\rm\undefined% may be \rm isn't allready defined (specially with LaTeX)
                   \def\graveDC{\mathaccent"7000 }% so test such char
                   \ifx\graveDC\grave\ECMtrue\else\ECMfalse\fi%
  \else% try on fontname that is a better security
     \def\is@DC#1#2#3\relax{\if d#11\fi \if e#11\fi \if c#22\fi}%
     \def\dcdo{% \dcdo code Version 3 as of 01/27/92 on DCFONT discussion list
               \ifnum 12=0\expandafter\is@DC\fontname\font xx\relax\space%
                          \expandafter\dc@first%
               \else      \expandafter\dc@second%
               \fi}%
          \def\dc@first#1#2{#1}%
          \def\dc@second#1#2{#2}%
  {\rm\dcdo{\global\ECMtrue}{\global\ECMfalse}}% final DC test
  \fi%\ifx\rm\undefined
  \fi%\ifECM\else..
%
  \ifECM\global\def\encodingdefault{T1}%   T1 is for DC/EC
   \else\global\def\encodingdefault{OT1}% OT1 is for CM
  \fi%
%
\else%
\ifx\f@encoding\undefined\edef\f@encoding{\encodingdefault}\fi%
%     \edef\@tempa{OT1}\ifx\@tempa\f@encoding%
%                          {\global\ECMfalse}%
%                     \else{\global\ECMtrue}%
%                     \fi%
 \def\@tempa{OT1}\ifx\@tempa\f@encoding%
                      \def\@tempa{\global\ECMfalse}%
                 \else\def\@tempa{LO1}\ifx\@tempa\f@encoding%
                                       \def\@tempa{\global\ECMfalse}%
                                      \else%  could be LY1
                                       \def\@tempa{\global\ECMtrue}%
                                      \fi%
                  \fi%
\@tempa%
\fi%\encodingdefault
\fi% ifECM
%%%%%%
% Prevent LaTeX2e invalid chars
\ifx\documentclass\undefined\else
\ifECM%
\catcode`\^^_=11%
\catcode`\^^Y=11%
\else%
\catcode`\^^P=11%
\catcode`\^^Q=11%
\catcode`\^^Y=11%
\catcode`\^^Z=11%
\catcode`\^^]=11%
\catcode`\^^[=11%
\catcode`\^^^=11%
\catcode`\^^\=11%
\catcode`\^^_=11%
\fi\fi%
%%%%%%
\newif\ifMACRO\MACROfalse\newif\ifLIGS\LIGSfalse
%------------------------------------------------------------------
% Now where is the accent in the font? local mods of plain code.
% and how code it: diacritic+letter or accented 8bits char?
%
%Caution: never use TeX V2 hexadecimal notation, lowercase would be wrong
\ifECM\def\POSgr{"00}\def\POSac{"01}\def\POSan{"06}
      \def\POSv{"07}\def\POSu{"08}\def\POSeq{"09}
      \def\POShat{"02}\def\POSdot{"0a}\def\POSH{"05}\def\POStil{"03}
      \def\POSum{"04}\def\POSc{"13}
\else\def\POSgr{18}\def\POSac{19}
     \def\POSv{20}\def\POSu{21}\def\POSeq{22}\def\POSan{23}
     \def\POShat{94}\def\POSdot{95}\def\POSH{125}\def\POStil{126}
     \def\POSum{127}\def\POSc{24} 
\fi%
     \let\MPOSgr\grave\let\MPOSac\acute\let\MPOSv\check\let\MPOSu\breve%
     \let\MPOSeq\bar\let\MPOSan\undefined% \r
     \let\MPOShat\hat\let\MPOSdot\dot\let\MPOSH\undefined% Hugarian umlaut
     \let\MPOStil\tilde\let\MPOSum\ddot\let\MPOSc\undefined% cedilla
\ifLEX\begingroup\catcode`+=0\catcode`[= 1\catcode`]=2
                 \catcode`\{=12\catcode`\}=12\catcode`\\=12 
   +gdef+ESC[\]% set escape char
   +gdef+GobbEmpty#1[+ifx#1+empty+else+expandafter[#1]+fi]
   +gdef+ToEight[% Due to lex capacities we keep only one expansion of 
                 % usual accent macros e.g. {\'E} but not \'{E} nor \'E
      +def+`##1[%\\`\{##1\}|\\`##1|
                \{\\`##1\}]
      +def+'##1[%\\'\{##1\}|\\'##1|
                \{\\'##1\}]
      +def+r##1[\\"r "##1|\\r\{##1\}]
      +def+v##1[\\"v "##1|\\v\{##1\}]
      +def+u##1[\\"u "##1|\\u\{##1\}]
      +def+=##1[%\\=\{##1\}|\\=##1|
                \{\\=##1\}]
      +def+^##1[%\\^\{##1\}|\\^##1|
                \{\\^##1\}]
      +def+.##1[%\\.\{##1\}|\\.##1|
                \{\\.##1\}]
      +def+H##1[\\"H "##1|\\H\{##1\}]
      +def+~##1[%\\~\{##1\}|\\~##1|
                \{\\~##1\}]
      +def+"##1[%\\\"\{##1\}|\\\"##1|
                \{\\\"##1\}]
      +def+c##1[\\"c "##1|\\c\{##1\}]
      +def+i[\\i+GobbEmpty]
      +def+I[\\I+GobbEmpty]
      +def+j[\\j+GobbEmpty]
      +def+copyright[\{\\"copyright"\}|\\"copyright"\{\}|\\"copyright "%
                     +GobbEmpty]
      +def+oe[\\"oe "|\{\\"oe"\}|\\"oe"\{\}+GobbEmpty]
      +def+OE[\\"OE "|\{\\"OE"\}|\\"OE"\{\}+GobbEmpty]
      +def+ss[\\"ss "|\{\\"ss"\}|\\"ss"\{\}+GobbEmpty]
      +def+SS[\\"SS "|\{\\"SS"\}|\\"SS"\{\}+GobbEmpty]
      +def+ae[\\"ae "|\{\\"ae"\}|\\"ae"\{\}+GobbEmpty]
      +def+AE[\\"AE "|\{\\"AE"\}|\\"AE"\{\}+GobbEmpty]
      +def+l[\\"l "|\{\\l\}|\\l\{\}+GobbEmpty]
      +def+L[\\"L "|\{\\L\}|\\L\{\}+GobbEmpty]
      +def+o[\\"o "|\{\\o\}|\\o\{\}+GobbEmpty]
      +def+O[\\"O "|\{\\O\}|\\O\{\}+GobbEmpty]
      +def+P[\\"P "|\{\\P\}|\\P\{\}+GobbEmpty]
      +def+unskip[\"unskip "]% for \ESC\unskip, just one "\" due to \ESC
      +def+degre[\\"degre"]% only one expansion
      +def+texteuro[\\"texteuro "|\{\\"texteuro"\}|\\"texteuro"\{\}+GobbEmpty]
      +def+pounds[\\"pounds "|\{\\"pounds"\}|\\"pounds"\{\}+GobbEmpty]
      +def+S[\\"S "|\{\\S\}|\\S\{\}+GobbEmpty]
      +def+guillemotleft["+string<+string<"+GobbEmpty]
      +def+guillemotright["+string>+string>"+GobbEmpty]%
            ]%
   +gdef+ToSeven[%
      +def+`##1[{\\`##1}]
      +def+'##1[{\\'##1}]
      +def+r##1[\\r{##1}]
      +def+v##1[\\v{##1}]
      +def+u##1[\\u{##1}]
      +def+=##1[{\\=##1}]
      +def+^##1[{\\^##1}]
      +def+.##1[{\\.##1}]
      +def+H##1[\\H{##1}]
      +def+~##1[{\\~##1}]
      +def+"##1[{\\\"##1}]
      +def+c##1[\\c{##1}]
      +def+i[\\i+GobbEmpty]
      +def+I[I+GobbEmpty]
      +def+j[\\j+GobbEmpty]
      +def+copyright[{\\copyright}+GobbEmpty]
      +def+oe[{\\oe}+GobbEmpty]
      +def+OE[{\\OE}+GobbEmpty]
      +def+ss[{\\ss}+GobbEmpty]
      +def+SS[{\\SS}+GobbEmpty]
      +def+ae[{\\ae}+GobbEmpty]
      +def+AE[{\\AE}+GobbEmpty]
      +def+l[{\\l}+GobbEmpty]
      +def+L[{\\L}+GobbEmpty]
      +def+o[{\\o}+GobbEmpty]
      +def+O[{\\O}+GobbEmpty]
      +def+P[{\\P}+GobbEmpty]
      +def+pounds[{\\pounds}+GobbEmpty]
      +def+texteuro[{\\texteuro}+GobbEmpty]
      +def+degre##1##2[\\degre##1##2]% no {} 
      +def+S[{\\S}+GobbEmpty]
      +def+guillemotleft[+string<+string<+GobbEmpty]
      +def+guillemotright[+string>+string>+GobbEmpty]%
            ]%
      +endgroup
\else%
% Folowing \ifx are not required there are here in case of any misplacement 
% of kbconfig (eg after hyconfig).
\ifx\documentclass\undefined% do it in 2.09
\edef\`#1{\expandafter\ifx\csname @gr@#1\endcsname\relax%
                           \ifECM{\accent"00 #1}\else{\accent18 #1}\fi%
                       \else\csname @gr@#1\endcsname\fi}% 
\edef\'#1{\expandafter\ifx\csname @ac@#1\endcsname\relax%
                           \ifECM{\accent"01 #1}\else{\accent19 #1}\fi%
                       \else\csname @ac@#1\endcsname\fi}% 
\edef\v#1{\expandafter\ifx\csname @v@#1\endcsname\relax%
                           \ifECM{\accent"07 #1}\else{\accent20 #1}\fi%
                       \else\csname @v@#1\endcsname\fi}% 
\edef\u#1{\expandafter\ifx\csname @u@#1\endcsname\relax%
                           \ifECM{\accent"08 #1}\else{\accent21 #1}\fi%
                       \else\csname @u@#1\endcsname\fi}% 
\edef\=#1{\expandafter\ifx\csname @eq@#1\endcsname\relax%
                           \ifECM{\accent"09 #1}\else{\accent22 #1}\fi%
                       \else\csname @eq@#1\endcsname\fi}% 
\edef\^#1{\expandafter\ifx\csname @hat@#1\endcsname\relax%
                           \ifECM{\accent"02 #1}\else{\accent94 #1}\fi%
                       \else\csname @hat@#1\endcsname\fi}% 
\edef\.#1{\expandafter\ifx\csname @dot@#1\endcsname\relax%
                           \ifECM{\accent"0a #1}\else{\accent95 #1}\fi%
                       \else\csname @dot@#1\endcsname\fi}% 
\edef\H#1{\expandafter\ifx\csname @H@#1\endcsname\relax%
                           \ifECM{\accent"05 #1}\else{\accent125 #1}\fi%
                       \else\csname @H@#1\endcsname\fi}% 
\edef\~#1{\expandafter\ifx\csname @til@#1\endcsname\relax%
                           \ifECM{\accent"03 #1}\else{\accent126 #1}\fi%
                       \else\csname @til@#1\endcsname\fi}% 
% plain defined it ``wrongly'' in hex ("7F) and so could be wrongly lowercased
\edef\"#1{\expandafter\ifx\csname @um@#1\endcsname\relax%plain define it in hex
                           \ifECM{\accent"04 #1}\else{\accent127 #1}\fi%
                       \else\csname @um@#1\endcsname\fi}%
\def\c#1{\expandafter\ifx\csname @c@#1\endcsname\relax\noexpand\c#1%
                       \else\csname @c@#1\endcsname\fi}% 
% D. Knuth defined \oalign in a way that we can't use it in
%          an \edef or \xdef so i changed it temporarily
\def\oalign#1{\leavevmode\vtop{\baselineskip\z@skip \lineskip.25ex%
  \ialign{####\crcr#1\crcr}}}% put characters over each other
% our new def for angstrom bec. undefined in plain as an accent. macro
\def\r#1{\if#1a\@a:a\else\if#1A\@A:A\fi\fi}% 
\def\@a:a{\expandafter\ifx\csname @an@a\endcsname\relax%
                          \ifECM{\accent"06a}\else{\accent23a}\fi%
                       \else\csname @an@a\endcsname\fi}% 
\def\@A:A{\expandafter\ifx\csname @an@A\endcsname\relax%
                          \leavevmode\setbox0\hbox{h}\dimen@\ht0%
                            \advance\dimen@-1ex\rlap{\raise.67\dimen@\hbox{%
                                    \ifECM\char"06\else\char'27\fi}}A%
                       \else\csname @an@A\endcsname\fi}%
\xdef\aa{\r a}\xdef\AA{\r A}%
\fi% done for 2.09
\fi%\ifLEX
%
\catcode`\^^[=11%
\catcode`\^^^=11%
\catcode`\^^Y=11%
\catcode`\^^Z=11%
\catcode`\^^]=11%
\catcode`\^^_=11%
\catcode`\^^\=11%
\catcode`\^^P=11%
\catcode`\^^Q=11%
% Strings def are global to allow \@accent@ to work properly (not for 2e)
\def\@gobbletwo#1#2{}%
\ifx\documentclass\undefined\let\Gdef=\gdef%
\else\let\Gdef\@gobbletwo% Prevent LaTeX2e invalid chars even if gobbled
\fi%
\ifECM\Gdef\oe{\string^^f7}\else\Gdef\oe{^^[}\fi%
\ifECM\Gdef\OE{\string^^d7}\else\Gdef\OE{^^^}\fi%
\ifECM\Gdef\ss{\string^^ff}\else\Gdef\ss{^^Y}\fi%
\ifECM\Gdef\ae{\string^^e6}% ^^e6 introduce a pb, why?
                          \else\Gdef\ae{^^Z}% 
                          \fi%
\ifECM\Gdef\AE{\string^^c6}\else\Gdef\AE{^^]}\fi%
\ifECM\else\global\lccode`^^]=`^^Z% a bypass for V2
           \global\uccode`^^Z=`^^]%
           \global\uccode`^^[=`^^^%
           \global\lccode`^^^=`^^[%
           \global\lccode`^^[=`^^[% 98/12
           \global\lccode`^^_=`^^\%
           \global\uccode`^^\=`^^_%
           \global\uccode`^^P=`I%
           \global\uccode`^^Q=`J%
\fi%
\ifECM\Gdef\o {\string^^f8}\else\Gdef\o {^^\}\fi%
\ifECM\Gdef\O {\string^^d8}\else\Gdef\O {^^_}\fi%
% but require an uppercase def for \ss different for ec/dc ie:
\ifECM\Gdef\SS{\string^^df}\fi% valid global def for DC
%
\def\D{\char^^bf}%
\ifx\D\pounds\Gdef\pounds{\string^^bf}\fi%
% Plain has no definition of \pounds
\ifx\pounds\undefined{\ifECM\Gdef\pounds{\string ^^bf}%lfonts.tex will redef.it
                     \else\Gdef\pounds{{\csname it\endcsname\char'44}}\fi}\fi% 
%
\ifx<\undefined\gdef<{\string<}\fi%  defs until french.sty were activated
\ifx>\undefined\gdef>{\string>}\fi%
%
\ifECM\Gdef\i{^^Y}\else\Gdef\i{^^P}\fi% needed by \csubinverse for patterns
\ifECM\Gdef\j{^^Z}\else\Gdef\j{^^Q}\fi% dotless letters 
% Localy needed anyway:
\ifECM\def\i{^^Y}\else\def\i{^^P}\fi% needed for \csubinverse 
% LaTeX 2e doesn't care of i and j without dot on it
\ifx\documentclass\undefined\else%
 \ifECM\edef\i{i}\edef\j{j}\fi%
\fi%
% 
% Are we in TeX V2 or V3?
\newif\ifVtwo \newif\ifSkip \Skipfalse 
\newif\ifnonActifCar\nonActifCartrue % 
\def\ACTIVEtrue{\nonActifCarfalse}% user interface is reversed.
\def\ACTIVEfalse{\nonActifCartrue}% 
\newif\ifMlTeXthree \MlTeXthreefalse
\catcode`^=\active% non hexa processing in V2
\ifx\undefined\lefthyphenmin\Vtwotrue% Vtwo means MlTeX V2
                          \def^#1{\ifx#1^\else\string^#1\fi}% eat ^^ in TeX v2
                         \message{-28- ATTENTION : TeX Version 2 ne permet pas 
                                  d'utiliser des caracteres accentues 8bits}%
                            \ifnum\catcode`\{=1%\} emacs
                            \message{Vous devez :}
                            \message{- soit utiliser un moteur MlTeX,}
                            \message{- soit passer en codage T1 par defaut.}
                            \Stop% a vous de choisir... --bg
                            \fi%
                              \Skiptrue%
                     \else\ifx\starthyph\undefined\Vtwofalse\else\Vtwotrue\fi%
                          \ifx\charsubdef\undefined\else\MlTeXthreetrue\fi%
%%%\ifx\SetCfgFor\undefined%
\ifLEX\else%
  \ifMlTeXthree\else%
   \ifECM\else%
   {\catcode`\^=12\newlinechar=`\^
    \message{^-29- kbconfig ****Warning****\string: your TeX V3 engine +  CM}}
   \message{fonts (your format default) isn't sufficient to hyphenate}%
   \message{words containing diacritics (like in French).}%
   \fi%
  \fi%
\fi% ifLEX
%%%\fi%\SerCfg
\fi% lefthyphenmin
\ifVtwo\else\catcode`\^=7% reset value of plain
% reset first 32 chars too erroneously (?) illegal since 2e
\catcode`\^^00=11%
\catcode`\^^01=11%
\catcode`\^^02=11%
\catcode`\^^03=11%
\catcode`\^^04=11%
\catcode`\^^05=11%
\catcode`\^^06=11%
\catcode`\^^07=11%
\catcode`\^^08=11%
%\catcode`\^^09=11% is tab ^^I
%\catcode`\^^0a=11% is nl  ^^J
\catcode`\^^0b=11%
%\catcode`\^^0c=11% is ff  ^^L
%\catcode`\^^0d=11% is cr  ^^M
\catcode`\^^0e=11%
\catcode`\^^0f=11%
\catcode`\^^10=11%
\catcode`\^^11=11%
\catcode`\^^12=11%
\catcode`\^^13=11%
\catcode`\^^14=11%
\catcode`\^^15=11%
\catcode`\^^16=11%
\catcode`\^^17=11%
\catcode`\^^18=11%
\catcode`\^^19=11%
\catcode`\^^1a=11%
\catcode`\^^1b=11%
\catcode`\^^1c=11%
\catcode`\^^1d=11%
\catcode`\^^1e=11%
\catcode`\^^1f=11%
\fi%
\ifSkip\else% The code is only for MlTeX or TeX V3.xxxx
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Codage du tableau : definition de l'accentuation
\def\ac[ #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 ]%
       {\ifLEX\message{^^J PROCESSED CHARACTERS ARE:}\fi
        \ifx.#1\let\ACa\undefined\else\def\ACa{#1}\fi% si different d'un point
        \ifx.#2\let\ACb\undefined\else\def\ACb{#2}\fi%
        \ifx.#3\let\ACc\undefined\else\def\ACc{#3}\fi%
        \ifx.#4\let\ACd\undefined\else\def\ACd{#4}\fi%
        \ifx.#5\let\ACe\undefined\else\def\ACe{#5}\fi%
        \ifx.#6\let\ACf\undefined\else\def\ACf{#6}\fi%
        \ifx.#7\let\ACg\undefined\else\def\ACg{#7}\fi%
        \ifx.#8\let\ACh\undefined\else\def\ACh{#8}\fi\let[\minu%]
       }%
% La macro precisant les noms internes
\def\noms| #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 |%
       {\ifx.#1\let\ANa\undefined\else\def\ANa{#1}\fi%
        \ifx.#2\let\ANb\undefined\else\def\ANb{#2}\fi%
        \ifx.#3\let\ANc\undefined\else\def\ANc{#3}\fi%
        \ifx.#4\let\ANd\undefined\else\def\ANd{#4}\fi%
        \ifx.#5\let\ANe\undefined\else\def\ANe{#5}\fi%
        \ifx.#6\let\ANf\undefined\else\def\ANf{#6}\fi%
        \ifx.#7\let\ANg\undefined\else\def\ANg{#7}\fi%
        \ifx.#8\let\ANh\undefined\else\def\ANh{#8}\fi}%
\newif\ifONE\newif\ifOK%
\def\ONECHAR#1#2/{\ifx9#2\ONEtrue\else\ONEfalse\fi}%
%definition des minuscules
%==>\madef{caract accentue}{accentuation}{Nom minuscule}{lettre}
\def\madef#1#2#3#4{\ifx.#1\else\@madef{#1}{#2}{#3}{#4}\fi}% si pas un . 
\def\@madef#1#2#3#4{\ONECHAR#19/%
    \ifx#2\undefined% 
    \else
         \ifVtwo\ifONE% #1 is defaultly \active with MlTeX R1
                              \DEBUGmessage{K0(\noexpand #1)}%
                              \xdef#1{#2{#4}}%
                            \fi% 
         \else\def\tempb{\catcode`}% now in V3
                  \let\A=A\ifMACRO\let\A\active\else\ifLIGS\let\A\active\fi\fi%
                  \ifx#2\empty\let\A=\active\fi%
                  \ifcat\active\A% 
                     \ifECM\OKfalse% normally nothing to do
                       \ifMACRO\OKtrue\fi% except for macros
                       \ifLIGS\OKtrue\fi% except for ligs
                       \ifnonActifCar\ifx\ss #4\OKtrue\fi% \ss is specific
                        \else\OKtrue\fi% except if active char
                       \ifOK%
                          \ifONE% exclude multiletters
                                \ifLEX\else%
\DEBUGmessage{K1(\noexpand #1)}%
                                       \gdef #1{#4}% 98/12/24
                                \fi%
% Defaultly there is no lower/upper case
\global\lccode`#1=`#1%
\global\uccode`#1=`#1%
                          \edef\OldActiveChars{\@tempc}%
                          \xdef\@tempc{\OldActiveChars%
                                            \tempb\string#1=\active}%
                          \fi% ifONE
                       \fi% ifOK
                     \else% Not using ECM
                          \ifONE% exclude multiletters
\ifnonActifCar\else\tempb#1=\active\fi%
                                \ifMlTeXthree\else\tempb#1=\active\fi%
                             \ifLEX\else%  don't xdef for oe, ae, etc.
% future dev: test if #4 need to be ended by {} or not. Today assumed.
\DEBUGmessage{K2(\noexpand #1)}%
                                   \gdef #1{#4}% usually ended by {} 1/99
% Defaultly there is no lower/upper case
\global\lccode`#1=`#1%
\global\uccode`#1=`#1%
                             \fi%ifLEX
                                \edef\OldActiveChars{\@tempc}%
                                \xdef\@tempc{\OldActiveChars%
                                                  \tempb\string#1=\active}%
                          \fi%
                     \fi%
                  \else% Not a Macro, Not a lig, ..
                        \ifLEX\else\def\D{#4}%
                                    \if\i #4\def\D{\noexpand\i}\fi%
                                    \if\j #4\def\D{\noexpand\j}\fi%
\DEBUGmessage{K3(\noexpand #1)}%
                                    \xdef#1{\expandafter\noexpand#2{\D}}%
% Defaultly there is no lower/upper case
\global\lccode`#1=`#1%
\global\uccode`#1=`#1%
                        \fi%
\ifnonActifCar\else\tempb#1=\active\fi%
                       \ifMlTeXthree\else\tempb#1=\active\fi%
                       \edef\OldActiveChars{\@tempc}%
                       \xdef\@tempc{\OldActiveChars%
                                         \tempb\string#1=\active}%
                  \fi%
         \fi% ifVtwo
     \expandafter\def\csname #3\endcsname{#1}% for further use
     \fi% ifx#2
 \ifLEX\ifLEXhic\ifONE\message{\string#1 \space}
  {\ToSeven\def\GUILL{"}
              \edef\FULL{#2\LaLettre}%
  \ifx\empty#2\edef\FULL{\LaLettre}\fi
  \immediate\write\kbseven{\string#1\space\space\space 
                                     printf(\GUILL\FULL\GUILL);}}
  {\ToEight\def\GUILL{\ifLIGS"\fi}%
              \edef\FULL{#2{\GUILL\LaLettre\GUILL}}%
  \ifx\empty#2\edef\FULL{\GUILL\LaLettre\GUILL}\fi
  \immediate\write\kbeight{\FULL%
                           |\string#1\space\space\space printf("\string#1");}}
 \fi\fi\fi% ifLEX
}% @madef 
\def\minu#1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 |%
    {%
%\let\LAa\undefined\let\LAb\undefined\let\LAc\undefined\let\LAd\undefined
%     \let\LAe\undefined\let\LAf\undefined\let\LAg\undefined\let\LAh\undefined
\ifLEX\edef\@tempc{}\fi% required for LaTeX kb2lex!
\def\@tempa##1/{\def\LaLettre{##1}}\@tempa#1/%     
     \madef#2{\ACa}{LAa}{#1}%
     \madef#3{\ACb}{LAb}{#1}%
     \madef#4{\ACc}{LAc}{#1}%
     \madef#5{\ACd}{LAd}{#1}%
     \madef#6{\ACe}{LAe}{#1}%
     \madef#7{\ACf}{LAf}{#1}%
     \madef#8{\ACg}{LAg}{#1}%
     \madef#9{\ACh}{LAh}{#1}% 
     \let\A=A\ifMACRO\let\A\active\else\ifLIGS\let\A\active\fi\fi%
     \ifcat\A\active\xdef\Lchar{}\else\xdef\Lchar{#1}\fi%dummy for \oe \ae etc.
     \let\hex\hexminu}%
\def\hexminu| #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 %[
                                                    ]%
    {\ifx.#1\let\HLa\undefined\else\edef\HLa{\noexpand#1}\fi%
     \ifx.#2\let\HLb\undefined\else\edef\HLb{\noexpand#2}\fi%
     \ifx.#3\let\HLc\undefined\else\edef\HLc{\noexpand#3}\fi%
     \ifx.#4\let\HLd\undefined\else\edef\HLd{\noexpand#4}\fi%
     \ifx.#5\let\HLe\undefined\else\edef\HLe{\noexpand#5}\fi%
     \ifx.#6\let\HLf\undefined\else\edef\HLf{\noexpand#6}\fi%
     \ifx.#7\let\HLg\undefined\else\edef\HLg{\noexpand#7}\fi%
     \ifx.#8\let\HLh\undefined\else\edef\HLh{\noexpand#8}\fi%
     \let[\MAJU%]
    }%
%definition des majuscules
%==>\Madef{caract accentue}{accentuation}{Nom majuscule}{lettre}
\def\Madef#1#2#3#4{\ifx.#1\else\@madef{#1}{#2}{#3}{#4}\fi}% si pas un . 
\def\MAJU#1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 |%
    {\let\MAa\undefined\let\MAb\undefined\let\MAc\undefined\let\MAd\undefined
     \let\MAe\undefined\let\MAf\undefined\let\MAg\undefined\let\MAh\undefined
     \ifLEX\edef\@tempc{}\fi% required for LaTeX kb2lex!
\def\@tempa##1/{\def\LaLettre{##1}}\@tempa#1/%
     \Madef#2{\ACa}{MAa}{#1}%
     \Madef#3{\ACb}{MAb}{#1}%
     \Madef#4{\ACc}{MAc}{#1}%
     \Madef#5{\ACd}{MAd}{#1}%
     \Madef#6{\ACe}{MAe}{#1}%
     \Madef#7{\ACf}{MAf}{#1}%
     \Madef#8{\ACg}{MAg}{#1}%
     \Madef#9{\ACh}{MAh}{#1}%
     \let\A=A\ifMACRO\let\A\active\else\ifLIGS\let\A\active\fi\fi%
     \ifcat\A\active\xdef\Mchar{}\else%
                   \ifx.#1\xdef\Mchar{}\else\xdef\Mchar{#1}\fi%
     \fi% dummy for \OE etc.
     \let\hex\hexMAJU}%
\def\hexMAJU| #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 %[
                                                    ]%
    {\ifx.#1\let\HMa\undefined\else\edef\HMa{\noexpand#1}\fi%
     \ifx.#2\let\HMb\undefined\else\edef\HMb{\noexpand#2}\fi%
     \ifx.#3\let\HMc\undefined\else\edef\HMc{\noexpand#3}\fi%
     \ifx.#4\let\HMd\undefined\else\edef\HMd{\noexpand#4}\fi%
     \ifx.#5\let\HMe\undefined\else\edef\HMe{\noexpand#5}\fi%
     \ifx.#6\let\HMf\undefined\else\edef\HMf{\noexpand#6}\fi%
     \ifx.#7\let\HMg\undefined\else\edef\HMg{\noexpand#7}\fi%
     \ifx.#8\let\HMh\undefined\else\edef\HMh{\noexpand#8}\fi%
     % process hexdecimal codes if necessary
     \ifx\HLa\undefined\else\DOhex\ACa{\LAa}{\HLa}{\MAa}{\HMa}{\ANa}\fi%
     \ifx\HLb\undefined\else\DOhex\ACb{\LAb}{\HLb}{\MAb}{\HMb}{\ANb}\fi%
     \ifx\HLc\undefined\else\DOhex\ACc{\LAc}{\HLc}{\MAc}{\HMc}{\ANc}\fi%
     \ifx\HLd\undefined\else\DOhex\ACd{\LAd}{\HLd}{\MAd}{\HMd}{\ANd}\fi%
     \ifx\HLe\undefined\else\DOhex\ACe{\LAe}{\HLe}{\MAe}{\HMe}{\ANe}\fi%
     \ifx\HLf\undefined\else\DOhex\ACf{\LAf}{\HLf}{\MAf}{\HMf}{\ANf}\fi%
     \ifx\HLg\undefined\else\DOhex\ACg{\LAg}{\HLg}{\MAg}{\HMg}{\ANg}\fi%
     \ifx\HLh\undefined\else\DOhex\ACh{\LAh}{\HLh}{\MAh}{\HMh}{\ANh}\fi%
     % now ready to start a 4up
     \let[\minu%]
    }%
\def\@tempc{}%
\def\DOhex#1#2#3#4#5#6{%
%                1              2         3           4        5        6
%           accentuation, lettre_min+ code_hex, lettre_maj+code_hex, nom_accent
%look firstly to see if there are more than one letter character
\ONEfalse\ifx\undefined#4\else\expandafter\ONECHAR#49/\fi%
    \ifVtwo% nothing to do in MlTeX V2 
           \else% we are with TeX 3 or MlTeX
               \ifECM\ifnonActifCar\else%as just a chardef adjustement in hex.
                            \ifLEX\else% not for LEX 
                            \def\tempa{\catcode`}\expandafter\tempa#2=\active%
\DEBUGmessage{K4(#2)}%
\ifx #3\undefined%
                            \expandafter\xdef#2{\expandafter\string#3}%
\else%
\expandafter\let\expandafter\tempe #2% For plain especially: first expansion,
\expandafter\def\expandafter\tempe\expandafter{\tempe}% second and last.
                            \expandafter\xdef#2{\noexpand\IeC{%only one expansion
                                                        \expandafter\noexpand\tempe}}%  for plain
\fi%
                            \fi%
                        \ifONE% exclude multiletters
                         \ifx\undefined#4\else%
                            \def\tempa{\catcode`}\expandafter\tempa#4=\active%
\DEBUGmessage{K4(#4)}%
\ifx #5\undefined%
                            \expandafter\xdef#4{\expandafter\string#5}%
\else%
\expandafter\let\expandafter\tempe #4% For plain especially: first expansion,
\expandafter\def\expandafter\tempe\expandafter{\tempe}% second and last.
                            \expandafter\xdef#4{\noexpand\IeC{%only one expansion
                                                        \expandafter\noexpand\tempe}}%  for plain
\fi%
                         \fi%
                        \fi%
                      \fi%
                \fi% now define \lccode & \uccode %%%%%%%%%%%%%%%%%%%%%%%%%%%%
                \ifx\empty#1\let\X=X%
                         \ifECM\ifnonActifCar%don't activate oe ae etc in 8bits
                          \expandafter\ifx #2\undefined\else\edef\D{#2}\fi%
                                     \edef\E{\noexpand\ss}
                                  \ifx \D\E% but let s-tzet
                                  \else%
                             \def\tempa{\catcode`}%\def\tempb{^}%
                             \def\tempe{\string}%
                             \expandafter\tempa#2=11%
                             \edef\OldActiveChars{\@tempc}%  disactivate
                             \xdef\@tempc{\OldActiveChars%
                                             \tempa\expandafter\tempe#2=11}%
                             \ifx\undefined#4\else
                                 \ifONE\expandafter\tempa#4=11%
                                 \edef\OldActiveChars{\@tempc}%disactivate
                                 \xdef\@tempc{\OldActiveChars%
                                             \tempa\expandafter\tempe#4=11}%
                                 \else%
                                   \ifx\undefined#5\else% case hex code is undef
                                     \let\tempc=#5\expandafter\tempa\tempc=11%
                                   \fi% ifx undefined
                                 \fi%
                             \fi
                             \let\X=\active%
                                  \fi% s-tzet
                         \fi\fi%
                \else\let\X\active\ifnonActifCar%
                               \def\tempa{\catcode`}\expandafter\tempa#2=11%
                               \ifx\undefined#4\else\expandafter\tempa#4=11\fi%
                                  \fi%
                \ifECM\ifnonActifCar\let\X=\active\fi\fi% Usually no lcc/ucc
                \fi%
                \def\tempa{\lccode`}\def\tempb{=`}%
                \ifLIGS\let\X=\active\fi% don't do that for ligs
                \ifMACRO\let\X=\active\fi% don't do that for macros
                \ifcat\X\active% do usual ucc/lcc encoding
                      \global\expandafter\tempa#2\expandafter\tempb#2%
                    \ifx\undefined#4\else% 
                      \ifONE%
                           \global\expandafter\tempa#4\expandafter\tempb#2%
                           \def\tempa{\global\uccode`}%
                           \expandafter\tempa#2\expandafter\tempb#4%
                           \expandafter\tempa#4\expandafter\tempb#4%
                      \else% do it in hexa for #4 ==> #5 replace #4
                        \expandafter%
                        \ifx#5\undefined\else% hex code may be undef
                        \global\expandafter\tempa #5\expandafter\tempb #2%
                        \ifLEX\else\def\tempa{\global\uccode`}%
                             \edef\D{\expandafter\string#5}\edef\E{#2}%
                             \expandafter\ifx#5\undefined\else\edef\D{#5}\fi%
%
\ifECM% \D expansion could stop to \ss, so let it be the target code for
\expandafter\ifx\D\ss\edef\D{\string ^^ff}\fi% the next comparison.
\fi%
                         \ifx\D\E%
                  \expandafter\ifx \@unusedslot \undefined% do it once
                                 {\def\tempa{\catcode`}\expandafter\tempa#2=11%
                                  \def\tempa{\global\uccode`}%
                               \edef\tempb{`\expandafter\noexpand\@unusedslot}%
                                 \expandafter\tempa#2\tempb}%
                                 \expandafter\xdef \@unusedslot{#4}%
                                 \def\tempa{\catcode`}%
                                 \edef\OldActiveChars{\@tempc}%  disactivate
                                 \xdef\@tempc{\OldActiveChars%
                                              \tempa\expandafter
                                              \string \@unusedslot =13}%
                              \else%
\ifx\undefined\unusedslot\def\unusedslot{undefined}\fi%
\message{\string\unusedslot\space (\unusedslot) is invalid} 
\message{(active char. generating: \@unusedslot)}%
                              \fi%
                          \else%
% When #5 is undefined it is defaulty defined to #4 
% to avoid \uppercase to issue an undefined cs message.
\expandafter\ifx#5\undefined\expandafter\xdef#5{#4}\fi%
                              \expandafter\tempa #2\expandafter\tempb #5%
                              \expandafter\tempa #5\expandafter\tempb #5%
                          \fi%    
                        \ifECM\ifnonActifCar\else%
                        \ifx\D\E\else% case estzet and SS
                \global\expandafter\edef #3{\expandafter\string #3}% dont point
                \global\expandafter\edef #5{\expandafter\string #5}% elsewhere
                        \fi\fi\fi%
                        \fi% ifLEX
                        \fi% ifx undefined
                      \fi%
                    \fi%
                \else\edef\D{#2}% do ucc/lcc encoding *after* expanding macros
                    \global\expandafter\tempa\D\expandafter\tempb\D%
                    \ifx\undefined#4\else\edef\Q{#4}%
                    \global\expandafter\tempa\Q\expandafter\tempb\D%
                    \def\tempa{\uccode`}%
                    \global\expandafter\tempa\D\expandafter\tempb\Q%
                    \global\expandafter\tempa\Q\expandafter\tempb\Q\fi%
                \fi%
                \ifMlTeXthree\OKfalse% MlTeX V3
                    \ifx\Lchar\empty% ............. this is a control sequence
                    \else% ........................ this is a letter+diacritic
                        \ifx\undefined#6\else%maybe we dont have an accent-name
                        \OKtrue\ifLEX\else%
                        \def\tempa{\charsubdef`}\def\tempb{= }%
                        \edef\tempc{`\Lchar}%
\ifnonActifCar%
                        \global\expandafter\tempa#2%
                        \expandafter\tempb\csname POS#6\endcsname \tempc%
                    %%%% accented chars in maths are activated:
                    %%%% but not when already activated
\ifECM\else%%%%%%%%%%%%% nor when any T1 font in use.
                        \def\tempa{\catcode`}% reset to
                        \expandafter\tempa#2\tempb11% unactive
                        \def\tempa{\mathcode`}%
\let\LcharSave\Lchar%
\ifx\i\Lchar\def\Lchar{\imath}\fi%
\ifx\j\Lchar\def\Lchar{\jmath}\fi%
                        \def\tempe##1##2/{##1}% get first char only
                        \edef\tempe{\csname MPOS\tempe#6X/\endcsname}%
                        \expandafter%
                        \ifx\tempe\relax\else%
                          \global\expandafter\tempa#2\tempb"8000%
                          \edef\tempe{\expandafter\noexpand%
                                      \csname MPOS#6\endcsname}
                          \begingroup\def\tempa{\uccode`\~`}%
                          \expandafter\tempa#2\uppercase{\endgroup%
                          \global\edef~}{\tempe \Lchar}%
                        \fi% end MPOS#6
\let\Lchar\LcharSave%
                    %%%%
\fi% ECM %%%%%%%%%%%%%%%
\else%
                        \global\expandafter\tempa#3%
                        \expandafter\tempb\csname POS#6\endcsname \tempc%
\fi% nonActifCar
                               \fi%\ifLEX
                        \fi
                    \fi%
                    \ifx\Mchar\empty% and now uppercase
                    \else%
                        \ifx\undefined#6\else%maybe we dont have an accent-name
                        \OKtrue\ifLEX\else%
                        \def\tempa{\charsubdef`}\def\tempb{= }%
                        \edef\tempc{`\Mchar}%
\ifnonActifCar%
                        \global\expandafter\tempa#4%
                        \expandafter\tempb\csname POS#6\endcsname \tempc%
                    %%%% accented chars in maths are activated:
                    %%%% but not when already activated
\ifECM\OKfalse\else%%%%% nor when any T1 font in use.
                        \def\tempa{\catcode`}% reset to
                        \expandafter\tempa#4\tempb11% unactive
                        \def\tempa{\mathcode`}%
                        \def\tempe##1##2/{##1}% get first char only
                        \edef\tempe{\csname MPOS\tempe#6X/\endcsname}%
                        \expandafter%
                        \ifx\tempe\relax\else%
                          \global\expandafter\tempa#4\tempb"8000%
                          \edef\tempe{\expandafter\noexpand%
                                      \csname MPOS#6\endcsname}
                          \begingroup\def\tempa{\uccode`\~`}%
                          \expandafter\tempa#4\uppercase{\endgroup%
                          \global\edef~}{\tempe \Mchar}%
                        \fi% end MPOS#6
                    %%%%
\fi% ECM %%%%%%%%%%%%%%%
\else%
                        \ifx#5\undefined\else% might be undefined
                        \global\expandafter\tempa#5%
                        \expandafter\tempb\csname POS#6\endcsname \tempc%
                        \fi%
\fi% nonActifCar
                               \fi%\ifLEX
                        \fi
                    \fi%
\ifnonActifCar%
                    \ifOK%
                      \def\tempb{\catcode`}%
                      \def\tempe{\string}%
                      \edef\OldActiveChars{\@tempc}% in fact disactivate
                      \xdef\@tempc{\OldActiveChars%
                                        \tempb\expandafter\tempe#2=11}%
                      \ifx\undefined#4\else%
                          \ifONE%
                         \edef\OldActiveChars{\@tempc}% disactivate 
                         \xdef\@tempc{\OldActiveChars%
                                            \tempb\expandafter\tempe#4=11}%
                          \fi%
                      \fi%
                    \fi% ifOK
\fi% nonActifCar
                \fi% MlTeX3
           \fi%\ifVtwo
                \ifx\undefined#6\else%
% remove any trailing {}.
\def\tempe##1##29{\edef\tempa{##1}}\expandafter\tempe\Lchar{}9%
\def\tempe##1##29{\edef\tempb{##1}}\expandafter\tempe\Mchar{}9%
                  \ifnonActifCar%
                    \csubinverse {\expandafter\string#2}{@#6@}\tempa%
                    \ifx\Mchar\empty\else%
                    \csubinverse {\expandafter\string#4}{@#6@}\tempb%
                    \fi%
                  \else%
%\message{\string\csubinverse {\expandafter\string#3}{@#6@}\tempa/}
                    \csubinverse {\expandafter\string#3}{@#6@}\tempa%
                    \ifx\Mchar\empty\else%
%\message{\string\csubinverse {\expandafter\string#5}{@#6@}\tempb/}
                    \csubinverse {\expandafter\string#5}{@#6@}\tempb%
                    \fi%
                  \fi%
                \fi
                  }%end of DOhex
%
\ifx\degre\undefined%
     \edef\degre{{\ifECM\char\rq006\else\char\rq27\fi}\space}%
\fi%
%
\ifx\texteuro\undefined%
     \edef\texteuro{E}% assuming we have the font
\fi%
%
\ifx\@@input\undefined\let\@@input\input\fi
\ifx\@kbencoding\undefined\def\kbencoding#1{\def\@kbencoding{#1}}%
     \@@input keyboard.dat 
  % then check again \unusedslot
  \ifx\unusedslot\undefined\edef\@unusedslot{\noexpand ^^9c}%
    \else\edef\@unusedslot{\unusedslot}%
  \fi%
  \expandafter\let \@unusedslot =\undefined%
\fi%
\ifx\forceMlTeXtoCork\undefined\else% Apply in 2 cases:
 \ifECM\ifx\documentclass\undefined\ACTIVEtrue\fi\fi% first if plain T1,
 \ifx\charsubdef\undefined\else\ACTIVEtrue\fi% secondly when MlTeX (OT1)
\fi% \forceMlTeXtoCork
\ifx\@kbencoding\undefined\def\@kbencoding{decmulti}\fi%
\@@input \@kbencoding.kbc % load my keyboard specs
\fi% de \ifSkip
\endgroup%
\expandafter\ifx\csname ^^63\endcsname\c % 128-255 going chars in V3 
\def\reserved@c#1{\catcode#1=11\relax}% 
\reserved@a{"7F}{"FF}%
\ifLEX\else%
\expandafter\catcode\expandafter`\@unusedslot=13%
\fi%
%%%%%%
\ifx\documentclass\undefined
  \ifECM\else% Prevent Plain invalid chars
    \catcode`\^^]=11%
    \catcode`\^^[=11%
  \fi%
\else% Prevent LaTeX2e invalid chars
  \ifECM%
    \catcode`\^^_=11%
    \catcode`\^^Y=11%
    \catcode`\^^Z=11%
    \catcode`\^^P=11%
    \catcode`\^^Q=11%
  \else%
    \catcode`\^^P=11%
    \catcode`\^^Q=11%
    \catcode`\^^Y=11%
    \catcode`\^^Z=11%
    \catcode`\^^]=11%
    \catcode`\^^[=11%
    \catcode`\^^^=11%
    \catcode`\^^\=11%
    \catcode`\^^_=11%
  \fi%
\fi%
%%%%%%
% now intitialize only \oe \ae etc.
\@tempc%
%
% Take in account \mathaccent for OT1 and T1 ***PLAIN TeX ONLY***
%
\def\@tempc{plain}%
\ifx\fmtname\@tempc%
% Currently math accents are provided only in cm...
%\ifECM% when the new math font scheme will be available
%\def\acute{\mathaccent"7001 }
%\def\grave{\mathaccent"7000 }
%\def\ddot{\mathaccent"7004 }
%%%%%\def\tilde{\mathaccent"7003 }
%\def\bar{\mathaccent"7009 }
%\def\breve{\mathaccent"7008 }
%\def\check{\mathaccent"7007 }
%\def\hat{\mathaccent"7002 }
%\def\dot{\mathaccent"700A }
%\else
\def\acute{\mathaccent"7013 }
\def\grave{\mathaccent"7012 }
\def\ddot{\mathaccent"707F }
\def\tilde{\mathaccent"707E }
\def\bar{\mathaccent"7016 }
\def\breve{\mathaccent"7015 }
\def\check{\mathaccent"7014 }
\def\hat{\mathaccent"705E }
\def\dot{\mathaccent"705F }
%\fi
\fi% fmtname=plain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reset no more useful macros
\global\let\Lchar\undefined\global\let\Mchar\undefined%
\ifx\guillemotleft\undefined\def\guillemotleft{<<}\fi%
\ifx\guillemotright\undefined\def\guillemotright{>>}\fi%
%
% Now provide 7-bit new accent macros to produce 8-bit chars
%
\let\next\undefined
\ifx\charsubdef\undefined\else\let\next\relax\fi
%%
%\ifECM\else% The following to avoid invalid char msg.
\catcode`\^^P=11%
\catcode`\^^Q=11%
\catcode`\^^Y=11%
\catcode`\^^Z=11%
%\fi%
\ifx\documentclass\undefined%
     \let\Edef\edef\let\Def\def\let\Let\let%
     \ifECM\let\next\relax\fi% Plain-T1 is a good candidate
\else%
\def\@temp@{LO1}\ifx\@temp@\f@encoding\edef\@temp@{OL}%
                 \else\edef\@temp@{OT}\fi%
   \def\Edef#1{\expandafter\relax% define only for MlTeX OT1
               \expandafter\global%
               \expandafter\edef\csname\@temp@\string1\string#1\endcsname}
    \def\Def#1{\expandafter\relax% define only for MlTeX OT1
               \expandafter\global%
               \expandafter\def\csname\@temp@\string1\string#1\endcsname}
    \def\Let#1{\expandafter\relax% define only for MlTeX OT1
               \expandafter\global%
               \expandafter\let\csname\@temp@\string1\string#1\endcsname}
\ifECM\Edef\i{^^Y}\else\Edef\i{^^P}\fi% needed by \csubinverse for patterns
\ifECM\Edef\j{^^Z}\else\Edef\j{^^Q}\fi% dotless letters 
\fi%
\let\@tempc\undefined%
\ifx\next\relax% then do it (we have 8bits chars)
\Edef\`#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @gr@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"00 #1}\else{\accent18 #1}\fi%
          \noexpand\else%
           \noexpand\csname @gr@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\'#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @ac@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"01 #1}\else{\accent19 #1}\fi%
          \noexpand\else%
           \noexpand\csname @ac@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\v#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @v@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"07 #1}\else{\accent20 #1}\fi%
          \noexpand\else%
           \noexpand\csname @v@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\u#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @u@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"08 #1}\else{\accent21 #1}\fi%
          \noexpand\else%
           \noexpand\csname @u@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\=#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @eq@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"09 #1}\else{\accent22 #1}\fi%
          \noexpand\else%
           \noexpand\csname @eq@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\^#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @hat@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"02 #1}\else{\accent94 #1}\fi%
          \noexpand\else%
           \noexpand\csname @hat@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\.#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @dot@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"0a #1}\else{\accent95 #1}\fi%
          \noexpand\else%
           \noexpand\csname @dot@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\H#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @H@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"05 #1}\else{\accent125 #1}\fi%
          \noexpand\else%
           \noexpand\csname @H@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\~#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @til@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"03 #1}\else{\accent126 #1}\fi%
           \noexpand\else%
            \noexpand\csname @til@#1\noexpand\endcsname\noexpand\fi}% 
\Edef\"#1{\noexpand\expandafter%
           \noexpand\ifx\noexpand\csname @um@%
           \noexpand\ifcat #1Z#1\noexpand\else\noexpand\empty\noexpand\fi%
                        \noexpand\endcsname\noexpand\relax%
                         \ifECM{\accent"04 #1}\else{\accent127 #1}\fi%
           \noexpand\else%
            \noexpand\csname @um@#1\noexpand\endcsname\noexpand\fi}%
\ifx\@c@@\undefined% needed for OT1
\def\@c@@#1{\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent24 #1%
  \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}%
\fi%
\Def\c#1{{\expandafter\ifx%
         \csname @c@#1\endcsname\relax%
         \@c@@{#1}%
                               \else%
         \csname @c@#1\endcsname\fi}}%
\ifx\@an@a\undefined\else\Let\aa\@an@a\fi%
\ifx\@an@A\undefined\else\Let\AA\@an@A\fi%
\ifx\r\undefined%
\global\Def\r#1{\if#1a\@a:a\else\if#1A\@A:A\fi\fi}% 
\global\Def\@a:a{\expandafter\ifx\csname @an@a\endcsname\relax%
                          \ifECM{\accent"06a}\else{\accent23a}\fi%
                       \else\csname @an@a\endcsname\fi}% 
\global\Def\@A:A{\expandafter\ifx\csname @an@A\endcsname\relax%
                          \leavevmode\setbox0\hbox{h}\dimen@\ht0%
                            \advance\dimen@-1ex\rlap{\raise.67\dimen@\hbox{%
                                    \ifECM\char"06\else\char'27\fi}}A%
                       \else\csname @an@A\endcsname\fi}%
\fi% \r undefined
\fi% we have 8bits chars

\ifx\next\undefined% we don't have any csubsinverse mechanism
\ifx\documentclass\undefined% and we aren't in LaTeX
%                  % so reset any previous accent macros to usual
\edef\`#1{\ifECM{\accent"00 #1}\else{\accent18 #1}\fi}%
\edef\'#1{\ifECM{\accent"01 #1}\else{\accent19 #1}\fi}%
\edef\v#1{\ifECM{\accent"07 #1}\else{\accent20 #1}\fi}%
\edef\u#1{\ifECM{\accent"08 #1}\else{\accent21 #1}\fi}%
\edef\=#1{\ifECM{\accent"09 #1}\else{\accent22 #1}\fi}%
\edef\^#1{\ifECM{\accent"02 #1}\else{\accent94 #1}\fi}%
\edef\.#1{\ifECM{\accent"0a #1}\else{\accent95 #1}\fi}%
\edef\H#1{\ifECM{\accent"05 #1}\else{\accent125 #1}\fi}%
\edef\~#1{\ifECM{\accent"03 #1}\else{\accent126 #1}\fi}%
\edef\"#1{\ifECM{\accent"04 #1}\else{\accent127 #1}\fi}%
\ifx\@c@@\undefined\else\let\c=\@c@@\fi%
\def\aa{\ifECM{\accent"06a}\else{\accent23a}\fi}%
\def\AA{\leavevmode\setbox0\hbox{h}\dimen@\ht0%
         \advance\dimen@-1ex\rlap{\raise.67\dimen@\hbox{%
         \ifECM\char"06\else\char'27\fi}}A}%
\fi% documentclass
\fi%we don't have any csubsinverse mechanism

\fi

% reset misc
\let\Edef\undefined\let\Def\undefined\let\Let\undefined%
\endinput%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
