From c3a8dac6ff48eb52e3529b23f3db84021bbc2f4a Mon Sep 17 00:00:00 2001 From: "kay.sievers@vrfy.org" Date: Mon, 17 Jan 2005 09:26:07 +0100 Subject: [PATCH] [PATCH] klibc: update to version 0.196 --- klibc/Makefile | 2 +- klibc/include/string.h | 3 ++- klibc/klibc/Makefile | 2 +- klibc/klibc/getopt.c | 1 + klibc/klibc/memchr.c | 1 + klibc/klibc/memrchr.c | 20 ++++++++++++++++++++ klibc/version | 2 +- 7 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 klibc/klibc/memrchr.c diff --git a/klibc/Makefile b/klibc/Makefile index 8823a33b..2506417e 100644 --- a/klibc/Makefile +++ b/klibc/Makefile @@ -1,5 +1,5 @@ VERSION := $(shell cat version) -SUBDIRS = klibc +SUBDIRS = klibc ash ipconfig nfsmount utils kinit gzip all: diff --git a/klibc/include/string.h b/klibc/include/string.h index 3bbb217e..5608a3c9 100644 --- a/klibc/include/string.h +++ b/klibc/include/string.h @@ -10,6 +10,7 @@ __extern void *memccpy(void *, const void *, int, size_t); __extern void *memchr(const void *, int, size_t); +__extern void *memrchr(const void *, int, size_t); __extern int memcmp(const void *, const void *, size_t); __extern void *memcpy(void *, const void *, size_t); __extern void *memmove(void *, const void *, size_t); @@ -20,6 +21,7 @@ __extern int strcasecmp(const char *, const char *); __extern int strncasecmp(const char *, const char *, size_t); __extern char *strcat(char *, const char *); __extern char *strchr(const char *, int); +__extern char *strrchr(const char *, int); __extern int strcmp(const char *, const char *); __extern char *strcpy(char *, const char *); __extern size_t strcspn(const char *, const char *); @@ -34,7 +36,6 @@ __extern int strncmp(const char *, const char *, size_t); __extern char *strncpy(char *, const char *, size_t); __extern size_t strlcpy(char *, const char *, size_t); __extern char *strpbrk(const char *, const char *); -__extern char *strrchr(const char *, int); __extern char *strsep(char **, const char *); __extern size_t strspn(const char *, const char *); __extern char *strstr(const char *, const char *); diff --git a/klibc/klibc/Makefile b/klibc/klibc/Makefile index 0d44ce54..d01b2e43 100644 --- a/klibc/klibc/Makefile +++ b/klibc/klibc/Makefile @@ -30,7 +30,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ sigaction.o sigpending.o sigprocmask.o sigsuspend.o \ brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \ memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \ - memmove.o memchr.o \ + memmove.o memchr.o memrchr.o \ strcasecmp.o strncasecmp.o strndup.o strerror.o \ strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \ strncat.o strlcpy.o strlcat.o \ diff --git a/klibc/klibc/getopt.c b/klibc/klibc/getopt.c index 5a992dcd..cd534bf3 100644 --- a/klibc/klibc/getopt.c +++ b/klibc/klibc/getopt.c @@ -51,6 +51,7 @@ int getopt(int argc, char * const *argv, const char *optstring) optind += 2; } else { /* Missing argument */ + optind++; return (optstring[0] == ':') ? ':' : '?'; } } diff --git a/klibc/klibc/memchr.c b/klibc/klibc/memchr.c index c5c5fa29..2e5e4cc7 100644 --- a/klibc/klibc/memchr.c +++ b/klibc/klibc/memchr.c @@ -12,6 +12,7 @@ void *memchr(const void *s, int c, size_t n) while ( n-- ) { if ( *sp == (unsigned char)c ) return (void *)sp; + sp++; } return NULL; diff --git a/klibc/klibc/memrchr.c b/klibc/klibc/memrchr.c new file mode 100644 index 00000000..10d9c298 --- /dev/null +++ b/klibc/klibc/memrchr.c @@ -0,0 +1,20 @@ +/* + * memrchr.c + */ + +#include +#include + +void *memrchr(const void *s, int c, size_t n) +{ + const unsigned char *sp = + (const unsigned char *)s + n - 1; + + while ( n-- ) { + if ( *sp == (unsigned char)c ) + return (void *)sp; + sp--; + } + + return NULL; +} diff --git a/klibc/version b/klibc/version index b553d446..3759b0aa 100644 --- a/klibc/version +++ b/klibc/version @@ -1 +1 @@ -0.194 +0.196 -- 2.39.5