X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fbrkstring.c;h=205c8c9e9df7b247cdc38608b79ed4b90cf605aa;hp=68c7b70312c757a0a0fc6b565a717add4d17b535;hb=a2ca51e05aaad418d652ce36f232a9076b3b2d08;hpb=b25e57753f3f4fb3fdde4240e0f617ef8dbea043 diff --git a/sbr/brkstring.c b/sbr/brkstring.c index 68c7b70..205c8c9 100644 --- a/sbr/brkstring.c +++ b/sbr/brkstring.c @@ -7,6 +7,7 @@ ** complete copyright information. */ +#include #include #include @@ -46,7 +47,7 @@ brkstring(char *str, char *brksep, char *brkterm) } /* handle separators */ - while (strchr(brksep, c = *s)) { + while ((c=*s) && brksep && strchr(brksep, c)) { *s++ = '\0'; } @@ -54,7 +55,7 @@ brkstring(char *str, char *brksep, char *brkterm) ** we are either at the end of the string, or the ** terminator found has been found, so finish up. */ - if (!c || strchr(brkterm, c)) { + if (!c || (brkterm && strchr(brkterm, c))) { *s = '\0'; broken[i] = NULL; return broken; @@ -62,9 +63,14 @@ brkstring(char *str, char *brksep, char *brkterm) /* set next start addr and walk over word */ broken[i] = s; - while ((c=*++s) && !strchr(brksep, c) && !strchr(brkterm, c)) { - continue; + while ((c = *++s)) { + if (brksep && strchr(brksep, c)) { + break; + } + if (brkterm && strchr(brkterm, c)) { + break; + } } } - adios("brkstring()", "reached unreachable point"); + adios(EX_SOFTWARE, "brkstring()", "reached unreachable point"); }