X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fstr-fix.c;h=2610fcf7f31783d0da21e53ec9dafcd16ab49664;hb=5403c0fab834f71416e627dfd7346a577a0ca6f5;hp=deb128e89d623f7e35ac1a1ccb816de55fc73fa7;hpb=521609b4721376161eabe89c9431aa221e87e263;p=libucw.git diff --git a/ucw/str-fix.c b/ucw/str-fix.c index deb128e8..2610fcf7 100644 --- a/ucw/str-fix.c +++ b/ucw/str-fix.c @@ -7,20 +7,20 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/string.h" +#include +#include #include int -str_has_prefix(char *str, char *prefix) +str_has_prefix(const char *str, const char *prefix) { size_t pxlen = strlen(prefix); return !strncmp(str, prefix, pxlen); } int -str_has_suffix(char *str, char *suffix) +str_has_suffix(const char *str, const char *suffix) { size_t sxlen = strlen(suffix); size_t len = strlen(str); @@ -32,14 +32,14 @@ str_has_suffix(char *str, char *suffix) } int -str_hier_prefix(char *str, char *prefix, uns sep) +str_hier_prefix(const char *str, const char *prefix, uint sep) { while (*str && *prefix) { size_t sl=0, pl=0; - while (str[sl] && (uns) str[sl] != sep) + while (str[sl] && (uint) str[sl] != sep) sl++; - while (prefix[pl] && (uns) prefix[pl] != sep) + while (prefix[pl] && (uint) prefix[pl] != sep) pl++; if (sl != pl || memcmp(str, prefix, sl)) return 0; @@ -54,16 +54,16 @@ str_hier_prefix(char *str, char *prefix, uns sep) } int -str_hier_suffix(char *str, char *suffix, uns sep) +str_hier_suffix(const char *str, const char *suffix, uint sep) { - char *st = str + strlen(str); - char *sx = suffix + strlen(suffix); + const char *st = str + strlen(str); + const char *sx = suffix + strlen(suffix); while (st > str && sx > suffix) { size_t sl=0, pl=0; - while (st-sl > str && (uns) st[-sl-1] != sep) + while (st-sl > str && (uint) st[-sl-1] != sep) sl++; - while (sx-pl > suffix && (uns) sx[-pl-1] != sep) + while (sx-pl > suffix && (uint) sx[-pl-1] != sep) pl++; if (sl != pl || memcmp(st-sl, sx-pl, sl)) return 0;