diff options
author | Karl Berry <karl@freefriends.org> | 2009-11-16 01:44:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-11-16 01:44:59 +0000 |
commit | 2b1511b76524ed6e4b906094ee4a63aacf7d68e5 (patch) | |
tree | 7e7f3ab490a4e0c1140ba03ed59373be4c4dd226 /Master/texmf-dist/tex/latex/datatool/datatool.sty | |
parent | faaa36262649a67fb85d27b3e605d94da0b75fa4 (diff) |
datalog 2.03 (15nov09)
git-svn-id: svn://tug.org/texlive/trunk@16023 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/datatool/datatool.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/datatool/datatool.sty | 807 |
1 files changed, 428 insertions, 379 deletions
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,6 +3622,366 @@ \dtl@message{`\@dtl@a' <=> `\@dtl@b' = \number\dtl@sortresult}% \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)}{}% + }% +} +\newcommand{\dtl@trim}[1]{% +\def\@dtl@trmstr{}% +\expandafter\@dtl@starttrim#1\@nil% +\let#1=\@dtl@trmstr +} +\long\def\@dtl@starttrim#1#2{% +\ifx\par#1% + \def\@dtl@dotrim{\@dtl@trim{} #2}% +\else + \def\@dtl@dotrim{\@dtl@trim#1#2}% +\fi +\@dtl@dotrim% +} +\long\def\@dtl@trim#1 \@nil{\long\def\@dtl@trmstr{#1}} +\newcommand*\DTLloadrawdb{% + \let\@dtl@doreadline\@dtl@readrawline + \@dtlloaddb +} +\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 + \def\@dtl@tmp{{#1}{#2}} + \protected@edef\@dtl@rawmappings{\the\@dtl@toks,\@dtl@tmp} +\fi +} +\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*{\dtl@choplast}[3]{% \let#2\@empty \let#3\@empty @@ -4227,353 +4636,6 @@ \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)}{}% - }% -} -\newcommand{\dtl@trim}[1]{% -\def\@dtl@trmstr{}% -\expandafter\@dtl@starttrim#1\@nil% -\let#1=\@dtl@trmstr -} -\long\def\@dtl@starttrim#1#2{% -\ifx\par#1% - \def\@dtl@dotrim{\@dtl@trim{} #2}% -\else - \def\@dtl@dotrim{\@dtl@trim#1#2}% -\fi -\@dtl@dotrim% -} -\long\def\@dtl@trim#1 \@nil{\long\def\@dtl@trmstr{#1}} -\newcommand*\DTLloadrawdb{% - \let\@dtl@doreadline\@dtl@readrawline - \@dtlloaddb -} -\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 - \def\@dtl@tmp{{#1}{#2}} - \protected@edef\@dtl@rawmappings{\the\@dtl@toks,\@dtl@tmp} -\fi -} -\newcommand*{\@dtl@rawmappings}{} -\newcommand*{\dtl@domappings}[1]{% -\@for\@dtl@map:=\@dtl@rawmappings\do{% - \expandafter\DTLsubstitute\expandafter#1\@dtl@map -}} \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}% |