%%
%% This is file `mfirstuc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mfirstuc.dtx  (with options: `mfirstuc.sty,package')
%% 
%%  mfirstuc.dtx
%%  Copyright 2015 Nicola Talbot
%% 
%%  This work may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.3
%%  of this license of (at your option) any later version.
%%  The latest version of this license is in
%%    http://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 Maintainer of this work is Nicola Talbot.
%% 
%%  This work consists of the files mfirstuc.dtx and mfirstuc.ins and the derived files mfirstuc.sty, mfirstuc-english.sty, sample-mfirstuc.tex, mfirstuc.perl.
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mfirstuc}[2015/12/17 v2.02 (NLCT)]
\RequirePackage{etoolbox}
\newif\if@glscs
\newtoks\@glsmfirst
\newtoks\@glsmrest
\newrobustcmd*{\makefirstuc}[1]{%
  \@MFU@p@makefirstuc#1\relax\relax\relax\@end@MFU@protected{#1}%
}
\def\@MFU@p@makefirstuc#1#2#3\@end@MFU@protected#4{%
  \ifx\protect#1\relax
   \@makefirstuc{#2#3}%
  \else
   \@makefirstuc{#4}%
  \fi
}
\newcommand*{\@makefirstuc}[1]{%
  \def\gls@argi{#1}%
  \ifx\gls@argi\@empty
  \else
    \def\@gls@tmp{\ #1}%
    \@onelevel@sanitize\@gls@tmp
    \expandafter\@gls@checkcs\@gls@tmp\relax\relax
    \if@glscs
     \expandafter\def\expandafter\@gls@tmp\expandafter{\expandafter
       \ \@gobble #1}%
     \@onelevel@sanitize\@gls@tmp
     \expandafter\@gls@checkcs\@gls@tmp\relax\relax
     \if@glscs\@glscsfalse\else\@glscstrue\fi
    \fi
    \if@glscs
      \@gls@getbody #1{}\@nil
      \ifx\@gls@rest\@empty
        \glsmakefirstuc{#1}%
      \else
        \expandafter\@gls@split\@gls@rest\@nil
        \ifx\@gls@first\@empty
           \glsmakefirstuc{#1}%
        \else
           \expandafter\@glsmfirst\expandafter{\@gls@first}%
           \expandafter\@glsmrest\expandafter{\@gls@rest}%
           \edef\@gls@domfirstuc{\noexpand\@gls@body
             {\noexpand\glsmakefirstuc\the\@glsmfirst}%
             \the\@glsmrest}%
           \@gls@domfirstuc
        \fi
      \fi
    \else
      \glsmakefirstuc{#1}%
    \fi
  \fi
}
\def\@gls@split#1#2\@nil{%
  \def\@gls@first{#1}\def\@gls@rest{#2}%
}
\def\@gls@checkcs#1 #2#3\relax{%
  \def\@gls@argi{#1}\def\@gls@argii{#2}%
  \ifx\@gls@argi\@gls@argii
    \@glscstrue
  \else
    \@glscsfalse
  \fi
}
\def\@gls@makefirstuc#1{\mfirstucMakeUppercase #1}
\newcommand*{\mfirstucMakeUppercase}{\MakeUppercase}
\newcommand*{\glsmakefirstuc}[1]{\@gls@makefirstuc{#1}}
\def\@gls@getbody#1#{\def\@gls@body{#1}\@gls@gobbletonil}
\def\@gls@gobbletonil#1\@nil{\def\@gls@rest{#1}}
\newcommand*{\xmakefirstuc}[1]{%
\expandafter\makefirstuc\expandafter{#1}}
\DeclareRobustCommand*{\emakefirstuc}[1]{%
  \protected@edef\@MFU@caparg{#1}%
  \expandafter\makefirstuc\expandafter{\@MFU@caparg}%
}
\newrobustcmd*{\capitalisewords}[1]{%
  \def\gls@add@space{}%
  \let\@mfu@domakefirstuc\makefirstuc
  \let\@mfu@checkword\@gobble
  \mfu@capitalisewords#1 \@nil\mfu@endcap
}
\def\mfu@capitalisewords#1 #2\mfu@endcap{%
  \def\mfu@cap@first{#1}%
  \def\mfu@cap@second{#2}%
  \gls@add@space
  \@mfu@checkword{#1}%
  \@mfu@domakefirstuc{#1}%
  \def\gls@add@space{ }%
  \ifx\mfu@cap@second\@nnil
    \let\next@mfu@cap\mfu@noop
  \else
    \let\next@mfu@cap\mfu@capitalisewords
    \let\@mfu@checkword\mfu@checkword
  \fi
  \next@mfu@cap#2\mfu@endcap
}
\def\mfu@noop#1\mfu@endcap{}
\newcommand*\mfu@checkword[1]{%
  \def\mfu@checkword@arg{#1}%
  \let\@mfu@domakefirstuc\makefirstuc
  \forlistloop\mfu@checkword@do\@mfu@nocaplist
}
\newcommand*{\mfu@checkword@do}[1]{%
 \ifdefstring{\mfu@checkword@arg}{#1}%
 {%
   \let\@mfu@domakefirstuc\@firstofone
   \listbreak
 }%
 {}%
}
\newcommand*{\@mfu@nocaplist}{}
\newcommand*{\MFUnocap}[1]{\listadd{\@mfu@nocaplist}{#1}}
\newcommand*{\gMFUnocap}[1]{\listgadd{\@mfu@nocaplist}{#1}}
\newcommand*{\MFUclear}{\renewcommand*{\@mfu@nocaplist}{}}
\newcommand*{\xcapitalisewords}[1]{%
  \expandafter\capitalisewords\expandafter{#1}%
}
\DeclareRobustCommand*{\ecapitalisewords}[1]{%
  \protected@edef\@MFU@caparg{#1}%
  \expandafter\capitalisewords\expandafter{\@MFU@caparg}%
}
\endinput
%%
%% End of file `mfirstuc.sty'.
