From 19f51c58f9a7eda52a1108dd836825631b3cbf08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= <mpg@elzevir.fr>
Date: Sun, 28 Mar 2010 13:39:06 +0200
Subject: Add catcode defenses.

---
 luatexbase-modutils.dtx | 49 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 39 insertions(+), 10 deletions(-)

(limited to 'luatexbase-modutils.dtx')

diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx
index 6cea769..f623183 100644
--- a/luatexbase-modutils.dtx
+++ b/luatexbase-modutils.dtx
@@ -155,6 +155,43 @@ See source file '\inFileName' for details.
 \expandafter\let\csname lltxb@modutils@loaded\endcsname\endinput
 %    \end{macrocode}
 %
+%    Catcode defenses.
+%
+%    \begin{macrocode}
+\begingroup
+  \catcode123 1 % {
+  \catcode125 2 % }
+  \catcode 35 6 % #
+  \toks0{}%
+  \def\x{}%
+  \def\y#1 #2 {%
+    \toks0\expandafter{\the\toks0 \catcode#1 \the\catcode#1}%
+    \edef\x{\x \catcode#1 #2}}%
+  \y 123 1  % {
+  \y 125 2  % }
+  \y  35 6  % #
+  \y  10 12 % ^^J
+  \y  34 12 % "
+  \y  36 3  % $ $
+  \y  39 12 % '
+  \y  40 12 % (
+  \y  41 12 % )
+  \y  42 12 % *
+  \y  43 12 % +
+  \y  44 12 % ,
+  \y  45 12 % -
+  \y  46 12 % .
+  \y  47 12 % /
+  \y  60 12 % <
+  \y  61 12 % =
+  \y  64 11 % @ (letter)
+  \y  62 12 % >
+  \y  95 12 % _ (other)
+  \y  96 12 % `
+  \edef\y#1{\endgroup\edef#1{\the\toks0\relax}\x}%
+\expandafter\y\csname lltxb@modutils@AtEnd\endcsname
+%    \end{macrocode}
+%
 %    Package declaration.
 %
 %    \begin{macrocode}
@@ -186,20 +223,12 @@ See source file '\inFileName' for details.
       \let\x\PackageWarningNoLine
     \fi
   \expandafter\endgroup
-  \x{luatexbase-modutils}{LuaTeX is required for this package.^^J
-    Aborting package loading.}
+  \x{luatexbase-modutils}{LuaTeX is required for this package. Aborting.}
+  \lltxb@modutils@AtEnd
   \expandafter\endinput
 \fi
 %    \end{macrocode}
 %
-%    Make sure the catcode of @ is correct, especially for \plaintex.
-%
-%    \begin{macrocode}
-\expandafter\edef\csname lltxb@modutils@AtEnd\endcsname{%
-  \catcode64 \the\catcode64\relax}
-\catcode64 11
-%    \end{macrocode}
-%
 %    Load the package loader.
 %
 %    \begin{macrocode}
-- 
cgit v1.2.3

