From ee0045bb26510bf9200dfc2d5b283d0efd3f73fd Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 28 Apr 2017 21:20:36 +0000
Subject: babel (28apr17)

git-svn-id: svn://tug.org/texlive/trunk@44101 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/generic/babel/babel.def | 292 ++++++++++++++------------
 1 file changed, 157 insertions(+), 135 deletions(-)

(limited to 'Master/texmf-dist/tex/generic/babel/babel.def')

diff --git a/Master/texmf-dist/tex/generic/babel/babel.def b/Master/texmf-dist/tex/generic/babel/babel.def
index 0853150c854..4d3a6bbcae9 100644
--- a/Master/texmf-dist/tex/generic/babel/babel.def
+++ b/Master/texmf-dist/tex/generic/babel/babel.def
@@ -38,14 +38,14 @@
 %% and covered by LPPL is defined by the unpacking scripts (with
 %% extension .ins) which are part of the distribution.
 %% File 'babel.dtx'
-%%\ProvidesFile{babel.dtx}[2016/04/23 v3.9r The Babel package]
+%%\ProvidesFile{babel.dtx}[2017/04/28 v3.9t The Babel package]
 %% Babel package for LaTeX2e.
 %% Copyright (C) 1989-2008 by Johannes Braams,
 %%                            TeXniek
 %%                            all rights reserved.
-%% Copyright (C) 2013-2016 by Johannes Braams
+%% Copyright (C) 2013-2017 by Johannes Braams
 %%                            TeXniek
-%%                            by Javier Bezos
+%%                         by Javier Bezos
 %%                            all rights reserved.
 \ifx\ldf@quit\@undefined
 \else
@@ -56,7 +56,7 @@
     \wlog{File: #1 #4 #3 <#2>}%
     \let\ProvidesFile\@undefined}
 \fi
-\ProvidesFile{babel.def}[2016/04/23 3.9r Babel common definitions]
+\ProvidesFile{babel.def}[2017/04/28 3.9t Babel common definitions]
 \ifx\AtBeginDocument\@undefined
   \input plain.def\relax
 \fi
@@ -67,7 +67,7 @@
   \let\bbl@afterlang\relax
   \let\bbl@language@opts\@empty
 \fi
-\def\bbl@tempa{3.9r}%
+\def\bbl@tempa{3.9t}%
 \ifx\bbl@version\bbl@tempa\else
   \input switch.def\relax
 \fi
@@ -97,13 +97,12 @@
     \input luababel.def
   \fi
 \fi
+\def\bbl@stripslash{\expandafter\@gobble\string}
 \def\bbl@add#1#2{%
