diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex | 145 |
1 files changed, 116 insertions, 29 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex index 4a31f8fc84d..37eed5ad6ce 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex @@ -56,7 +56,6 @@ \newif\ifpgfplotstable@firstline@is@header \newcount\c@pgfplotstable@counta \newtoks\t@pgfplotstable@a -\newwrite\pgfplotstable@outfile \newif\ifpgfplots@addplotimpl@readcompletely % should always be false; use only in grouped internal macros \newif\ifpgfplots@table@options@areset @@ -97,6 +96,8 @@ /pgfplots/table/z error expr/.initial=, /pgfplots/table/ignore chars/.initial=, /pgfplots/table/white space chars/.initial=, + /pgfplots/table/comment chars/.initial=, + /pgfplots/table/skip first n/.initial=0, /pgfplots/table/trim cells/.is if=pgfplotstable@trimcells, /pgfplots/table/trim cells/.default=true, /pgfplots/table/read completely/.is choice, @@ -481,9 +482,31 @@ \expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to{#3}% }% +% Defines #3 to be the column name of the column with index '#1'. +% +% #1: a column index (starting with 0) +% #2: a loaded table structure +% #3: an output macro name. \def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{% \pgfplotslistselect#1\of#2\to#3\relax }% + +% Defines #3 to be the column index of the column with name '#1'. +% +% #1: a column name +% #2: a loaded table structure +% #3: an output macro name which will be filled with the index (or -1 +% if there is no such index) +\def\pgfplotstablegetcolumnindexforname#1\of#2\to#3{% + \def#3{-1}% + \edef\pgfplotstablegetcolumnindexforname@@{#1}% + \pgfplotstableforeachcolumn{#2}\as\pgfplotstablegetcolumnindexforname@{% + \relax + \ifx\pgfplotstablegetcolumnindexforname@\pgfplotstablegetcolumnindexforname@@ + \edef#3{\pgfplotstablecol}% + \fi + }% +}% \def\pgfplotstablegetcolumnbyindex#1\of#2\to#3{% \pgfplotslistselect#1\of#2\to#3\relax \expandafter\pgfplotstablegetcolumnbyname#3\of#2\to{#3}% @@ -664,7 +687,7 @@ }% }% \long\def\pgfplotstableread@impl@collectfirstarg#1#2{% - \pgfutil@ifnextchar t{% + \pgfplotsutil@ifnextchar t{% \pgfplotstableread@impl@@{#1}{#2}% }{% \pgfplotstableread@impl@{#1}{#2}% @@ -752,6 +775,15 @@ \pgfplotstableread@inlinefalse \fi % + % optimizations: + \pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd + \ifx\pgfplots@loc@TMPd\pgfutil@empty + \let\pgfplotstableread@checkspecial@line@default=\relax + \fi + \pgfkeysgetvalue{/pgfplots/table/skip first n}\pgfplots@loc@TMPd + \ifx\pgfplots@loc@TMPd\pgfutil@empty \let\pgfplotstableread@check@skipfirstn=\relax \fi + \ifnum\pgfplots@loc@TMPd=0 \let\pgfplotstableread@check@skipfirstn=\relax \fi + % \ifpgfplotstableread@inline \def\pgfplotstableread@impl@fCLOSE{}% \let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@frominline% @@ -877,6 +909,8 @@ \pgfplotstableset@every@table{#2}{#1}% \fi % + \def\pgfplotstablename{\pgfplotstable@colnames@glob}% provide the name of the actual table struct (during \pgfplotstableread, only partial functionality is available!) + % % local counter definitions: \ifpgfplots@tableread@use@begingroup \let\pgfplotstableread@lineno=\c@pgf@counta @@ -1024,10 +1058,17 @@ }% }% +\def\pgfplotstableread@check@skipfirstn{% + \ifnum\pgfplotstableread@lineno<\pgfkeysvalueof{/pgfplots/table/skip first n} % + \pgfplotstableread@skiplinetrue + \fi +}% + % PRECONDITION: % \pgfplotstable@LINE contains the current input line. \def\pgfplotstableread@loop@processnextline{% \expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI + \pgfplotstableread@check@skipfirstn \ifpgfplotstableread@skipline \def\pgfplotstableread@gnuplotcheck{####x y type}% \ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE @@ -1055,6 +1096,7 @@ \fi \pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE \pgfplotstableread@countset\pgfplotstableread@numcols{\pgfplotstableread@curcol}% + \edef\pgfplotstablecols{\thepgfplotstableread@numcols}% \pgfplotstableread@countreset\pgfplotstableread@curcol % Create empty column lists: \pgfplotstableread@create@column@lists @@ -1109,30 +1151,78 @@ % WARNING: this routine is also used in pgfplots.code.tex ... \def\pgfplotstableread@checkspecial@line{% - \pgfutil@ifnextchar##{% + \futurelet\pgfplotstableread@tmp\pgfplotstableread@checkspecial@line@ +}% +\def\pgfplotstableread@checkspecial@line@{% + \pgfplotstableread@skiplinefalse + \let\pgfplotstableread@checkspecial@line@@\pgfplotstableread@impl@gobble% + % + \let\pgfplotstableread@tmpb=##% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb \pgfplotstableread@skiplinetrue - \pgfplotstableread@impl@gobble - }{% - \pgfutil@ifnextchar${% - \pgfplotstableread@process@flags@line - }{% - \pgfutil@ifnextchar\pgfplotstable@EOI{% + \else + \let\pgfplotstableread@tmpb=$% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \let\pgfplotstableread@checkspecial@line@@=\pgfplotstableread@process@flags@line + \else + \let\pgfplotstableread@tmpb=\pgfplotstable@EOI% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb \pgfplotstableread@skiplinetrue \pgfplotsscanlinecomplete% the line is empty; same as \par! - \pgfplotstableread@impl@gobble - }{% - \pgfutil@ifnextchar\par{% + \else + \let\pgfplotstableread@tmpb=\par% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb \pgfplotstableread@skiplinetrue - \pgfplotsscanlinecomplete - \pgfplotstableread@impl@gobble - }{% - \pgfplotstableread@skiplinefalse - \pgfplotstableread@impl@gobble - }% - }% + \pgfplotsscanlinecomplete% the line is empty; + \else + \pgfplotstableread@checkspecial@line@default% + \fi + \fi + \fi + \fi + \pgfplotstableread@checkspecial@line@@ +}% +\def\pgfplotstableread@checkspecial@line@default{% + % this routine can be optimized away + \pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd + \ifx\pgfplots@loc@TMPd\pgfutil@empty + \else + \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPd}\as\pgfplots@loc@TMPd{% + \expandafter\let\expandafter\pgfplotstableread@tmpb\pgfplots@loc@TMPd + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \pgfplotstableread@skiplinetrue + \fi }% - }% -} + \fi +}% + +%-------------------------------------------------- +% \def\pgfplotstableread@checkspecial@line{% +% \pgfutil@ifnextchar##{% +% \pgfplotstableread@skiplinetrue +% \pgfplotstableread@impl@gobble +% }{% +% \pgfutil@ifnextchar${% +% \pgfplotstableread@process@flags@line +% }{% +% \pgfutil@ifnextchar\pgfplotstable@EOI{% +% \pgfplotstableread@skiplinetrue +% \pgfplotsscanlinecomplete% the line is empty; same as \par! +% \pgfplotstableread@impl@gobble +% }{% +% \pgfutil@ifnextchar\par{% +% \pgfplotstableread@skiplinetrue +% \pgfplotsscanlinecomplete +% \pgfplotstableread@impl@gobble +% }{% +% \pgfplotstableread@skiplinefalse +% \pgfplotstableread@impl@gobble +% }% +% }% +% }% +% }% +% } +%-------------------------------------------------- \long\def\pgfplotstableread@process@flags@line$flags {% %\pgfplots@message{Ignoring flags line ...}% @@ -1435,7 +1525,7 @@ \else \begingroup \t@pgfplots@tokc={#1}% - \pgfplotstable@error{Table '\pgfplotstableread@filename' has too much columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary). This error is not critical}% + \pgfplotstable@error{Table '\pgfplotstableread@filename' appears to have too many columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. PGFPlots found that the number of columns is larger than the previously determined number of columns. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary. Also verify that column names are plain ASCII.). This error is not critical}% \endgroup \fi } @@ -1648,17 +1738,14 @@ }% \let\pgfplotstablecol=\relax }% +\let\pgfplotstableforeachcolumn@orig=\pgfplotstableforeachcolumn + % A variant of \pgfplotstableforeachcolumn which is used inside of % \pgfplotstableread to listener. % % It is used as \pgfplotstableforeachcolumn\as\cur{<do something with \cur>} -\long\def\pgfplotstableforeachcolumn@listener\as#1#2{% - \def\pgfplotstablecol{0}% - \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as#1{% - #2\relax% - \pgfplotsutil@advancestringcounter\pgfplotstablecol - }% - \let\pgfplotstablecol=\relax +\long\def\pgfplotstableforeachcolumn@listener#1\as#2#3{% + \pgfplotstableforeachcolumn@orig\pgfplotstable@colnames@glob\as{#2}{#3}% }% % Reports every element t_{ij} for a fixed column j (in read-only |