Add eina_strbuf_append_escaped for edje
authorenglebass <englebass>
Sat, 6 Feb 2010 21:43:02 +0000 (21:43 +0000)
committerenglebass <englebass@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 6 Feb 2010 21:43:02 +0000 (21:43 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@45950 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/include/eina_strbuf.h
src/lib/eina_strbuf.c

index 0ffdfe8..985b3a3 100644 (file)
@@ -10,6 +10,7 @@ typedef struct _Eina_Strbuf Eina_Strbuf;
 EAPI Eina_Strbuf *eina_strbuf_new(void);
 EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
 EAPI void eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+EAPI void eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
 EAPI void eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, unsigned int maxlen) EINA_ARG_NONNULL(1, 2);
 EAPI void eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
 EAPI void eina_strbuf_insert(Eina_Strbuf *buf, const char *str, 
index 2e60e32..52a00de 100644 (file)
@@ -103,6 +103,26 @@ eina_strbuf_append(Eina_Strbuf *buf, const char *str)
 }
 
 /**
+ * Append an escaped string to a buffer, reallocating as necessary.
+ * @param buf the Eina_Strbuf to append to
+ * @param str the string to append
+ */
+EAPI void
+eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str)
+{
+   size_t len;
+   char *esc;
+   EINA_MAGIC_CHECK_STRBUF(buf);
+
+   esc = eina_str_escape(str);
+   len = strlen(str);
+   _eina_strbuf_resize(buf, buf->len + len);
+   eina_strlcpy(buf->buf + buf->len, str, buf->size - buf->len);
+   buf->len += len;
+   free(esc);
+}
+
+/**
  * Append a string to a buffer, reallocating as necessary. Limited by maxlen.
  * @param buf the Eina_Strbuf to append to
  * @param str the string to append