Current File : //usr/share/texlive/texmf-dist/tex/latex/oberdiek/flags.sty |
%%
%% This is file `flags.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% flags.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Project: flags
%% Version: 2016/05/16 v0.5
%%
%% Copyright (C)
%% 2007 Heiko Oberdiek
%% 2016-2019 Oberdiek Package Support Group
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%% https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%% https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The Current Maintainers of this work are
%% Heiko Oberdiek and the Oberdiek Package Support Group
%% https://github.com/ho-tex/oberdiek/issues
%%
%%
%% This work consists of the main source file flags.dtx
%% and the derived files
%% flags.sty, flags.pdf, flags.ins, flags.drv.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{flags}%
[2016/05/16 v0.5 Setting/clearing of flags in bit fields (HO)]%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname numexpr\endcsname\relax
\PackageError{flags}{%
Missing e-TeX, package loading aborted%
}{%
This packages makes heavy use of \string\numexpr.%
}%
\expandafter\endinput
\fi
\newcommand*{\resetflags}[1]{%
\expandafter\let\csname flags@#1\endcsname\@empty
}
\newcommand*{\printflags}[1]{%
\expandafter\@printflags\csname flags@#1\endcsname
}
\def\@printflags#1{%
\expandafter\@firstofone\expandafter{%
\number\numexpr
\ifx#1\@empty
0%
\else
\expandafter\@@printflags#1%
\fi
}%
}
\def\@@printflags#1#2\fi{%
\fi
#1%
\ifx\\#2\\%
\else
+2*\numexpr\expandafter\@@printflags#2%
\fi
}
\newcommand*{\setflag}[2]{%
\ifnum#2>\z@
\expandafter\@setflag\csname flags@#1\expandafter\endcsname
\expandafter{\romannumeral\number\numexpr#2-1\relax000}%
\else
\PackageError{flags}{Position must be a positive number}\@ehc
\fi
}
\def\@setflag#1#2{%
\ifx#1\relax
\let#1\@empty
\fi
\edef#1{%
\expandafter\@@setflag\expandafter{#1}{#2}%
}%
}
\def\@@setflag#1#2{%
\ifx\\#1\\%
\FLAGS@zero#2\relax
1%
\else
\ifx\\#2\\%
1\@gobble#1%
\else
\@@@setflag#1|#2%
\fi
\fi
}
\def\@@@setflag#1#2|#3#4\fi\fi{%
\fi\fi
#1%
\@@setflag{#2}{#4}%
}
\newcommand*{\clearflag}[2]{%
\ifnum#2>\z@
\expandafter\@clearflag\csname flags@#1\expandafter\endcsname
\expandafter{\romannumeral\number\numexpr#2-1\relax000}%
\else
\PackageError{flags}{Position must be a positive number}\@ehc
\fi
}
\def\@clearflag#1#2{%
\ifx#1\relax
\let#1\@empty
\fi
\edef#1{%
\expandafter\@@clearflag\expandafter{#1}{#2}%
}%
}
\def\@@clearflag#1#2{%
\ifx\\#1\\%
\else
\ifx\\#2\\%
0\@gobble#1%
\else
\@@@clearflag#1|#2%
\fi
\fi
}
\def\@@@clearflag#1#2|#3#4\fi\fi{%
\fi\fi
#1%
\@@clearflag{#2}{#4}%
}
\def\FLAGS@zero#1{%
\ifx#1\relax
\else
0%
\expandafter\FLAGS@zero
\fi
}
\newcommand*{\queryflag}[2]{%
\ifnum\extractflag{#1}{#2}=\@ne
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\newcommand*{\extractflag}[1]{%
\expandafter\@extractflag\csname flags@#1\endcsname
}
\def\@extractflag#1#2{%
\ifx#1\@undefined
0%
\else
\ifx#1\relax
0%
\else
\ifx#1\@empty
0%
\else
\expandafter\expandafter\expandafter\@@extractflag
\expandafter\expandafter\expandafter{%
\expandafter#1\expandafter
}\expandafter{%
\romannumeral\number\numexpr#2-1\relax000%
}%
\fi
\fi
\fi
}
\def\@@extractflag#1#2{%
\ifx\\#1\\%
0%
\else
\ifx\\#2\\%
\@car#1\@nil
\else
\@@@extractflag#1|#2%
\fi
\fi
}
\def\@@@extractflag#1#2|#3#4\fi\fi{%
\fi\fi
\@@extractflag{#2}{#4}%
}
\endinput
%%
%% End of file `flags.sty'.