From: Julian Seward Date: Fri, 20 Aug 2010 18:24:16 +0000 (+0000) Subject: Add in comments a (validated) strspn replacement, should it become X-Git-Tag: svn/VALGRIND_3_6_0~185 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2113a567d29643502492994b9c7e9d62977587f;p=thirdparty%2Fvalgrind.git Add in comments a (validated) strspn replacement, should it become necessary. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11270 --- diff --git a/memcheck/mc_replace_strmem.c b/memcheck/mc_replace_strmem.c index f928769dfb..14334c2110 100644 --- a/memcheck/mc_replace_strmem.c +++ b/memcheck/mc_replace_strmem.c @@ -984,6 +984,36 @@ STRCSPN(VG_Z_LIBC_SONAME, strcspn) #endif +// And here's a validated strspn replacement, should it +// become necessary. +//UWord mystrspn( UChar* s, UChar* accept ) +//{ +// /* find the length of 'accept', not including terminating zero */ +// UWord nacc = 0; +// while (accept[nacc]) nacc++; +// if (nacc == 0) return 0; +// +// UWord len = 0; +// while (1) { +// UWord i; +// UChar sc = *s; +// if (sc == 0) +// break; +// for (i = 0; i < nacc; i++) { +// if (sc == accept[i]) +// break; +// } +// assert(i >= 0 && i <= nacc); +// if (i == nacc) +// break; +// s++; +// len++; +// } +// +// return len; +//} + + /*------------------------------------------------------------*/ /*--- Improve definedness checking of process environment ---*/ /*------------------------------------------------------------*/