Ticket #3327: wince-missing.patch
File wince-missing.patch, 1.2 KB (added by , 17 years ago) |
---|
-
backends/platform/wince/missing/missing.cpp
40 40 41 41 void *bsearch(const void *key, const void *base, size_t nmemb, 42 42 size_t size, int (*compar)(const void *, const void *)) { 43 size_t i; 43 // Perform binary search 44 size_t lo = 0; 45 size_t hi = nmemb; 46 while (lo < hi) { 47 size_t mid = (lo + hi) / 2; 48 const void *p = ((const char *)base) + mid * size; 49 int tmp = (*compar)(key, p); 50 if (tmp < 0) 51 hi = mid; 52 else if (tmp > 0) 53 lo = mid + 1; 54 else 55 return (void *)p; 56 } 44 57 45 for (i=0; i<nmemb; i++)46 if (compar(key, (void*)((size_t)base + size * i)) == 0)47 return (void*)((size_t)base + size * i);48 58 return NULL; 49 59 } 50 60 … … 465 475 } 466 476 467 477 char *strpbrk(const char *s, const char *accept) { 468 int i;469 470 478 if (!s || !accept) 471 479 return NULL; 472 480 473 for ( i=0; i<strlen(s); i++) {474 int j;475 for (j=0; j<strlen(accept); j++)476 if (s[i] == accept[j])477 return (char*)&s[i];481 for (; *s != 0; ++s) { 482 for (const char *a = accept; *a != 0; ++a) { 483 if (*s == *a) 484 return (char *)s; 485 } 478 486 } 479 487 480 488 return NULL;