aboutsummaryrefslogtreecommitdiffstats
path: root/strchrnul.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-10-21 11:51:38 +0200
committerMattias Andrée <maandree@kth.se>2018-10-21 11:51:38 +0200
commit160eaaddcfed8075abd06624835a2d49548eb5de (patch)
tree6883e07688ad43520b7407d2728f41d0cf9c68a9 /strchrnul.c
parentAdd man pages for more str-functions (diff)
downloadlibsimple-160eaaddcfed8075abd06624835a2d49548eb5de.tar.gz
libsimple-160eaaddcfed8075abd06624835a2d49548eb5de.tar.bz2
libsimple-160eaaddcfed8075abd06624835a2d49548eb5de.tar.xz
Add strcasechr and strcasechrnul
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'strchrnul.c')
-rw-r--r--strchrnul.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/strchrnul.c b/strchrnul.c
index 3ec6a0f..e4ed5ab 100644
--- a/strchrnul.c
+++ b/strchrnul.c
@@ -4,7 +4,7 @@
char *
-libsimple_strchrnul(const char *s_, char c_)
+libsimple_strchrnul(const char *s_, int c_)
{
char *s = *(char **)(void *)&s_, c = (char)c_;
for (; *s && *s != c; s++);
@@ -18,9 +18,20 @@ libsimple_strchrnul(const char *s_, char c_)
int
main(void)
{
- assert(!strcmpnul(libsimple_strchrnul("1234512345", '3'), "34512345"));
- assert(!strcmpnul(libsimple_strchrnul("1234512345", '1'), "1234512345"));
- assert(!strcmpnul(libsimple_strchrnul("1234512345", 'x'), ""));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'c'), "cABCabcABCx"));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'a'), "abcABCabcABCx"));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'x'), "x"));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'C'), "CabcABCx"));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'A'), "ABCabcABCx"));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'X'), ""));
+ assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", '0'), ""));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'c'), "cABCabcX"));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'a'), "abcABCabcX"));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'x'), ""));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'C'), "CabcABCabcX"));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'A'), "ABCabcABCabcX"));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'X'), "X"));
+ assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", '0'), ""));
return 0;
}