* rename _edje_strbuf_append to _edje_strbuf_append1 and

_edje_strbuf_append2 in edje_util.c and edje_textblock_styles.c
   respectiveley (for amalgamation. See next commit)
 * fixes for vc++


SVN revision: 43428
This commit is contained in:
Vincent Torri 2009-11-03 09:26:15 +00:00
parent 3d77c82d15
commit fd17f32a19
4 changed files with 57 additions and 50 deletions

View File

@ -17,10 +17,13 @@
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#ifndef _MSC_VER
# include <unistd.h>
#endif
#ifdef HAVE_LOCALE_H #ifdef HAVE_LOCALE_H
# include <locale.h> # include <locale.h>
#endif #endif

View File

@ -6,7 +6,9 @@
# include <config.h> # include <config.h>
#endif #endif
#define _GNU_SOURCE #ifndef _WIN32
# define _GNU_SOURCE
#endif
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
# include <alloca.h> # include <alloca.h>

View File

@ -107,7 +107,7 @@ _edje_format_is_param(char *item)
} }
static char * static char *
_edje_strbuf_append(char *s, const char *s2, int *len, int *alloc) _edje_strbuf_append2(char *s, const char *s2, int *len, int *alloc)
{ {
int l2, tlen; int l2, tlen;
@ -131,14 +131,14 @@ _edje_strbuf_append(char *s, const char *s2, int *len, int *alloc)
} }
static char * static char *
_edje_strbuf_append_escaped(char *s, const char *unescaped_s, int *len, int *alloc) _edje_strbuf_append2_escaped(char *s, const char *unescaped_s, int *len, int *alloc)
{ {
char *tmp; char *tmp;
tmp = _edje_str_escape(unescaped_s); tmp = _edje_str_escape(unescaped_s);
if (!tmp) return s; if (!tmp) return s;
s = _edje_strbuf_append(s, tmp, len, alloc); s = _edje_strbuf_append2(s, tmp, len, alloc);
free(tmp); free(tmp);
return s; return s;
@ -183,9 +183,9 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag **tag_ret)
char *tmpstr = NULL; char *tmpstr = NULL;
int tmplen = 0, tmpalloc = 0; int tmplen = 0, tmpalloc = 0;
tmpstr = _edje_strbuf_append(tmpstr, "fonts/", tmpstr = _edje_strbuf_append2(tmpstr, "fonts/",
&tmplen, &tmpalloc); &tmplen, &tmpalloc);
tmpstr = _edje_strbuf_append(tmpstr, val, tmpstr = _edje_strbuf_append2(tmpstr, val,
&tmplen, &tmpalloc); &tmplen, &tmpalloc);
(*tag_ret)->font = eina_stringshare_add(tmpstr); (*tag_ret)->font = eina_stringshare_add(tmpstr);
free(tmpstr); free(tmpstr);
@ -201,8 +201,8 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag **tag_ret)
s2 = _edje_str_escape(item); s2 = _edje_str_escape(item);
if (s2) if (s2)
{ {
if (newstr) newstr = _edje_strbuf_append(newstr, " ", &newlen, &newalloc); if (newstr) newstr = _edje_strbuf_append2(newstr, " ", &newlen, &newalloc);
newstr = _edje_strbuf_append(newstr, s2, &newlen, &newalloc); newstr = _edje_strbuf_append2(newstr, s2, &newlen, &newalloc);
free(s2); free(s2);
} }
} }
@ -211,8 +211,8 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag **tag_ret)
} }
else else
{ {
if (newstr) newstr = _edje_strbuf_append(newstr, " ", &newlen, &newalloc); if (newstr) newstr = _edje_strbuf_append2(newstr, " ", &newlen, &newalloc);
newstr = _edje_strbuf_append(newstr, item, &newlen, &newalloc); newstr = _edje_strbuf_append2(newstr, item, &newlen, &newalloc);
} }
free(item); free(item);
} }
@ -259,8 +259,8 @@ _edje_textblock_style_all_update(Edje *ed)
if (!tag->key) continue; if (!tag->key) continue;
/* Add Tag Key */ /* Add Tag Key */
buf = _edje_strbuf_append(buf, tag->key, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, tag->key, &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "='", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "='", &buflen, &bufalloc);
/* Configure fonts from text class if it exists */ /* Configure fonts from text class if it exists */
if ((tc = _edje_text_class_find(ed, tag->text_class))) if ((tc = _edje_text_class_find(ed, tag->text_class)))
@ -270,19 +270,19 @@ _edje_textblock_style_all_update(Edje *ed)
} }
/* Add and Ha`ndle tag parsed data */ /* Add and Ha`ndle tag parsed data */
buf = _edje_strbuf_append(buf, tag->value, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, tag->value, &buflen, &bufalloc);
if (!strcmp(tag->key, "DEFAULT")) if (!strcmp(tag->key, "DEFAULT"))
{ {
if (fontset) if (fontset)
{ {
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font_fallbacks=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font_fallbacks=", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, fontset, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, fontset, &buflen, &bufalloc);
} }
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font_source=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font_source=", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, fontsource, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, fontsource, &buflen, &bufalloc);
} }
if (tag->font_size != 0) if (tag->font_size != 0)
{ {
@ -293,24 +293,24 @@ _edje_textblock_style_all_update(Edje *ed)
else else
snprintf(font_size, sizeof(font_size), "%f", tag->font_size); snprintf(font_size, sizeof(font_size), "%f", tag->font_size);
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font_size=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font_size=", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, font_size, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, font_size, &buflen, &bufalloc);
} }
/* Add font name last to save evas from multiple loads */ /* Add font name last to save evas from multiple loads */
if (tag->font) if (tag->font)
{ {
const char *f; const char *f;
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font=", &buflen, &bufalloc);
f = (found) ? tc->font : tag->font; f = (found) ? tc->font : tag->font;
buf = _edje_strbuf_append_escaped(buf, f, &buflen, &bufalloc); buf = _edje_strbuf_append2_escaped(buf, f, &buflen, &bufalloc);
} }
found = 0; found = 0;
buf = _edje_strbuf_append(buf, "'", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "'", &buflen, &bufalloc);
} }
if (fontset) free(fontset); if (fontset) free(fontset);
if (fontsource) free(fontsource); if (fontsource) free(fontsource);
@ -398,8 +398,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
if (!tag->key) continue; if (!tag->key) continue;
/* Add Tag Key */ /* Add Tag Key */
buf = _edje_strbuf_append(buf, tag->key, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, tag->key, &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "='", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "='", &buflen, &bufalloc);
ts = _edje_format_reparse(edf, tag->value, &(tag)); ts = _edje_format_reparse(edf, tag->value, &(tag));
@ -409,7 +409,7 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
if (eet_dictionary_string_check(eet_dictionary_get(edf->ef), tag->value) == 0) if (eet_dictionary_string_check(eet_dictionary_get(edf->ef), tag->value) == 0)
eina_stringshare_del(tag->value); eina_stringshare_del(tag->value);
tag->value = eina_stringshare_add(ts); tag->value = eina_stringshare_add(ts);
buf = _edje_strbuf_append(buf, tag->value, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, tag->value, &buflen, &bufalloc);
free(ts); free(ts);
} }
@ -417,31 +417,31 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
{ {
if (fontset) if (fontset)
{ {
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font_fallbacks=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font_fallbacks=", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, fontset, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, fontset, &buflen, &bufalloc);
} }
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font_source=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font_source=", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, fontsource, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, fontsource, &buflen, &bufalloc);
} }
if (tag->font_size > 0) if (tag->font_size > 0)
{ {
char font_size[32]; char font_size[32];
snprintf(font_size, sizeof(font_size), "%f", tag->font_size); snprintf(font_size, sizeof(font_size), "%f", tag->font_size);
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font_size=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font_size=", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, font_size, &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, font_size, &buflen, &bufalloc);
} }
/* Add font name last to save evas from multiple loads */ /* Add font name last to save evas from multiple loads */
if (tag->font) if (tag->font)
{ {
buf = _edje_strbuf_append(buf, " ", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, " ", &buflen, &bufalloc);
buf = _edje_strbuf_append(buf, "font=", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "font=", &buflen, &bufalloc);
buf = _edje_strbuf_append_escaped(buf, tag->font, &buflen, &bufalloc); buf = _edje_strbuf_append2_escaped(buf, tag->font, &buflen, &bufalloc);
} }
buf = _edje_strbuf_append(buf, "'", &buflen, &bufalloc); buf = _edje_strbuf_append2(buf, "'", &buflen, &bufalloc);
} }
if (fontset) free(fontset); if (fontset) free(fontset);
if (fontsource) free(fontsource); if (fontsource) free(fontsource);

