diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2014-05-05 20:58:56 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2014-05-05 20:58:56 +0000 |
commit | b41cac6cebc8095cf8eaf7e84f8a2d5f63b7be38 (patch) | |
tree | 485b647339dff06549a9e6209d29f420cb6e1834 /Master/texmf-dist/metapost/context/base/mp-grap.mpiv | |
parent | 28d5537add2c5bc2b860143edfa07d359d8ddec0 (diff) |
ConTeXt 2014.05.05 22:31
git-svn-id: svn://tug.org/texlive/trunk@33858 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/context/base/mp-grap.mpiv')
-rw-r--r-- | Master/texmf-dist/metapost/context/base/mp-grap.mpiv | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/Master/texmf-dist/metapost/context/base/mp-grap.mpiv b/Master/texmf-dist/metapost/context/base/mp-grap.mpiv index 6d69c0b1ed0..6d2924c5263 100644 --- a/Master/texmf-dist/metapost/context/base/mp-grap.mpiv +++ b/Master/texmf-dist/metapost/context/base/mp-grap.mpiv @@ -64,9 +64,9 @@ fi % are of the form X_.<suffix>, Y_.<suffix>, or Z_.<suffix>, or they start % with `graph_' -% Depends on : +% Used to depend on : -input string.mp +% input string.mp % Private version of a few marith macros, fixed for double math... @@ -467,16 +467,50 @@ enddef ; % initial "%", and return true if at least one token is found. The tokens % are stored in @#1, @#2, .. with "" in the last @#[] entry. +% String manipulation routines for MetaPost +% It is harmless to input this file more than once. + +vardef isdigit primary d = + ("0"<=d)and(d<="9") +enddef ; + +% Number of initial characters of string s where `c <character>' is true + +vardef graph_cspan(expr s)(text c) = + 0 + for i=1 upto length s: + exitunless c substring (i-1,i) of s; + + 1 + endfor +enddef ; + +% String s is composed of items separated by white space. Lop off the first +% item and the surrounding white space and return just the item. + +vardef graph_loptok suffix s = + save t, k; + k = graph_cspan(s," ">=); + if k > 0 : + s := substring(k,infinity) of s ; + fi + k := graph_cspan(s," "<); + string t; + t = substring (0,k) of s; + s := substring (k,infinity) of s; + s := substring (graph_cspan(s," ">=),infinity) of s; + t +enddef ; + vardef graph_read_line@#(expr f) = save n_, s_ ; string s_; s_ = readfrom f ; string @#[] ; if s_<>EOF : @#0 := s_ ; - @#1 := loptok s_ ; + @#1 := graph_loptok s_ ; n_ = if @#1="%" : 0 else : 1 fi ; forever : - @#[incr n_] := loptok s_ ; + @#[incr n_] := graph_loptok s_ ; exitif @#[n_]="" ; endfor @#1<>"" |