Search a memory buffer for any set of bytes, like strpbrk(). * Returns pointer to first found char or NULL. */
| 248 | * Returns pointer to first found char or NULL. |
| 249 | */ |
| 250 | const char *mempbrk(const char *s, size_t len, const char *chars, size_t charslen) { |
| 251 | for (size_t j = 0; j < len; j++) { |
| 252 | for (size_t n = 0; n < charslen; n++) |
| 253 | if (s[j] == chars[n]) return &s[j]; |
| 254 | } |
| 255 | |
| 256 | return NULL; |
| 257 | } |
| 258 | |
| 259 | /* Modify the buffer replacing all occurrences of chars from the 'from' |
| 260 | * set with the corresponding char in the 'to' set. Always returns s. |