View File

@ -3,6 +3,7 @@
*/ */
#include <string.h> #include <string.h>
#include "edje_private.h" #include "edje_private.h"
typedef struct _Edje_Box_Layout Edje_Box_Layout; typedef struct _Edje_Box_Layout Edje_Box_Layout;
@ -1294,8 +1295,9 @@ edje_object_part_text_get(const Evas_Object *obj, const char *part)
} }
return NULL; return NULL;
} }
static Eina_Bool static Eina_Bool
_edje_strbuf_append(char **p_str, size_t *allocated, size_t *used, const char *news, size_t news_len) _edje_strbuf_append1(char **p_str, size_t *allocated, size_t *used, const char *news, size_t news_len)
{ {
if (*used + news_len >= *allocated) if (*used + news_len >= *allocated)
{ {
@ -1349,12 +1351,12 @@ _edje_text_escape(const char *text)
else else
escaped_len = strlen(escaped); escaped_len = strlen(escaped);
if (!_edje_strbuf_append(&ret, &ret_len, &used, escaped, escaped_len)) if (!_edje_strbuf_append1(&ret, &ret_len, &used, escaped, escaped_len))
return NULL; return NULL;
text += advance; text += advance;
} }
if (!_edje_strbuf_append(&ret, &ret_len, &used, "", 1)) if (!_edje_strbuf_append1(&ret, &ret_len, &used, "", 1))
return NULL; return NULL;
return ret; return ret;
} }
@ -1397,7 +1399,7 @@ _edje_text_unescape(const char *text)
if (len > 0) if (len > 0)
{ {
if (!_edje_strbuf_append(&ret, &ret_len, &used, str, len)) if (!_edje_strbuf_append1(&ret, &ret_len, &used, str, len))
return NULL; return NULL;
} }
@ -1418,7 +1420,7 @@ _edje_text_unescape(const char *text)
len = text + 1 - escape_start; len = text + 1 - escape_start;
} }
if (!_edje_strbuf_append(&ret, &ret_len, &used, str, len)) if (!_edje_strbuf_append1(&ret, &ret_len, &used, str, len))
return NULL; return NULL;
escape_start = NULL; escape_start = NULL;
@ -1432,11 +1434,11 @@ _edje_text_unescape(const char *text)
if (last && (text > last)) if (last && (text > last))
{ {
size_t len = text - last; size_t len = text - last;
if (!_edje_strbuf_append(&ret, &ret_len, &used, last, len)) if (!_edje_strbuf_append1(&ret, &ret_len, &used, last, len))
return NULL; return NULL;
} }
if (!_edje_strbuf_append(&ret, &ret_len, &used, "", 1)) if (!_edje_strbuf_append1(&ret, &ret_len, &used, "", 1))
return NULL; return NULL;
return ret; return ret;
} }