Unicde strnlen, and a slight fix to the header so at least part can be read by
authornash <nash@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 30 Jul 2010 03:39:12 +0000 (03:39 +0000)
committernash <nash@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 30 Jul 2010 03:39:12 +0000 (03:39 +0000)
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

src/include/eina_unicode.h
src/lib/eina_unicode.c

index efce509..b0ddb8d 100644 (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(
index 3b9a70d..fc72ed6 100644 (file)
@@ -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 *