From 5f84a89c9d174ed6242a65b2e4ed26d2e339be44 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Fri, 1 Feb 2019 08:13:39 +0000 Subject: [PATCH] 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 a96933f964b1757b9d9f8a4cce14d883f35a6665 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 a96933f964b1757b9d9f8a4cce14d883f35a6665. This commit restores commit b4112b9735ce75bce95974a257aa1880fa52a6bf. This commit restores commit be770d37fb05b8486907796dd16f4635bceb4ce1. Reviewed-by: Cedric BAIL Differential Revision: https://phab.enlightenment.org/D7856 --- src/lib/efl/interfaces/efl_ui_format.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/efl/interfaces/efl_ui_format.c b/src/lib/efl/interfaces/efl_ui_format.c index e722d22..f6f1b81 100644 --- a/src/lib/efl/interfaces/efl_ui_format.c +++ b/src/lib/efl/interfaces/efl_ui_format.c @@ -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 { -- 2.7.4