From 4656f98e224c9be3e23680a6dfac12b9ee6648e4 Mon Sep 17 00:00:00 2001 From: Woochan Lee Date: Tue, 22 Aug 2017 14:17:41 +0900 Subject: [PATCH] efl_ui_clock: Parses the format recursively. Summary: Some of locale formats convert as extension format. For example, uk_UA d_t_fmt is "%a, %d-%b-%Y %X %z". The %X will convert as %T. The %T format has to convert one more time to convert as %H:%M:%S. ref : https://lh.2xlibre.net/locale/uk_UA/ We need to parse the format recursively to support that kind of case. @fix Test Plan: Change the locale as uk_UA. Run elementary_test -> datetime See the time field is not appear. Reviewers: jpeg, cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5021 --- src/lib/elementary/efl_ui_clock.c | 50 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/lib/elementary/efl_ui_clock.c b/src/lib/elementary/efl_ui_clock.c index d936332631..45dc85746b 100644 --- a/src/lib/elementary/efl_ui_clock.c +++ b/src/lib/elementary/efl_ui_clock.c @@ -202,33 +202,39 @@ static void _expand_format(char *dt_fmt) { char *ptr, *expanded_fmt, ch; - unsigned int idx = 0, len = 0; + unsigned int idx, len = 0; char buf[EFL_UI_CLOCK_MAX_FORMAT_LEN] = {0, }; - Eina_Bool fmt_char = EINA_FALSE; + Eina_Bool fmt_char, fmt_expanded; - ptr = dt_fmt; - while ((ch = *ptr)) - { - if ((fmt_char) && (strchr(multifield_formats, ch))) - { - /* replace the multi-field format characters with - * corresponding expanded format */ - expanded_fmt = _expanded_fmt_str_get(ch); - len = strlen(expanded_fmt); - buf[--idx] = 0; - strncat(buf, expanded_fmt, len); - idx += len; - } - else buf[idx++] = ch; + do { + idx = 0; + fmt_char = EINA_FALSE; + fmt_expanded = EINA_FALSE; + ptr = dt_fmt; + while ((ch = *ptr)) + { + if ((fmt_char) && (strchr(multifield_formats, ch))) + { + /* replace the multi-field format characters with + * corresponding expanded format */ + expanded_fmt = _expanded_fmt_str_get(ch); + len = strlen(expanded_fmt); + if (len > 0) fmt_expanded = EINA_TRUE; + buf[--idx] = 0; + strncat(buf, expanded_fmt, len); + idx += len; + } + else buf[idx++] = ch; - if (ch == '%') fmt_char = EINA_TRUE; - else fmt_char = EINA_FALSE; + if (ch == '%') fmt_char = EINA_TRUE; + else fmt_char = EINA_FALSE; - ptr++; - } + ptr++; + } - buf[idx] = 0; - strncpy(dt_fmt, buf, EFL_UI_CLOCK_MAX_FORMAT_LEN); + buf[idx] = 0; + strncpy(dt_fmt, buf, EFL_UI_CLOCK_MAX_FORMAT_LEN); + } while (fmt_expanded); } static void