diff --git a/src/cstrings.i b/src/cstrings.i index 1e94204..f786657 100644 --- a/src/cstrings.i +++ b/src/cstrings.i @@ -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 **************************************************************************** * 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: *)