From 521d01e8ad87e931af3e9a763cc84a6cf7fe5ee3 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sun, 5 Dec 2021 09:47:21 -0800 Subject: Feat: basic string and memory functions Continue filling out the basic standard lib functions. Included prototypes of the str* and mem* families. Plan to add e(str|mem) and n(str|mem) variants as well. --- src/base/string/raw/ecompare.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/base/string/raw/ecompare.c (limited to 'src/base/string/raw/ecompare.c') diff --git a/src/base/string/raw/ecompare.c b/src/base/string/raw/ecompare.c new file mode 100644 index 0000000..f0e20e8 --- /dev/null +++ b/src/base/string/raw/ecompare.c @@ -0,0 +1,20 @@ +#include +#include + +int +strĀ·ecompare(char *l, char *e, char *r) +{ + int cl, cr; + + if(l > e) /* l is nil */ + return *r ? -1 : 0; + + while(l != e){ + cl=*l++, cr=*r++; + if(cl != cr) + return cl-cr; + if(!cl) + return 0; + } + return *r ? -1 : 0; +} -- cgit v1.2.1