diff options
author | Karl Berry <karl@freefriends.org> | 2013-08-22 22:47:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-08-22 22:47:28 +0000 |
commit | fa864f80ab102c4ee90a371ea8ff10dcac94076b (patch) | |
tree | 19fde11035d7b2d974518649442f89deceaa47d2 /Master/texmf-dist/tex/latex/macroswap | |
parent | 2cf57b8121d8967a875c1efba4e1df2e86f9bd14 (diff) |
macroswap (22aug13)
git-svn-id: svn://tug.org/texlive/trunk@31498 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/macroswap')
-rw-r--r-- | Master/texmf-dist/tex/latex/macroswap/macroswap.sty | 40 |
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'. |