-  \@ifundefined{\expandafter\@gobble\string#1}%
+  \bbl@ifunset{\bbl@stripslash#1}%
     {\def#1{#2}}%
     {\expandafter\def\expandafter#1\expandafter{#1#2}}}
 \def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
-\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
-\long\def\bbl@afterfi#1\fi{\fi#1}
 \def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
 \def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
 \def\bbl@@loop#1#2#3,{%
@@ -111,7 +110,66 @@
     \def#1{#3}#2\bbl@afterfi\bbl@@loop#1{#2}%
   \fi}
 \def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
-\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl@add@list#1#2{%
+  \edef#1{%
+    \bbl@ifunset{\bbl@stripslash#1}%
+      {}%
+      {\ifx#1\@empty\else#1,\fi}%
+    #2}}
+\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
+\long\def\bbl@afterfi#1\fi{\fi#1}
+\def\bbl@tempa#1{%
+  \long\def\bbl@trim##1##2{%
+    \futurelet\bbl@trim@a\bbl@trim@c##2\@nil\@nil#1\@nil\relax{##1}}%
+  \def\bbl@trim@c{%
+    \ifx\bbl@trim@a\@sptoken
+      \expandafter\bbl@trim@b
+    \else
+      \expandafter\bbl@trim@b\expandafter#1%
+    \fi}%
+  \long\def\bbl@trim@b#1##1 \@nil{\bbl@trim@i##1}}
+\bbl@tempa{ }
+\long\def\bbl@trim@i#1\@nil#2\relax#3{#3{#1}}
+\long\def\bbl@trim@def#1{\bbl@trim{\def#1}}
+\def\bbl@ifunset#1{%
+  \expandafter\ifx\csname#1\endcsname\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi}
+\bbl@ifunset{ifcsname}%
+  {}%
+  {\def\bbl@ifunset#1{%
+     \ifcsname#1\endcsname
+       \expandafter\ifx\csname#1\endcsname\relax
+         \bbl@afterelse\expandafter\@firstoftwo
+       \else
+         \bbl@afterfi\expandafter\@secondoftwo
+       \fi
+     \else
+       \expandafter\@firstoftwo
+     \fi}}
+\def\bbl@ifblank#1{%
+  \bbl@ifblank@i#1\@nil\@nil\@secondoftwo\@firstoftwo\@nil}
+\long\def\bbl@ifblank@i#1#2\@nil#3#4#5\@nil{#4}
+\def\bbl@exp#1{%
+  \begingroup
+    \let\\\noexpand
+    \def\<##1>{\expandafter\noexpand\csname##1\endcsname}%
+    \edef\bbl@exp@aux{\endgroup#1}%
+  \bbl@exp@aux}
+\def\bbl@ifsamestring#1#2{%
+  \begingroup
+    \protected@edef\bbl@tempb{#1}%
+    \edef\bbl@tempb{\expandafter\strip@prefix\meaning\bbl@tempb}%
+    \protected@edef\bbl@tempc{#2}%
+    \edef\bbl@tempc{\expandafter\strip@prefix\meaning\bbl@tempc}%
+    \ifx\bbl@tempb\bbl@tempc
+      \aftergroup\@firstoftwo
+    \else
+      \aftergroup\@secondoftwo
+    \fi
+  \endgroup}
 \chardef\bbl@engine=%
   \ifx\directlua\@undefined
     \ifx\XeTeXinputencoding\@undefined
@@ -122,8 +180,6 @@
   \else
     \@ne
   \fi
-\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
-\long\def\bbl@afterfi#1\fi{\fi#1}
 \def\addto#1#2{%
   \ifx#1\@undefined
     \def#1{#2}%
@@ -140,32 +196,28 @@
     \lccode`~=`#2\relax
     \lowercase{\endgroup#1~}}
 \def\bbl@redefine#1{%
-  \edef\bbl@tempa{\expandafter\@gobble\string#1}%
+  \edef\bbl@tempa{\bbl@stripslash#1}%
   \expandafter\let\csname org@\bbl@tempa\endcsname#1%
   \expandafter\def\csname\bbl@tempa\endcsname}
 \@onlypreamble\bbl@redefine
 \def\bbl@redefine@long#1{%
-  \edef\bbl@tempa{\expandafter\@gobble\string#1}%
+  \edef\bbl@tempa{\bbl@stripslash#1}%
   \expandafter\let\csname org@\bbl@tempa\endcsname#1%
   \expandafter\long\expandafter\def\csname\bbl@tempa\endcsname}
 \@onlypreamble\bbl@redefine@long
 \def\bbl@redefinerobust#1{%
-  \edef\bbl@tempa{\expandafter\@gobble\string#1}%
-  \expandafter\ifx\csname\bbl@tempa\space\endcsname\relax
-    \expandafter\let\csname org@\bbl@tempa\endcsname#1%
-    \expandafter\edef\csname\bbl@tempa\endcsname{\noexpand\protect
-      \expandafter\noexpand\csname\bbl@tempa\space\endcsname}%
-  \else
-    \expandafter\let\csname org@\bbl@tempa\expandafter\endcsname
-                    \csname\bbl@tempa\space\endcsname
-  \fi
-  \expandafter\def\csname\bbl@tempa\space\endcsname}
+  \edef\bbl@tempa{\bbl@stripslash#1}%
+  \bbl@ifunset{\bbl@tempa\space}%
+    {\expandafter\let\csname org@\bbl@tempa\endcsname#1%
+     \bbl@exp{\def\\#1{\\\protect\<\bbl@tempa\space>}}}%
+    {\bbl@exp{\let\<org@\bbl@tempa>\<\bbl@tempa\space>}}%
+    \@namedef{\bbl@tempa\space}}
 \@onlypreamble\bbl@redefinerobust
 \def\AddBabelHook#1#2{%
-  \@ifundefined{bbl@hk@#1}{\EnableBabelHook{#1}}{}%
+  \bbl@ifunset{bbl@hk@#1}{\EnableBabelHook{#1}}{}%
   \def\bbl@tempa##1,#2=##2,##3\@empty{\def\bbl@tempb{##2}}%
   \expandafter\bbl@tempa\bbl@evargs,#2=,\@empty
-  \@ifundefined{bbl@ev@#1@#2}%
+  \bbl@ifunset{bbl@ev@#1@#2}%
     {\bbl@csarg\bbl@add{ev@#2}{\bbl@elt{#1}}%
      \bbl@csarg\newcommand}%
     {\bbl@csarg\let{ev@#1@#2}\relax
@@ -202,28 +254,27 @@
     \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{%
       \expandafter{\bbl@ens@exclude}}%
     \toks@\expandafter{\bbl@tempc}%
-    \edef\x{%
-      \endgroup
-      \noexpand\@namedef{bbl@e@#2}{\the\toks@{\bbl@ens@fontenc}}}%
-    \x}
+    \bbl@exp{%
+  \endgroup
+  \def\<bbl@e@#2>{\the\toks@{\bbl@ens@fontenc}}}}
 \def\bbl@ensure#1#2#3{%
   \def\bbl@tempb##1{% elt for \bbl@ensured list
     \ifx##1\@empty\else
       \in@{##1}{#2}%
       \ifin@\else
+        \bbl@ifunset{bbl@ensure@\languagename}%
+          {\bbl@exp{%
+            \\\DeclareRobustCommand\<bbl@ensure@\languagename>[1]{%
+              \\\foreignlanguage{\languagename}%
+              {\ifx\relax#3\else
+                \\\fontencoding{#3}\\\selectfont
+               \fi
+               ########1}}}}%
+          {}%
         \toks@\expandafter{##1}%
-        \edef\bbl@tempa{%
-          \noexpand\DeclareRobustCommand
-          \bbl@csarg\noexpand{ensure@\languagename}[1]{%
-            \noexpand\foreignlanguage{\languagename}%
-            {\ifx\relax#3\else
-              \noexpand\fontencoding{#3}\noexpand\selectfont
-             \fi
-             ########1}}}%
-        \bbl@tempa
         \edef##1{%
            \bbl@csarg\noexpand{ensure@\languagename}%
-           {\the\toks@}}
+           {\the\toks@}}%
       \fi
       \expandafter\bbl@tempb
     \fi}%
@@ -289,6 +340,12 @@
   \bbl@patterns{\languagename}}
 \AtBeginDocument{%
   \expandafter\selectlanguage\expandafter{\bbl@main@language}}
+\def\select@language@x#1{%
+  \ifcase\bbl@select@type
+    \bbl@ifsamestring\languagename{#1}{}{\select@language{#1}}%
+  \else
+    \select@language{#1}%
+  \fi}
 \def\bbl@add@special#1{%
   \begingroup
     \def\do{\noexpand\do\noexpand}%
@@ -307,7 +364,7 @@
     \def\@makeother{\x\@makeother}%
   \edef\x{\endgroup
     \def\noexpand\dospecials{\dospecials}%
-    \expandafter\ifx\csname @sanitize\endcsname\relax \else
+    \expandafter\ifx\csname @sanitize\endcsname\relax\else
       \def\noexpand\@sanitize{\@sanitize}%
     \fi}%
   \x}
@@ -325,19 +382,17 @@
       \bbl@afterfi\csname#2@sh@#1@\string##1@\endcsname
     \fi}}%
 \def\initiate@active@char#1{%
-  \expandafter\ifx\csname active@char\string#1\endcsname\relax
-    \bbl@withactive
-      {\expandafter\@initiate@active@char\expandafter}#1\string#1#1%
-  \fi}
+  \bbl@ifunset{active@char\string#1}%
+    {\bbl@withactive
+      {\expandafter\@initiate@active@char\expandafter}#1\string#1#1}%
+    {}}
 \def\@initiate@active@char#1#2#3{%
-  \expandafter\edef\csname bbl@oricat@#2\endcsname{%
-    \catcode`#2=\the\catcode`#2\relax}%
+  \bbl@csarg\edef{oricat@#2}{\catcode`#2=\the\catcode`#2\relax}%
   \ifx#1\@undefined
-    \expandafter\edef\csname bbl@oridef@#2\endcsname{%
-      \let\noexpand#1\noexpand\@undefined}%
+    \bbl@csarg\edef{oridef@#2}{\let\noexpand#1\noexpand\@undefined}%
   \else
-    \expandafter\let\csname bbl@oridef@@#2\endcsname#1%
-    \expandafter\edef\csname bbl@oridef@#2\endcsname{%
+    \bbl@csarg\let{oridef@@#2}#1%
+    \bbl@csarg\edef{oridef@#2}{%
       \let\noexpand#1%
       \expandafter\noexpand\csname bbl@oridef@@#2\endcsname}%
   \fi
@@ -440,7 +495,7 @@
   \def\bbl@tempa{#3}%
   \ifx\bbl@tempa\@empty
     \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@scndcs
-    \@ifundefined{#1@sh@\string#2@}{}%
+    \bbl@ifunset{#1@sh@\string#2@}{}%
       {\def\bbl@tempa{#4}%
        \expandafter\ifx\csname#1@sh@\string#2@\endcsname\bbl@tempa
        \else
@@ -451,7 +506,7 @@
     \@namedef{#1@sh@\string#2@}{#4}%
   \else
     \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@firstcs
-    \@ifundefined{#1@sh@\string#2@\string#3@}{}%
+    \bbl@ifunset{#1@sh@\string#2@\string#3@}{}%
       {\def\bbl@tempa{#4}%
        \expandafter\ifx\csname#1@sh@\string#2@\string#3@\endcsname\bbl@tempa
        \else
@@ -488,7 +543,7 @@
         turned off in the package options}}}
 \def\user@language@group{user@\language@group}
 \def\bbl@set@user@generic#1#2{%
-  \@ifundefined{user@generic@active#1}%
+  \bbl@ifunset{user@generic@active#1}%
     {\bbl@active@def#1\user@language@group{user@active}{user@generic@active}%
      \bbl@active@def#1\user@group{user@generic@active}{language@active}%
      \expandafter\edef\csname#2@sh@#1@@\endcsname{%
@@ -537,7 +592,7 @@
 \def\bbl@shorthandoff#1#2{\bbl@switch@sh#1#2\@nnil}
 \def\bbl@switch@sh#1#2{%
   \ifx#2\@nnil\else
-    \@ifundefined{bbl@active@\string#2}%
+    \bbl@ifunset{bbl@active@\string#2}%
       {\bbl@error
          {I cannot switch `\string#2' on or off--not a shorthand}%
          {This character is not a shorthand. Maybe you made\\%
@@ -554,7 +609,7 @@
   \fi}
 \def\babelshorthand{\active@prefix\babelshorthand\bbl@putsh}
 \def\bbl@putsh#1{%
-  \@ifundefined{bbl@active@\string#1}%
+  \bbl@ifunset{bbl@active@\string#1}%
      {\bbl@putsh@i#1\@empty\@nnil}%
      {\csname bbl@active@\string#1\endcsname}}
 \def\bbl@putsh@i#1#2\@nnil{%
@@ -652,17 +707,6 @@
     \bbl@afterfi#4%
   \fi
   }
-\def\bbl@add@list#1#2{%
-  \ifx#1\@undefined
-    \def#1{#2}%
-  \else
-    \ifx#1\@empty
-      \def#1{#2}%
-    \else
-      \edef#1{#1,#2}%
-    \fi
-  \fi
-  }
 \def\bbl@ifknown@ttrib#1#2{%
   \let\bbl@tempa\@secondoftwo
   \bbl@loopx\bbl@tempb{#2}{%
@@ -679,8 +723,7 @@
       \expandafter\bbl@clear@ttrib\bbl@tempa.
       }%
     \let\bbl@attributes\@undefined
-  \fi
-  }
+  \fi}
 \def\bbl@clear@ttrib#1-#2.{%
   \expandafter\let\csname#1@attr@#2\endcsname\@undefined}
 \AtBeginDocument{\bbl@clear@ttribs}
@@ -743,7 +786,7 @@
         \bbl@fixname\bbl@tempa
         \bbl@iflanguage\bbl@tempa{%
           \bbl@csarg\protected@edef{hyphenation@\bbl@tempa}{%
-            \@ifundefined{bbl@hyphenation@\bbl@tempa}%
+            \bbl@ifunset{bbl@hyphenation@\bbl@tempa}%
               \@empty
               {\csname bbl@hyphenation@\bbl@tempa\endcsname\space}%
             #2}}}%
@@ -756,13 +799,13 @@
 \def\bbl@hyphen{%
   \@ifstar{\bbl@hyphen@i @}{\bbl@hyphen@i\@empty}}
 \def\bbl@hyphen@i#1#2{%
-  \@ifundefined{bbl@hy@#1#2\@empty}%
+  \bbl@ifunset{bbl@hy@#1#2\@empty}%
     {\csname bbl@#1usehyphen\endcsname{\discretionary{#2}{}{#2}}}%
     {\csname bbl@hy@#1#2\@empty\endcsname}}
 \def\bbl@usehyphen#1{%
   \leavevmode
-  \ifdim\lastskip>\z@\mbox{#1}\nobreak\else\nobreak#1\fi
-  \hskip\z@skip}
+  \ifdim\lastskip>\z@\mbox{#1}\else\nobreak#1\fi
+  \nobreak\hskip\z@skip}
 \def\bbl@@usehyphen#1{%
   \leavevmode\ifdim\lastskip>\z@\mbox{#1}\else#1\fi}
 \def\bbl@hyphenchar{%
@@ -775,12 +818,11 @@
 \def\bbl@hy@@soft{\bbl@@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
 \def\bbl@hy@hard{\bbl@usehyphen\bbl@hyphenchar}
 \def\bbl@hy@@hard{\bbl@@usehyphen\bbl@hyphenchar}
-\def\bbl@hy@nobreak{\bbl@usehyphen{\mbox{\bbl@hyphenchar}\nobreak}}
+\def\bbl@hy@nobreak{\bbl@usehyphen{\mbox{\bbl@hyphenchar}}}
 \def\bbl@hy@@nobreak{\mbox{\bbl@hyphenchar}}
 \def\bbl@hy@repeat{%
   \bbl@usehyphen{%
-    \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}%
-    \nobreak}}
+    \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
 \def\bbl@hy@@repeat{%
   \bbl@@usehyphen{%
     \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
@@ -804,7 +846,7 @@
     \g@addto@macro\@uclclist{\reserved@b{\reserved@b\bbl@uclc}}%
     \gdef\bbl@uclc##1{%
       \let\bbl@encoded\bbl@encoded@uclc
-      \@ifundefined{\languagename @bbl@uclc}% and resumes it
+      \bbl@ifunset{\languagename @bbl@uclc}% and resumes it
         {##1}%
         {\let\bbl@tempa##1\relax % Used by LANG@bbl@uclc
          \csname\languagename @bbl@uclc\endcsname}%
@@ -818,7 +860,7 @@
   \def\SetStringLoop##1##2{%
     \def\bbl@templ####1{\expandafter\noexpand\csname##1\endcsname}%
     \count@\z@
-    \bbl@loop\bbl@tempa{##2}{%
+    \bbl@loop\bbl@tempa{##2}{% empty items and spaces are ok
       \advance\count@\@ne
       \toks@\expandafter{\bbl@tempa}%
       \edef\bbl@tempb{%
@@ -890,7 +932,7 @@
     \edef\bbl@sc@charset{\expandafter\zap@space\bbl@sc@charset\@empty}%
     \def\bbl@encstring##1##2{%
       \bbl@for\bbl@tempc\bbl@sc@fontenc{%
-        \@ifundefined{T@\bbl@tempc}%
+        \bbl@ifunset{T@\bbl@tempc}%
           {}%
           {\ProvideTextCommand##1\bbl@tempc{##2}%
            \bbl@toglobal##1%
@@ -920,7 +962,6 @@
          captions or extras, but you set none}}%
   \fi
   \ifx\@empty#1%
-    \@expandtwoargs
     \bbl@usehooks{defaultcommands}{}%
   \else
     \@expandtwoargs
@@ -943,7 +984,7 @@
       \fi
     \fi}}
 \AtEndOfPackage{%
-  \def\bbl@forlang#1#2{\bbl@for#1\bbl@L{\@ifundefined{date#1}{}{#2}}}%
+  \def\bbl@forlang#1#2{\bbl@for#1\bbl@L{\bbl@ifunset{date#1}{}{#2}}}%
   \let\bbl@scswitch\relax}
 \@onlypreamble\EndBabelCommands
 \def\EndBabelCommands{%
@@ -953,8 +994,8 @@
   \bbl@scafter}
 \def\bbl@setstring#1#2{%
   \bbl@forlang\bbl@tempa{%
-    \edef\bbl@LC{\bbl@tempa\expandafter\@gobble\string#1}%
-    \@ifundefined{\bbl@LC}% eg, \germanchaptername
+    \edef\bbl@LC{\bbl@tempa\bbl@stripslash#1}%
+    \bbl@ifunset{\bbl@LC}% eg, \germanchaptername
       {\global\expandafter
        \bbl@add\csname\bbl@G\bbl@tempa\expandafter\endcsname\expandafter
          {\expandafter\bbl@scset\expandafter#1\csname\bbl@LC\endcsname}}%
@@ -1202,7 +1243,7 @@
 \ifx\bbl@opt@safe\@empty\else
   \def\@newl@bel#1#2#3{%
    {\@safe@activestrue
-    \@ifundefined{#1@#2}%
+    \bbl@ifunset{#1@#2}%
        \relax
        {\gdef\@multiplelabels{%
           \@latex@warning@no@line{There were multiply-defined labels}}%
@@ -1277,45 +1318,27 @@
   \let\org@@bibitem\@bibitem
 \fi
 \bbl@redefine\markright#1{%
-  \edef\bbl@tempb{\noexpand\protect
-    \noexpand\foreignlanguage{\languagename}}%
-  \def\bbl@arg{#1}%
-  \ifx\bbl@arg\@empty
-    \toks@{}%
-  \else
-    \expandafter\toks@\expandafter{%
-             \bbl@tempb{\protect\bbl@restore@actives#1}}%
-  \fi
-  \edef\bbl@tempa{%
-    \noexpand\org@markright{\the\toks@}}%
-  \bbl@tempa
-}
+  \bbl@ifblank{#1}%
+    {\org@markright{}}%
+    {\toks@{#1}%
+     \bbl@exp{%
+       \\\org@markright{\\\protect\\\foreignlanguage{\languagename}%
+         {\\\protect\\\bbl@restore@actives\the\toks@}}}}}
 \ifx\@mkboth\markboth
   \def\bbl@tempc{\let\@mkboth\markboth}
 \else
   \def\bbl@tempc{}
 \fi
 \bbl@redefine\markboth#1#2{%
-  \edef\bbl@tempb{\noexpand\protect
-    \noexpand\foreignlanguage{\languagename}}%
-  \def\bbl@arg{#1}%
-  \ifx\bbl@arg\@empty
-    \toks@{}%
-  \else
-   \expandafter\toks@\expandafter{%
-             \bbl@tempb{\protect\bbl@restore@actives#1}}%
-  \fi
-  \def\bbl@arg{#2}%
-  \ifx\bbl@arg\@empty
-    \toks8{}%
-  \else
-    \expandafter\toks8\expandafter{%
-             \bbl@tempb{\protect\bbl@restore@actives#2}}%
-  \fi
-  \edef\bbl@tempa{%
-    \noexpand\org@markboth{\the\toks@}{\the\toks8}}%
-  \bbl@tempa
-}
+  \protected@edef\bbl@tempb##1{%
+    \protect\foreignlanguage{\languagename}{\protect\bbl@restore@actives##1}}%
+  \bbl@ifblank{#1}%
+    {\toks@{}}%
+    {\toks@\expandafter{\bbl@tempb{#1}}}%
+  \bbl@ifblank{#2}%
+    {\@temptokena{}}%
+    {\@temptokena\expandafter{\bbl@tempb{#2}}}%
+  \bbl@exp{\\\org@markboth{\the\toks@}{\the\@temptokena}}}
 \bbl@tempc
 \@expandtwoargs\in@{R}\bbl@opt@safe
 \ifin@
@@ -1327,15 +1350,15 @@
         \let\bbl@temp@ref\ref
         \let\ref\org@ref
         \@safe@activestrue
-        \org@ifthenelse{#1}{%
-          \let\pageref\bbl@temp@pref
-          \let\ref\bbl@temp@ref
-          \@safe@activesfalse
-          #2}{%
-          \let\pageref\bbl@temp@pref
-          \let\ref\bbl@temp@ref
-          \@safe@activesfalse
-          #3}%
+        \org@ifthenelse{#1}%
+          {\let\pageref\bbl@temp@pref
+           \let\ref\bbl@temp@ref
+           \@safe@activesfalse
+           #2}%
+          {\let\pageref\bbl@temp@pref
+           \let\ref\bbl@temp@ref
+           \@safe@activesfalse
+           #3}%
         }%
       }{}%
     }
@@ -1364,12 +1387,9 @@
        \fi}%
       {}}}
 \AtBeginDocument{%
-  \@ifundefined{pdfstringdefDisableCommands}%
-    {}%
-    {\pdfstringdefDisableCommands{%
-       \languageshorthands{system}}%
-    }%
-}
+  \ifx\pdfstringdefDisableCommands\@undefined\else
+    \pdfstringdefDisableCommands{\languageshorthands{system}}%
+  \fi}
 \DeclareRobustCommand{\FOREIGNLANGUAGE}[1]{%
   \lowercase{\foreignlanguage{#1}}}
 \def\substitutefontfamily#1#2#3{%
@@ -1409,7 +1429,7 @@
     \def\bbl@tempb#1\@@{\uppercase{\bbl@tempc#1}ENC.DEF\@empty\@@}%
     \def\bbl@tempc#1ENC.DEF#2\@@{%
       \ifx\@empty#2\else
-        \@ifundefined{T@#1}%
+        \bbl@ifunset{T@#1}%
           {}%
           {\@expandtwoargs\in@{,#1,}{,\BabelNonASCII,}%
            \ifin@
@@ -1430,9 +1450,11 @@
 \AtBeginDocument{%
   \@ifpackageloaded{fontspec}%
     {\xdef\latinencoding{%
-       \@ifundefined{UTFencname}%
-         {EU\ifcase\bbl@engine\or2\or1\fi}%
-         {\UTFencname}}}%
+       \ifx\UTFencname\@undefined
+         EU\ifcase\bbl@engine\or2\or1\fi
+       \else
+         \UTFencname
+       \fi}}%
     {\gdef\latinencoding{OT1}%
      \ifx\cf@encoding\bbl@t@one
        \xdef\latinencoding{\bbl@t@one}%
-- 
cgit v1.2.3

