git-svn-id: https://spexeah.com:8443/svn/Asuro@517 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
aaron
2018-04-13 18:59:19 +00:00
parent e63c51045b
commit 383f36bad3
4 changed files with 155 additions and 19 deletions

View File

@ -13,7 +13,8 @@ interface
uses
util,
lmemorymanager;
lmemorymanager,
lists;
function stringToUpper(str : pchar) : pchar;
function stringToLower(str : pchar) : pchar;
@ -26,9 +27,13 @@ function stringContains(str : pchar; sub : pchar) : boolean;
function stringToInt(str : pchar) : uint32;
function intToString(i : uint32) : pchar;
function boolToString(b : boolean; ext : boolean) : pchar;
function stringToLL(str : pchar; delimter : char) : PLinkedListBase;
implementation
uses
console;
function stringToUpper(str : pchar) : pchar;
var
result : pchar;
@ -173,4 +178,42 @@ begin
end;
end;
function stringToLL(str : pchar; delimter : char) : PLinkedListBase; //todo implment function for freeing pointer lists
var
list : PLinkedListBase;
i : uint32 = 0;
out_str : pchar;
elm : puint32;
head : pchar;
tail : pchar;
size : uint32;
null_delim : boolean;
begin
list := LL_New(sizeof(uint32));
stringToLL:= list;
head:= str;
tail:= head;
null_delim:= false;
while not null_delim do begin
if (head^ = delimter) or (head^ = char(0)) then begin
if head^ = char(0) then null_delim:= true;
size:= uint32(head) - uint32(tail);
console.writeintln(size);
if size > 0 then begin
elm:= puint32(LL_Add(list));
out_str:= stringNew(size);
memcpy(uint32(tail), uint32(out_str), size);
elm^:= uint32(out_str);
end;
tail:= head+1;
end else begin
console.writecharln(head^);
end;
inc(head);
end;
end;
end.