Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        aclass.c cmclass.c menus.c 


Log Message:
Eliminate use of word() and atword().

===================================================================
RCS file: /cvs/e/e16/e/src/aclass.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- aclass.c    1 Feb 2007 01:23:40 -0000       1.40
+++ aclass.c    25 Feb 2007 20:44:22 -0000      1.41
@@ -30,7 +30,6 @@
 #include "ewins.h"
 #include "file.h"
 #include "grabs.h"
-#include "parse.h"
 #include <ctype.h>
 
 typedef struct _actiontype
@@ -139,8 +138,9 @@
    at = EMALLOC(ActionType, 1);
    if (!at)
       return;
+
    at->next = NULL;
-   at->params = Estrdup(params);
+   at->params = (params && *params) ? Estrdup(params) : NULL;
    if (!aa->action)
      {
        aa->action = at;
@@ -274,13 +274,13 @@
    char               *aclass_tooltipstring = NULL;
    char               *action_tooltipstring = NULL;
    char global = 0;
-   int                 fields;
+   int                 fields, len2, len;
 
    while (GetLine(s, sizeof(s), fs))
      {
        s2[0] = 0;
        i1 = CONFIG_INVALID;
-       fields = sscanf(s, "%i %4000s", &i1, s2);
+       fields = sscanf(s, "%i %n%4000s %n", &i1, &len2, s2, &len);
 
        if (fields < 1)
          {
@@ -486,15 +486,15 @@
                  ActionclassAddAction(ac, aa);
                  first = 0;
               }
-            ActionAddTo(aa, atword(s, 2));
+            ActionAddTo(aa, s + len2);
             break;
          case CONFIG_ACTION_TOOLTIP:
             action_tooltipstring =
-               Estrdupcat2(action_tooltipstring, "\n", atword(s, 2));
+               Estrdupcat2(action_tooltipstring, "\n", s + len2);
             break;
          case CONFIG_TOOLTIP:
             aclass_tooltipstring =
-               Estrdupcat2(aclass_tooltipstring, "\n", atword(s, 2));
+               Estrdupcat2(aclass_tooltipstring, "\n", s + len2);
             break;
          default:
             RecoverUserConfig();
@@ -722,7 +722,7 @@
    char                prm1[128], prm2[128], prm3[128];
    ActionClass        *ac = NULL;
    Action             *aa = NULL;
-   int                 len;
+   int                 len, len2;
 
    for (;;)
      {
@@ -736,7 +736,8 @@
        s[len] = '\0';
 
        prm3[0] = '\0';
-       len = sscanf(s, "%16s %128s %16s", prm1, prm2, prm3);
+       len2 = 0;
+       len = sscanf(s, "%16s %n%128s %16s", prm1, &len2, prm2, prm3);
        if (len < 2)
           continue;
 
@@ -785,12 +786,12 @@
             if (aa)
               {
                  aa->tooltipstring =
-                    Estrdupcat2(aa->tooltipstring, "\n", atword(s, 2));
+                    Estrdupcat2(aa->tooltipstring, "\n", s + len2);
               }
             else if (ac)
               {
                  ac->tooltipstring =
-                    Estrdupcat2(ac->tooltipstring, "\n", atword(s, 2));
+                    Estrdupcat2(ac->tooltipstring, "\n", s + len2);
               }
          }
      }
@@ -1338,6 +1339,10 @@
    char                buf[FILEPATH_LEN_MAX];
    const char         *sp, *ss;
 
+   ss = params;
+   if (!ss || !ss[0])
+      return;
+
    Mode.keybinds_changed = 1;
 
    ac = (ActionClass *) ecore_list_remove_node(aclass_list_global,
@@ -1347,9 +1352,7 @@
       ActionclassDestroy(ac);
 
    ac = ActionclassCreate("KEYBINDINGS", 1);
-
-   ss = atword(params, 1);
-   if (!ss)
+   if (!ac)
       return;
 
    i = 0;
@@ -1359,7 +1362,7 @@
        char                key[256];
        int                 mod = 0;
        int                 act_id = 0;
-       int                 j = 0;
+       int                 j = 0, len;
 
        /* put line in buf */
        sp = &(ss[i]);
@@ -1374,7 +1377,8 @@
        i += j;
 
        /* parse the line */
-       sscanf(buf, "%250s %i %i", key, &mod, &act_id);
+       len = 0;
+       sscanf(buf, "%250s %i %i %n", key, &mod, &act_id, &len);
        if (mod == 0)
           mod = 0;
        else if (mod == 1)
@@ -1420,10 +1424,7 @@
 
        aa = ActionCreate(4, 0, mod, 0, 0, 0, key, NULL);
        ActionclassAddAction(ac, aa);
-       if (atword(buf, 4))
-          ActionAddTo(aa, atword(buf, 4));
-       else
-          ActionAddTo(aa, NULL);
+       ActionAddTo(aa, buf + len);
        GrabActionKey(aa);
      }
 
===================================================================
RCS file: /cvs/e/e16/e/src/cmclass.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- cmclass.c   13 Jan 2007 19:14:26 -0000      1.23
+++ cmclass.c   25 Feb 2007 20:44:22 -0000      1.24
@@ -180,14 +180,15 @@
    int                 i = 0, tx, ty;
    int                 rnum = 0, gnum = 0, bnum = 0;
    ColorModifierClass *cm;
-   int                 fields;
+   int                 fields, len2;
 
    while (GetLine(s, sizeof(s), fs))
      {
        s2[0] = 0;
        i = 0;
        i1 = CONFIG_INVALID;
-       fields = sscanf(s, "%i %4000s", &i1, s2);
+       len2 = 0;
+       fields = sscanf(s, "%i %n%4000s", &i1, &len2, s2);
 
        if (fields < 1)
          {
@@ -230,7 +231,7 @@
             name = Estrdup(s2);
             break;
          case COLORMOD_RED:
-            params = atword(s, 2);
+            params = (s[len2]) ? s + len2 : NULL;
             current_param = params;
             if (!current_param)
                goto done;
@@ -262,7 +263,7 @@
             rnum = i;
             break;
          case COLORMOD_GREEN:
-            params = atword(s, 2);
+            params = (s[len2]) ? s + len2 : NULL;
             current_param = params;
             if (!current_param)
                goto done;
@@ -294,7 +295,7 @@
             gnum = i;
             break;
          case COLORMOD_BLUE:
-            params = atword(s, 2);
+            params = (s[len2]) ? s + len2 : NULL;
             current_param = params;
             if (!current_param)
                goto done;
===================================================================
RCS file: /cvs/e/e16/e/src/menus.c,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -3 -r1.270 -r1.271
--- menus.c     25 Feb 2007 01:38:30 -0000      1.270
+++ menus.c     25 Feb 2007 20:44:22 -0000      1.271
@@ -35,7 +35,6 @@
 #include "hints.h"
 #include "iclass.h"
 #include "menus.h"
-#include "parse.h"
 #include "screen.h"
 #include "settings.h"
 #include "tclass.h"
@@ -1822,13 +1821,14 @@
    MenuItem           *mi;
    MenuStyle          *ms;
    ImageClass         *ic = NULL;
-   int                 fields;
+   int                 fields, len2, len;
 
    while (GetLine(s, sizeof(s), fs))
      {
        s2[0] = 0;
        i1 = CONFIG_INVALID;
-       fields = sscanf(s, "%i %4000s", &i1, s2);
+       len = 0;
+       fields = sscanf(s, "%i %n%4000s %n", &i1, &len2, s2, &len);
 
        if (fields < 1)
          {
@@ -1880,7 +1880,7 @@
             break;
          case MENU_TITLE:
             if (m)
-               MenuSetTitle(m, atword(s, 2));
+               MenuSetTitle(m, s + len2);
             break;
          case MENU_ITEM:
 #if 0                          /* FIXME - Why ? */
@@ -1893,7 +1893,7 @@
             ic = NULL;
             if (strcmp("NULL", s2))
                ic = ImageclassFind(s2, 0);
-            params = atword(s, 3);
+            params = s + len;
             _EFDUP(txt, params);
             break;
          case MENU_ACTION:
@@ -1905,18 +1905,12 @@
                   * on your system before adding the menu entry */
                  if (!strcmp(s2, "exec"))
                    {
-                      char                buf[1024];
-
-                      params = atword(s, 3);
-                      if (params)
-                        {
-                           sscanf(atword(s, 3), "%1000s", buf);
-                           ok = path_canexec(buf);
-                        }
+                      sscanf(s + len, "%1000s", s3);
+                      ok = path_canexec(s3);
                    }
                  if (ok)
                    {
-                      params = atword(s, 2);
+                      params = s + len2;
                       mi = MenuItemCreate(txt, ic, params, NULL);
                       MenuAddItem(m, mi);
                    }
@@ -1925,7 +1919,8 @@
               }
             break;
          case MENU_SUBMENU:
-            sscanf(s, "%i %4000s %4000s", &i1, s2, s3);
+            len2 = 0;
+            sscanf(s + len, "%4000s %n", s3, &len2);
             ic = NULL;
             if (strcmp("NULL", s3))
                ic = ImageclassFind(s3, 0);
@@ -1935,7 +1930,7 @@
             if (MenuIsEmpty(mm))
                break;
 #endif
-            mi = MenuItemCreate(atword(s, 4), ic, NULL, mm);
+            mi = MenuItemCreate(s + len2, ic, NULL, mm);
             MenuAddItem(m, mi);
             break;
          default:



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to