X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=misc.c;h=0f96b7a878316948c11d98a70259865d5e70ac55;hb=7c88cafcd333277b6bfd55370a5ec1c5b76c2b0d;hp=01bdd545095073254211065d076f4930a9b11b3f;hpb=4909ba20244f55ee7326a40d751cf6737c2bc2b6;p=pkg%2Fabook.git diff --git a/misc.c b/misc.c index 01bdd54..0f96b7a 100644 --- a/misc.c +++ b/misc.c @@ -64,6 +64,41 @@ strtrim(char *s) return s; } +int +is_number(char *p) +{ + if(!p || !*p || (*p == '-' && !*++p)) + return 0; + + for(; *p; p++) + if(!isdigit(*p)) + return 0; + + return 1; +} + +#ifndef HAVE_STRCASESTR +char * +strcasestr(const char *haystack, const char *needle) +{ + int i; + int k; + + assert(haystack != NULL); + assert(needle != NULL); + + for(i=0; i