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