efl_ui_format: fix to display %% and unknown format element

This fixes 2 things as follows.

1. Displays format string "%%" as "%".
   Like printf does, "%%" is displayed as "%".

2. Displays unknown format element as it is.
   In format string "(50%)", ")" is an unknown format element.
   Although format string has unknown format element, the format string
   is displayed like printf does.

The cause of the issue displaying "0%" which was mentioned on
a96933f964 is as follows.

The default format string of progressbar is set as "%.0f%%".
Therefore, if progressbar's format string is not set, then "%" postfix
is always displayed.

This commit reverts commit a96933f964.
This commit restores commit b4112b9735.
This commit restores commit be770d37fb.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7856
This commit is contained in:
Jaehyun Cho 2019-02-01 08:13:39 +00:00 committed by Cedric BAIL
parent 7b19573895
commit a7eb0695b8
1 changed files with 5 additions and 2 deletions

View File

@ -38,6 +38,8 @@ _format_string_check(const char *fmt)
if (itr[1] == '%')
{
itr++;
if (ret_type == FORMAT_TYPE_STATIC)
ret_type = FORMAT_TYPE_STRING;
continue;
}
@ -69,7 +71,8 @@ _format_string_check(const char *fmt)
}
else
{
ret_type = FORMAT_TYPE_INVALID;
ERR("Format string '%s' has unknown format element '%c' in format. It must have one format element of type 's', 'f', 'F', 'd', 'u', 'i', 'o', 'x' or 'X'", fmt, *itr);
found = EINA_FALSE;
break;
}
}
@ -121,7 +124,7 @@ _default_format_cb(void *data, Eina_Strbuf *str, const Eina_Value value)
}
else if (sd->format_type == FORMAT_TYPE_STATIC)
{
eina_strbuf_append_printf(str, "%s", sd->template);
eina_strbuf_append(str, sd->template);
}
else
{