<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% (c) 2001-2005 Javier Bezos

\def\mem@protected#1#2#3{%
  \ifx\thepage\relax
    \string#2{#3}%
  \else\ifx\protect\@unexpandable@protect
    \noexpand#2{#3}%
  \else
    #1%
  \fi\fi}

% \mem@foreach{list}{code}:
% for each element in the comma separated list,
% do code with ##1 being the current item.
% Cannot be nested.

\def\mem@foreach#1#2{%
  \def\mem@forcmd##1{#2}%
  \mem@fornext#1,\@nil}

\def\mem@fornext#1,#2{%
  \mem@forcmd{#1}%
  \ifx#2\@nil
    \expandafter\@gobble
  \else
    \expandafter\mem@fornext
  \fi
  #2}

% \mem@lastfor makes the following elements
% in the list to be ignored. 

\def\mem@lastfor{\let\mem@forcmd\@gobble}

% mem@eforeach is like mem@foreach but list
% is expanded first. That means that a list
% item cannot be a macro name as such
% (except if unexpandable). mem@forcmd is used
% as a temporary macro.

\def\mem@eforeach#1{%
  \edef\mem@forcmd{#1}%
  \expandafter\mem@foreach\expandafter{\mem@forcmd}}

\def\mem@error#1{\PackageError{mem}{#1}%
  {See mem documentation for explanation}}
\def\mem@bug#1{\mem@error{Bug found (#1)}}

% \mem@after\macro{code}:
% Adds code at the end of macro, without expansion.

\def\mem@after#1#2{%
  \toks@\expandafter{#1}%
  \@temptokena{#2}%
  \edef#1{\the\toks@\the\@temptokena}}

% \mem@eafter\macro{code}:
% As above, but expands code before adding it to \macro
% (whose previous code is not expanded).

\def\mem@eafter#1#2{%
  \toks@\expandafter{#1}%
  \edef#1{\the\toks@#2}}

% \mem@lafter\macro\eltmacro{list}
% Yet another variant.  This time {list} is a comma
% separated list which is converted first to
% \eltmacro{elem}\eltmacro{elem}... Empty items are
% ignored.

\def\mem@lafter#1#2#3{%
  \def\mem@a{\noexpand#2}%
  \mem@eafter#1{\mem@lafterget#3,\@nil,}}

\def\mem@lafterget#1,{%
  \ifx\@nil#1\@empty\else % if #1=\@nil, #1 can be {}
    \ifx\\#1\\\else\mem@a{#1}\fi % if #1={}
    \expandafter\mem@lafterget
  \fi}

% Macros to show info for debugging

\newcounter{memdebuglevel}
\c@memdebuglevel\@ne

\def\mem@debug#1#2{%
  \ifnum\c@memdebuglevel=\@ne
    \typeout{(Mem) #2}%
  \fi}

% \mem@setcsvar\macro
% If \macro is undefined, define it as empty

\def\mem@setcsvar#1{%
  \@ifundefined{#1}%
    {\mem@ecs\let{#1}\@empty}%
    {}}

% \mem@ecs\macro{name}
% A convenient shorthand -- the same as \macro\name.

\def\mem@ecs#1#2{%
  \expandafter#1%
  \csname#2\endcsname}

%%% \mem@csuse
%%% Like \csname\mem@use{prefix}{suffix}\endcsname
%%% ny implemented

\endinput
%%
%% End of file `mem-comm.sty'.
</pre></body></html>