edje: fix float comparison warning in edje_cc.

This commit is contained in:
Cedric BAIL 2016-12-20 15:47:57 -08:00
parent 4cbca7c357
commit 9730eb1f47
2 changed files with 16 additions and 10 deletions

View File

@ -3676,7 +3676,7 @@ st_collections_base_scale(void)
check_min_arg_count(1); check_min_arg_count(1);
edje_file->base_scale = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0)); edje_file->base_scale = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0));
if (edje_file->base_scale == ZERO) if (EQ(edje_file->base_scale, ZERO))
{ {
ERR("The base_scale is 0.0. The value should be bigger than 0.0."); ERR("The base_scale is 0.0. The value should be bigger than 0.0.");
exit(-1); exit(-1);
@ -8095,7 +8095,7 @@ st_collections_group_parts_part_description_inherit(void)
exit(-1); exit(-1);
} }
if (!strcmp (parent_name, "default") && parent_val == 0.0) if (!strcmp (parent_name, "default") && EINA_DBL_CMP(parent_val, 0.0))
parent = ep->default_desc; parent = ep->default_desc;
else else
{ {
@ -8127,8 +8127,8 @@ st_collections_group_parts_part_description_inherit(void)
} }
} }
if (min_dst) if (EINA_DBL_CMP(min_dst, 0.0))
{ {
WRN("%s:%i: couldn't find an exact match in part '%s' when looking for '%s' %lf. Falling back to nearest one '%s' %lf.", WRN("%s:%i: couldn't find an exact match in part '%s' when looking for '%s' %lf. Falling back to nearest one '%s' %lf.",
file_in, line - 1, ep->name, parent_name, parent_val, parent ? parent->state.name : NULL, parent ? parent->state.value : 0); file_in, line - 1, ep->name, parent_name, parent_val, parent ? parent->state.name : NULL, parent ? parent->state.value : 0);
} }
@ -8390,8 +8390,12 @@ _part_description_state_update(Edje_Part_Description_Common *ed)
Edje_Part *ep = current_part; Edje_Part *ep = current_part;
if (ed == ep->default_desc) return; if (ed == ep->default_desc) return;
if ((ep->default_desc->state.name && !strcmp(ed->state.name, ep->default_desc->state.name) && ed->state.value == ep->default_desc->state.value) || if ((ep->default_desc->state.name &&
(!ep->default_desc->state.name && !strcmp(ed->state.name, "default") && ed->state.value == ep->default_desc->state.value)) !strcmp(ed->state.name, ep->default_desc->state.name) &&
EQ(ed->state.value, ep->default_desc->state.value)) ||
(!ep->default_desc->state.name &&
!strcmp(ed->state.name, "default") &&
EQ(ed->state.value, ep->default_desc->state.value)))
{ {
if (ep->type == EDJE_PART_TYPE_IMAGE) if (ep->type == EDJE_PART_TYPE_IMAGE)
_edje_part_description_image_remove((Edje_Part_Description_Image*) ed); _edje_part_description_image_remove((Edje_Part_Description_Image*) ed);
@ -8407,7 +8411,8 @@ _part_description_state_update(Edje_Part_Description_Common *ed)
unsigned int i; unsigned int i;
for (i = 0; i < ep->other.desc_count - 1; ++i) for (i = 0; i < ep->other.desc_count - 1; ++i)
{ {
if (!strcmp(ed->state.name, ep->other.desc[i]->state.name) && ed->state.value == ep->other.desc[i]->state.value) if (!strcmp(ed->state.name, ep->other.desc[i]->state.name) &&
EQ(ed->state.value, ep->other.desc[i]->state.value))
{ {
if (ep->type == EDJE_PART_TYPE_IMAGE) if (ep->type == EDJE_PART_TYPE_IMAGE)
_edje_part_description_image_remove((Edje_Part_Description_Image*) ed); _edje_part_description_image_remove((Edje_Part_Description_Image*) ed);
@ -8462,7 +8467,8 @@ st_collections_group_parts_part_description_state(void)
val = parse_float_range(1, 0.0, 1.0); val = parse_float_range(1, 0.0, 1.0);
/* if only default desc exists and current desc is not default, commence paddling */ /* if only default desc exists and current desc is not default, commence paddling */
if ((!ep->other.desc_count) && (val || (!eina_streq(s, "default")))) if ((!ep->other.desc_count) &&
(!EINA_DBL_CMP(val, 0) || (!eina_streq(s, "default"))))
{ {
ERR("parse error %s:%i. invalid state name: '%s'. \"default\" state must always be first.", ERR("parse error %s:%i. invalid state name: '%s'. \"default\" state must always be first.",
file_in, line - 1, s); file_in, line - 1, s);

View File

@ -1891,7 +1891,7 @@ _calcf(char op, double a, double b)
a -= b; a -= b;
return a; return a;
case '/': case '/':
if (b != 0) a /= b; if (NEQ(b, 0)) a /= b;
else else
ERR("%s:%i divide by zero", file_in, line - 1); ERR("%s:%i divide by zero", file_in, line - 1);
return a; return a;
@ -1899,7 +1899,7 @@ _calcf(char op, double a, double b)
a *= b; a *= b;
return a; return a;
case '%': case '%':
if (0 != b) a = (double)((int)a % (int)b); if (NEQ(b, 0)) a = (double)((int)a % (int)b);
else else
ERR("%s:%i modula by zero", file_in, line - 1); ERR("%s:%i modula by zero", file_in, line - 1);
return a; return a;