summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/macroswap/macroswap.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/macroswap/macroswap.sty')
-rw-r--r--Master/texmf-dist/tex/latex/macroswap/macroswap.sty40
1 files changed, 24 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/latex/macroswap/macroswap.sty b/Master/texmf-dist/tex/latex/macroswap/macroswap.sty
index 6d719cde5a0..cecd5aa8ef7 100644
--- a/Master/texmf-dist/tex/latex/macroswap/macroswap.sty
+++ b/Master/texmf-dist/tex/latex/macroswap/macroswap.sty
@@ -20,24 +20,32 @@
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
%%
-\makeatletter
-\newcommand{\gmacroswap}[2]{%
- \edef\macro@swap@left{\csexpandonce{#1}}%
- \edef\macro@swap@right{\csexpandonce{#2}}%
- \expandafter\xdef\csname#2\endcsname{\expandonce{\macro@swap@left}}%
- \expandafter\xdef\csname#1\endcsname{\expandonce{\macro@swap@right}}%
- \let\macroswap@left\relax%
- \let\macroswap@right\relax%
-}
\newcommand{\macroswap}[2]{%
- \edef\macro@swap@left{\csexpandonce{#1}}%
- \edef\macro@swap@right{\csexpandonce{#2}}%
- \expandafter\edef\csname#2\endcsname{\expandonce{\macro@swap@left}}%
- \expandafter\edef\csname#1\endcsname{\expandonce{\macro@swap@right}}%
- \let\macroswap@left\relax%
- \let\macroswap@right\relax%
+ \expandafter\ifcsname#1\endcsname%
+ \else%
+ \PackageError{macrocode}{Two macro names are required for macroswap %
+ (got ``#1'' and ``#2'')}{%
+ Two macro names are required, but the first parameter does not %
+ expand to a defined macro name. Macros have not been swapped.}%
+ \fi%
+ \expandafter\ifcsname#2\endcsname%
+ \else%
+ \PackageError{macrocode}{Two macro names are required for macroswap %
+ (got ``#1'' and ``#2'')}{%
+ Two macro names are required, but the second parameter does not %
+ expand to a defined macro name. Macros have not been swapped.}%
+ \fi%
+ \expandafter\let\expandafter\macroswap@temp\csname#1\endcsname%
+ \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname%
+ \expandafter\let\csname#2\endcsname\macroswap@temp%
+ \let\macroswap@temp\relax%
+}
+\newcommand{\gmacroswap}[2]{%
+ \expandafter\let\expandafter\macroswap@temp\csname#1\endcsname%
+ \expandafter\global\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname%
+ \expandafter\global\expandafter\let\csname#2\endcsname\macroswap@temp%
+ \let\macroswap@temp\relax%
}
-\makeatother
\endinput
%%
%% End of file `macroswap.sty'.