From 8e74d025f29ddaa619b46e996370103da4d7dfe7 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sun, 17 May 2020 19:29:29 +0200 Subject: [PATCH] mescc: Mes C Library: Prepare for M2-Planet: memcmp. * lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet. --- lib/string/memcmp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/string/memcmp.c b/lib/string/memcmp.c index 5c28af8c..4f33e1c3 100644 --- a/lib/string/memcmp.c +++ b/lib/string/memcmp.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -23,14 +23,17 @@ int memcmp (void const *s1, void const *s2, size_t size) { - if (!size) + if (size == 0) return 0; + char const *a = s1; char const *b = s2; - while (*a == *b && --size) + + while (a[0] == b[0] && size > 0) { - a++; - b++; + size = size - 1; + a = a + 1; + b = b + 1; } - return *a - *b; + return a[0] - b[0]; }