Enlightenment CVS committal
Author : rephorm
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore
Modified Files:
Ecore_Data.h Makefile.am ecore_str.c
Added Files:
ecore_strbuf.c
Log Message:
add ecore_strlcat for symmetry
add ecore_strbuf, an auto-expanding string buffer for building long strings
whose length isn't easily determinable beforehand. for now just supports append.
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/Ecore_Data.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- Ecore_Data.h 12 Feb 2007 22:47:46 -0000 1.33
+++ Ecore_Data.h 16 Feb 2007 23:49:55 -0000 1.34
@@ -60,6 +60,9 @@
typedef struct _ecore_list_node Ecore_List_Node;
# define ECORE_LIST_NODE(node) ((Ecore_List_Node *)node)
+
+ typedef struct _ecore_strbuf Ecore_Strbuf;
+# define ECORE_STRBUF(buf) ((Ecore_Strbuf *)buf)
struct _ecore_list_node {
void *data;
@@ -475,6 +478,14 @@
/* Add a function to free the data stored in nodes */
EAPI int ecore_tree_set_free_cb(Ecore_Tree * tree, Ecore_Free_Cb free_func);
+
+
+Ecore_Strbuf * ecore_strbuf_new(void);
+Ecore_Strbuf * ecore_strbuf_new(void);
+void ecore_strbuf_free(Ecore_Strbuf *buf);
+void ecore_strbuf_append(Ecore_Strbuf *buf, const char *str);
+void ecore_strbuf_append_char(Ecore_Strbuf *buf, char c);
+const char * ecore_strbuf_string_get(Ecore_Strbuf *buf);
#ifdef __cplusplus
}
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- Makefile.am 10 Jan 2007 11:28:41 -0000 1.10
+++ Makefile.am 16 Feb 2007 23:49:55 -0000 1.11
@@ -25,6 +25,7 @@
ecore_sheap.c \
ecore_signal.c \
ecore_str.c \
+ecore_strbuf.c \
ecore_strings.c \
ecore_time.c \
ecore_timer.c \
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/ecore_str.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ecore_str.c 27 Jan 2007 03:51:05 -0000 1.3
+++ ecore_str.c 16 Feb 2007 23:49:55 -0000 1.4
@@ -60,6 +60,42 @@
#endif
}
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
+
+
int
ecore_str_has_prefix(const char *str, const char *prefix)
{
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs