[Pal/lib] Add strcmp() function

This commit is contained in:
Thomas Knauth
2019-12-19 20:07:06 -08:00
committed by Dmitrii Kuvaiskii
parent 3174ec726c
commit de5efcd53d
3 changed files with 23 additions and 6 deletions
+1
View File
@@ -123,6 +123,7 @@ typedef ptrdiff_t ssize_t;
/* Libc String functions string.h/stdlib.h */
size_t strnlen (const char *str, size_t maxlen);
size_t strlen (const char *str);
int strcmp(const char* a, const char* b);
long strtol (const char *s, char **endptr, int base);
int atoi (const char *nptr);
+22
View File
@@ -0,0 +1,22 @@
#include "api.h"
/* Copyright © 2005-2014 Rich Felker, et al. */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* musl 1.1.24 */
int strcmp(const char* l, const char* r) {
for (; *l == *r && *l; l++, r++)
;
return *(unsigned char*)l - *(unsigned char*)r;
}
-6
View File
@@ -3,12 +3,6 @@
#include "pal_defs.h"
#include "pal_error.h"
static int strcmp(const char* a, const char* b) {
for (; *a && *b && *a == *b; a++, b++)
;
return *a - *b;
}
static const char* get_norm_path_cases[][2] = {
{"/", "/"},
{"/a/b/c", "/a/b/c"},