Unicde strnlen, and a slight fix to the header so at least part can be read by

humans.

Also strlen/strnlen are pure.


SVN revision: 50676
This commit is contained in:
Brett Nash 2010-07-30 03:39:12 +00:00
parent ec7e390bdf
commit 4414556323
2 changed files with 26 additions and 3 deletions

View File

@ -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(

View File

@ -80,6 +80,29 @@ eina_unicode_strlen(const Eina_Unicode *ustr)
return end - 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.
*/