/usr/share/texmf-texlive/metapost/base/string.mp is in texlive-metapost 2009-15.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | % $Id: string.mp,v 1.2 2004/09/19 21:47:11 karl Exp $
% Public domain.
% 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 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 loptok suffix s =
save t, k;
k = cspan(s," ">=);
if k>0: s:=substring(k,infinity) of s; fi
k := cspan(s," "<);
string t;
t = substring (0,k) of s;
s := substring (k,infinity) of s;
s := substring (cspan(s," ">=),infinity) of s;
t
enddef;
|