]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add an intercept for strpbrk (copied from Memcheck).
authorJulian Seward <jseward@acm.org>
Sat, 21 Aug 2010 09:04:38 +0000 (09:04 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 21 Aug 2010 09:04:38 +0000 (09:04 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11273

exp-ptrcheck/h_intercepts.c

index caabcd38093d497b3cff5f3c5cfd70d70592bc8d..54fbc624deda753717b1afbf8fa934fed3e083d6 100644 (file)
@@ -356,6 +356,43 @@ STRSTR(VG_Z_LIBC_SONAME,          strstr)
 #endif
 
 
+#define STRPBRK(soname, fnname) \
+   void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
+         (void* sV, void* acceptV); \
+   void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
+         (void* sV, void* acceptV) \
+   { \
+      UChar* s = (UChar*)sV; \
+      UChar* accept = (UChar*)acceptV; \
+      \
+      /*  find the length of 'accept', not including terminating zero */ \
+      UWord nacc = 0; \
+      while (accept[nacc]) nacc++; \
+      \
+      /* if n is the empty string, fail immediately. */ \
+      if (nacc == 0) return NULL; \
+      \
+      /* assert(nacc >= 1); */ \
+      while (1) { \
+         UWord i; \
+         UChar sc = *s; \
+         if (sc == 0) \
+            break; \
+         for (i = 0; i < nacc; i++) { \
+            if (sc == accept[i]) \
+               return s; \
+         } \
+         s++; \
+      } \
+      \
+      return NULL; \
+   }
+
+#if defined(VGO_linux)
+STRPBRK(VG_Z_LIBC_SONAME,          strpbrk)
+#endif
+
+
 /*--------------------------------------------------------------------*/
 /*--- end                                          pc_intercepts.c ---*/
 /*--------------------------------------------------------------------*/