summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/datatool
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-02-03 23:45:48 +0000
committerKarl Berry <karl@freefriends.org>2014-02-03 23:45:48 +0000
commit5b1c9fe4a8686f1d474467ad220e0714515d2a73 (patch)
tree3b011e35663c51c8f1e58e835b262194caa19f72 /Master/texmf-dist/tex/latex/datatool
parent79d56558dc21e3b3497b1c19c76cc06e42139b1d (diff)
datatool (3feb14)
git-svn-id: svn://tug.org/texlive/trunk@32860 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/datatool')
-rw-r--r--Master/texmf-dist/tex/latex/datatool/datatool.sty101
1 files changed, 80 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/latex/datatool/datatool.sty b/Master/texmf-dist/tex/latex/datatool/datatool.sty
index 7d85323adc7..af902a2cf02 100644
--- a/Master/texmf-dist/tex/latex/datatool/datatool.sty
+++ b/Master/texmf-dist/tex/latex/datatool/datatool.sty
@@ -39,7 +39,7 @@
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{datatool}[2014/01/17 v2.19 (NLCT)]
+\ProvidesPackage{datatool}[2014/02/03 v2.20 (NLCT)]
\RequirePackage{xkeyval}
\RequirePackage{ifthen}
\RequirePackage{xfor}
@@ -614,24 +614,62 @@
\newcommand{\DTLifdbexists}[3]{%
\@ifundefined{dtldb@#1}{#3}{#2}}
\newcommand*{\DTLassign}[3]{%
+ \DTLifdbexists{#1}
{%
- \dtlgetrow{#1}{#2}%
+ {%
+ \dtlgetrow{#1}{#2}%
\@dtl@assign{#3}{#1}%
+ }%
+ }%
+ {%
+ \PackageError{datatool}{Database `#1' doesn't exist}{}%
+ }%
+}
+\newcommand*{\DTLassignfirstmatch}[4]{%
+ \dtl@assignfirstmatch{#3}{#1}{#2}{#4}%
+}
+\newcommand*{\xDTLassignfirstmatch}[4]{%
+ \protected@edef\@dtl@asg@value{\expandonce{#3}}%
+ \expandafter\dtl@assignfirstmatch\expandafter
+ {\@dtl@asg@value}{#1}{#2}{#4}%
+}
+\newcommand*{\dtl@assignfirstmatch}[4]{%
+ \DTLifdbexists{#2}%
+ {%
+ {%
+ \dtlgetrowindex{\dtl@asg@rowidx}{#2}{\dtlcolumnindex{#2}{#3}}{#1}%
+ \ifx\dtl@asg@rowidx\dtlnovalue
+ \PackageError{datatool}{No match found for
+ \string\DTLassignfirstmatch{#2}{#3}{#1}{#4}}{}%
+ \else
+ \dtlgetrow{#2}{\dtl@asg@rowidx}%
+ \@dtl@assign{#4}{#2}%
+ \fi
+ }%
+ }%
+ {%
+ \PackageError{datatool}{Data base `#2' doesn't exist}{}%
}%
}
\newcommand*{\@dtl@assign}[2]{%
- \@dtl@assigncmd#1,\@nil\@@{#2}%
+ \ifstrempty{#1}{}%
+ {%
+ \@dtl@assigncmd#1,\@nil\@@{#2}%
+ }%
}
\def\@dtl@assigncmd#1#2=#3,#4\@@#5{%
+ \edef\@dtl@dbname{#5}%
\@sDTLifhaskey{#5}{#3}%
{%
\edef\@dtl@dogetentry{%
\noexpand\dtlgetentryfromcurrentrow
{\noexpand#1}{\dtlcolumnindex{#5}{#3}}}%
\@dtl@dogetentry
- \ifx#1\dtlnovalue
+ \ifdefequal{#1}{\dtlnovalue}%
+ {%
\@@dtl@setnull{#1}{#3}%
- \fi
+ }%
+ {}%
\global\let#1=#1\relax
}%
{%
@@ -684,6 +722,9 @@
\fi
\fi
}
+\newcommand*{\DTLifnullorempty}[3]{%
+ \ifdefempty{#1}{#2}{\DTLifnull{#1}{#2}{#3}}%
+}
\def\@dtlnovalue{Undefined Value}
\def\dtlnovalue{\@dtlnovalue}
\newcommand*{\DTLgetkeydata}{%
@@ -1237,7 +1278,7 @@
{%
\refstepcounter{DTLrow}%
\global\c@DTLrow=\c@DTLrow\relax
- \gdef\@dtl@dbname{#2}%
+ \xdef\@dtl@dbname{#2}%
\global\advance\dtlforeachlevel by 1\relax
\ifnum\dtlforeachlevel>3\relax
\PackageError{datatool}{\string\DTLforeach\space nested too
@@ -1391,6 +1432,7 @@
{%
\refstepcounter{DTLrow}%
\global\c@DTLrow=\c@DTLrow
+ \xdef\@dtl@dbname{#2}%
\global\advance\dtlforeachlevel by 1\relax
\ifnum\dtlforeachlevel>3\relax
\PackageError{datatool}{\string\DTLforeach\space nested too
@@ -2108,12 +2150,12 @@
}
\newcommand*{\@dtlsumforkeys}[4][]{%
\def#4{0}%
- \@for\@dtl@dbname:=#2\do{%
- \@sDTLforeach{\@dtl@dbname}%
+ \@for\@dtl@db@name:=#2\do{%
+ \@sDTLforeach{\@dtl@db@name}%
{#1}% assignment list
{%
\@for\@dtl@key:=#3\do{%
- \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}%
+ \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}%
\dtlcurrentrow=\expandafter{\dtl@thisrow}%
\dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}%
\expandafter\ifthenelse\expandafter{\@dtl@cond}%
@@ -2152,12 +2194,12 @@
\newcommand*{\@dtlmeanforkeys}[4][]{%
\def#4{0}%
\@dtl@elements=0\relax
- \@for\@dtl@dbname:=#2\do{%
- \@sDTLforeach{\@dtl@dbname}%
+ \@for\@dtl@db@name:=#2\do{%
+ \@sDTLforeach{\@dtl@db@name}%
{#1}% assignment list
{%
\@for\@dtl@key:=#3\do{%
- \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}%
+ \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}%
\dtlcurrentrow=\expandafter{\dtl@thisrow}%
\dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}%
\expandafter\ifthenelse\expandafter{\@dtl@cond}%
@@ -2214,12 +2256,12 @@
\@dtlmeanforkeys[#1]{#2}{#3}{\dtl@mean}%
\def#4{0}%
\@dtl@elements=0\relax
- \@for\@dtl@dbname:=#2\do{%
- \@sDTLforeach{\@dtl@dbname}%
+ \@for\@dtl@db@name:=#2\do{%
+ \@sDTLforeach{\@dtl@db@name}%
{#1}% assignment list
{%
\@for\@dtl@key:=#3\do{%
- \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}%
+ \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}%
\dtlcurrentrow=\expandafter{\dtl@thisrow}%
\dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}%
\expandafter\ifthenelse\expandafter{\@dtl@cond}%
@@ -2292,12 +2334,12 @@
}
\newcommand*{\@dtlminforkeys}[4][]{%
\def#4{}%
- \@for\@dtl@dbname:=#2\do{%
- \@sDTLforeach{\@dtl@dbname}%
+ \@for\@dtl@db@name:=#2\do{%
+ \@sDTLforeach{\@dtl@db@name}%
{#1}% assignment list
{%
\@for\@dtl@key:=#3\do{%
- \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}%
+ \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}%
\dtlcurrentrow=\expandafter{\dtl@thisrow}%
\dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}%
\expandafter\ifthenelse\expandafter{\@dtl@cond}%
@@ -2348,12 +2390,12 @@
}
\newcommand*{\@dtlmaxforkeys}[4][]{%
\def#4{}%
- \@for\@dtl@dbname:=#2\do{%
- \@sDTLforeach{\@dtl@dbname}%
+ \@for\@dtl@db@name:=#2\do{%
+ \@sDTLforeach{\@dtl@db@name}%
{#1}% assignment list
{%
\@for\@dtl@key:=#3\do{%
- \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}%
+ \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}%
\dtlcurrentrow=\expandafter{\dtl@thisrow}%
\dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}%
\expandafter\ifthenelse\expandafter{\@dtl@cond}%
@@ -2972,6 +3014,23 @@
database}{}%
}%
}
+\newcommand*{\DTLloaddbtex}[2]{%
+ \IfFileExists{#2}%
+ {%
+ \input{#2}%
+ \ifdef#1%
+ {%
+ \PackageError{datatool}{Command \string#1\space is already defined}%
+ {}%
+ }%
+ {%
+ \let#1\dtllastloadeddb
+ }%
+ }%
+ {%
+ \PackageError{datatool}{File `#2' doesn't exist.}{}%
+ }%
+}
\newread\@dtl@read
\newcount\dtl@entrycr
\define@boolkey{loaddb}[dtl]{noheader}[true]{}