diff options
author | Hans Hagen <pragma@wxs.nl> | 2004-08-30 00:00:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2004-08-30 00:00:00 +0200 |
commit | 334f3edd2304915fc8b50a722a56765f41b1a7d5 (patch) | |
tree | 0d62c2871118f4971fa7b0b6bb1e87b12f647bff /metapost | |
parent | 08a4bcc9bff26007ca9b5d14d6beaacab74c9ce4 (diff) | |
download | context-334f3edd2304915fc8b50a722a56765f41b1a7d5.tar.gz |
stable 2004.08.30
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mp-spec.mp | 9 | ||||
-rw-r--r-- | metapost/context/base/mp-tool.mp | 25 |
2 files changed, 25 insertions, 9 deletions
diff --git a/metapost/context/base/mp-spec.mp b/metapost/context/base/mp-spec.mp index ceff7fe90..bef6cd2fa 100644 --- a/metapost/context/base/mp-spec.mp +++ b/metapost/context/base/mp-spec.mp @@ -614,9 +614,12 @@ vardef transparent(expr n, t, c) = elseif is_spot : spotcolorpattern[bluepart cc] else : dddecimal cc fi ; % check if this one is already used -% ss := "tr_" & s ; -% ss := cleanstring(ss) ; ss := cleanstring("tr_" & s) ; + % we now have rather unique names, i.e. a color spec of .234 becomes + % tr..._234.... and metapost gives a number overflow (parse error) + % for variables like tr_12345678 which may result from many decimal + % positions (imo mp bug) + ss := asciistring(ss) ; % efficiency hack if expandafter unknown scantokens(ss) : ok := false ; % not yet defined @@ -701,4 +704,4 @@ enddef ; % spotcolor is already scaled -endinput ;
\ No newline at end of file +endinput ; diff --git a/metapost/context/base/mp-tool.mp b/metapost/context/base/mp-tool.mp index 2609e130f..1f299807a 100644 --- a/metapost/context/base/mp-tool.mp +++ b/metapost/context/base/mp-tool.mp @@ -2130,21 +2130,34 @@ enddef ; % obscure macros: create var from string and replace - and : % (needed for process color id's) -string _clean_ascii[] ; +string _clean_ascii_[] ; def register_dirty_chars(expr str) = for i = 0 upto length(str)-1 : - _clean_ascii[ASCII substring(i,i+1) of str] := "_" ; + _clean_ascii_[ASCII substring(i,i+1) of str] := "_" ; endfor ; enddef ; -register_dirty_chars("+-*/:;.,") ; +register_dirty_chars("+-*/:;., ") ; vardef cleanstring (expr s) = - save ss ; string ss, si ; ss = "" ; + save ss ; string ss, si ; ss = "" ; save i ; for i=0 upto length(s) : si := substring(i,i+1) of s ; - ss := ss & if known _clean_ascii[ASCII si] : _clean_ascii[ASCII si] else : si fi ; + ss := ss & if known _clean_ascii_[ASCII si] : _clean_ascii_[ASCII si] else : si fi ; + endfor ; + ss +enddef ; + +vardef asciistring (expr s) = + save ss ; string ss, si ; ss = "" ; save i ; + for i=0 upto length(s) : + si := substring(i,i+1) of s ; + if (ASCII si >= ASCII "0") and (ASCII si <= ASCII "9") : + ss := ss & char(scantokens(si) + ASCII "A") ; + else : + ss := ss & si ; + fi ; endfor ; ss enddef ; @@ -2244,4 +2257,4 @@ enddef ; % done -endinput ;
\ No newline at end of file +endinput ; |