Added Compare function

This commit is contained in:
2020-10-04 16:35:00 +02:00
parent 3009f3dc7a
commit 2e45a338d1

View File

@@ -1,7 +1,7 @@
(**************************************************************************** (****************************************************************************
* File name: CSTRINGS.I * File name: CSTRINGS.I
* Created On: Sat 03 Oct 2020 03:18:19 PM CEST * Created On: Sat 03 Oct 2020 03:18:19 PM CEST
* Last Modified: Sat 03 Oct 2020 03:18:19 PM CEST * Last Modified: Sun 04 Oct 2020 04:34:02 PM CEST
* Author: Jali <jali@orca-central.de> * Author: Jali <jali@orca-central.de>
**************************************************************************** ****************************************************************************
* Implementation for handling C-Like strings * Implementation for handling C-Like strings
@@ -9,6 +9,8 @@
IMPLEMENTATION MODULE CStrings; IMPLEMENTATION MODULE CStrings;
FROM Storage IMPORT ALLOCATE;
PROCEDURE Compare(strA : CString, strB : CString) : CompareResult PROCEDURE Compare(strA : CString, strB : CString) : CompareResult
(* $L- *) (* $L- *)
BEGIN BEGIN
@@ -34,16 +36,34 @@ BEGIN
(* $L+ *) (* $L+ *)
END Compare; END Compare;
PROCEDURE CopyMem(tgt, src : CString)
p : POINTER TO CHAR;
BEGIN
p := tgt;
WHILE src^ <> NULL DO
p^ := src^;
p += 1;
src += 1;
END;
END CopyStr;
PROCEDURE Concat(strA, strB : CString) : CString PROCEDURE Concat(strA, strB : CString) : CString
VAR VAR
r : POINTER TO CHAR;
len : LONGCARD; len : LONGCARD;
newString : ARRAY
resultString : POINTER TO CHAR;
BEGIN BEGIN
len := Length(strA) + Length(strB); len := Length(strA) + Length(strB);
ALLOCATE(r, lenA + lenB);
CopyMem(r, strA);
CopyMem(r, strB);
(r + len)^ := NULL;
END Concat; END Concat;
PROCEDURE Contains
BEGIN
END Contains;
END CStrings; END CStrings;
(* vim: set filetype=modula2: *) (* vim: set filetype=modula2: *)