summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/macroswap/macroswap.sty
blob: cecd5aa8ef78c68f542243829a68201bf26e5016 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%%
%% This is file `macroswap.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% macroswap.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2013 by Robert J Lee
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.2 of this license or (at your option) any later
%% version. The latest version of this license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
%% 
\newcommand{\macroswap}[2]{%
  \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%
}
\endinput
%%
%% End of file `macroswap.sty'.