scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 830384d068b500a18a6aeb7a5a45e70bfad72d51
parent 8983432321fac3cb410bb19beae46d891c438328
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 16 Feb 2017 21:05:39 +0100

[libc] Add strcmp()

Diffstat:
Mlibc/src/Makefile | 2+-
Alibc/src/strcmp.c | 11+++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/libc/src/Makefile b/libc/src/Makefile @@ -1,7 +1,7 @@ # See LICENSE file for copyright and license details. .POSIX: -LIBCOBJ = assert.o strcpy.o +LIBCOBJ = assert.o strcpy.o strcmp.o libc.a: $(LIBCOJB) ar $(ARFLAGS) $@ $? diff --git a/libc/src/strcmp.c b/libc/src/strcmp.c @@ -0,0 +1,11 @@ +/* See LICENSE file for copyright and license details. */ + +#include <string.h> + +int +strcmp(const char *s1, const char *s2) +{ + while (*s1 && *s2 && *s1 != *s2) + ++s1, ++s2; + return *s1 - *s2; +}