[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [Mini-OS] Add strrchr()



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1195836164 0
# Node ID dc9246357cdbe27655fd0ac7ef229d25b00c628c
# Parent  b1324eca1cd991001b4f8ea75e1121b29cec7b4a
[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@xxxxxxxxxx>
---
 extras/mini-os/include/lib.h |    1 +
 extras/mini-os/lib/string.c  |    9 +++++++++
 2 files changed, 10 insertions(+)

diff -r b1324eca1cd9 -r dc9246357cdb extras/mini-os/include/lib.h
--- a/extras/mini-os/include/lib.h      Fri Nov 23 16:42:23 2007 +0000
+++ b/extras/mini-os/include/lib.h      Fri Nov 23 16:42:44 2007 +0000
@@ -87,6 +87,7 @@ size_t strnlen(const char *s, size_t cou
 size_t strnlen(const char *s, size_t count);
 size_t strlen(const char *s);
 char  *strchr(const char *s, int c);
+char  *strrchr(const char *s, int c);
 char  *strstr(const char *s1, const char *s2);
 char * strcat(char * dest, const char * src);
 char  *strdup(const char *s);
diff -r b1324eca1cd9 -r dc9246357cdb extras/mini-os/lib/string.c
--- a/extras/mini-os/lib/string.c       Fri Nov 23 16:42:23 2007 +0000
+++ b/extras/mini-os/lib/string.c       Fri Nov 23 16:42:44 2007 +0000
@@ -140,6 +140,15 @@ char * strchr(const char * s, int c)
         return (char *)s;
 }
 
+char * strrchr(const char * s, int c)
+{
+        const char *res;
+        for(; *s != '\0'; ++s)
+                if (*s == (char) c)
+                        res = s;
+        return (char *)res;
+}
+
 char * strstr(const char * s1,const char * s2)
 {
         int l1, l2;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.