Eina_List *redo_nodes = NULL;
/* Generic pop, should just pop. */
- if (((format[0] == ' ') && !format[1]) ||
+ if (((format[0] == '/') && !format[1]) ||
!format[0])
{
_format_unref_free(c->obj, fmt);
* starting tag, and the starting tag's next char is either
* NULL or white. Skip the starting '+'. */
if (_FORMAT_IS_CLOSER_OF(
- fmt->fnode->orig_format, format, len))
+ fmt->fnode->orig_format, format + 1, len - 1))
{
_format_unref_free(c->obj, fmt);
break;
size_t fstr_len;
fstr_len = strlen(fstr);
/* Generic popper, just pop */
- if (((fstr[0] == ' ') && !fstr[1]) || !fstr[0])
+ if (((fstr[0] == '/') && !fstr[1]) || !fstr[0])
{
fstack = eina_list_remove_list(fstack, fstack);
balance--;
EINA_LIST_FOREACH(fstack, i, fnode2)
{
if (_FORMAT_IS_CLOSER_OF(
- fnode2->orig_format, fstr, fstr_len))
+ fnode2->orig_format, fstr + 1, fstr_len - 1))
{
fstack = eina_list_remove_list(fstack, i);
break;
const char *match;
size_t format_len = eina_stringshare_strlen(fnode->orig_format);
/* Is this safe to use alloca here? Strings might possibly get large */
- char *format = alloca(format_len + 2);
- if (!fnode->opener)
- {
- format[0] = '/';
- format[1] = '\0';
- }
- else
- {
- format[0] = '\0';
- }
-
- strcat(format, fnode->orig_format);
+ if (fnode->own_closer)
+ format_len--;
- match = _textblock_format_node_from_style_tag(o, fnode, format,
+ match = _textblock_format_node_from_style_tag(o, fnode, fnode->orig_format,
format_len);
if (match && fnode->format && strcmp(match, fnode->format))
// FIXME: need to escape
s = fnode->orig_format;
- if (!fnode->opener && !fnode->own_closer)
- eina_strbuf_append_char(txt, '/');
eina_strbuf_append(txt, s);
- if (fnode->own_closer)
- eina_strbuf_append_char(txt, '/');
}
eina_strbuf_append_char(txt, '>');
}
size_t fstr_len;
fstr_len = strlen(fstr);
/* Generic popper, just pop */
- if (((fstr[0] == ' ') && !fstr[1]) || !fstr[0])
+ if (((fstr[0] == '/') && !fstr[1]) || !fstr[0])
{
fstack = eina_list_remove_list(fstack, fstack);
if (!fstack)
EINA_LIST_FOREACH(fstack, i, fnode)
{
if (_FORMAT_IS_CLOSER_OF(
- fnode->orig_format, fstr, fstr_len))
+ fnode->orig_format, fstr + 1, fstr_len - 1))
{
/* Last one, this is our item! */
if (!eina_list_next(i))
size_t fstr_len;
fstr_len = strlen(fstr);
/* Generic popper, just pop (if there's anything to pop). */
- if (formats && (((fstr[0] == ' ') && !fstr[1]) || !fstr[0]))
+ if (formats && (((fstr[0] == '/') && !fstr[1]) || !fstr[0]))
{
fnode = eina_list_data_get(formats);
formats = eina_list_remove_list(formats, formats);
EINA_LIST_FOREACH_SAFE(formats, i, next, fnode)
{
if (_FORMAT_IS_CLOSER_OF(
- fnode->orig_format, fstr, fstr_len))
+ fnode->orig_format, fstr + 1, fstr_len - 1))
{
fnode = eina_list_data_get(i);
formats = eina_list_remove_list(formats, i);
if ((format_len > 0) && format[format_len - 1] == '>')
{
format_len--; /* We don't care about '>' */
+ n->orig_format = eina_stringshare_add_length(format, format_len);
/* Check if it closes itself, i.e. one of the following:
* 1. Ends with a "/" e.g. "<my_tag/>"
* 2. Is a paragraph separator */
}
}
- n->orig_format = eina_stringshare_add_length(format, format_len);
-
if (!pre_stripped_format)
pre_stripped_format = n->orig_format;
}
/* Strip format */
{
const char *tmp = pre_stripped_format;
+ int len = strlen(tmp);
if ((*tmp == '+') || (*tmp == '-'))
{
+ len--;
tmp++;
while (*tmp == ' ') tmp++;
}
- n->format = eina_stringshare_add(tmp);
+ if (tmp[len - 1] == '/')
+ {
+ len--;
+ }
+ else if (tmp[0] == '/')
+ {
+ len--;
+ tmp++;
+ }
+ n->format = eina_stringshare_add_length(tmp, len);
}
format = n->format;
{
static char *ret = NULL;
char *tmp;
+ const char *stripped;
+ size_t stripped_len;
if (!fmt) return NULL;
if (ret) free(ret);
- ret = malloc(strlen(fmt->orig_format) + 2 + 1);
+ stripped = fmt->orig_format;
+ stripped_len = strlen(fmt->orig_format);
+ if (stripped[stripped_len - 1] == '/')
+ {
+ stripped_len--;
+ }
+ else if (stripped[0] == '/')
+ {
+ stripped++;
+ stripped_len--;
+ }
+
+ ret = calloc(stripped_len + 2 + 1, sizeof(char));
tmp = ret;
if (fmt->opener && !fmt->own_closer)
*(tmp++) = '-';
*(tmp++) = ' ';
}
- strcpy(tmp, fmt->orig_format);
+ strncpy(tmp, stripped, stripped_len);
return ret;
}