ia64/xen-unstable

changeset 16439:dc9246357cdb

[Mini-OS] Add strrchr()

Add strrchr(), useful e.g. for grabbing the last part of a xenbus
path.

Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Nov 23 16:42:44 2007 +0000 (2007-11-23)
parents b1324eca1cd9
children 0814fb0f8a4d
files extras/mini-os/include/lib.h extras/mini-os/lib/string.c
line diff
     1.1 --- a/extras/mini-os/include/lib.h	Fri Nov 23 16:42:23 2007 +0000
     1.2 +++ b/extras/mini-os/include/lib.h	Fri Nov 23 16:42:44 2007 +0000
     1.3 @@ -87,6 +87,7 @@ void  *memset(void *s,int c, size_t coun
     1.4  size_t strnlen(const char *s, size_t count);
     1.5  size_t strlen(const char *s);
     1.6  char  *strchr(const char *s, int c);
     1.7 +char  *strrchr(const char *s, int c);
     1.8  char  *strstr(const char *s1, const char *s2);
     1.9  char * strcat(char * dest, const char * src);
    1.10  char  *strdup(const char *s);
     2.1 --- a/extras/mini-os/lib/string.c	Fri Nov 23 16:42:23 2007 +0000
     2.2 +++ b/extras/mini-os/lib/string.c	Fri Nov 23 16:42:44 2007 +0000
     2.3 @@ -140,6 +140,15 @@ char * strchr(const char * s, int c)
     2.4          return (char *)s;
     2.5  }
     2.6  
     2.7 +char * strrchr(const char * s, int c)
     2.8 +{
     2.9 +        const char *res;
    2.10 +        for(; *s != '\0'; ++s)
    2.11 +                if (*s == (char) c)
    2.12 +                        res = s;
    2.13 +        return (char *)res;
    2.14 +}
    2.15 +
    2.16  char * strstr(const char * s1,const char * s2)
    2.17  {
    2.18          int l1, l2;