[SeaBIOS] [PATCH 3/9] Add strchr() function.

Kevin O'Connor kevin at koconnor.net
Fri Dec 24 16:41:45 CET 2010


On Thu, Dec 23, 2010 at 11:29:37AM +0200, Gleb Natapov wrote:
> 
> Signed-off-by: Gleb Natapov <gleb at redhat.com>
> ---
>  src/util.c |   11 +++++++++++
>  src/util.h |    1 +
>  2 files changed, 12 insertions(+), 0 deletions(-)

How about this instead?

-Kevin


--- a/src/util.c
+++ b/src/util.c
@@ -262,6 +262,15 @@ strtcpy(char *dest, const char *src, size_t len)
     return dest;
 }
 
+// locate first occurance of character c in the string s
+char *
+strchr(const char *s, int c)
+{
+    for (; *s; s++)
+        if (*s == c)
+            return (char*)s;
+    return NULL;
+}
 
 /****************************************************************
  * Keyboard calls
diff --git a/src/util.h b/src/util.h
index fa7b20f..f5b9446 100644
--- a/src/util.h
+++ b/src/util.h
@@ -209,6 +209,7 @@ void *memcpy(void *d1, const void *s1, size_t len);
 void iomemcpy(void *d, const void *s, u32 len);
 void *memmove(void *d, const void *s, size_t len);
 char *strtcpy(char *dest, const char *src, size_t len);
+char *strchr(const char *s, int c);
 int get_keystroke(int msec);
 
 // stacks.c



More information about the SeaBIOS mailing list