]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a strrchr implementation.
authorTom Hughes <tom@compton.nu>
Sun, 13 Jun 2004 09:55:22 +0000 (09:55 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 13 Jun 2004 09:55:22 +0000 (09:55 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2407

coregrind/vg_mylibc.c
include/vg_skin.h.base

index 2023aa58d402372600f534d0f85a0afb8afd5085..b2940fe75fe8062ed3da9a5cf39faae55341404d 100644 (file)
@@ -1013,6 +1013,16 @@ Char* VG_(strchr) ( const Char* s, Char c )
 }
 
 
+Char* VG_(strrchr) ( const Char* s, Char c )
+{
+   Int n = VG_(strlen)(s);
+   while (--n > 0) {
+      if (s[n] == c) return (Char*)s + n;
+   }
+   return NULL;
+}
+
+
 void* VG_(memcpy) ( void *dest, const void *src, Int sz )
 {
    const Char *s = (const Char *)src;
index 60c50d97e59f56eed79f838c0ca9668f7365870d..2a682996f4a3fd7e02316da5d3465185862b1d5e 100644 (file)
@@ -431,6 +431,7 @@ extern Int   VG_(strcmp)         ( const Char* s1, const Char* s2 );
 extern Int   VG_(strncmp)        ( const Char* s1, const Char* s2, Int nmax );
 extern Char* VG_(strstr)         ( const Char* haystack, Char* needle );
 extern Char* VG_(strchr)         ( const Char* s, Char c );
+extern Char* VG_(strrchr)        ( const Char* s, Char c );
 extern Char* VG_(strdup)         ( const Char* s);
 extern void* VG_(memcpy)         ( void *d, const void *s, Int sz );
 extern void* VG_(memset)         ( void *s, Int c, Int sz );