From: David Given Date: Sun, 15 Mar 2015 21:32:23 +0000 (+0100) Subject: Never write your own stringlib function. They're always wrong. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=df0018cbf67b802773cd7fa5fc141ed899911054;p=FUZIX.git Never write your own stringlib function. They're always wrong. --HG-- extra : source : edba20538064196b2309e94b20e085b51024ea88 --- diff --git a/Library/libs/strlen.c b/Library/libs/strlen.c index 98c1e274..a0e6c016 100644 --- a/Library/libs/strlen.c +++ b/Library/libs/strlen.c @@ -1,16 +1,17 @@ -/* string.c - * Copyright (C) 1995,1996 Robert de Bath - * This file is part of the Linux-8086 C library and is distributed - * under the GNU Library General Public License. +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * This file is licensed under the terms of the MIT open source license. */ -#include +#include -/********************** Function strlen ************************************/ -size_t strlen(const char *str) +size_t +strlen(const char *org) { - const char* start = str; - while (*str++) - ; - return str - start; + register const char *s = org; + + while (*s++) + /* EMPTY */ ; + + return --s - org; }