diff options
Diffstat (limited to 'src/base/string/raw/ecompare.c')
-rw-r--r-- | src/base/string/raw/ecompare.c | 20 |
1 files changed, 20 insertions, 0 deletions
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 <u.h> +#include <base.h> + +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; +} |