From: Robert Spalek Date: Sat, 11 Apr 2009 21:26:50 +0000 (-0700) Subject: move strnlen() to ucw/string.c X-Git-Tag: holmes-import~24 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=c53020c26307aaae5d519ae2f90ea6dbd8911c39;p=libucw.git move strnlen() to ucw/string.c --- diff --git a/ucw/stkstring.c b/ucw/stkstring.c index e501ba20..32bd9743 100644 --- a/ucw/stkstring.c +++ b/ucw/stkstring.c @@ -15,17 +15,6 @@ #include -#ifdef CONFIG_DARWIN -uns -strnlen(const char *str, uns n) -{ - const char *end = str + n; - const char *c; - for (c = str; *c && c < end; c++); - return c - str; -} -#endif - uns stk_array_len(char **s, uns cnt) { diff --git a/ucw/stkstring.h b/ucw/stkstring.h index d96b7238..5cd2c6b8 100644 --- a/ucw/stkstring.h +++ b/ucw/stkstring.h @@ -15,10 +15,7 @@ #include #include #include - -#ifdef CONFIG_DARWIN -uns strnlen(const char *str, uns n); -#endif +#include "ucw/string.h" #define stk_strdup(s) ({ const char *_s=(s); uns _l=strlen(_s)+1; char *_x=alloca(_l); memcpy(_x, _s, _l); _x; }) #define stk_strndup(s,n) ({ const char *_s=(s); uns _l=strnlen(_s,(n)); char *_x=alloca(_l+1); memcpy(_x, _s, _l); _x[_l]=0; _x; }) diff --git a/ucw/string.c b/ucw/string.c index 19597697..bd9303ee 100644 --- a/ucw/string.c +++ b/ucw/string.c @@ -13,6 +13,17 @@ #include "ucw/lib.h" #include "ucw/string.h" +#ifdef CONFIG_DARWIN +uns +strnlen(const char *str, uns n) +{ + const char *end = str + n; + const char *c; + for (c = str; *c && c < end; c++); + return c - str; +} +#endif + char * str_format_flags(char *dest, const char *fmt, uns flags) { diff --git a/ucw/string.h b/ucw/string.h index f96bd023..935da33b 100644 --- a/ucw/string.h +++ b/ucw/string.h @@ -13,6 +13,10 @@ /* string.c */ +#ifdef CONFIG_DARWIN +uns strnlen(const char *str, uns n); +#endif + char *str_format_flags(char *dest, const char *fmt, uns flags); uns str_count_char(const char *str, uns chr);