Enlightenment CVS committal

Author  : tsauerbeck
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/bin


Modified Files:
        edje_cc.h edje_cc_handlers.c edje_cc_parse.c 


Log Message:
boolean values can now be specified in the following ways: 0, false, off resp 1, true, 
on (case insensitive)
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- edje_cc.h   10 Oct 2004 11:58:43 -0000      1.18
+++ edje_cc.h   13 Oct 2004 18:07:55 -0000      1.19
@@ -104,6 +104,7 @@
 int     parse_enum(int n, ...);
 int     parse_int(int n);
 int     parse_int_range(int n, int f, int t);
+int     parse_bool(int n);
 double  parse_float(int n);
 double  parse_float_range(int n, double f, double t);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_handlers.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- edje_cc_handlers.c  13 Oct 2004 03:43:41 -0000      1.39
+++ edje_cc_handlers.c  13 Oct 2004 18:07:56 -0000      1.40
@@ -607,7 +607,7 @@
    
    pc = evas_list_data(evas_list_last(edje_collections));
    ep = evas_list_data(evas_list_last(pc->parts));
-   ep->mouse_events = parse_int_range(0, 0, 1);
+   ep->mouse_events = parse_bool(0);
 }
 
 static void
@@ -618,7 +618,7 @@
    
    pc = evas_list_data(evas_list_last(edje_collections));
    ep = evas_list_data(evas_list_last(pc->parts));
-   ep->repeat_events = parse_int_range(0, 0, 1);
+   ep->repeat_events = parse_bool(0);
 }
 
 static void
@@ -769,7 +769,7 @@
    ep = evas_list_data(evas_list_last(pc->parts));   
    ed = ep->default_desc;
    if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
-   ed->visible = parse_int_range(0, 0, 1);
+   ed->visible = parse_bool(0);
 }
 
 static void
@@ -1119,7 +1119,7 @@
    ep = evas_list_data(evas_list_last(pc->parts));
    ed = ep->default_desc;
    if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
-   ed->fill.smooth = parse_int_range(0, 0, 1);
+   ed->fill.smooth = parse_bool(0);
 }
 
 static void
@@ -1334,8 +1334,8 @@
    ep = evas_list_data(evas_list_last(pc->parts));
    ed = ep->default_desc;
    if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
-   ed->text.fit_x = parse_int_range(0, 0, 1);
-   ed->text.fit_y = parse_int_range(1, 0, 1);
+   ed->text.fit_x = parse_bool(0);
+   ed->text.fit_y = parse_bool(1);
 }
 
 static void
@@ -1349,8 +1349,8 @@
    ep = evas_list_data(evas_list_last(pc->parts));
    ed = ep->default_desc;
    if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
-   ed->text.min_x = parse_int_range(0, 0, 1);
-   ed->text.min_y = parse_int_range(1, 0, 1);
+   ed->text.min_x = parse_bool(0);
+   ed->text.min_y = parse_bool(1);
 }
 
 static void
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_parse.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- edje_cc_parse.c     6 Oct 2004 05:25:03 -0000       1.22
+++ edje_cc_parse.c     13 Oct 2004 18:07:56 -0000      1.23
@@ -1,3 +1,7 @@
+/*
+ * vim:ts=8:sw=3:sts=3:noexpandtab
+ */
+
 #include "edje_cc.h"
 
 static void  new_object(void);
@@ -30,6 +34,7 @@
 static int _is_op1f(char c);
 static int _is_op2f(char c);
 static double _calcf(char op, double a, double b);
+static int strstrip(const char *in, char *out, size_t size);
 
 
 int        line = 0;
@@ -716,6 +721,42 @@
    return i;
 }
 
+int
+parse_bool(int n)
+{
+   char *str, buf[4096];
+   int i;
+
+   str = evas_list_nth(params, n);
+   if (!str)
+     {
+       fprintf(stderr, "%s: Error. %s:%i no parameter supplied as argument %i\n",
+               progname, file_in, line, n + 1);
+       exit(-1);
+     }
+
+   if (!strstrip(str, buf, sizeof (buf)))
+     {
+       fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
+               progname, file_in, line);
+       return 0;
+     }
+
+   if (!strcasecmp(buf, "false") || !strcasecmp(buf, "off"))
+      return 0;
+   if (!strcasecmp(buf, "true") || !strcasecmp(buf, "on"))
+      return 1;
+
+   i = my_atoi(str);
+   if ((i < 0) || (i > 1))
+     {
+       fprintf(stderr, "%s: Error. %s:%i integer %i out of range of 0 to 1 
inclusive\n",
+               progname, file_in, line, i);
+       exit(-1);
+     }
+   return i;
+}
+
 double
 parse_float(int n)
 {
@@ -772,34 +813,19 @@
 my_atoi(const char * s)
 {
    int res = 0;
-   char *p, *p_in, *p_out;
    char buf[4096];
    
    if (!s)
      return 0;
    
-   if (4095 < strlen(s))
+   if (!strstrip(s, buf, sizeof (buf)))
      {
        fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
                progname, file_in, line);
        return 0;
      }
    
-   /* remove spaces and tabs */
-   p_in = (char *)s;
-   p_out = buf;
-   while (*p_in)
-     {
-       if ((0x20 != *p_in) && (0x09 != *p_in))
-         {
-            *p_out = *p_in;
-            p_out++;
-         }
-       p_in++;
-     }
-   *p_out = '\0';
-   
-   p = _alphai(buf, &res);
+   _alphai(buf, &res);
    return res;
 }
 
@@ -983,35 +1009,19 @@
 my_atof(const char * s)
 {
    double res = 0;
-   char *p, *p_in, *p_out;
    char buf[4096];
    
    if (!s)
      return 0;
    
-   if (4095 < strlen(s))
+   if (!strstrip(s, buf, sizeof (buf)))
      {
        fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
                progname, file_in, line);
        return 0;
      }
    
-   /* remove spaces and tabs */
-   p_in = (char *)s;
-   p_out = buf;
-   while (*p_in)
-     {
-       if ((0x20 != *p_in) && (0x09 != *p_in))
-         {
-            *p_out = *p_in;
-            p_out++;
-         }
-       p_in++;
-     }
-   *p_out = '\0';
-   
-   
-   p = _alphaf(buf, &res);
+   _alphaf(buf, &res);
    return res;
 }
 
@@ -1192,3 +1202,29 @@
        return a;
      }
 }
+
+static int
+strstrip(const char *in, char *out, size_t size)
+{
+   if ((size -1 ) < strlen(in))
+     {
+       fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
+               progname, file_in, line);
+       return 0;
+     }
+
+   /* remove spaces and tabs */
+   while (*in)
+     {
+       if ((0x20 != *in) && (0x09 != *in))
+         {
+            *out = *in;
+            out++;
+         }
+       in++;
+     }
+
+   *out = '\0';
+
+   return 1;
+}




-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to