From: nash Date: Fri, 30 Jul 2010 03:39:12 +0000 (+0000) Subject: Unicde strnlen, and a slight fix to the header so at least part can be read by X-Git-Tag: 2.0_alpha~70^2~455 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a4fec08475bebb5f595732fecf3e6b64eaff6b6;p=framework%2Fuifw%2Feina.git Unicde strnlen, and a slight fix to the header so at least part can be read by humans. Also strlen/strnlen are pure. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@50676 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/include/eina_unicode.h b/src/include/eina_unicode.h index efce509..b0ddb8d 100644 --- a/src/include/eina_unicode.h +++ b/src/include/eina_unicode.h @@ -42,9 +42,9 @@ typedef unsigned int Eina_Unicode; EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING; -EAPI size_t - eina_unicode_strlen( - const Eina_Unicode *ustr) EINA_ARG_NONNULL(1); +EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1) EINA_PURE; +EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EINA_ARG_NONNULL(1) EINA_PURE; + EAPI Eina_Unicode * eina_unicode_strdup( diff --git a/src/lib/eina_unicode.c b/src/lib/eina_unicode.c index 3b9a70d..fc72ed6 100644 --- a/src/lib/eina_unicode.c +++ b/src/lib/eina_unicode.c @@ -81,6 +81,29 @@ eina_unicode_strlen(const Eina_Unicode *ustr) } /** + * @brief Returns the length of a Eina_Unicode string, up to a limit. + * + * This function returns the number of characters in string, up to a maximum + * of n. If the terminating character is not found in the string, it returns + * n. + * + * @param ustr String to search + * @param n Max length to search + * @return Number of characters or n. + */ +EAPI size_t +eina_unicode_strnlen(const Eina_Unicode *ustr, int n) +{ + const Eina_Unicode *end; + for (end = ustr; *end; end++) + ; + return end - ustr; +} + + + + +/** * @brief Same as the standard strdup just with Eina_Unicode instead of char. */ EAPI Eina_Unicode *