Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / Strings.def
1 DEFINITION MODULE Strings;
2 (*
3   Module:       String manipulations
4   Author:       Ceriel J.H. Jacobs
5   Version:      $Id: Strings.def,v 1.3 1994/06/24 12:50:00 ceriel Exp $
6 *)
7 (* Note: truncation of strings may occur if the user does not provide
8    large enough variables to contain the result of the operation.
9 *)
10
11 (* Strings are of type ARRAY OF CHAR, and their length is the size
12    of the array, unless a 0-byte occurs in the string to indicate the
13    end of the string.
14 *)
15
16 PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
17 (* Assign string source to dest
18 *)
19
20 PROCEDURE Insert(substr: ARRAY OF CHAR; VAR str: ARRAY OF CHAR; inx: CARDINAL);
21 (* Insert the string substr into str, starting at str[inx].
22    If inx is equal to or greater than Length(str) then substr is appended
23    to the end of str.
24 *)
25
26 PROCEDURE Delete(VAR str: ARRAY OF CHAR; inx, len: CARDINAL);
27 (* Delete len characters from str, starting at str[inx].
28    If inx >= Length(str) then nothing happens.
29    If there are not len characters to delete, characters to the end of the
30    string are deleted.
31 *)
32
33 PROCEDURE Pos(substr, str: ARRAY OF CHAR): CARDINAL;
34 (* Return the index into str of the first occurrence of substr.
35    Pos returns a value greater than HIGH(str) of no occurrence is found.
36 *)
37
38 PROCEDURE Copy(str: ARRAY OF CHAR;
39                inx, len: CARDINAL;
40                VAR result: ARRAY OF CHAR);
41 (* Copy at most len characters from str into result, starting at str[inx].
42 *)
43
44 PROCEDURE Concat(s1, s2: ARRAY OF CHAR; VAR result: ARRAY OF CHAR);
45 (* Concatenate two strings.
46 *)
47
48 PROCEDURE Length(str: ARRAY OF CHAR): CARDINAL;
49 (* Return number of characters in str.
50 *)
51
52 PROCEDURE CompareStr(s1, s2: ARRAY OF CHAR): INTEGER;
53 (* Compare two strings, return -1 if s1 < s2, 0 if s1 = s2, and 1 if s1 > s2.
54 *)
55
56 END Strings.