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
* 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>
****************************************************************************
* Implementation for handling C-Like strings
@@ -9,6 +9,8 @@
IMPLEMENTATION MODULE CStrings;
FROM Storage IMPORT ALLOCATE;
PROCEDURE Compare(strA : CString, strB : CString) : CompareResult
(* $L- *)
BEGIN
@@ -34,16 +36,34 @@ BEGIN
(* $L+ *)
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
VAR
r : POINTER TO CHAR;
len : LONGCARD;
newString : ARRAY
resultString : POINTER TO CHAR;
BEGIN
len := Length(strA) + Length(strB);
ALLOCATE(r, lenA + lenB);
CopyMem(r, strA);
CopyMem(r, strB);
(r + len)^ := NULL;
END Concat;
PROCEDURE Contains
BEGIN
END Contains;
END CStrings;
(* vim: set filetype=modula2: *)