Parser: enhance quality of parsing the part state names.
Summary: added ability parsing different cases of usage "description" and "desc" keywords. Now support descriptions without names - those states will be defined as "default". For keyword "description" attribute "state" non mandatory. Examples of support syntax: desc {"state_name";} desc {image.normal: "img";} <- "default" 0.0; description {state: "state_name"; ...} description {"state_name";...} description {image.normal: "img";} <- "default" 0.0; @fix T2680 Reviewers: Hermet Maniphest Tasks: T2680 Differential Revision: https://phab.enlightenment.org/D2969
This commit is contained in:
parent
27c17e9a43
commit
e011f68951
|
@ -254,17 +254,47 @@ cur_state_thread_blocking(void *data, Ecore_Thread *thread EINA_UNUSED)
|
||||||
//we got a description!
|
//we got a description!
|
||||||
if (desc_idx != -1)
|
if (desc_idx != -1)
|
||||||
{
|
{
|
||||||
p += DESC_LEN[desc_idx];
|
desc_name = DEF_STATE_NAME; /* By default state will be */
|
||||||
char *name_begin = strstr(p, QUOT_UTF8);
|
desc_name_len = DEF_STATE_LEN; /* recognized as "default" 0.0*/
|
||||||
if (!name_begin) goto end;
|
value_convert = 0;
|
||||||
char *state = strstr(p, STATE);
|
|
||||||
if ((desc_idx == 1) && (!state || state > name_begin))
|
p += DESC_LEN[desc_idx]; /* skip keyword */
|
||||||
|
p = strstr(p, "{");
|
||||||
|
if (!p) goto end;
|
||||||
|
char *end_brace = strstr(p, "}"); /*Limit size of text for processing*/
|
||||||
|
if (!end_brace)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
/* proccessing for "description" keyword with "state" attribute */
|
||||||
|
if (desc_idx == 1)
|
||||||
{
|
{
|
||||||
desc_name = DEF_STATE_NAME;
|
char *state = strstr(p, STATE);
|
||||||
desc_name_len = DEF_STATE_LEN;
|
if (!state || state > end_brace) /* if name of state didn't find, */
|
||||||
value_convert = 0;
|
continue; /* description will recognized as default 0.0*/
|
||||||
continue;
|
else
|
||||||
|
p += 5; /*5 is strlen("state");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *name_begin = strstr(p, QUOT_UTF8);
|
||||||
|
if (!name_begin)
|
||||||
|
continue;
|
||||||
|
char *end_range = strstr(p, ";");
|
||||||
|
if (!end_range) goto end;
|
||||||
|
|
||||||
|
if ((name_begin > end_brace) || /* if string placed outside desc block*/
|
||||||
|
(name_begin > end_range) ||
|
||||||
|
(end_range > end_brace))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Exception cases like: desc {image.normal: "img";} */
|
||||||
|
int alpha_present = 0;
|
||||||
|
for (char *string_itr = name_begin; (string_itr > p) && (!alpha_present); string_itr--)
|
||||||
|
alpha_present = isalpha((int)*string_itr);
|
||||||
|
|
||||||
|
if (alpha_present && desc_idx == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*Extract state name and value */
|
||||||
name_begin += QUOT_UTF8_LEN;
|
name_begin += QUOT_UTF8_LEN;
|
||||||
p = name_begin;
|
p = name_begin;
|
||||||
char *name_end = strstr(p, QUOT_UTF8);
|
char *name_end = strstr(p, QUOT_UTF8);
|
||||||
|
|
Loading…
Reference in New Issue