cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7d33ae501b2263ff1450c6351dea181573afe517

commit 7d33ae501b2263ff1450c6351dea181573afe517
Author: Nak-Gyeong Kim <nakkyong....@samsung.com>
Date:   Fri May 29 18:11:49 2015 +0200

    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....@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 <ced...@osg.samsung.com>
---
 src/Makefile_Edje.am                | 12 ++++++++----
 src/bin/edje/edje_cc_parse.c        | 14 ++++++++++++--
 src/tests/edje/data/test_parens.edc | 24 ++++++++++++++++++++++++
 src/tests/edje/edje_test_edje.c     | 20 ++++++++++++++++++++
 4 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index b9b9c14..15a8fed 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -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
 
diff --git a/src/bin/edje/edje_cc_parse.c b/src/bin/edje/edje_cc_parse.c
index 4e28843..b87afb0 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)
                        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 (
diff --git a/src/tests/edje/data/test_parens.edc 
b/src/tests/edje/data/test_parens.edc
new file mode 100644
index 0000000..7df748a
--- /dev/null
+++ b/src/tests/edje/data/test_parens.edc
@@ -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;                  
+               }
+            }
+         }
+   }
+}
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 5a2fcee..5e3485c 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)
 }
 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);
 }

-- 


Reply via email to