From: Julian Seward Date: Sat, 21 Aug 2010 09:04:38 +0000 (+0000) Subject: Add an intercept for strpbrk (copied from Memcheck). X-Git-Tag: svn/VALGRIND_3_6_0~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64fcacf70d670150298cb4c086c89e3a1d25dbf8;p=thirdparty%2Fvalgrind.git Add an intercept for strpbrk (copied from Memcheck). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11273 --- diff --git a/exp-ptrcheck/h_intercepts.c b/exp-ptrcheck/h_intercepts.c index caabcd3809..54fbc624de 100644 --- a/exp-ptrcheck/h_intercepts.c +++ b/exp-ptrcheck/h_intercepts.c @@ -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 ---*/ /*--------------------------------------------------------------------*/