xref: /inferno-os/module/string.m (revision a584e84874abd077df5ee1f3687f84d9d4fc3bfa)
146439007SCharles.ForsythString: module
246439007SCharles.Forsyth{
346439007SCharles.Forsyth	PATH:		con	"/dis/lib/string.dis";
446439007SCharles.Forsyth
546439007SCharles.Forsyth	# the second arg of the following is a character class
646439007SCharles.Forsyth	#    e.g., "a-zA-Z", or "^ \t\n"
746439007SCharles.Forsyth	# (ranges indicated by - except in first position;
846439007SCharles.Forsyth	#  ^ is first position means "not in" the following class)
946439007SCharles.Forsyth	# splitl splits just before first char in class;  (s, "") if no split
1046439007SCharles.Forsyth	# splitr splits just after last char in class; ("", s) if no split
1146439007SCharles.Forsyth	# drop removes maximal prefix in class
1246439007SCharles.Forsyth	# take returns maximal prefix in class
1346439007SCharles.Forsyth
1446439007SCharles.Forsyth	splitl:		fn(s, cl: string): (string, string);
1546439007SCharles.Forsyth	splitr:		fn(s, cl: string): (string, string);
1646439007SCharles.Forsyth	drop:		fn(s, cl: string): string;
1746439007SCharles.Forsyth	take:		fn(s, cl: string): string;
1846439007SCharles.Forsyth	in:		fn(c: int, cl: string): int;
1946439007SCharles.Forsyth
2046439007SCharles.Forsyth	# in these, the second string is a string to match, not a class
2146439007SCharles.Forsyth	splitstrl:	fn(s, t: string): (string, string);
2246439007SCharles.Forsyth	splitstrr:	fn(s, t: string): (string, string);
2346439007SCharles.Forsyth
2446439007SCharles.Forsyth	# is first arg a prefix of second?
2546439007SCharles.Forsyth	prefix:		fn(pre, s: string): int;
2646439007SCharles.Forsyth
2746439007SCharles.Forsyth	tolower:	fn(s: string): string;
2846439007SCharles.Forsyth	toupper:	fn(s: string): string;
2946439007SCharles.Forsyth
3046439007SCharles.Forsyth	# string to int returning value, remainder
3146439007SCharles.Forsyth	toint:		fn(s: string, base: int): (int, string);
3246439007SCharles.Forsyth	tobig:		fn(s: string, base: int): (big, string);
33*a584e848SCharles.Forsyth	toreal:		fn(s: string, base: int): (real, string);
3446439007SCharles.Forsyth
3546439007SCharles.Forsyth	# append s to end of l
3646439007SCharles.Forsyth	append:		fn(s: string, l: list of string): list of string;
3746439007SCharles.Forsyth	quoted:		fn(argv: list of string): string;
3846439007SCharles.Forsyth	quotedc:		fn(argv: list of string, cl: string): string;
3946439007SCharles.Forsyth	unquoted:		fn(args: string): list of string;
4046439007SCharles.Forsyth};
41