From 414dd110e53e9f20f3308de3525e7f7dea17264b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= <mpg@elzevir.fr>
Date: Mon, 23 May 2011 01:09:14 +0200
Subject: generalise better catcode defenses

---
 luatexbase.dtx | 53 +++++++++++++++++++++++------------------------------
 1 file changed, 23 insertions(+), 30 deletions(-)

(limited to 'luatexbase.dtx')

diff --git a/luatexbase.dtx b/luatexbase.dtx
index 4bfd5cb..a69721c 100644
--- a/luatexbase.dtx
+++ b/luatexbase.dtx
@@ -139,48 +139,42 @@ See source file '\inFileName' for licence and contact information.
 %
 %    \subsection{Preliminaries}
 %
-%    Reload protection, especially for \plaintex.
+%    Catcode defenses and reload protection.
 %
 %    \begin{macrocode}
-                \csname lltxb@core@loaded\endcsname
-\expandafter\let\csname lltxb@core@loaded\endcsname\endinput
-%    \end{macrocode}
-%
-%    Catcode defenses.
-%
-%    \begin{macrocode}
-\begingroup
+\begingroup\catcode61\catcode48\catcode32=10\relax% = and space
   \catcode123 1 % {
   \catcode125 2 % }
   \catcode 35 6 % #
-  \toks0{}%
-  \def\x{}%
+  \toks0\expandafter{\expandafter\endlinechar\the\endlinechar}%
+  \edef\x{\endlinechar13}%
   \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  13  5 % carriage return
+  \y  61 12 % =
+  \y  32 10 % space
+  \y 123  1 % {
+  \y 125  2 % }
+  \y  35  6 % #
+  \y  64 11 % @ (letter)
   \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  58 12 % :
+  \y  91 12 % [
+  \y  93 12 % ]
+  \y  94  7 % ^
   \y  96 12 % `
-  \edef\y#1{\endgroup\edef#1{\the\toks0\relax}\x}%
-\expandafter\y\csname lltxb@core@AtEnd\endcsname
+  \toks0\expandafter{\the\toks0 \relax\noexpand\endinput}%
+  \edef\y#1{\noexpand\expandafter\endgroup%
+    \noexpand\ifx#1\relax \edef#1{\the\toks0}\x\relax%
+    \noexpand\else \noexpand\expandafter\noexpand\endinput%
+    \noexpand\fi}%
+\expandafter\y\csname luatexbase@sty@endinput\endcsname%
 %    \end{macrocode}
 %
 %    Package declaration.
@@ -218,8 +212,7 @@ See source file '\inFileName' for licence and contact information.
     This package can only be used with the LuaTeX engine^^J%
     (command `lualatex' or `luatex').^^J%
     Package loading has been stopped to prevent additional errors.}
-  \lltxb@core@AtEnd
-  \expandafter\endinput
+  \expandafter\luatexbase@sty@endinput%
 \fi
 %    \end{macrocode}
 %
@@ -249,7 +242,7 @@ See source file '\inFileName' for licence and contact information.
 %    This is the end, my friend\dots the end.
 %
 %    \begin{macrocode}
-\lltxb@core@AtEnd
+\luatexbase@sty@endinput%
 %</texpackage>
 %    \end{macrocode}
 %
-- 
cgit v1.2.3

