diff options
author | Karl Berry <karl@freefriends.org> | 2013-07-11 23:29:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-07-11 23:29:36 +0000 |
commit | ced128389da6e12bc2da23bc40adfa2ee6eb7eec (patch) | |
tree | 52e007224ffd57a34c60740546dc7a1677c1e7e4 /Master/texmf-dist/tex/latex/datatool/datatool.sty | |
parent | b863f2bfeab599875bf798ab734b9404f972625f (diff) |
datatool (10jul13)
git-svn-id: svn://tug.org/texlive/trunk@31174 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 | 112 |
1 files changed, 85 insertions, 27 deletions
diff --git a/Master/texmf-dist/tex/latex/datatool/datatool.sty b/Master/texmf-dist/tex/latex/datatool/datatool.sty index 35300a8d2c1..4764e53d48d 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}[2013/06/28 v2.14 (NLCT)] +\ProvidesPackage{datatool}[2013/07/10 v2.15 (NLCT)] \RequirePackage{xkeyval} \RequirePackage{ifthen} \RequirePackage{xfor} @@ -2291,7 +2291,7 @@ \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% {% - \ifstrempty{#4}% + \ifdefempty{#4}% {% \let#4\DTLthisval }% @@ -2761,6 +2761,7 @@ \protected@write\@dtl@write{}{% \string\DTLsetheader*{#1}{\@dtl@k}{\@dtl@h}}% }% + \protected@write{\@dtl@write}{}{\string\def\string\dtllastloadeddb{#1}}% \closeout\@dtl@write }% {% @@ -2801,8 +2802,9 @@ \def\db@header@id@w{\expandafter\@gobble\string\%^^J\string\db@header@id@w\space}% \def\db@header@id@end@{\expandafter\@gobble\string\%^^J\string\db@header@id@end@\space}% \protected@write{\@dtl@write}{}{\string\bgroup\string\makeatletter}% - \protected@write{\@dtl@write}{}{\string\dtl@message{Reconstructing database - ^^J`#1'}\expandafter\@gobble\string\%}% + \protected@write{\@dtl@write}{}{% + \string\dtl@message{Reconstructing database^^J`#1'}% + \expandafter\@gobble\string\%}% \protected@write{\@dtl@write}{}{% \string\expandafter \string\global\string\expandafter^^J\string\newtoks @@ -2815,7 +2817,8 @@ \expandafter\protected@xdef\csname dtl@rawwritedbkeys@#1\endcsname{% \the\csname dtlkeys@#1\endcsname}% \protected@write{\@dtl@write}{}{\csname dtl@rawwritedbkeys@#1\endcsname}% - \protected@write{\@dtl@write}{}{\expandafter\@gobble\string\}\expandafter\@gobble\string\%}% + \protected@write{\@dtl@write}{}% + {\expandafter\@gobble\string\}\expandafter\@gobble\string\%}% \dtl@saverawdbhook \protected@write{\@dtl@write}{}{% \string\expandafter\string\global @@ -2825,12 +2828,9 @@ \string\expandafter \string\global^^J\string\csname\space dtldb@#1\string\endcsname =\expandafter\@gobble\string\{\expandafter\@gobble\string\%}% - \@dtl@fmt@bodytok{\csname dtldb@#1\endcsname}% - \expandafter\protected@xdef\csname dtl@rawwritedb@#1\endcsname{% - \@dtl@contents}% + \expandafter\protected@xdef\csname dtl@rawwritedb@#1\endcsname{\the\csname dtldb@#1\endcsname}% \protected@write{\@dtl@write}{}{\csname dtl@rawwritedb@#1\endcsname}% - \protected@write{\@dtl@write}{}{% - \expandafter\@gobble\string\}\expandafter\@gobble\string\%}% + \protected@write{\@dtl@write}{}{\expandafter\@gobble\string\}\expandafter\@gobble\string\%}% \protected@write{\@dtl@write}{}{\string\expandafter\string\global^^J \string\expandafter\string\newcount \string\csname\space dtlrows@#1\string\endcsname}% @@ -2855,6 +2855,7 @@ }% \protected@write{\@dtl@write}{}{\string\egroup}% }% + \protected@write{\@dtl@write}{}{\string\def\string\dtllastloadeddb{#1}}% \closeout\@dtl@write }% {% @@ -2862,23 +2863,80 @@ database}{}% }% } -\newcommand*{\@dtl@fmt@bodytok}[1]{% - \edef\@dtl@contents{\the#1}% - \@onelevel@sanitize\@dtl@contents - \@dtl@replace@elt{\@dtl@contents}{db@row@elt@w}% - \@dtl@replace@elt{\@dtl@contents}{db@row@elt@end@}% - \@dtl@replace@elt{\@dtl@contents}{db@row@id@w}% - \@dtl@replace@elt{\@dtl@contents}{db@row@id@end@}% - \@dtl@replace@elt{\@dtl@contents}{db@col@id@w}% - \@dtl@replace@elt{\@dtl@contents}{db@col@id@end@}% - \@dtl@replace@elt{\@dtl@contents}{db@col@elt@w}% - \@dtl@replace@elt{\@dtl@contents}{db@col@elt@end@}% -} -\newcommand*{\@dtl@replace@elt}[2]{% - \expandafter\def\expandafter\dtl@tmp\expandafter{\csname#2\endcsname }% - \@onelevel@sanitize\dtl@tmp - \expandafter\DTLsubstituteall\expandafter#1\expandafter{\dtl@tmp}% - {\csname#2\endcsname}% +\newcommand*{\DTLprotectedsaverawdb}[2]{% + \DTLifdbexists{#1}% + {% + \openout\@dtl@write=#2\relax + \protected@write{\@dtl@write}{}{% + \string\DTLifdbexists{#1}\expandafter\@gobble\string\%^^J% + {% + \string\PackageError{datatool}{Database `#1' ^^Jalready exists}{}% + \expandafter\@gobble\string\%^^J% + \string\aftergroup\string\endinput + }% + {% + }\expandafter\@gobble\string\% + }% + {% + \protected@write{\@dtl@write}{}{\string\bgroup\string\makeatletter}% + \protected@write{\@dtl@write}{}{\string\dtl@message{Reconstructing database + ^^J`#1'}\expandafter\@gobble\string\%}% + \protected@write{\@dtl@write}{}{% + \string\expandafter + \string\global\string\expandafter^^J\string\newtoks + \string\csname\space dtlkeys@#1\string\endcsname}% + \protected@write{\@dtl@write}{}{% + \string\expandafter + \string\global^^J + \string\csname\space dtlkeys@#1\string\endcsname + =\expandafter\@gobble\string\{\expandafter\@gobble\string\%}% + \edef\dtl@rawwrite@keys{\the\csname dtlkeys@#1\endcsname}% + \@onelevel@sanitize\dtl@rawwrite@keys + \expandafter\write\expandafter\@dtl@write\expandafter + {\dtl@rawwrite@keys\expandafter\@gobble\string\}}% + \protected@write{\@dtl@write}{}{% + \string\expandafter\string\global + \string\expandafter^^J\string\newtoks + \string\csname\space dtldb@#1\string\endcsname}% + \protected@write{\@dtl@write}{}{% + \string\expandafter + \string\global^^J\string\csname\space dtldb@#1\string\endcsname + =\expandafter\@gobble\string\{\expandafter\@gobble\string\%}% + \edef\dtl@rawwrite@db{\the\csname dtldb@#1\endcsname}% + \@onelevel@sanitize\dtl@rawwrite@db + \expandafter\write\expandafter\@dtl@write\expandafter + {\dtl@rawwrite@db\expandafter\@gobble\string\}}% + \protected@write{\@dtl@write}{}{\string\expandafter\string\global^^J + \string\expandafter\string\newcount + \string\csname\space dtlrows@#1\string\endcsname}% + \protected@write{\@dtl@write}{}{\string\expandafter\string\global^^J + \string\csname\space dtlrows@#1\string\endcsname + =\expandafter\number\csname dtlrows@#1\endcsname\string\relax}% + \protected@write{\@dtl@write}{}{\string\expandafter\string\global^^J + \string\expandafter\string\newcount + \string\csname\space dtlcols@#1\string\endcsname}% + \protected@write{\@dtl@write}{}{\string\expandafter\string\global^^J + \string\csname\space dtlcols@#1\string\endcsname + =\expandafter\number\csname dtlcols@#1\endcsname\string\relax}% + \dtlforeachkey(\@dtl@key,\@dtl@col,\@dtl@type,\@dtl@head)\in{#1}\do + {% + \edef\dtl@tmp{% + \string\expandafter^^J + \string\gdef + \string\csname\space dtl@ci@#1@\@dtl@key\string\endcsname + {\csname dtl@ci@#1@\@dtl@key\endcsname}\expandafter\@gobble\string\% + }% + \expandafter\write\expandafter\@dtl@write\expandafter{\dtl@tmp}% + }% + \protected@write{\@dtl@write}{}{\string\egroup}% + }% + \protected@write{\@dtl@write}{}{\string\def\string\dtllastloadeddb{#1}}% + \closeout\@dtl@write + }% + {% + \PackageError{datatool}{Can't save database `#1': no such + database}{}% + }% } \newread\@dtl@read \newcount\dtl@entrycr |