aboutsummaryrefslogtreecommitdiff
path: root/src/base/string/raw/ncompare.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/string/raw/ncompare.c')
-rw-r--r--src/base/string/raw/ncompare.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/base/string/raw/ncompare.c b/src/base/string/raw/ncompare.c
new file mode 100644
index 0000000..34c6d6d
--- /dev/null
+++ b/src/base/string/raw/ncompare.c
@@ -0,0 +1,17 @@
+#include <u.h>
+#include <base.h>
+
+int
+str·ncompare(char *l, intptr n, char *r)
+{
+ int cl, cr;
+
+ while(n-- > 0){
+ cl=*l++, cr=*r++;
+ if(cl != cr)
+ return cl-cr;
+ if(!cl)
+ return 0;
+ }
+ return *r ? -1 : 0;
+}