2 * Adapted from strchr.c code
4 * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
12 /*#define strchrnul TESTING*/
13 char *strchrnul(const char *s, int c)
24 /* with this, we'd get strchr(): */
25 /* " movl $1, %%esi\n" */
26 "2: leal -1(%%esi), %%eax\n"
27 : "=a" (eax), "=&S" (esi)
34 libc_hidden_def(strchrnul)
36 /* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os strchrnul.c -o strchrnul
41 static const char str[] = "abc.def";
42 printf((char*)strchrnul(str, '.') - str == 3 ? "ok\n" : "BAD!\n");
43 printf((char*)strchrnul(str, '*') - str == 7 ? "ok\n" : "BAD!\n");
44 printf((char*)strchrnul(str, 0) - str == 7 ? "ok\n" : "BAD!\n");
45 printf((char*)strchrnul(str+3, '.') - str == 3 ? "ok\n" : "BAD!\n");