summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-grap.mpiv10
-rw-r--r--metapost/context/base/mp-mlib.mpiv24
2 files changed, 30 insertions, 4 deletions
diff --git a/metapost/context/base/mp-grap.mpiv b/metapost/context/base/mp-grap.mpiv
index 64e63b90c..81a410db2 100644
--- a/metapost/context/base/mp-grap.mpiv
+++ b/metapost/context/base/mp-grap.mpiv
@@ -359,7 +359,7 @@ vardef graph_set_bounds@#(expr l, h) =
graph_clear_bounds@# ;
if @#graph_coordinate_type>0 :
@#low = if unknown l :
- whatever
+ whatever
else :
if abs @#graph_coordinate_type=log : graph_mlog fi if string l : scantokens fi l
fi ;
@@ -369,7 +369,7 @@ vardef graph_set_bounds@#(expr l, h) =
if abs @#graph_coordinate_type=log : graph_mlog fi if string h : scantokens fi h
fi ;
else :
- -@#high = if unknown l :
+ -@#high = if unknown l :
whatever
else :
if abs @#graph_coordinate_type=log : graph_mlog fi if string l : scantokens fi l
@@ -1075,6 +1075,8 @@ enddef ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% we could pass via variables and save escaping
+
Ten_to0 = 1 ;
Ten_to1 = 10 ;
Ten_to2 = 100 ;
@@ -1082,7 +1084,7 @@ Ten_to3 = 1000 ;
Ten_to4 = 10000 ;
vardef escaped_format(expr s) =
- "" for n=1 upto length(s) : &
+ "" for n=0 upto length(s) : &
if ASCII substring (n,n+1) of s = 37 :
"@"
else :
@@ -1092,7 +1094,7 @@ vardef escaped_format(expr s) =
enddef ;
vardef strfmt(expr f, x) =
- "\MPgraphformat{" & escaped_format(f) & "}{" & (if string x : x else : decimal x fi) & "}"
+ "\MPgraphformat{" & escaped_format(f) & "}{" & mfun_tagged_string(x) & "}"
enddef ;
vardef format(expr f, x) = textext(strfmt(f, x)) enddef ;
diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv
index e667e4064..6139a63c2 100644
--- a/metapost/context/base/mp-mlib.mpiv
+++ b/metapost/context/base/mp-mlib.mpiv
@@ -841,3 +841,27 @@ def passvariable(expr key, value) =
else : "2:" & key & "=" & value
fi ;
enddef ;
+
+vardef tostring(expr value) =
+ if numeric value : mfun_numeric_to_string(value)
+ elseif pair value : mfun_pair_to_string(value)
+ elseif rgbcolor value : mfun_rgbcolor_to_string(value)
+ elseif cmykcolor value : mfun_cmykcolor_to_string(value)
+ elseif boolean value : mfun_boolean_to_string(value)
+ elseif path value : mfun_path_to_string(value)
+ elseif transform value : mfun_transform_to_string(value)
+ else : value
+ fi
+enddef ;
+
+vardef mfun_tagged_string(expr value) =
+ if numeric value : "1:" & mfun_numeric_to_string(value)
+ elseif pair value : "4:" & mfun_pair_to_string(value)
+ elseif rgbcolor value : "5:" & mfun_rgbcolor_to_string(value)
+ elseif cmykcolor value : "6:" & mfun_cmykcolor_to_string(value)
+ elseif boolean value : "3:" & mfun_boolean_to_string(value)
+ elseif path value : "7:" & mfun_path_to_string(value)
+ elseif transform value : "8:" & mfun_transform_to_string(value)
+ else : "2:" & value
+ fi
+enddef ;