Category : Modula II Source Code
Archive   : FASTR.ZIP
Filename : FASTR.DEF

 
Output of file : FASTR.DEF contained in archive : FASTR.ZIP
DEFINITION MODULE FASTR; (* FastStrings by D. Body 7/89 *)

(* Strings are stored in "canonical" form, in which the length of the *)
(* string can be determined in constant time (no scan required). *)
(* Following Bron and Dijkstra, SIGPLAN Notices 24(6) June 1989, a *)
(* string may occupy part or all of an ARRAY OF CHAR, and is (usually)*)
(* null-terminated. The cases are as follows: *)
(* 1. The string exactly fills the array. In this case of course, *)
(* no null termination is used. In the other cases, the null *)
(* char is stored in the array at the position immedidately after*)
(* the end of the string. *)
(* 2. The distance from the end of the array to the null char is *)
(* less than 3. The last byte of the array stores this distance.*)
(* 3. The distance from the end of the array to the null char is at *)
(* least 3. In this case the length of the string is stroed in *)
(* the two bytes preceeding the last byte. The last byte holds *)
(* CHR(255) to flag this case. *)
(* To be consistant the user should declare all arrays of char with *)
(* index from zero. The index of the last char in the string is *)
(* length(string) - 1. *)

PROCEDURE Length (s: ARRAY OF CHAR): CARDINAL;
(* returns the length of a string stored in canonical form *)

PROCEDURE Terminate (VAR s: ARRAY OF CHAR; len: CARDINAL);
(* convert any array of chars into the canonical form *)

PROCEDURE Fix (VAR s: ARRAY OF CHAR);
(* assuming s is already null_terminated, convert it to canonical form *)

PROCEDURE Assign (VAR target: ARRAY OF CHAR; source: ARRAY OF CHAR);
(* assign the source string to the target string. truncate if necessary. *)

PROCEDURE Append (VAR target: ARRAY OF CHAR; source: ARRAY OF CHAR);
(* append the source string to the target. truncate if necessary *)

PROCEDURE Insert (VAR target: ARRAY OF CHAR; subStr: ARRAY OF CHAR; pos: CARDINAL);
(* insert subStr into the target, to start at position pos. truncate if necessary. *)

PROCEDURE FindPat (pattern, subject: ARRAY OF CHAR; start: CARDINAL): CARDINAL;
(* searches from position start for the first match of pattern in the subject. *)
(* returns the length (subject) to signal failure of the search. *)

PROCEDURE FindChar (ch, subject: ARRAY OF CHAR; start: CARDINAL): CARDINAL;
(* assuming ch has length 1, searches from position start for the first match *)
(* of ch in the subject. returns the Length (subject) to signal failure. *)

PROCEDURE FindOtherChar (ch, subject: ARRAY OF CHAR; start: CARDINAL): CARDINAL;
(* assuming ch has length 1, searches from postion start for the first non-match *)
(* of ch in the subject. returns the Length (subject) to signal failure. *)

PROCEDURE CopySub (VAR target: ARRAY OF CHAR; subject: ARRAY OF CHAR; start, len: CARDINAL);
(* assigns a copy of a substring of the subject to the target. the substring *)
(* begins at position start, and has a length of len. *)

PROCEDURE DeleteSub (VAR subject: ARRAY OF CHAR; start, len: CARDINAL);
(* delete a substring of the subject. the substring begins at position *)
(* start, and has length of len. *)

PROCEDURE Parse (VAR subject: ARRAY OF CHAR; pattern: ARRAY OF CHAR; VAR before: ARRAY OF CHAR);
(* search subject string, left to right, for first occurance of the substring pattern. *)
(* if not found, set before to subject, and subject to the empty string; else replace *)
(* subject by the remainder of the subject after the pattern. *)

PROCEDURE LexCompare (VAR s1, s2: ARRAY OF CHAR): INTEGER;
(* assume s1 and s2 are canonical strings. returns an indication of the *)
(* relative lexical comparision of the two strings. [NOTE: VAR parameters *)
(* are used solely for efficiency. *)

PROCEDURE IsLess (s1, s2: ARRAY OF CHAR): BOOLEAN;

PROCEDURE IsEqual (s1, s2: ARRAY OF CHAR): BOOLEAN;

PROCEDURE IsGreater (s1, s2: ARRAY OF CHAR): BOOLEAN;

PROCEDURE TrimL (VAR s: ARRAY OF CHAR; ch: CHAR);
(* trim-left: delete leading characters from the string *)

PROCEDURE TrimR (VAR s: ARRAY OF CHAR; ch: CHAR);
(* trim-right: delete trailing characters from the string *)

END FASTR.

  3 Responses to “Category : Modula II Source Code
Archive   : FASTR.ZIP
Filename : FASTR.DEF

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/