edje: edje_cc_parse should check pair of parens.

Summary:
Fix parens bug.
((x + y)-z) is OK.
((x + y) - z) is NOT OK. This patch can cover this case.

@fix

Signed-off-by: Nak-Gyeong Kim <nakkyong.kim@samsung.com>

Test Plan:
Test in edc.

((x + y)-z) is OK.
((x + y) - z) is NOT OK. This patch can cover this case.
If parens are not paired, it will notify.

Reviewers: raster, Hermet, cedric

Subscribers: kimcinoo, jaehwan

Differential Revision: https://phab.enlightenment.org/D2554

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Nak-Gyeong Kim 2015-05-29 18:11:49 +02:00 committed by Cedric BAIL
parent 7056b2f6e4
commit 7d33ae501b
4 changed files with 64 additions and 6 deletions

View File

@ -247,7 +247,8 @@ bin/edje/edje_convert_main.c \
lib/edje/edje_convert.c \
tests/edje/edje_tests_helpers.h \
tests/edje/data/complex_layout.edc \
tests/edje/data/test_layout.edc
tests/edje/data/test_layout.edc \
tests/edje/data/test_parens.edc
bin_SCRIPTS += bin/edje/edje_recc
@ -280,13 +281,16 @@ tests/edje/data/%.edj: tests/edje/data/%.edc bin/edje/edje_cc${EXEEXT}
$(EDJE_CC) $(EDJE_CC_FLAGS) -id $(srcdir)/tests/edje/data $< $@
EDJE_DATA_FILES = tests/edje/data/test_layout.edc \
tests/edje/data/complex_layout.edc
tests/edje/data/complex_layout.edc \
tests/edje/data/test_parens.edc
edjedatafilesdir = $(datadir)/edje/data
edjedatafiles_DATA = tests/edje/data/test_layout.edj \
tests/edje/data/complex_layout.edj
tests/edje/data/complex_layout.edj \
tests/edje/data/test_parens.edj
CLEANFILES += tests/edje/data/test_layout.edj \
tests/edje/data/complex_layout.edj
tests/edje/data/complex_layout.edj \
tests/edje/data/test_parens.edj
endif

View File

@ -387,10 +387,18 @@ next_token(char *p, char *end, char **new_p, int *delim)
else if (is_escaped)
is_escaped = 0;
}
else if (in_parens)
else if (in_parens != 0 && (!is_escaped))
{
if (((*p) == ')') && (!is_escaped))
if (*p == '(')
in_parens++;
else if (*p == ')')
in_parens--;
else if (isdelim(*p))
{
ERR("check pair of parens %s:%i.", file_in, line - 1);
err_show();
exit(-1);
}
}
else
{
@ -401,6 +409,8 @@ next_token(char *p, char *end, char **new_p, int *delim)
}
else if (*p == '(')
in_parens++;
else if (*p == ')')
in_parens--;
/* check for end-of-token */
if (

View File

@ -0,0 +1,24 @@
collections {
group {
name: "test_group";
parts {
part {
name: "background";
type: RECT;
mouse_events: 0;
description {
state: "default" 0.0;
min: ((1000 + 100) - 1000) 100;
rel1 {
relative: 0.0 0.0;
}
rel2 {
relative: 1.0 1.0;
}
}
}
}
}

View File

@ -151,6 +151,25 @@ START_TEST(edje_test_complex_layout)
}
END_TEST
START_TEST(edje_test_calculate_parens)
{
int x, y, w, h;
int r, g, b, a;
Evas *evas = EDJE_TEST_INIT_EVAS();
Evas_Object *obj;
const Evas_Object *bg;
obj = edje_object_add(evas);
fail_unless(edje_object_file_set(obj, test_layout_get("test_parens.edj"), "test_group"));
evas_object_resize(obj, 100, 100);
edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
fail_if(x != 0 || y != 0 || w != 100 || h != 100);
EDJE_TEST_FREE_EVAS();
}
END_TEST
void edje_test_edje(TCase *tc)
{
tcase_add_test(tc, edje_test_edje_init);
@ -158,4 +177,5 @@ void edje_test_edje(TCase *tc)
tcase_add_test(tc, edje_test_edje_load);
tcase_add_test(tc, edje_test_simple_layout_geometry);
tcase_add_test(tc, edje_test_complex_layout);
tcase_add_test(tc, edje_test_calculate_parens);
}