--- Gnu-Mach/kern/strings.c 2020/09/02 04:36:56 1.1.1.1 +++ Gnu-Mach/kern/strings.c 2020/09/02 04:51:57 1.1.1.4 @@ -31,7 +31,7 @@ * String functions. */ -#include /* make sure we sell the truth */ +#include #ifdef strcpy #undef strcmp @@ -50,15 +50,15 @@ * the contents are identical up to the length of s2. * It returns < 0 if the first differing character is smaller * in s1 than in s2 or if s1 is shorter than s2 and the - * contents are identical upto the length of s1. + * contents are identical up to the length of s1. */ -int +int __attribute__ ((pure)) strcmp( - register const char *s1, - register const char *s2) + const char *s1, + const char *s2) { - register unsigned int a, b; + unsigned int a, b; do { a = *s1++; @@ -80,13 +80,13 @@ strcmp( * comparison runs for at most "n" characters. */ -int +int __attribute__ ((pure)) strncmp( - register const char *s1, - register const char *s2, - unsigned long n) + const char *s1, + const char *s2, + size_t n) { - register unsigned int a, b; + unsigned int a, b; while (n != 0) { a = *s1++; @@ -113,10 +113,10 @@ strncmp( char * strcpy( - register char *to, - register const char *from) + char *to, + const char *from) { - register char *ret = to; + char *ret = to; while ((*to++ = *from++) != '\0') continue; @@ -135,11 +135,11 @@ strcpy( char * strncpy( - register char *to, - register const char *from, - register unsigned long count) + char *to, + const char *from, + size_t count) { - register char *ret = to; + char *ret = to; while (count != 0) { count--; @@ -157,18 +157,37 @@ strncpy( /* * Abstract: - * strlen returns the number of characters in "string" preceeding + * strlen returns the number of characters in "string" preceding * the terminating null character. */ -unsigned long +size_t __attribute__ ((pure)) strlen( - register const char *string) + const char *string) { - register const char *ret = string; + const char *ret = string; while (*string++ != '\0') continue; return string - 1 - ret; } + +/* + * Abstract: + * memset writes value "c" in the "n" bytes starting at address "s". + * The return value is a pointer to the "s" string. + */ + +void * +memset( + void *_s, int c, size_t n) +{ + char *s = _s; + size_t i; + + for (i = 0; i < n ; i++) + s[i] = c; + + return _s; +}