From 2b1511b76524ed6e4b906094ee4a63aacf7d68e5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 16 Nov 2009 01:44:59 +0000 Subject: datalog 2.03 (15nov09) git-svn-id: svn://tug.org/texlive/trunk@16023 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/datatool/databar.sty | 9 +- Master/texmf-dist/tex/latex/datatool/databib.sty | 9 +- Master/texmf-dist/tex/latex/datatool/datapie.sty | 9 +- Master/texmf-dist/tex/latex/datatool/dataplot.sty | 9 +- Master/texmf-dist/tex/latex/datatool/datatool.sty | 1449 +++++++++++---------- Master/texmf-dist/tex/latex/datatool/person.sty | 638 +++++++++ 6 files changed, 1415 insertions(+), 708 deletions(-) create mode 100644 Master/texmf-dist/tex/latex/datatool/person.sty (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/datatool/databar.sty b/Master/texmf-dist/tex/latex/datatool/databar.sty index ecf8ce763bf..a381960c486 100644 --- a/Master/texmf-dist/tex/latex/datatool/databar.sty +++ b/Master/texmf-dist/tex/latex/datatool/databar.sty @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot. %% -%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst. +%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst, person.sty. %% %% \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 @@ -38,8 +38,13 @@ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} +%% load student information from file "students.csv" +%% Iterate through the student database: +%% Define "anon": +%% Do the letter: +%% Undefine "anon": \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{databar}[2009/02/27 v2.0 (NLCT)] +\ProvidesPackage{databar}[2009/10/22 v2.01 (NLCT)] \RequirePackage{xkeyval} \RequirePackage{dataplot} \newif\ifDTLcolorbarchart diff --git a/Master/texmf-dist/tex/latex/datatool/databib.sty b/Master/texmf-dist/tex/latex/datatool/databib.sty index 44160a138d9..4e45c052256 100644 --- a/Master/texmf-dist/tex/latex/datatool/databib.sty +++ b/Master/texmf-dist/tex/latex/datatool/databib.sty @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot. %% -%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst. +%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst, person.sty. %% %% \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 @@ -38,8 +38,13 @@ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} +%% load student information from file "students.csv" +%% Iterate through the student database: +%% Define "anon": +%% Do the letter: +%% Undefine "anon": \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{databib}[2009/02/27 v2.0 (NLCT)] +\ProvidesPackage{databib}[2009/10/22 v2.01 (NLCT)] \RequirePackage{datatool} \newcommand*{\dtlbib@style}{plain} \define@choicekey{databib.sty}{style}{plain,abbrv,alpha}{% diff --git a/Master/texmf-dist/tex/latex/datatool/datapie.sty b/Master/texmf-dist/tex/latex/datatool/datapie.sty index f1af8129159..62916f4638d 100644 --- a/Master/texmf-dist/tex/latex/datatool/datapie.sty +++ b/Master/texmf-dist/tex/latex/datatool/datapie.sty @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot. %% -%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst. +%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst, person.sty. %% %% \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 @@ -38,8 +38,13 @@ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} +%% load student information from file "students.csv" +%% Iterate through the student database: +%% Define "anon": +%% Do the letter: +%% Undefine "anon": \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{datapie}[2007/02/27 v2.0 (NLCT)] +\ProvidesPackage{datapie}[2009/10/22 v2.01 (NLCT)] \RequirePackage{xkeyval} \newif\ifDTLcolorpiechart \DTLcolorpiecharttrue diff --git a/Master/texmf-dist/tex/latex/datatool/dataplot.sty b/Master/texmf-dist/tex/latex/datatool/dataplot.sty index 48500c6843c..3d67f7823de 100644 --- a/Master/texmf-dist/tex/latex/datatool/dataplot.sty +++ b/Master/texmf-dist/tex/latex/datatool/dataplot.sty @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot. %% -%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst. +%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst, person.sty. %% %% \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 @@ -38,8 +38,13 @@ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} +%% load student information from file "students.csv" +%% Iterate through the student database: +%% Define "anon": +%% Do the letter: +%% Undefine "anon": \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{dataplot}[2009/02/27 v2.0 (NLCT)] +\ProvidesPackage{dataplot}[2009/10/22 v2.01 (NLCT)] \RequirePackage{xkeyval} \RequirePackage{tikz} \RequirePackage{datatool} diff --git a/Master/texmf-dist/tex/latex/datatool/datatool.sty b/Master/texmf-dist/tex/latex/datatool/datatool.sty index 1d630179591..8306dba927c 100644 --- a/Master/texmf-dist/tex/latex/datatool/datatool.sty +++ b/Master/texmf-dist/tex/latex/datatool/datatool.sty @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot. %% -%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst. +%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst, person.sty. %% %% \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 @@ -38,8 +38,13 @@ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} +%% load student information from file "students.csv" +%% Iterate through the student database: +%% Define "anon": +%% Do the letter: +%% Undefine "anon": \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{datatool}[2009/07/13 v2.02 (NLCT)] +\ProvidesPackage{datatool}[2009/11/15 v2.03 (NLCT)] \RequirePackage{xkeyval} \RequirePackage{ifthen} \RequirePackage{xfor} @@ -1370,6 +1375,40 @@ \expandafter\newcount\csname dtlcols@#1\endcsname }% } +\newcommand*{\DTLcleardb}[1]{% + \DTLifdbexists{#1}% + {% + \dtlforeachkey(\@dtl@key,\@dtl@col,\@dtl@type,\@dtl@head)\in{#1}\do + {% + \expandafter\let\csname dtl@ci@#1@\@dtl@key\endcsname\undefined + }% + \csname dtldb@#1\endcsname{}% + \csname dtlkeys@#1\endcsname{}% + \csname dtlrows@#1\endcsname=0\relax + \csname dtlcols@#1\endcsname=0\relax + }% + {% + \PackageError{Can't clear database `#1': + database doesn't exist}{}{}% + }% +} +\newcommand*{\DTLdeletedb}[1]{% + \DTLifdbexists{#1}% + {% + \dtlforeachkey(\@dtl@key,\@dtl@col,\@dtl@type,\@dtl@head)\in{#1}\do + {% + \expandafter\let\csname dtl@ci@#1@\@dtl@key\endcsname\undefined + }% + \expandafter\let\csname dtldb@#1\endcsname\undefined + \expandafter\let\csname dtlkeys@#1\endcsname\undefined + \expandafter\let\csname dtlrows@#1\endcsname\undefined + \expandafter\let\csname dtlcols@#1\endcsname\undefined + }% + {% + \PackageError{Can't delete database `#1': + database doesn't exist}{}{}% + }% +} \newcommand*{\DTLrowcount}[1]{% \expandafter\number\csname dtlrows@#1\endcsname} \newcommand*{\DTLcolumncount}[1]{% @@ -1451,7 +1490,7 @@ \newcommand*{\@sdtl@getcolumnindex}[3]{% \expandafter\let\expandafter#1\csname dtl@ci@#2@#3\endcsname } -\newcommand*{\dtl@columnindex}[2]{% +\newcommand*{\dtlcolumnindex}[2]{% \csname dtl@ci@#1@#2\endcsname } \newcommand*{\DTLgetkeyforcolumn}{% @@ -1529,7 +1568,7 @@ \newcommand*{\@sdtlgetdatatype}[3]{% \edef\@dtl@dogetdata{\noexpand\@dtl@getdatatype{\noexpand#1}% {\expandafter\the\csname dtlkeys@#2\endcsname}% - {\dtl@columnindex{#2}{#3}}}% + {\dtlcolumnindex{#2}{#3}}}% \@dtl@dogetdata } \newcommand*{\@dtl@getdatatype}[3]{% @@ -1571,7 +1610,7 @@ \@sDTLifhaskey{#1}{#2}% {% \expandafter\dtlcolumnnum\expandafter - =\dtl@columnindex{#1}{#2}\relax + =\dtlcolumnindex{#1}{#2}\relax \edef\@dtl@dogetprops{\noexpand\@dtl@getprops {\noexpand\@dtl@key}{\noexpand\@dtl@type}% {\noexpand\@dtl@colhead}{\noexpand\@dtl@before}% @@ -1667,7 +1706,7 @@ } \newcommand*{\@sDTLsetheader}[3]{% \expandafter\dtlcolumnnum\expandafter - =\dtl@columnindex{#1}{#2}\relax + =\dtlcolumnindex{#1}{#2}\relax \@dtl@setheaderforindex{#1}{\dtlcolumnnum}{#3}% } \newcommand*{\@dtl@setheaderforindex}[3]{% @@ -1696,6 +1735,14 @@ }% {\@dtl@after}% } +\newcommand*{\dtlexpandnewvalue}{% + \def\@dtl@setnewvalue##1{\protected@edef\@dtl@tmp{##1}% + \expandafter\@dtl@toks\expandafter{\@dtl@tmp}}% +} +\newcommand*{\dtlnoexpandnewvalue}{% + \def\@dtl@setnewvalue##1{\@dtl@toks{##1}}% +} +\dtlnoexpandnewvalue \newcommand{\DTLnewdbentry}{% \@ifstar\@sDTLnewdbentry\@DTLnewdbentry } @@ -1708,7 +1755,7 @@ \newcommand*{\@sDTLnewdbentry}[3]{% \@dtl@updatekeys{#1}{#2}{#3}% \expandafter\dtlcolumnnum\expandafter - =\dtl@columnindex{#1}{#2}\relax + =\dtlcolumnindex{#1}{#2}\relax \edef\dtl@dogetrow{\noexpand\dtlgetrow{#1}% {\number\csname dtlrows@#1\endcsname}}% \dtl@dogetrow @@ -1717,7 +1764,7 @@ }% \dtl@dogetentry \ifx\dtl@entry\dtlnovalue - \@dtl@toks{#3}% + \@dtl@setnewvalue{#3}% \toks@gconcat@middle@cx{dtldb@#1}% {\dtlbeforerow}% {% @@ -1748,30 +1795,30 @@ \newcommand*{\@dtl@assign}[2]{% \@dtl@assigncmd#1,\@nil\@@{#2}% } -\def\@dtl@assigncmd#1=#2,#3\@@#4{% - \@sDTLifhaskey{#4}{#2}% +\def\@dtl@assigncmd#1#2=#3,#4\@@#5{% + \@sDTLifhaskey{#5}{#3}% {% \edef\@dtl@dogetentry{% \noexpand\dtlgetentryfromcurrentrow - {\noexpand#1}{\dtl@columnindex{#4}{#2}}}% + {\noexpand#1}{\dtlcolumnindex{#5}{#3}}}% \@dtl@dogetentry \ifx#1\dtlnovalue - \@@dtl@setnull{#1}{#2}% + \@@dtl@setnull{#1}{#3}% \fi \global\let#1=#1\relax }% {% \PackageError{datatool}{Can't assign \string#1\space: there - is no key `#2' in data base `#4'}{}% + is no key `#3' in data base `#5'}{}% \global\let#1\DTLstringnull }% - \def\dtl@tmp{#3}% + \def\dtl@tmp{#4}% \ifx\@nnil\dtl@tmp \let\@dtl@next\@dtl@assigncmdnoop \else \let\@dtl@next\@dtl@assigncmd \fi - \@dtl@next#3\@@{#4}% + \@dtl@next#4\@@{#5}% } \def\@dtl@assigncmdnoop#1\@@#2{} \newcommand*{\@dtl@setnull}[2]{% @@ -2097,7 +2144,7 @@ \toks@{#4}% \edef\@dtl@doforcol{\noexpand\dtl@forcolumn{\noexpand#1}% {\expandafter\the\csname dtldb@#2\endcsname}% - {\dtl@columnindex{#2}{#3}}{\the\toks@}% + {\dtlcolumnindex{#2}{#3}}{\the\toks@}% }% \@dtl@doforcol% } @@ -2463,7 +2510,7 @@ \csname dtl@row\romannumeral\dtlforeachlevel\endcsname\relax \@dtl@updatekeys{\@dtl@thisdb}{#1}{#2}% \expandafter\dtlcolumnnum\expandafter - =\dtl@columnindex{\@dtl@thisdb}{#1}\relax + =\dtlcolumnindex{\@dtl@thisdb}{#1}\relax \dtlcurrentrow = \csname @dtl@cur\romannumeral\dtlforeachlevel\endcsname \edef\dtl@dogetentry{\noexpand\dtlgetentryfromcurrentrow @@ -2471,7 +2518,8 @@ }% \dtl@dogetentry \ifx\dtl@entry\dtlnovalue - \expandafter\@dtl@toks\expandafter{#2}% + \protected@edef\@dtl@tmp{#2}% + \expandafter\@dtl@toks\expandafter{\@dtl@tmp}% \toks@gput@right@cx{@dtl@cur\romannumeral\dtlforeachlevel}% {% \noexpand\db@col@id@w \number\dtlcolumnnum @@ -2584,7 +2632,8 @@ {\noexpand\dtl@post}% }% \@dtl@dosplitrow - \@dtl@toks{#2}% new value + \protected@edef\@dtl@tmp{#2}% + \expandafter\@dtl@toks\expandafter{\@dtl@tmp}% new value \expandafter\@dtl@before\expandafter{\dtl@pre}% \expandafter\@dtl@after\expandafter{\dtl@post}% \toks@gconcat@middle@cx @@ -3573,174 +3622,534 @@ \dtl@message{`\@dtl@a' <=> `\@dtl@b' = \number\dtl@sortresult}% \fi } -\newcommand*{\dtl@choplast}[3]{% -\let#2\@empty -\let#3\@empty -\@for\@dtl@element:=#1\do{% -\ifx#3\@empty -\else - \ifx#2\@empty - \expandafter\toks@\expandafter{#3}% - \edef#2{{\the\toks@}}% - \else - \expandafter\toks@\expandafter{#3}% - \expandafter\@dtl@toks\expandafter{#2}% - \edef#2{\the\@dtl@toks,{\the\toks@}}% - \fi -\fi -\let#3=\@dtl@element% -}% -} -\newcommand*{\dtl@chopfirst}[3]{% -\let#2=\@empty -\let#3=\@empty -\@for\@dtl@element:=#1\do{% - \let#2=\@dtl@element - \@endfortrue -}% -\if@endfor - \let#3=\@forremainder -\fi -\@endforfalse +\newwrite\@dtl@write +\newcommand*{\DTLsavedb}[2]{% + \DTLifdbexists{#1}% + {% + \openout\@dtl@write=#2\relax + \def\@dtl@header{}% + \dtlforeachkey(\@dtl@key,\@dtl@col,\@dtl@type,\@dtl@head)% + \in{#1}\do + {% + \IfSubStringInString{\@dtl@separator}{\@dtl@key}% + {% + \ifx\@dtl@header\@empty + \protected@edef\@dtl@header{% + \@dtl@delimiter\@dtl@key\@dtl@delimiter}% + \else + \toks@=\expandafter{\@dtl@header}% + \protected@edef\@dtl@header{% + \the\toks@\@dtl@separator + \@dtl@delimiter\@dtl@key\@dtl@delimiter}% + \fi + }% + {% + \ifx\@dtl@header\@empty + \protected@edef\@dtl@header{\@dtl@key}% + \else + \toks@=\expandafter{\@dtl@header}% + \protected@edef\@dtl@header{\the\toks@ + \@dtl@separator\@dtl@key}% + \fi + }% + }% + \protected@write\@dtl@write{}{\@dtl@header}% + \@sDTLforeach{#1}{}% + {% + \def\@dtl@row{}% + \DTLforeachkeyinrow{\@dtl@val}% + {% + \IfSubStringInString{\@dtl@separator}{\@dtl@val}% + {% + \ifx\@dtl@row\@empty + \protected@edef\@dtl@row{% + \@dtl@delimiter\@dtl@val\@dtl@delimiter}% + \else + \toks@=\expandafter{\@dtl@row}% + \protected@edef\@dtl@row{\the\toks@\@dtl@separator + \@dtl@delimiter\@dtl@val\@dtl@delimiter}% + \fi + }% + {% + \ifx\@dtl@row\@empty + \protected@edef\@dtl@row{\@dtl@val}% + \else + \toks@=\expandafter{\@dtl@row}% + \protected@edef\@dtl@row{\the\toks@\@dtl@separator + \@dtl@val}% + \fi + }% + }% + \protected@write\@dtl@write{}{\@dtl@row}% + }% + \closeout\@dtl@write + }% + {% + \PackageError{datatool}{Can't save database `#1': no such + database}{}% + }% } -\newcommand{\dtl@sortlist}[2]{% -\def\@dtl@sortedlist{}% -\@for\@dtl@currentrow:=#1\do{% -\expandafter\dtl@insertinto\expandafter - {\@dtl@currentrow}{\@dtl@sortedlist}{#2}% -\@endforfalse}% -\let#1=\@dtl@sortedlist +\newcommand*{\DTLsavetexdb}[2]{% + \DTLifdbexists{#1}% + {% + \openout\@dtl@write=#2\relax + \protected@write\@dtl@write{}{\string\DTLnewdb{#1}}% + \@sDTLforeach{#1}{}% + {% + \protected@write\@dtl@write{}{\string\DTLnewrow*{#1}}% + \DTLforeachkeyinrow{\@dtl@val}% + {% + \DTLifnull{\@dtl@val}% + {\def\@dtl@val{}}% + {}% + \protected@write\@dtl@write{}{% + \string\DTLnewdbentry*{#1}{\dtlkey}{\@dtl@val}}% + }% + }% + \dtlforeachkey(\@dtl@k,\@dtl@c,\@dtl@t,\@dtl@h)\in{#1}\do + {% + \@onelevel@sanitize\@dtl@h + \protected@write\@dtl@write{}{% + \string\DTLsetheader*{#1}{\@dtl@k}{\@dtl@h}}% + }% + \closeout\@dtl@write + }% + {% + \PackageError{datatool}{Can't save database `#1': no such + database}{}% + }% } -\newcommand{\dtl@insertinto}[3]{% -\def\@dtl@newsortedlist{}% -\@dtl@insertdonefalse -\@for\dtl@srtelement:=#2\do{% -\if@dtl@insertdone - \expandafter\toks@\expandafter{\dtl@srtelement}% - \edef\@dtl@newstuff{{\the\toks@}}% -\else - \expandafter#3\expandafter{\dtl@srtelement}{#1}% - \ifnum\dtl@sortresult<0\relax - \expandafter\toks@\expandafter{\dtl@srtelement}% - \@dtl@toks{#1}% - \edef\@dtl@newstuff{{\the\@dtl@toks},{\the\toks@}}% - \@dtl@insertdonetrue - \else - \expandafter\toks@\expandafter{\dtl@srtelement}% - \edef\@dtl@newstuff{{\the\toks@}}% - \fi -\fi -\ifx\@dtl@newsortedlist\@empty - \expandafter\toks@\expandafter{\@dtl@newstuff}% - \edef\@dtl@newsortedlist{\the\toks@}% -\else - \expandafter\toks@\expandafter{\@dtl@newsortedlist}% - \expandafter\@dtl@toks\expandafter{\@dtl@newstuff}% - \edef\@dtl@newsortedlist{\the\toks@,\the\@dtl@toks}% -\fi -\@endforfalse -}% - \ifx\@dtl@newsortedlist\@empty - \@dtl@toks{#1}% - \edef\@dtl@newsortedlist{{\the\@dtl@toks}}% - \else - \if@dtl@insertdone - \else - \expandafter\toks@\expandafter{\@dtl@newsortedlist}% - \@dtl@toks{#1}% - \edef\@dtl@newsortedlist{\the\toks@,{\the\@dtl@toks}}% - \fi - \fi -\global\let#2=\@dtl@newsortedlist +\newcommand{\@longempty}{} +\newread\@dtl@read +\newcount\dtl@entrycr +\define@boolkey{loaddb}[dtl]{noheader}[true]{} +\define@key{loaddb}{keys}{% + \dtl@entrycr=0\relax + \@for\@dtl@key:=#1\do + {% + \advance\dtl@entrycr by 1\relax + \expandafter + \edef\csname @dtl@inky@\romannumeral\dtl@entrycr\endcsname{% + \@dtl@key}% + }% } -\newif\if@dtl@insertdone -\newcount\dtl@sortresult -\newcommand{\toks@gput@right@cx}[2]{% - \def\@toks@name{#1}% - \edef\@dtl@stuff{#2}% - \global\csname\@toks@name\endcsname\expandafter - \expandafter\expandafter{\expandafter\the - \csname\expandafter\@toks@name\expandafter\endcsname\@dtl@stuff}% +\define@key{loaddb}{headers}{% + \dtl@entrycr=0\relax + \@for\@dtl@head:=#1\do + {% + \advance\dtl@entrycr by 1\relax + \toks@=\expandafter{\@dtl@head}% + \expandafter + \edef\csname @dtl@inhd@\romannumeral\dtl@entrycr\endcsname{% + \the\toks@}% + }% } -\newcommand{\toks@gconcat@middle@cx}[4]{% - \def\@toks@name{#1}% - \edef\@dtl@stuff{#3}% - \global\csname\@toks@name\endcsname\expandafter\expandafter - \expandafter\expandafter\expandafter - \expandafter\expandafter{\expandafter\expandafter\expandafter - \the\expandafter\expandafter\expandafter#2% - \expandafter\@dtl@stuff\the#4}% +\newcommand*{\dtldefaultkey}{Column} +\newcommand*{\@dtl@readline}[2]{% + \read#1 to #2% + \dtl@trim#2% } -\newcommand*{\DTLadd}[3]{% -\DTLconverttodecimal{#2}{\@dtl@numi}% -\DTLconverttodecimal{#3}{\@dtl@numii}% -\FPadd{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}% -\ifx\@dtl@replaced\@empty - \DTLdecimaltolocale{\@dtl@tmp}{#1}% -\else - \DTLdecimaltocurrency{\@dtl@tmp}{#1}% -\fi +\newcommand*{\@dtl@readrawline}[2]{% + \@dtl@rawread#1 to #2% + \dtl@trim#2% + \dtl@domappings\@dtl@line } -\newcommand*{\DTLgadd}[3]{% -\DTLadd{\@dtl@tmpii}{#2}{#3}% -\global\let#1=\@dtl@tmpii + +\newcommand*{\DTLloaddb}{% + \let\@dtl@doreadline\@dtl@readline + \@dtlloaddb } -\newcommand*{\DTLaddall}[2]{% -\def\@dtl@sum{0}% -\@for\dtl@thisval:=#2\do{% - \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}% - \FPadd{\@dtl@sum}{\@dtl@sum}{\@dtl@num}% -}% -\ifx\@dtl@replaced\@empty - \DTLdecimaltolocale{\@dtl@sum}{#1}% -\else - \DTLdecimaltocurrency{\@dtl@sum}{#1}% -\fi +\newcommand*{\@dtlloaddb}[3][]{% + \IfFileExists{#3}{% + \begingroup + \catcode`\"12\relax + \dtlnoheaderfalse + \setkeys{loaddb}{#1}% + \openin\@dtl@read=#3% + \dtl@message{Reading `#3'}% + \DTLnewdb{#2}% + \ifeof\@dtl@read + \PackageWarning{datatool}{File `#3' has no data}% + \else + \ifdtlnoheader + \else + \loop + \@dtl@conditionfalse + \ifeof\@dtl@read + \else + \@dtl@doreadline\@dtl@read\@dtl@line + \ifx\@dtl@line\@longempty + \@dtl@conditiontrue + \fi + \fi + \if@dtl@condition + \repeat + \protected@edef\@dtl@lin@{% + \@dtl@separator\@dtl@line\@dtl@separator}% + \dtl@entrycr=0\relax + \loop + \expandafter\@dtl@lopoff\@dtl@lin@\to\@dtl@lin@\@dtl@key + \advance\dtl@entrycr by 1\relax + \expandafter\@dtl@toks\expandafter{\@dtl@key}% + \@ifundefined{@dtl@inky@\romannumeral\dtl@entrycr}% + {% + \expandafter + \edef\csname @dtl@inky@\romannumeral + \dtl@entrycr\endcsname{\the\@dtl@toks}% + }% + {% + \@ifundefined{@dtl@inhd@\romannumeral\dtl@entrycr}% + {% + \expandafter + \edef\csname @dtl@inhd@\romannumeral + \dtl@entrycr\endcsname{\the\@dtl@toks}% + }% + {}% + }% + \ifx\@dtl@lin@\@dtl@separator + \@dtl@conditionfalse + \else + \@dtl@conditiontrue + \fi + \if@dtl@condition + \repeat + \fi + \ifeof\@dtl@read + \ifdtlnoheader + \PackageWarning{datatool}{No data in `#3'}% + \else + \PackageWarning{datatool}{Only header row found in `#3'}% + \fi + \else + \@dtl@conditiontrue + \loop + \@dtl@doreadline\@dtl@read\@dtl@line + \ifx\@dtl@line\@longempty + \else + \@sDTLnewrow{#2}% + \expandafter\@dtl@toks\expandafter{\@dtl@line}% + \edef\@dtl@lin@{\@dtl@separator\the\@dtl@toks + \@dtl@separator}% + \dtl@entrycr=0\relax + {% + \@dtl@conditiontrue + \loop + \expandafter\@dtl@lopoff\@dtl@lin@\to + \@dtl@lin@\@dtl@thisentry + \advance\dtl@entrycr by 1\relax + \@ifundefined{@dtl@inky@\romannumeral\dtl@entrycr}% + {% + \edef\@dtl@thiskey{\dtldefaultkey + \number\dtl@entrycr}% + \expandafter\let + \csname @dtl@inky@\romannumeral + \dtl@entrycr\endcsname\@dtl@thiskey + }% + {% + \edef\@dtl@thiskey{% + \csname @dtl@inky@\romannumeral + \dtl@entrycr\endcsname}% + }% + \expandafter\@dtl@toks\expandafter{\@dtl@thisentry}% + \edef\@do@dtlnewentry{\noexpand\@sDTLnewdbentry + {#2}{\@dtl@thiskey}{\the\@dtl@toks}}% + \@do@dtlnewentry + \ifx\@dtl@lin@\@dtl@separator + \@dtl@conditionfalse + \fi + \if@dtl@condition + \repeat + }% + \fi + \ifeof\@dtl@read \@dtl@conditionfalse\fi + \if@dtl@condition + \repeat + \fi + \fi + \closein\@dtl@read + \edef\@dtl@maxcols{\expandafter + \number\csname dtlcols@#2\endcsname}% + \dtlgforint\dtl@entrycr=1\to\@dtl@maxcols\step1\do + {% + \@ifundefined{@dtl@inhd@\romannumeral\dtl@entrycr}% + {}% + {% + \expandafter\let\expandafter\@dtl@head + \csname @dtl@inhd@\romannumeral\dtl@entrycr\endcsname + \@dtl@toks=\expandafter{\@dtl@head}% + \edef\@dtl@dosetheader{\noexpand\@dtl@setheaderforindex + {#2}{\number\dtl@entrycr}{\the\@dtl@toks}}% + \@dtl@dosetheader + }% + }% + \endgroup + }{% + \PackageError{datatool}{Can't load database `#2' (file `#3' + doesn't exist)}{}% + }% } -\newcommand*{\DTLgaddall}[2]{% -\DTLaddall{\@dtl@tmpi}{#2}% -\global\let#1=\@dtl@tmpi +\newcommand{\dtl@trim}[1]{% +\def\@dtl@trmstr{}% +\expandafter\@dtl@starttrim#1\@nil% +\let#1=\@dtl@trmstr } -\newcommand*{\DTLsub}[3]{% -\DTLconverttodecimal{#2}{\@dtl@numi}% -\DTLconverttodecimal{#3}{\@dtl@numii}% -\FPsub{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}% -\ifx\@dtl@replaced\@empty - \DTLdecimaltolocale{\@dtl@tmp}{#1}% +\long\def\@dtl@starttrim#1#2{% +\ifx\par#1% + \def\@dtl@dotrim{\@dtl@trim{} #2}% \else - \DTLdecimaltocurrency{\@dtl@tmp}{#1}% + \def\@dtl@dotrim{\@dtl@trim#1#2}% \fi +\@dtl@dotrim% } -\newcommand*{\DTLgsub}[3]{% -\DTLsub{\@dtl@tmpii}{#2}{#3}% -\global\let#1=\@dtl@tmpii +\long\def\@dtl@trim#1 \@nil{\long\def\@dtl@trmstr{#1}} +\newcommand*\DTLloadrawdb{% + \let\@dtl@doreadline\@dtl@readrawline + \@dtlloaddb } -\newcommand*{\DTLmul}[3]{% -\let\@dtl@thisreplaced=\@empty -\DTLconverttodecimal{#2}{\@dtl@numi}% -\ifx\@dtl@replaced\@empty -\else - \let\@dtl@thisreplaced=\@dtl@replaced -\fi -\DTLconverttodecimal{#3}{\@dtl@numii}% -\ifx\@dtl@replaced\@empty -\else - \let\@dtl@thisreplaced=\@dtl@replaced -\fi -\FPmul{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}% -\ifx\@dtl@thisreplaced\@empty - \DTLdecimaltolocale{\@dtl@tmp}{#1}% +\begingroup +\catcode`\%=\active +\catcode`$=\active +\catcode`&=\active +\catcode`~=\active +\catcode`_=\active +\catcode`^=\active +\catcode`#=\active +\catcode`?=6\relax +\catcode`<=1\relax +\catcode`>=2\relax +\catcode`\{=\active +\catcode`\}=\active +\gdef\@dtl@rawread?1to?2<\relax +<<\catcode`\%=\active +\catcode`$=\active +\catcode`&=\active +\catcode`~=\active +\catcode`_=\active +\catcode`^=\active +\catcode`#=\active +\catcode`\{=\active +\catcode`\}=\active +\def%<\noexpand\%>\relax +\def$<\noexpand\$>\relax +\def&<\&>\relax +\def#<\#>\relax +\def~<\noexpand\textasciitilde>\relax +\def_<\noexpand\_>\relax +\def^<\noexpand\textasciicircum>\relax +\@dtl@activatebraces +\@dtl@doreadraw?1?2>>> +\gdef\@dtl@doreadraw?1?2<\relax +\read?1 to \tmp +\xdef?2<\tmp>\relax +> +\endgroup +\begingroup +\catcode`\{=\active +\catcode`\}=\active +\catcode`<=1\relax +\catcode`>=2\relax +\gdef\@dtl@activatebraces<% + \catcode`\{=\active + \catcode`\}=\active + \def{<\noexpand\{>% + \def}<\noexpand\}>% +>% +\endgroup +\newcommand*{\DTLrawmap}[2]{% +\expandafter\@dtl@toks\expandafter{\@dtl@rawmappings}% +\ifx\@dtl@rawmappings\@empty + \def\@dtl@rawmappings{{#1}{#2}}% \else - \DTLdecimaltocurrency{\@dtl@tmp}{#1}% + \def\@dtl@tmp{{#1}{#2}} + \protected@edef\@dtl@rawmappings{\the\@dtl@toks,\@dtl@tmp} \fi } -\newcommand*{\DTLgmul}[3]{% -\DTLmul{\@dtl@tmpii}{#2}{#3}% -\global\let#1=\@dtl@tmpii +\newcommand*{\@dtl@rawmappings}{} +\newcommand*{\dtl@domappings}[1]{% +\@for\@dtl@map:=\@dtl@rawmappings\do{% + \expandafter\DTLsubstitute\expandafter#1\@dtl@map +}} +\newcommand*{\DTLifinlist}[4]{% + \def\@dtl@doifinlist##1,#1,##2\end@dtl@doifinlist{% + \def\@before{##1}% + \def\@after{##2}% + }% + \expandafter\@dtl@doifinlist\expandafter,#2,#1,\@nil + \end@dtl@doifinlist + \ifx\@after\@nnil + #4% + \else + #3% + \fi } -\newcommand*{\DTLdiv}[3]{% -\let\@dtl@thisreplaced=\@empty -\DTLconverttodecimal{#2}{\@dtl@numi}% +\newcommand*{\dtl@choplast}[3]{% +\let#2\@empty +\let#3\@empty +\@for\@dtl@element:=#1\do{% +\ifx#3\@empty +\else + \ifx#2\@empty + \expandafter\toks@\expandafter{#3}% + \edef#2{{\the\toks@}}% + \else + \expandafter\toks@\expandafter{#3}% + \expandafter\@dtl@toks\expandafter{#2}% + \edef#2{\the\@dtl@toks,{\the\toks@}}% + \fi +\fi +\let#3=\@dtl@element% +}% +} +\newcommand*{\dtl@chopfirst}[3]{% +\let#2=\@empty +\let#3=\@empty +\@for\@dtl@element:=#1\do{% + \let#2=\@dtl@element + \@endfortrue +}% +\if@endfor + \let#3=\@forremainder +\fi +\@endforfalse +} +\newcommand{\dtl@sortlist}[2]{% +\def\@dtl@sortedlist{}% +\@for\@dtl@currentrow:=#1\do{% +\expandafter\dtl@insertinto\expandafter + {\@dtl@currentrow}{\@dtl@sortedlist}{#2}% +\@endforfalse}% +\let#1=\@dtl@sortedlist +} +\newcommand{\dtl@insertinto}[3]{% +\def\@dtl@newsortedlist{}% +\@dtl@insertdonefalse +\@for\dtl@srtelement:=#2\do{% +\if@dtl@insertdone + \expandafter\toks@\expandafter{\dtl@srtelement}% + \edef\@dtl@newstuff{{\the\toks@}}% +\else + \expandafter#3\expandafter{\dtl@srtelement}{#1}% + \ifnum\dtl@sortresult<0\relax + \expandafter\toks@\expandafter{\dtl@srtelement}% + \@dtl@toks{#1}% + \edef\@dtl@newstuff{{\the\@dtl@toks},{\the\toks@}}% + \@dtl@insertdonetrue + \else + \expandafter\toks@\expandafter{\dtl@srtelement}% + \edef\@dtl@newstuff{{\the\toks@}}% + \fi +\fi +\ifx\@dtl@newsortedlist\@empty + \expandafter\toks@\expandafter{\@dtl@newstuff}% + \edef\@dtl@newsortedlist{\the\toks@}% +\else + \expandafter\toks@\expandafter{\@dtl@newsortedlist}% + \expandafter\@dtl@toks\expandafter{\@dtl@newstuff}% + \edef\@dtl@newsortedlist{\the\toks@,\the\@dtl@toks}% +\fi +\@endforfalse +}% + \ifx\@dtl@newsortedlist\@empty + \@dtl@toks{#1}% + \edef\@dtl@newsortedlist{{\the\@dtl@toks}}% + \else + \if@dtl@insertdone + \else + \expandafter\toks@\expandafter{\@dtl@newsortedlist}% + \@dtl@toks{#1}% + \edef\@dtl@newsortedlist{\the\toks@,{\the\@dtl@toks}}% + \fi + \fi +\global\let#2=\@dtl@newsortedlist +} +\newif\if@dtl@insertdone +\newcount\dtl@sortresult +\newcommand{\toks@gput@right@cx}[2]{% + \def\@toks@name{#1}% + \edef\@dtl@stuff{#2}% + \global\csname\@toks@name\endcsname\expandafter + \expandafter\expandafter{\expandafter\the + \csname\expandafter\@toks@name\expandafter\endcsname\@dtl@stuff}% +} +\newcommand{\toks@gconcat@middle@cx}[4]{% + \def\@toks@name{#1}% + \edef\@dtl@stuff{#3}% + \global\csname\@toks@name\endcsname\expandafter\expandafter + \expandafter\expandafter\expandafter + \expandafter\expandafter{\expandafter\expandafter\expandafter + \the\expandafter\expandafter\expandafter#2% + \expandafter\@dtl@stuff\the#4}% +} +\newcommand*{\DTLadd}[3]{% +\DTLconverttodecimal{#2}{\@dtl@numi}% +\DTLconverttodecimal{#3}{\@dtl@numii}% +\FPadd{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}% +\ifx\@dtl@replaced\@empty + \DTLdecimaltolocale{\@dtl@tmp}{#1}% +\else + \DTLdecimaltocurrency{\@dtl@tmp}{#1}% +\fi +} +\newcommand*{\DTLgadd}[3]{% +\DTLadd{\@dtl@tmpii}{#2}{#3}% +\global\let#1=\@dtl@tmpii +} +\newcommand*{\DTLaddall}[2]{% +\def\@dtl@sum{0}% +\@for\dtl@thisval:=#2\do{% + \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}% + \FPadd{\@dtl@sum}{\@dtl@sum}{\@dtl@num}% +}% +\ifx\@dtl@replaced\@empty + \DTLdecimaltolocale{\@dtl@sum}{#1}% +\else + \DTLdecimaltocurrency{\@dtl@sum}{#1}% +\fi +} +\newcommand*{\DTLgaddall}[2]{% +\DTLaddall{\@dtl@tmpi}{#2}% +\global\let#1=\@dtl@tmpi +} +\newcommand*{\DTLsub}[3]{% +\DTLconverttodecimal{#2}{\@dtl@numi}% +\DTLconverttodecimal{#3}{\@dtl@numii}% +\FPsub{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}% +\ifx\@dtl@replaced\@empty + \DTLdecimaltolocale{\@dtl@tmp}{#1}% +\else + \DTLdecimaltocurrency{\@dtl@tmp}{#1}% +\fi +} +\newcommand*{\DTLgsub}[3]{% +\DTLsub{\@dtl@tmpii}{#2}{#3}% +\global\let#1=\@dtl@tmpii +} +\newcommand*{\DTLmul}[3]{% +\let\@dtl@thisreplaced=\@empty +\DTLconverttodecimal{#2}{\@dtl@numi}% +\ifx\@dtl@replaced\@empty +\else + \let\@dtl@thisreplaced=\@dtl@replaced +\fi +\DTLconverttodecimal{#3}{\@dtl@numii}% +\ifx\@dtl@replaced\@empty +\else + \let\@dtl@thisreplaced=\@dtl@replaced +\fi +\FPmul{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}% +\ifx\@dtl@thisreplaced\@empty + \DTLdecimaltolocale{\@dtl@tmp}{#1}% +\else + \DTLdecimaltocurrency{\@dtl@tmp}{#1}% +\fi +} +\newcommand*{\DTLgmul}[3]{% +\DTLmul{\@dtl@tmpii}{#2}{#3}% +\global\let#1=\@dtl@tmpii +} +\newcommand*{\DTLdiv}[3]{% +\let\@dtl@thisreplaced=\@empty +\DTLconverttodecimal{#2}{\@dtl@numi}% \ifx\@dtl@replaced\@empty \else \let\@dtl@thisreplaced=\@dtl@replaced @@ -4048,532 +4457,185 @@ \def\dtl@initials#1#2 #3{% \dtl@ifsingle{#1}{% \ifcat\noexpand#1\relax\relax - \def\@dtl@donextinitials{\@dtl@initials#2 {#3}}% -\else - \def\@dtl@donextinitials{\@dtl@initials#1#2 {#3}}% -\fi -}{% - \def\@dtl@donextinitials{\@dtl@initials{#1}#2 {#3}}% -}% -\@dtl@donextinitials -} -\def\@dtl@initials#1#2 #3{% -\dtl@initialshyphen#2-{}\dtl@endhyp -\expandafter\@dtl@toks\expandafter{\dtl@initialscmd}% -\toks@{#1}% -\ifx\dtl@inithyphen\@empty -\else - \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@}% - \expandafter\@dtl@toks\expandafter{\dtl@initialscmd}% - \expandafter\toks@\expandafter{\dtl@inithyphen}% -\fi -\def\dtl@tmp{#3}% -\ifx\@nnil\dtl@tmp - \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLafterinitials}% - \let\dtl@initialsnext=\@gobble -\else - \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLbetweeninitials}% - \let\dtl@initialsnext=\dtl@initials -\fi -\dtl@initialsnext{#3}} -\def\dtl@initialshyphen#1-#2#3\dtl@endhyp{% -\def\dtl@inithyphen{#2}% -\ifx\dtl@inithyphen\@empty -\else - \edef\dtl@inithyphen{% - \DTLafterinitialbeforehyphen\DTLinitialhyphen#2}% -\fi -} -\newcommand*{\DTLafterinitials}{.} -\newcommand*{\DTLbetweeninitials}{.} -\newcommand*{\DTLafterinitialbeforehyphen}{.} -\newcommand*{\DTLinitialhyphen}{-} -\newcommand*{\DTLifAllUpperCase}[3]{% -\protected@edef\dtl@tuc{#1}% -\expandafter\dtl@testifuppercase\dtl@tuc\@nil\relax -\if@dtl@condition#2\else#3\fi -} -\def\dtl@testifuppercase#1#2{% -\def\dtl@argi{#1}% -\def\dtl@argii{#2}% -\def\dtl@tc@rest{}% -\ifx\dtl@argi\@nnil - \let\dtl@testifuppernext=\@nnil -\else - \ifx#1\protect - \let\dtl@testifuppernext=\dtl@testifuppercase - \else - \ifx\uppercase#1\relax - \@dtl@conditiontrue - \def\dtl@tc@rest{}% - \let\dtl@testifuppernext=\relax - \else - \edef\dtl@tc@arg{\string#1}% - \expandafter\dtl@test@ifuppercase\dtl@tc@arg\end - \ifx\dtl@argii\@nnil - \let\dtl@testifuppernext=\@dtl@gobbletonil - \fi - \fi - \fi -\fi -\ifx\dtl@testifuppernext\relax - \edef\dtl@dotestifuppernext{% - \noexpand\dtl@testifuppercase}% -\else - \ifx\dtl@testifuppernext\@nnil - \edef\dtl@dotestifuppernext{#2}% - \else - \expandafter\toks@\expandafter{\dtl@tc@rest}% - \@dtl@toks{#2}% - \edef\dtl@dotestifuppernext{% - \noexpand\dtl@testifuppernext\the\toks@\the\@dtl@toks}% - \fi -\fi -\dtl@dotestifuppernext -} -\def\dtl@test@ifuppercase#1#2\end{% -\def\dtl@tc@rest{#2}% -\IfSubStringInString{\string\MakeUppercase}{#1#2}{% - \@dtl@conditiontrue - \def\dtl@tc@rest{}% - \let\dtl@testifuppernext=\relax -}{% - \IfSubStringInString{\string\MakeTextUppercase}{#1#2}{% - \@dtl@conditiontrue - \def\dtl@tc@rest{}% - \let\dtl@testifuppernext=\relax - }{% - \edef\dtl@uccode{\the\uccode`#1}% - \edef\dtl@code{\number`#1}% - \ifnum\dtl@code=\dtl@uccode\relax - \@dtl@conditiontrue - \let\dtl@testifuppernext=\dtl@testifuppercase - \else - \ifnum\dtl@uccode=0\relax - \@dtl@conditiontrue - \let\dtl@testifuppernext=\dtl@testifuppercase - \else - \@dtl@conditionfalse - \let\dtl@testifuppernext=\@dtl@gobbletonil - \fi - \fi -}}} -\newcommand*{\DTLifAllLowerCase}[3]{% -\protected@edef\dtl@tlc{#1}% -\expandafter\dtl@testiflowercase\dtl@tlc\@nil\relax -\if@dtl@condition#2\else#3\fi -} -\def\dtl@testiflowercase#1#2{% -\def\dtl@argi{#1}% -\def\dtl@argii{#2}% -\ifx\dtl@argi\@nnil - \let\dtl@testiflowernext=\@nnil -\else - \ifx#1\protect - \let\dtl@testiflowernext=\dtl@testiflowercase - \else - \ifx\lowercase#1\relax - \@dtl@conditiontrue - \def\dtl@tc@rest{}% - \let\dtl@testiflowernext=\relax - \else - \edef\dtl@tc@arg{\string#1}% - \expandafter\dtl@test@iflowercase\dtl@tc@arg\end - \ifx\dtl@argii\@nnil - \let\dtl@testiflowernext=\@dtl@gobbletonil - \fi - \fi - \fi -\fi -\ifx\dtl@testiflowernext\relax - \edef\dtl@dotestiflowernext{% - \noexpand\dtl@testiflowercase}% -\else - \ifx\dtl@testiflowernext\@nnil - \edef\dtl@dotestiflowernext{#2}% - \else - \expandafter\toks@\expandafter{\dtl@tc@rest}% - \@dtl@toks{#2}% - \edef\dtl@dotestiflowernext{% - \noexpand\dtl@testiflowernext\the\toks@\the\@dtl@toks}% - \fi -\fi -\dtl@dotestiflowernext -} -\def\dtl@test@iflowercase#1#2\end{% -\def\dtl@tc@rest{#2}% -\IfSubStringInString{\string\MakeLowercase}{#1#2}{% - \@dtl@conditiontrue - \def\dtl@tc@rest{}% - \let\dtl@testiflowernext=\relax -}{% - \IfSubStringInString{\string\MakeTextLowercase}{#1#2}{% - \@dtl@conditiontrue - \def\dtl@tc@rest{}% - \let\dtl@testiflowernext=\relax - }{% - \edef\dtl@lccode{\the\lccode`#1}% - \edef\dtl@code{\number`#1}% - \ifnum\dtl@code=\dtl@lccode\relax - \@dtl@conditiontrue - \let\dtl@testiflowernext=\dtl@testiflowercase - \else - \ifnum\dtl@lccode=0\relax - \@dtl@conditiontrue - \let\dtl@testiflowernext=\dtl@testiflowercase - \else - \@dtl@conditionfalse - \let\dtl@testiflowernext=\@dtl@gobbletonil - \fi - \fi -}}} -\newwrite\@dtl@write -\newcommand*{\DTLsavedb}[2]{% - \DTLifdbexists{#1}% - {% - \openout\@dtl@write=#2\relax - \def\@dtl@header{}% - \dtlforeachkey(\@dtl@key,\@dtl@col,\@dtl@type,\@dtl@head)% - \in{#1}\do - {% - \IfSubStringInString{\@dtl@separator}{\@dtl@key}% - {% - \ifx\@dtl@header\@empty - \protected@edef\@dtl@header{% - \@dtl@delimiter\@dtl@key\@dtl@delimiter}% - \else - \toks@=\expandafter{\@dtl@header}% - \protected@edef\@dtl@header{% - \the\toks@\@dtl@separator - \@dtl@delimiter\@dtl@key\@dtl@delimiter}% - \fi - }% - {% - \ifx\@dtl@header\@empty - \protected@edef\@dtl@header{\@dtl@key}% - \else - \toks@=\expandafter{\@dtl@header}% - \protected@edef\@dtl@header{\the\toks@ - \@dtl@separator\@dtl@key}% - \fi - }% - }% - \protected@write\@dtl@write{}{\@dtl@header}% - \@sDTLforeach{#1}{}% - {% - \def\@dtl@row{}% - \DTLforeachkeyinrow{\@dtl@val}% - {% - \IfSubStringInString{\@dtl@separator}{\@dtl@val}% - {% - \ifx\@dtl@row\@empty - \protected@edef\@dtl@row{% - \@dtl@delimiter\@dtl@val\@dtl@delimiter}% - \else - \toks@=\expandafter{\@dtl@row}% - \protected@edef\@dtl@row{\the\toks@\@dtl@separator - \@dtl@delimiter\@dtl@val\@dtl@delimiter}% - \fi - }% - {% - \ifx\@dtl@row\@empty - \protected@edef\@dtl@row{\@dtl@val}% - \else - \toks@=\expandafter{\@dtl@row}% - \protected@edef\@dtl@row{\the\toks@\@dtl@separator - \@dtl@val}% - \fi - }% - \protected@write\@dtl@write{}{\@dtl@row}% - }% - }% - \closeout\@dtl@write - }% - {% - \PackageError{datatool}{Can't save database `#1': no such - database}{}% - }% -} -\newcommand*{\DTLsavetexdb}[2]{% - \DTLifdbexists{#1}% - {% - \openout\@dtl@write=#2\relax - \protected@write\@dtl@write{}{\string\DTLnewdb{#1}}% - \@sDTLforeach{#1}{}% - {% - \protected@write\@dtl@write{}{\string\DTLnewrow*{#1}}% - \DTLforeachkeyinrow{\@dtl@val}% - {% - \DTLifnull{\@dtl@val}% - {\def\@dtl@val{}}% - {}% - \protected@write\@dtl@write{}{% - \string\DTLnewdbentry*{#1}{\dtlkey}{\@dtl@val}}% - }% - }% - \dtlforeachkey(\@dtl@k,\@dtl@c,\@dtl@t,\@dtl@h)\in{#1}\do - {% - \@onelevel@sanitize\@dtl@h - \protected@write\@dtl@write{}{% - \string\DTLsetheader*{#1}{\@dtl@k}{\@dtl@h}}% - }% - \closeout\@dtl@write - }% - {% - \PackageError{datatool}{Can't save database `#1': no such - database}{}% - }% -} -\newcommand{\@longempty}{} -\newread\@dtl@read -\newcount\dtl@entrycr -\define@boolkey{loaddb}[dtl]{noheader}[true]{} -\define@key{loaddb}{keys}{% - \dtl@entrycr=0\relax - \@for\@dtl@key:=#1\do - {% - \advance\dtl@entrycr by 1\relax - \expandafter - \edef\csname @dtl@inky@\romannumeral\dtl@entrycr\endcsname{% - \@dtl@key}% - }% -} -\define@key{loaddb}{headers}{% - \dtl@entrycr=0\relax - \@for\@dtl@head:=#1\do - {% - \advance\dtl@entrycr by 1\relax - \toks@=\expandafter{\@dtl@head}% - \expandafter - \edef\csname @dtl@inhd@\romannumeral\dtl@entrycr\endcsname{% - \the\toks@}% - }% -} -\newcommand*{\dtldefaultkey}{Column} -\newcommand*{\@dtl@readline}[2]{% - \read#1 to #2% - \dtl@trim#2% -} -\newcommand*{\@dtl@readrawline}[2]{% - \@dtl@rawread#1 to #2% - \dtl@trim#2% - \dtl@domappings\@dtl@line -} - -\newcommand*{\DTLloaddb}{% - \let\@dtl@doreadline\@dtl@readline - \@dtlloaddb -} -\newcommand*{\@dtlloaddb}[3][]{% - \IfFileExists{#3}{% - \begingroup - \catcode`\"12\relax - \dtlnoheaderfalse - \setkeys{loaddb}{#1}% - \openin\@dtl@read=#3% - \dtl@message{Reading `#3'}% - \DTLnewdb{#2}% - \ifeof\@dtl@read - \PackageWarning{datatool}{File `#3' has no data}% - \else - \ifdtlnoheader - \else - \loop - \@dtl@conditionfalse - \ifeof\@dtl@read - \else - \@dtl@doreadline\@dtl@read\@dtl@line - \ifx\@dtl@line\@longempty - \@dtl@conditiontrue - \fi - \fi - \if@dtl@condition - \repeat - \protected@edef\@dtl@lin@{% - \@dtl@separator\@dtl@line\@dtl@separator}% - \dtl@entrycr=0\relax - \loop - \expandafter\@dtl@lopoff\@dtl@lin@\to\@dtl@lin@\@dtl@key - \advance\dtl@entrycr by 1\relax - \expandafter\@dtl@toks\expandafter{\@dtl@key}% - \@ifundefined{@dtl@inky@\romannumeral\dtl@entrycr}% - {% - \expandafter - \edef\csname @dtl@inky@\romannumeral - \dtl@entrycr\endcsname{\the\@dtl@toks}% - }% - {% - \@ifundefined{@dtl@inhd@\romannumeral\dtl@entrycr}% - {% - \expandafter - \edef\csname @dtl@inhd@\romannumeral - \dtl@entrycr\endcsname{\the\@dtl@toks}% - }% - {}% - }% - \ifx\@dtl@lin@\@dtl@separator - \@dtl@conditionfalse - \else - \@dtl@conditiontrue - \fi - \if@dtl@condition - \repeat - \fi - \ifeof\@dtl@read - \ifdtlnoheader - \PackageWarning{datatool}{No data in `#3'}% - \else - \PackageWarning{datatool}{Only header row found in `#3'}% - \fi - \else - \@dtl@conditiontrue - \loop - \@dtl@doreadline\@dtl@read\@dtl@line - \ifx\@dtl@line\@longempty - \else - \@sDTLnewrow{#2}% - \expandafter\@dtl@toks\expandafter{\@dtl@line}% - \edef\@dtl@lin@{\@dtl@separator\the\@dtl@toks - \@dtl@separator}% - \dtl@entrycr=0\relax - {% - \@dtl@conditiontrue - \loop - \expandafter\@dtl@lopoff\@dtl@lin@\to - \@dtl@lin@\@dtl@thisentry - \advance\dtl@entrycr by 1\relax - \@ifundefined{@dtl@inky@\romannumeral\dtl@entrycr}% - {% - \edef\@dtl@thiskey{\dtldefaultkey - \number\dtl@entrycr}% - \expandafter\let - \csname @dtl@inky@\romannumeral - \dtl@entrycr\endcsname\@dtl@thiskey - }% - {% - \edef\@dtl@thiskey{% - \csname @dtl@inky@\romannumeral - \dtl@entrycr\endcsname}% - }% - \expandafter\@dtl@toks\expandafter{\@dtl@thisentry}% - \edef\@do@dtlnewentry{\noexpand\@sDTLnewdbentry - {#2}{\@dtl@thiskey}{\the\@dtl@toks}}% - \@do@dtlnewentry - \ifx\@dtl@lin@\@dtl@separator - \@dtl@conditionfalse - \fi - \if@dtl@condition - \repeat - }% - \fi - \ifeof\@dtl@read \@dtl@conditionfalse\fi - \if@dtl@condition - \repeat - \fi - \fi - \closein\@dtl@read - \edef\@dtl@maxcols{\expandafter - \number\csname dtlcols@#2\endcsname}% - \dtlgforint\dtl@entrycr=1\to\@dtl@maxcols\step1\do - {% - \@ifundefined{@dtl@inhd@\romannumeral\dtl@entrycr}% - {}% - {% - \expandafter\let\expandafter\@dtl@head - \csname @dtl@inhd@\romannumeral\dtl@entrycr\endcsname - \@dtl@toks=\expandafter{\@dtl@head}% - \edef\@dtl@dosetheader{\noexpand\@dtl@setheaderforindex - {#2}{\number\dtl@entrycr}{\the\@dtl@toks}}% - \@dtl@dosetheader - }% - }% - \endgroup - }{% - \PackageError{datatool}{Can't load database `#2' (file `#3' - doesn't exist)}{}% - }% + \def\@dtl@donextinitials{\@dtl@initials#2 {#3}}% +\else + \def\@dtl@donextinitials{\@dtl@initials#1#2 {#3}}% +\fi +}{% + \def\@dtl@donextinitials{\@dtl@initials{#1}#2 {#3}}% +}% +\@dtl@donextinitials } -\newcommand{\dtl@trim}[1]{% -\def\@dtl@trmstr{}% -\expandafter\@dtl@starttrim#1\@nil% -\let#1=\@dtl@trmstr +\def\@dtl@initials#1#2 #3{% +\dtl@initialshyphen#2-{}\dtl@endhyp +\expandafter\@dtl@toks\expandafter{\dtl@initialscmd}% +\toks@{#1}% +\ifx\dtl@inithyphen\@empty +\else + \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@}% + \expandafter\@dtl@toks\expandafter{\dtl@initialscmd}% + \expandafter\toks@\expandafter{\dtl@inithyphen}% +\fi +\def\dtl@tmp{#3}% +\ifx\@nnil\dtl@tmp + \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLafterinitials}% + \let\dtl@initialsnext=\@gobble +\else + \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLbetweeninitials}% + \let\dtl@initialsnext=\dtl@initials +\fi +\dtl@initialsnext{#3}} +\def\dtl@initialshyphen#1-#2#3\dtl@endhyp{% +\def\dtl@inithyphen{#2}% +\ifx\dtl@inithyphen\@empty +\else + \edef\dtl@inithyphen{% + \DTLafterinitialbeforehyphen\DTLinitialhyphen#2}% +\fi } -\long\def\@dtl@starttrim#1#2{% -\ifx\par#1% - \def\@dtl@dotrim{\@dtl@trim{} #2}% +\newcommand*{\DTLafterinitials}{.} +\newcommand*{\DTLbetweeninitials}{.} +\newcommand*{\DTLafterinitialbeforehyphen}{.} +\newcommand*{\DTLinitialhyphen}{-} +\newcommand*{\DTLifAllUpperCase}[3]{% +\protected@edef\dtl@tuc{#1}% +\expandafter\dtl@testifuppercase\dtl@tuc\@nil\relax +\if@dtl@condition#2\else#3\fi +} +\def\dtl@testifuppercase#1#2{% +\def\dtl@argi{#1}% +\def\dtl@argii{#2}% +\def\dtl@tc@rest{}% +\ifx\dtl@argi\@nnil + \let\dtl@testifuppernext=\@nnil \else - \def\@dtl@dotrim{\@dtl@trim#1#2}% + \ifx#1\protect + \let\dtl@testifuppernext=\dtl@testifuppercase + \else + \ifx\uppercase#1\relax + \@dtl@conditiontrue + \def\dtl@tc@rest{}% + \let\dtl@testifuppernext=\relax + \else + \edef\dtl@tc@arg{\string#1}% + \expandafter\dtl@test@ifuppercase\dtl@tc@arg\end + \ifx\dtl@argii\@nnil + \let\dtl@testifuppernext=\@dtl@gobbletonil + \fi + \fi + \fi \fi -\@dtl@dotrim% +\ifx\dtl@testifuppernext\relax + \edef\dtl@dotestifuppernext{% + \noexpand\dtl@testifuppercase}% +\else + \ifx\dtl@testifuppernext\@nnil + \edef\dtl@dotestifuppernext{#2}% + \else + \expandafter\toks@\expandafter{\dtl@tc@rest}% + \@dtl@toks{#2}% + \edef\dtl@dotestifuppernext{% + \noexpand\dtl@testifuppernext\the\toks@\the\@dtl@toks}% + \fi +\fi +\dtl@dotestifuppernext } -\long\def\@dtl@trim#1 \@nil{\long\def\@dtl@trmstr{#1}} -\newcommand*\DTLloadrawdb{% - \let\@dtl@doreadline\@dtl@readrawline - \@dtlloaddb +\def\dtl@test@ifuppercase#1#2\end{% +\def\dtl@tc@rest{#2}% +\IfSubStringInString{\string\MakeUppercase}{#1#2}{% + \@dtl@conditiontrue + \def\dtl@tc@rest{}% + \let\dtl@testifuppernext=\relax +}{% + \IfSubStringInString{\string\MakeTextUppercase}{#1#2}{% + \@dtl@conditiontrue + \def\dtl@tc@rest{}% + \let\dtl@testifuppernext=\relax + }{% + \edef\dtl@uccode{\the\uccode`#1}% + \edef\dtl@code{\number`#1}% + \ifnum\dtl@code=\dtl@uccode\relax + \@dtl@conditiontrue + \let\dtl@testifuppernext=\dtl@testifuppercase + \else + \ifnum\dtl@uccode=0\relax + \@dtl@conditiontrue + \let\dtl@testifuppernext=\dtl@testifuppercase + \else + \@dtl@conditionfalse + \let\dtl@testifuppernext=\@dtl@gobbletonil + \fi + \fi +}}} +\newcommand*{\DTLifAllLowerCase}[3]{% +\protected@edef\dtl@tlc{#1}% +\expandafter\dtl@testiflowercase\dtl@tlc\@nil\relax +\if@dtl@condition#2\else#3\fi } -\begingroup -\catcode`\%=\active -\catcode`$=\active -\catcode`&=\active -\catcode`~=\active -\catcode`_=\active -\catcode`^=\active -\catcode`#=\active -\catcode`?=6\relax -\catcode`<=1\relax -\catcode`>=2\relax -\catcode`\{=\active -\catcode`\}=\active -\gdef\@dtl@rawread?1to?2<\relax -<<\catcode`\%=\active -\catcode`$=\active -\catcode`&=\active -\catcode`~=\active -\catcode`_=\active -\catcode`^=\active -\catcode`#=\active -\catcode`\{=\active -\catcode`\}=\active -\def%<\noexpand\%>\relax -\def$<\noexpand\$>\relax -\def&<\&>\relax -\def#<\#>\relax -\def~<\noexpand\textasciitilde>\relax -\def_<\noexpand\_>\relax -\def^<\noexpand\textasciicircum>\relax -\@dtl@activatebraces -\@dtl@doreadraw?1?2>>> -\gdef\@dtl@doreadraw?1?2<\relax -\read?1 to \tmp -\xdef?2<\tmp>\relax -> -\endgroup -\begingroup -\catcode`\{=\active -\catcode`\}=\active -\catcode`<=1\relax -\catcode`>=2\relax -\gdef\@dtl@activatebraces<% - \catcode`\{=\active - \catcode`\}=\active - \def{<\noexpand\{>% - \def}<\noexpand\}>% ->% -\endgroup -\newcommand*{\DTLrawmap}[2]{% -\expandafter\@dtl@toks\expandafter{\@dtl@rawmappings}% -\ifx\@dtl@rawmappings\@empty - \def\@dtl@rawmappings{{#1}{#2}}% +\def\dtl@testiflowercase#1#2{% +\def\dtl@argi{#1}% +\def\dtl@argii{#2}% +\ifx\dtl@argi\@nnil + \let\dtl@testiflowernext=\@nnil \else - \def\@dtl@tmp{{#1}{#2}} - \protected@edef\@dtl@rawmappings{\the\@dtl@toks,\@dtl@tmp} + \ifx#1\protect + \let\dtl@testiflowernext=\dtl@testiflowercase + \else + \ifx\lowercase#1\relax + \@dtl@conditiontrue + \def\dtl@tc@rest{}% + \let\dtl@testiflowernext=\relax + \else + \edef\dtl@tc@arg{\string#1}% + \expandafter\dtl@test@iflowercase\dtl@tc@arg\end + \ifx\dtl@argii\@nnil + \let\dtl@testiflowernext=\@dtl@gobbletonil + \fi + \fi + \fi +\fi +\ifx\dtl@testiflowernext\relax + \edef\dtl@dotestiflowernext{% + \noexpand\dtl@testiflowercase}% +\else + \ifx\dtl@testiflowernext\@nnil + \edef\dtl@dotestiflowernext{#2}% + \else + \expandafter\toks@\expandafter{\dtl@tc@rest}% + \@dtl@toks{#2}% + \edef\dtl@dotestiflowernext{% + \noexpand\dtl@testiflowernext\the\toks@\the\@dtl@toks}% + \fi \fi +\dtl@dotestiflowernext } -\newcommand*{\@dtl@rawmappings}{} -\newcommand*{\dtl@domappings}[1]{% -\@for\@dtl@map:=\@dtl@rawmappings\do{% - \expandafter\DTLsubstitute\expandafter#1\@dtl@map -}} +\def\dtl@test@iflowercase#1#2\end{% +\def\dtl@tc@rest{#2}% +\IfSubStringInString{\string\MakeLowercase}{#1#2}{% + \@dtl@conditiontrue + \def\dtl@tc@rest{}% + \let\dtl@testiflowernext=\relax +}{% + \IfSubStringInString{\string\MakeTextLowercase}{#1#2}{% + \@dtl@conditiontrue + \def\dtl@tc@rest{}% + \let\dtl@testiflowernext=\relax + }{% + \edef\dtl@lccode{\the\lccode`#1}% + \edef\dtl@code{\number`#1}% + \ifnum\dtl@code=\dtl@lccode\relax + \@dtl@conditiontrue + \let\dtl@testiflowernext=\dtl@testiflowercase + \else + \ifnum\dtl@lccode=0\relax + \@dtl@conditiontrue + \let\dtl@testiflowernext=\dtl@testiflowercase + \else + \@dtl@conditionfalse + \let\dtl@testiflowernext=\@dtl@gobbletonil + \fi + \fi +}}} \newcommand{\DTLsubstitute}[3]{% \expandafter\DTLsplitstring\expandafter {#1}{#2}{\@dtl@beforepart}{\@dtl@afterpart}% @@ -4628,19 +4690,6 @@ \@dtl@dosubstnext{#1}{#2}% } \def\@dtl@dosubstitutenoop#1#2{} -\newcommand*{\DTLifinlist}[4]{% - \def\@dtl@doifinlist##1,#1,##2\end@dtl@doifinlist{% - \def\@before{##1}% - \def\@after{##2}% - }% - \expandafter\@dtl@doifinlist\expandafter,#2,#1,\@nil - \end@dtl@doifinlist - \ifx\@after\@nnil - #4% - \else - #3% - \fi -} \newcommand*{\@dtl@currencies}{\$,\pounds} \newcommand*{\DTLnewcurrencysymbol}[1]{% \expandafter\toks@\expandafter{\@dtl@currencies}% diff --git a/Master/texmf-dist/tex/latex/datatool/person.sty b/Master/texmf-dist/tex/latex/datatool/person.sty new file mode 100644 index 00000000000..3a6ea1b6d27 --- /dev/null +++ b/Master/texmf-dist/tex/latex/datatool/person.sty @@ -0,0 +1,638 @@ +%% +%% This is file `person.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% datatool.dtx (with options: `person.sty,package') +%% +%% datatool.dtx +%% Copyright 2009 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 datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst, person.sty. +%% +%% \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 \~} +%% load student information from file "students.csv" +%% Iterate through the student database: +%% Define "anon": +%% Do the letter: +%% Undefine "anon": +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{person}[2009/11/15 v1.01 (NLCT)] +\RequirePackage{ifthen} +\RequirePackage{datatool} +\newcounter{people} +\newcounter{person} +\newcommand*{\@people@list}{,} +\newcommand*{\@get@firstperson}[1]{% + \expandafter\@@get@firstperson\@people@list,\@nil{#1}} + \def\@@get@firstperson,#1,#2\@nil#3{% + \def#3{#1}% +} +\newcommand*{\malelabels}{male,Male,MALE,M,m} +\newcommand*{\addmalelabel}[1]{% + \expandafter\@dtl@toksA\expandafter{\malelabels}% + \expandafter\@dtl@toksB\expandafter{#1}% + \edef\malelabels{\the\@dtl@toksA,\the\@dtl@toksB}% +} +\newcommand*{\addfemalelabel}[1]{% + \expandafter\@dtl@toksA\expandafter{\femalelabels}% + \expandafter\@dtl@toksB\expandafter{#1}% + \edef\femalelabels{\the\@dtl@toksA,\the\@dtl@toksB}% +} +\newcommand*{\femalelabels}{female,Female,FEMALE,F,f} +\newcommand{\ifmalelabel}[3]{% + \expandafter\DTLifinlist\expandafter{#1}{\malelabels}{#2}{#3}% +} +\newcommand{\iffemalelabel}[3]{% + \expandafter\DTLifinlist\expandafter{#1}{\femalelabels}{#2}{#3}% +} +\newcommand*{\newperson}[4][anon]{% + \@ifundefined{person@#1@name}% + {% + \ifmalelabel{#4}% + {% + \expandafter\gdef\csname person@#1@gender\endcsname{male}% + }% + {% + \iffemalelabel{#4}% + {% + \expandafter\gdef\csname person@#1@gender\endcsname{female}% + }% + {% + \PackageError{person}{Unknown gender `#4' for person + `#1'}{Allowed gender labels are: \malelabels\space or + \femalelabels}% + \@namedef{person@#1@gender}{other}% + }% + }% + \expandafter + \protected@xdef\csname person@#1@fullname\endcsname{#2}% + \expandafter + \protected@xdef\csname person@#1@name\endcsname{#3}% + \protected@xdef\@people@list{\@people@list#1,}% + \stepcounter{people}% + }% + {% + \PackageError{person}{Person `#1' has already been defined}{}% + }% +} +\newcommand*{\removeperson}[1][anon]{% + \edef\@person@label{#1}% + \expandafter\@removeperson\expandafter{\@person@label}% +} +\newcommand*{\@removeperson}[1]{% + \ifpersonexists{#1}% + {% + \def\@remove@person##1,#1,##2\@nil{% + \def\@prsn@pre{##1}\def\@prsn@post{##2}}% + \expandafter\@remove@person\@people@list\@nil + \xdef\@people@list{\@prsn@pre,\@prsn@post}% + \addtocounter{people}{-1}% + \expandafter\global\expandafter + \let\csname person@#1@name\endcsname\undefined + \expandafter\global\expandafter + \let\csname person@#1@fullname\endcsname\undefined + \expandafter\global\expandafter + \let\csname person@#1@gender\endcsname\undefined + }% + {% + \PackageError{person}{Can't remove person `#1': no such + person}{}% + }% +} +\newcommand*{\removepeople}[1]{% + \@for\@thisperson:=#1\do{% + \ifx\@thisperson\@empty + \else + \expandafter\removeperson\expandafter[\@thisperson]% + \fi + }% +} +\newcommand*{\removeallpeople}{% + \@for\@thisperson:=\@people@list\do{% + \expandafter\global\expandafter + \let\csname person@\@thisperson @name\endcsname\undefined + \expandafter\global\expandafter + \let\csname person@\@thisperson @fullname\endcsname\undefined + \expandafter\global\expandafter + \let\csname person@\@thisperson @gender\endcsname\undefined + }% + \setcounter{people}{0}% + \gdef\@people@list{,}% +} +\newcommand{\ifpersonexists}[3]{% + \@ifundefined{person@#1@name}{#3}{#2}% +} +\newcommand{\ifmale}[3]{% + \ifpersonexists{#1}% + {% + \edef\@gender{\csname person@\@thisperson @gender\endcsname}% + \ifx\@gender\@male@label + #2% + \else + #3% + \fi + }% + {% + \PackageError{person}{Person `#1' doesn't exist.}{}% + }% +} +\def\@male@label{male} +\newcommand{\ifallmale}[3][\@people@list]{% + \@for\@thisperson:=#1\do{% + \ifpersonexists{\@thisperson}% + {% + \edef\@gender{\csname person@\@thisperson @gender\endcsname}% + \ifx\@gender\@male@label + \else + \@endfortrue + \fi + }% + {% + \PackageError{person}{Person `#1' doesn't exist.}{}% + }% + }% + \if@endfor + #3% + \else + #2% + \fi +} +\newcommand{\iffemale}[3]{% + \ifpersonexists{#1}% + {% + \edef\@gender{\csname person@\@thisperson @gender\endcsname}% + \ifx\@gender\@female@label + #2% + \else + #3% + \fi + }% + {% + \PackageError{person}{Person `#1' doesn't exist.}{}% + }% +} +\def\@female@label{female} +\newcommand{\ifallfemale}[3][\@people@list]{% + \@for\@thisperson:=#1\do{% + \edef\@gender{\csname person@\@thisperson @gender\endcsname}% + \ifx\@gender\@female@label + \else + \@endfortrue + \fi + }% + \if@endfor + #3% + \else + #2% + \fi +} +\def\foreachperson(#1,#2,#3,#4)#5{% + \ifx#5\in + \def\@do@foreachperson{\@foreachperson(#1,#2,#3,#4)#5}% + \else + \def\@do@foreachperson{% + \@foreachperson(#1,#2,#3,#4)\in\@people@list#5}% + \fi + \@do@foreachperson +} +\long\def\@foreachperson(#1,#2,#3,#4)\in#5\do#6{% + \@for#4:=#5\do{% + \ifx#4\@empty + \else + \ifpersonexists{#4}% + {% + \expandafter + \let\expandafter#1\csname person@#4@name\endcsname + \expandafter + \let\expandafter#2\csname person@#4@fullname\endcsname + \expandafter + \let\expandafter#3\csname person@#4@gender\endcsname + \ifx#3\@male@label + \let#3\malename + \else + \ifx#3\@female@label + \let#3\femalename + \fi + \fi + #6% + }% + {% + \PackageError{person}{Person `#4' doesn't exist}{}% + }% + \fi + }% +} +\newcommand*{\malepronoun}{he} +\newcommand*{\femalepronoun}{she} +\newcommand*{\pluralpronoun}{they} +\newcommand*{\maleobjpronoun}{him} +\newcommand*{\femaleobjpronoun}{her} +\newcommand*{\pluralobjpronoun}{them} +\newcommand*{\malepossadj}{his} +\newcommand*{\femalepossadj}{her} +\newcommand*{\pluralpossadj}{their} +\newcommand*{\maleposspronoun}{his} +\newcommand*{\femaleposspronoun}{hers} +\newcommand*{\pluralposspronoun}{theirs} +\newcommand*{\malechild}{son} +\newcommand*{\femalechild}{daughter} +\newcommand*{\pluralchild}{children} +\newcommand*{\malechildren}{sons} +\newcommand*{\femalechildren}{daughters} +\newcommand*{\maleparent}{father} +\newcommand*{\femaleparent}{mother} +\newcommand*{\pluralparent}{parents} +\newcommand*{\malesibling}{brother} +\newcommand*{\femalesibling}{sister} +\newcommand*{\pluralsibling}{siblings} +\newcommand*{\malesiblings}{brothers} +\newcommand*{\femalesiblings}{sisters} +\providecommand*{\andname}{and} +\newcommand*{\malename}{male} +\newcommand*{\femalename}{female} +\newcommand*{\personsep}{, } +\newcommand*{\personlastsep}{\space\andname\space} +\newcommand*{\twopeoplesep}{\space\andname\space} +\newcommand*{\personfullname}[1][anon]{% + \@ifundefined{person@#1@fullname}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \csname person@#1@fullname\endcsname + }% +} +\newcommand*{\peoplefullname}{% + \setcounter{person}{1}% + \@for\@thisperson:=\@people@list\do{% + \ifthenelse{\equal{\@thisperson}{}}% + {}% + {% + \personfullname[\@thisperson]% + \stepcounter{person}% + \ifnum\c@people=1\relax + \else + \ifnum\c@person=\c@people + \ifnum\c@people=2\relax + \twopeoplesep + \else + \personlastsep + \fi + \else + \ifnum\c@person<\c@people + \personsep + \fi + \fi + \fi + }% + }% +} +\newcommand*{\personname}[1][anon]{% + \@ifundefined{person@#1@name}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \csname person@#1@name\endcsname + }% +} +\newcommand*{\peoplename}{% + \setcounter{person}{1}% + \@for\@thisperson:=\@people@list\do{% + \ifthenelse{\equal{\@thisperson}{}}% + {}% + {% + \personname[\@thisperson]% + \stepcounter{person}% + \ifnum\c@people=1\relax + \else + \ifnum\c@person=\c@people + \ifnum\c@people=2\relax + \twopeoplesep + \else + \personlastsep + \fi + \else + \ifnum\c@person<\c@people + \personsep + \fi + \fi + \fi + }% + }% +} +\newcommand*{\personpronoun}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender pronoun\endcsname + }% +} +\newcommand*{\Personpronoun}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter + \MakeUppercase\csname\@gender pronoun\endcsname + }% +} +\newcommand*{\peoplepronoun}{% + \ifnum\c@people>1\relax + \pluralpronoun + \else + \@get@firstperson{\@thisperson}% + \personpronoun[\@thisperson]% + \fi +} +\newcommand*{\Peoplepronoun}{% + \ifnum\c@people>1\relax + \expandafter\MakeUppercase\pluralpronoun + \else + \@get@firstperson{\@thisperson}% + \Personpronoun[\@thisperson]% + \fi +} +\newcommand*{\personobjpronoun}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender objpronoun\endcsname + }% +} +\newcommand*{\Personobjpronoun}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter + \MakeUppercase\csname\@gender objpronoun\endcsname + }% +} +\newcommand*{\peopleobjpronoun}{% + \ifnum\c@people>1\relax + \pluralobjpronoun + \else + \@get@firstperson{\@thisperson}% + \personobjpronoun[\@thisperson]% + \fi +} +\newcommand*{\Peopleobjpronoun}{% + \ifnum\c@people>1\relax + \expandafter\MakeUppercase\pluralobjpronoun + \else + \@get@firstperson{\@thisperson}% + \Personobjpronoun[\@thisperson]% + \fi +} +\newcommand*{\personpossadj}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender possadj\endcsname + }% +} +\newcommand*{\Personpossadj}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter + \MakeUppercase\csname\@gender possadj\endcsname + }% +} +\newcommand*{\peoplepossadj}{% + \ifnum\c@people>1\relax + \pluralpossadj + \else + \@get@firstperson{\@thisperson}% + \personpossadj[\@thisperson]% + \fi +} +\newcommand*{\Peoplepossadj}{% + \ifnum\c@people>1\relax + \expandafter\MakeUppercase\pluralpossadj + \else + \@get@firstperson{\@thisperson}% + \Personpossadj[\@thisperson]% + \fi +} +\newcommand*{\personposspronoun}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender posspronoun\endcsname + }% +} +\newcommand*{\Personposspronoun}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter + \MakeUppercase\csname\@gender posspronoun\endcsname + }% +} +\newcommand*{\peopleposspronoun}{% + \ifnum\c@people>1\relax + \pluralposspronoun + \else + \@get@firstperson{\@thisperson}% + \personposspronoun[\@thisperson]% + \fi +} +\newcommand*{\Peopleposspronoun}{% + \ifnum\c@people>1\relax + \expandafter\MakeUppercase\pluralposspronoun + \else + \@get@firstperson{\@thisperson}% + \Personposspronoun[\@thisperson]% + \fi +} +\newcommand*{\personchild}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender child\endcsname + }% +} +\newcommand*{\Personchild}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter\MakeUppercase + \csname\@gender child\endcsname + }% +} +\newcommand*{\peoplechild}{% + \ifnum\c@people>1\relax + \ifallmale + {\malechildren}% + {\ifallfemale{\femalechildren}{\pluralchild}}% + \else + \@get@firstperson{\@thisperson}% + \personchild[\@thisperson]% + \fi +} +\newcommand*{\Peoplechild}{% + \ifnum\c@people>1\relax + \ifallmale + {\expandafter\MakeUppercase\malechildren}% + {\ifallfemale + {\expandafter\MakeUppercase\femalechildren} + {\expandafter\MakeUppercase\pluralchild}}% + \else + \@get@firstperson{\@thisperson}% + \Personchild[\@thisperson]% + \fi +} +\newcommand*{\personparent}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender parent\endcsname + }% +} +\newcommand*{\Personparent}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter\MakeUppercase + \csname\@gender parent\endcsname + }% +} +\newcommand*{\peopleparent}{% + \ifnum\c@people>1\relax + \pluralparent + \else + \@get@firstperson{\@thisperson}% + \personparent[\@thisperson]% + \fi +} +\newcommand*{\Peopleparent}{% + \ifnum\c@people>1\relax + \expandafter\MakeUppercase\pluralparent + \else + \@get@firstperson{\@thisperson}% + \Personparent[\@thisperson]% + \fi +} +\newcommand*{\personsibling}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \csname\@gender sibling\endcsname + }% +} +\newcommand*{\Personsibling}[1][anon]{% + \@ifundefined{person@#1@gender}% + {% + \PackageError{person}{Person `#1' has not been defined}{}% + }% + {% + \edef\@gender{\csname person@#1@gender\endcsname}% + \expandafter\expandafter\expandafter\MakeUppercase + \csname\@gender sibling\endcsname + }% +} +\newcommand*{\peoplesibling}{% + \ifnum\c@people>1\relax + \ifallmale + {\malesiblings}% + {\ifallfemale{\femalesiblings}{\pluralsibling}}% + \else + \@get@firstperson{\@thisperson}% + \personsibling[\@thisperson]% + \fi +} +\newcommand*{\persongender}[1]{% + \ifpersonmale{#1}{\malename}{\femalename}% +} +\newcommand*{\getpersongender}[2]{% + \ifpersonmale{#2}{\let#1\malename}{\let#1\femalename}% +} +\newcommand*{\getpersonname}[2]{% + \ifpersonexists{#2}% + {% + \expandafter\let\expandafter#1\csname person@#2@name\endcsname + }% + {% + \PackageError{person}{Person `#2' doesn't exist}{}% + }% +} +\newcommand*{\getpersonfullname}[2]{% + \ifpersonexists{#2}% + {% + \expandafter + \let\expandafter#1\csname person@#2@fullname\endcsname + }% + {% + \PackageError{person}{Person `#2' doesn't exist}{}% + }% +} +\endinput +%% +%% End of file `person.sty'. -- cgit v1.2.3