summaryrefslogtreecommitdiff
path: root/klibc
diff options
context:
space:
mode:
Diffstat (limited to 'klibc')
-rw-r--r--klibc/Makefile2
-rw-r--r--klibc/include/string.h3
-rw-r--r--klibc/klibc/Makefile2
-rw-r--r--klibc/klibc/getopt.c1
-rw-r--r--klibc/klibc/memchr.c1
-rw-r--r--klibc/klibc/memrchr.c20
-rw-r--r--klibc/version2
7 files changed, 27 insertions, 4 deletions
diff --git a/klibc/Makefile b/klibc/Makefile
index 8823a33bfd..2506417ef5 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 3bbb217e98..5608a3c963 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 0d44ce5494..d01b2e4326 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 5a992dcdd7..cd534bf304 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 c5c5fa2963..2e5e4cc7f2 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 0000000000..10d9c29851
--- /dev/null
+++ b/klibc/klibc/memrchr.c
@@ -0,0 +1,20 @@
+/*
+ * memrchr.c
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+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 b553d446e1..3759b0aad0 100644
--- a/klibc/version
+++ b/klibc/version
@@ -1 +1 @@
-0.194
+0.196