summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNak-Gyeong Kim <nakkyong.kim@samsung.com>2015-05-29 18:11:49 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-29 18:22:09 +0200
commit7d33ae501b2263ff1450c6351dea181573afe517 (patch)
treecd46ff3b8749c8206e433f68a8847e414db3d4f6
parent7056b2f6e4af9c1ef9445472c018655a19a54e71 (diff)
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>
-rw-r--r--src/Makefile_Edje.am12
-rw-r--r--src/bin/edje/edje_cc_parse.c14
-rw-r--r--src/tests/edje/data/test_parens.edc24
-rw-r--r--src/tests/edje/edje_test_edje.c20
4 files changed, 64 insertions, 6 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index b9b9c14e83..15a8fed37e 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -247,7 +247,8 @@ bin/edje/edje_convert_main.c \
247lib/edje/edje_convert.c \ 247lib/edje/edje_convert.c \
248tests/edje/edje_tests_helpers.h \ 248tests/edje/edje_tests_helpers.h \
249tests/edje/data/complex_layout.edc \ 249tests/edje/data/complex_layout.edc \
250tests/edje/data/test_layout.edc 250tests/edje/data/test_layout.edc \
251tests/edje/data/test_parens.edc
251 252
252 253
253bin_SCRIPTS += bin/edje/edje_recc 254bin_SCRIPTS += bin/edje/edje_recc
@@ -280,13 +281,16 @@ tests/edje/data/%.edj: tests/edje/data/%.edc bin/edje/edje_cc${EXEEXT}
280 $(EDJE_CC) $(EDJE_CC_FLAGS) -id $(srcdir)/tests/edje/data $< $@ 281 $(EDJE_CC) $(EDJE_CC_FLAGS) -id $(srcdir)/tests/edje/data $< $@
281 282
282EDJE_DATA_FILES = tests/edje/data/test_layout.edc \ 283EDJE_DATA_FILES = tests/edje/data/test_layout.edc \
283 tests/edje/data/complex_layout.edc 284 tests/edje/data/complex_layout.edc \
285 tests/edje/data/test_parens.edc
284 286
285edjedatafilesdir = $(datadir)/edje/data 287edjedatafilesdir = $(datadir)/edje/data
286edjedatafiles_DATA = tests/edje/data/test_layout.edj \ 288edjedatafiles_DATA = tests/edje/data/test_layout.edj \
287 tests/edje/data/complex_layout.edj 289 tests/edje/data/complex_layout.edj \
290 tests/edje/data/test_parens.edj
288CLEANFILES += tests/edje/data/test_layout.edj \ 291CLEANFILES += tests/edje/data/test_layout.edj \
289 tests/edje/data/complex_layout.edj 292 tests/edje/data/complex_layout.edj \
293 tests/edje/data/test_parens.edj
290 294
291endif 295endif
292 296
diff --git a/src/bin/edje/edje_cc_parse.c b/src/bin/edje/edje_cc_parse.c
index 4e2884318f..b87afb08ac 100644
--- a/src/bin/edje/edje_cc_parse.c
+++ b/src/bin/edje/edje_cc_parse.c
@@ -387,10 +387,18 @@ next_token(char *p, char *end, char **new_p, int *delim)
387 else if (is_escaped) 387 else if (is_escaped)
388 is_escaped = 0; 388 is_escaped = 0;
389 } 389 }
390 else if (in_parens) 390 else if (in_parens != 0 && (!is_escaped))
391 { 391 {
392 if (((*p) == ')') && (!is_escaped)) 392 if (*p == '(')
393 in_parens++;
394 else if (*p == ')')
393 in_parens--; 395 in_parens--;
396 else if (isdelim(*p))
397 {
398 ERR("check pair of parens %s:%i.", file_in, line - 1);
399 err_show();
400 exit(-1);
401 }
394 } 402 }
395 else 403 else
396 { 404 {
@@ -401,6 +409,8 @@ next_token(char *p, char *end, char **new_p, int *delim)
401 } 409 }
402 else if (*p == '(') 410 else if (*p == '(')
403 in_parens++; 411 in_parens++;
412 else if (*p == ')')
413 in_parens--;
404 414
405 /* check for end-of-token */ 415 /* check for end-of-token */
406 if ( 416 if (
diff --git a/src/tests/edje/data/test_parens.edc b/src/tests/edje/data/test_parens.edc
new file mode 100644
index 0000000000..7df748ad73
--- /dev/null
+++ b/src/tests/edje/data/test_parens.edc
@@ -0,0 +1,24 @@
1collections {
2 group {
3 name: "test_group";
4
5 parts {
6 part {
7 name: "background";
8 type: RECT;
9 mouse_events: 0;
10
11 description {
12 state: "default" 0.0;
13 min: ((1000 + 100) - 1000) 100;
14
15 rel1 {
16 relative: 0.0 0.0;
17 }
18 rel2 {
19 relative: 1.0 1.0;
20 }
21 }
22 }
23 }
24}
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 5a2fcee1dc..5e3485c8e1 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -151,6 +151,25 @@ START_TEST(edje_test_complex_layout)
151} 151}
152END_TEST 152END_TEST
153 153
154START_TEST(edje_test_calculate_parens)
155{
156 int x, y, w, h;
157 int r, g, b, a;
158 Evas *evas = EDJE_TEST_INIT_EVAS();
159 Evas_Object *obj;
160 const Evas_Object *bg;
161
162 obj = edje_object_add(evas);
163 fail_unless(edje_object_file_set(obj, test_layout_get("test_parens.edj"), "test_group"));
164
165 evas_object_resize(obj, 100, 100);
166 edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
167 fail_if(x != 0 || y != 0 || w != 100 || h != 100);
168
169 EDJE_TEST_FREE_EVAS();
170}
171END_TEST
172
154void edje_test_edje(TCase *tc) 173void edje_test_edje(TCase *tc)
155{ 174{
156 tcase_add_test(tc, edje_test_edje_init); 175 tcase_add_test(tc, edje_test_edje_init);
@@ -158,4 +177,5 @@ void edje_test_edje(TCase *tc)
158 tcase_add_test(tc, edje_test_edje_load); 177 tcase_add_test(tc, edje_test_edje_load);
159 tcase_add_test(tc, edje_test_simple_layout_geometry); 178 tcase_add_test(tc, edje_test_simple_layout_geometry);
160 tcase_add_test(tc, edje_test_complex_layout); 179 tcase_add_test(tc, edje_test_complex_layout);
180 tcase_add_test(tc, edje_test_calculate_parens);
161} 181}