|
From: <sv...@va...> - 2010-08-21 09:04:47
|
Author: sewardj
Date: 2010-08-21 10:04:38 +0100 (Sat, 21 Aug 2010)
New Revision: 11273
Log:
Add an intercept for strpbrk (copied from Memcheck).
Modified:
trunk/exp-ptrcheck/h_intercepts.c
Modified: trunk/exp-ptrcheck/h_intercepts.c
===================================================================
--- trunk/exp-ptrcheck/h_intercepts.c 2010-08-20 18:25:40 UTC (rev 11272)
+++ trunk/exp-ptrcheck/h_intercepts.c 2010-08-21 09:04:38 UTC (rev 11273)
@@ -356,6 +356,43 @@
#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 ---*/
/*--------------------------------------------------------------------*/
|