Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        backgrounds.c iclass.c ipc.c tclass.c 


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

===================================================================
RCS file: /cvs/e/e16/e/src/backgrounds.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -3 -r1.90 -r1.91
--- backgrounds.c       25 Feb 2007 01:38:30 -0000      1.90
+++ backgrounds.c       25 Feb 2007 18:05:52 -0000      1.91
@@ -31,7 +31,6 @@
 #include "emodule.h"
 #include "file.h"
 #include "iclass.h"
-#include "parse.h"
 #include "settings.h"
 #include "tclass.h"
 #include "timers.h"
@@ -2378,7 +2377,7 @@
    Background         *bg;
    XColor              xclr;
 
-   if (!p)
+   if (!p || !p[0])
       return;
 
    bg = BackgroundFind(name);
@@ -2514,7 +2513,7 @@
 {
    const char         *p;
    char                cmd[128], prm[128], buf[4096];
-   int                 i, len, num;
+   int                 i, len, num, len2;
    Background         *bg;
 
    cmd[0] = prm[0] = '\0';
@@ -2522,7 +2521,7 @@
    if (p)
      {
        len = 0;
-       sscanf(p, "%100s %100s %n", cmd, prm, &len);
+       sscanf(p, "%100s %n%100s %n", cmd, &len2, prm, &len);
        p += len;
      }
 
@@ -2626,32 +2625,38 @@
    else
      {
        /* Compatibility with pre- 0.16.8 clients */
-       BackgroundSet1(cmd, atword(params, 2));
+       BackgroundSet1(cmd, params + len2);
      }
 }
 
 static void
 IPC_BackgroundUse(const char *params, Client * c __UNUSED__)
 {
-   char                param1[FILEPATH_LEN_MAX], w[FILEPATH_LEN_MAX];
+   char                name[1024];
+   const char         *p;
    Background         *bg;
-   int                 i, wd;
+   int                 i, l;
 
-   word(params, 1, param1);
+   p = params;
+   name[0] = '\0';
+   l = 0;
+   sscanf(p, "%1000s %n", name, &l);
+   p += l;
 
-   bg = BackgroundFind(param1);
+   bg = BackgroundFind(name);
    if (!bg)
       return;
 
-   for (wd = 2;; wd++)
+   for (;;)
      {
-       w[0] = 0;
-       word(params, wd++, w);
-       if (!w[0])
+       i = l = -1;
+       sscanf(p, "%d %n", &i, &l);
+       p += l;
+       if (i < 0)
           break;
-       i = atoi(w);
        DeskBackgroundSet(DeskGet(i), bg);
      }
+
    autosave();
 }
 
===================================================================
RCS file: /cvs/e/e16/e/src/iclass.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -3 -r1.114 -r1.115
--- iclass.c    25 Feb 2007 04:15:41 -0000      1.114
+++ iclass.c    25 Feb 2007 18:05:52 -0000      1.115
@@ -29,7 +29,6 @@
 #include "eimage.h"
 #include "emodule.h"
 #include "iclass.h"
-#include "parse.h"
 #include "tclass.h"
 #include "xwin.h"
 
@@ -1466,9 +1465,10 @@
 static void
 ImageclassIpc(const char *params, Client * c __UNUSED__)
 {
-   char                param1[FILEPATH_LEN_MAX];
-   char                param2[FILEPATH_LEN_MAX];
-   char                param3[FILEPATH_LEN_MAX];
+   char                param1[1024];
+   char                param2[1024];
+   int                 l;
+   const char         *p;
    ImageClass         *ic;
 
    if (!params)
@@ -1477,12 +1477,11 @@
        return;
      }
 
-   param1[0] = 0;
-   param2[0] = 0;
-   param3[0] = 0;
-
-   word(params, 1, param1);
-   word(params, 2, param2);
+   p = params;
+   l = 0;
+   param1[0] = param2[0] = '\0';
+   sscanf(p, "%1000s %1000s %n", param1, param2, &l);
+   p += l;
 
    if (!strncmp(param1, "list", 2))
      {
@@ -1503,11 +1502,10 @@
      }
    else if (!strcmp(param2, "free_pixmap"))
      {
-       Pixmap              p;
+       Pixmap              pmap;
 
-       word(params, 3, param3);
-       p = (Pixmap) strtol(param3, (char **)NULL, 0);
-       EImagePixmapFree(p);
+       pmap = (Pixmap) strtol(p, NULL, 0);
+       EImagePixmapFree(pmap);
        return;
      }
 
@@ -1549,17 +1547,21 @@
        Window              xwin;
        Win                 win;
        char                state[20];
-       const char         *winptr, *hptr;
-       int                 st, w = -1, h = -1;
+       int                 st, w, h;
+
+       /* 3:xwin 4:state 5:w 6:h */
+       xwin = None;
+       state[0] = '\0';
+       w = h = -1;
+       sscanf(p, "%lx %16s %d %d", &xwin, state, &w, &h);
 
-       winptr = atword(params, 3);
-       xwin = (Window) strtoul(winptr, NULL, 0);
        win = ECreateWinFromXwin(xwin);
        if (!win)
           return;
 
-       word(params, 4, state);
-       if (!strcmp(state, "hilited"))
+       if (!strcmp(state, "normal"))
+          st = STATE_NORMAL;
+       else if (!strcmp(state, "hilited"))
           st = STATE_HILITED;
        else if (!strcmp(state, "clicked"))
           st = STATE_CLICKED;
@@ -1568,13 +1570,6 @@
        else
           st = STATE_NORMAL;
 
-       hptr = atword(params, 6);
-       if (hptr)
-         {
-            w = (int)strtol(atword(params, 5), NULL, 0);
-            h = (int)strtol(hptr, NULL, 0);
-         }
-
        ImageclassApply(ic, win, w, h, 0, 0, st, ST_SOLID);
        EDestroyWin(win);
      }
@@ -1583,15 +1578,22 @@
        Window              xwin;
        Win                 win;
        char                state[20];
-       const char         *winptr, *hptr;
-       int                 st, w = -1, h = -1;
+       int                 st, w, h;
        PmapMask            pmm;
 
-       winptr = atword(params, 3);
-       xwin = (Window) strtoul(winptr, NULL, 0);
+       /* 3:xwin 4:state 5:w 6:h */
+       xwin = None;
+       state[0] = '\0';
+       w = h = -1;
+       sscanf(p, "%lx %16s %d %d", &xwin, state, &w, &h);
 
-       word(params, 4, state);
-       if (!strcmp(state, "hilited"))
+       win = ECreateWinFromXwin(xwin);
+       if (!win)
+          return;
+
+       if (!strcmp(state, "normal"))
+          st = STATE_NORMAL;
+       else if (!strcmp(state, "hilited"))
           st = STATE_HILITED;
        else if (!strcmp(state, "clicked"))
           st = STATE_CLICKED;
@@ -1600,19 +1602,11 @@
        else
           st = STATE_NORMAL;
 
-       hptr = atword(params, 6);
-       if (!hptr)
+       if (w < 0 || h < 0)
          {
             IpcPrintf("Error:  missing width and/or height\n");
             return;
          }
-
-       w = (int)strtol(atword(params, 5), NULL, 0);
-       h = (int)strtol(hptr, NULL, 0);
-
-       win = ECreateWinFromXwin(xwin);
-       if (!win)
-          return;
 
        ImageclassApplyCopy(ic, win, w, h, 0, 0, st, &pmm, 1, ST_SOLID);
        IpcPrintf("0x%08lx 0x%08lx\n", pmm.pmap, pmm.mask);
===================================================================
RCS file: /cvs/e/e16/e/src/ipc.c,v
retrieving revision 1.292
retrieving revision 1.293
diff -u -3 -r1.292 -r1.293
--- ipc.c       25 Feb 2007 04:13:37 -0000      1.292
+++ ipc.c       25 Feb 2007 18:05:52 -0000      1.293
@@ -31,7 +31,6 @@
 #include "ewin-ops.h"
 #include "grabs.h"
 #include "hints.h"             /* FIXME - Should not be here */
-#include "parse.h"
 #include "screen.h"
 #include "session.h"
 #include "snaps.h"
@@ -994,7 +993,7 @@
 static void
 IPC_Remember(const char *params, Client * c __UNUSED__)
 {
-   int                 window;
+   int                 window, l;
    EWin               *ewin;
 
    if (!params)
@@ -1003,8 +1002,12 @@
        goto done;
      }
 
+   l = 0;
    window = 0;
-   sscanf(params, "%x", &window);
+   sscanf(params, "%x %n", &window, &l);
+   if (l <= 0)
+      return;
+
    ewin = EwinFindByClient(window);
    if (!ewin)
      {
@@ -1012,7 +1015,7 @@
        goto done;
      }
 
-   SnapshotEwinParse(ewin, atword(params, 2));
+   SnapshotEwinParse(ewin, params + l);
 
  done:
    return;
@@ -1033,10 +1036,14 @@
 static void
 IPC_Exit(const char *params, Client * c __UNUSED__)
 {
-   char                param1[FILEPATH_LEN_MAX];
+   char                param1[1024];
+   const char         *p2;
+   int                 l;
 
    param1[0] = 0;
-   word(params, 1, param1);
+   l = 0;
+   sscanf(params, "%1000s %n", param1, &l);
+   p2 = (l > 0) ? params + l : NULL;
 
    if (!param1[0])
       SessionExit(EEXIT_EXIT, NULL);
@@ -1045,9 +1052,9 @@
    else if (!strcmp(param1, "restart"))
       SessionExit(EEXIT_RESTART, NULL);
    else if (!strcmp(param1, "theme"))
-      SessionExit(EEXIT_THEME, atword(params, 2));
+      SessionExit(EEXIT_THEME, p2);
    else if (!strcmp(param1, "exec"))
-      SessionExit(EEXIT_EXEC, atword(params, 2));
+      SessionExit(EEXIT_EXEC, p2);
 }
 
 static void
@@ -1588,7 +1595,8 @@
 HandleIPC(const char *params, Client * c)
 {
    int                 i, num, ok;
-   char                w[FILEPATH_LEN_MAX];
+   char                cmd[128];
+   const char         *prm;
    const IpcItem     **lst, *ipc;
 
    if (EDebug(EDBUG_TYPE_IPC))
@@ -1596,24 +1604,20 @@
 
    IpcPrintInit();
 
-   lst = IPC_GetList(&num);
+   cmd[0] = 0;
+   sscanf(params, "%100s %n", cmd, &num);
+   prm = (num > 0) ? params + num : NULL;
 
-   w[0] = 0;
-   word(params, 1, w);
+   lst = IPC_GetList(&num);
 
    ok = 0;
    for (i = 0; i < num; i++)
      {
        ipc = lst[i];
-       if (!(ipc->nick && !strcmp(w, ipc->nick)) && strcmp(w, ipc->name))
+       if (!(ipc->nick && !strcmp(cmd, ipc->nick)) && strcmp(cmd, ipc->name))
           continue;
 
-       w[0] = 0;
-       word(params, 2, w);
-       if (w[0])
-          ipc->func(atword(params, 2), c);
-       else
-          ipc->func(NULL, c);
+       ipc->func(prm, c);
 
        ok = 1;
        break;
===================================================================
RCS file: /cvs/e/e16/e/src/tclass.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- tclass.c    25 Feb 2007 04:15:41 -0000      1.52
+++ tclass.c    25 Feb 2007 18:05:53 -0000      1.53
@@ -26,7 +26,6 @@
 #include "e16-ecore_list.h"
 #include "emodule.h"
 #include "iclass.h"
-#include "parse.h"
 #include "tclass.h"
 #include "xwin.h"
 
@@ -494,9 +493,10 @@
 static void
 TextclassIpc(const char *params, Client * c __UNUSED__)
 {
-   char                param1[FILEPATH_LEN_MAX];
-   char                param2[FILEPATH_LEN_MAX];
-   char                param3[FILEPATH_LEN_MAX];
+   char                param1[1024];
+   char                param2[1024];
+   int                 l;
+   const char         *p;
    TextClass          *tc;
 
    if (!params)
@@ -505,12 +505,11 @@
        return;
      }
 
-   param1[0] = 0;
-   param2[0] = 0;
-   param3[0] = 0;
-
-   word(params, 1, param1);
-   word(params, 2, param2);
+   p = params;
+   l = 0;
+   param1[0] = param2[0] = '\0';
+   sscanf(params, "%1000s %1000s %n", param1, param2, &l);
+   p += l;
 
    if (!strncmp(param1, "list", 2))
      {
@@ -549,49 +548,49 @@
      {
        Window              xwin;
        Win                 win;
-       int                 state;
-       int                 x, y;
-       const char         *txt;
-
-       word(params, 3, param3);
-       xwin = (Window) strtoul(param3, NULL, 0);
-
-       word(params, 4, param3);
-       x = atoi(param3);
-       word(params, 5, param3);
-       y = atoi(param3);
-
-       word(params, 6, param3);
-       state = STATE_NORMAL;
-       if (!strcmp(param3, "normal"))
-          state = STATE_NORMAL;
-       else if (!strcmp(param3, "hilited"))
-          state = STATE_HILITED;
-       else if (!strcmp(param3, "clicked"))
-          state = STATE_CLICKED;
-       else if (!strcmp(param3, "disabled"))
-          state = STATE_DISABLED;
+       char                state[20];
+       int                 x, y, st;
+
+       /* 3:xwin 4:x 5:y 6:state 7-:txt */
+       xwin = None;
+       x = y = 0;
+       state[0] = '\0';
+       l = 0;
+       sscanf(p, "%lx %d %d %16s %n", &xwin, &x, &y, state, &l);
+       p += l;
+
+       if (!strcmp(state, "normal"))
+          st = STATE_NORMAL;
+       else if (!strcmp(state, "hilited"))
+          st = STATE_HILITED;
+       else if (!strcmp(state, "clicked"))
+          st = STATE_CLICKED;
+       else if (!strcmp(state, "disabled"))
+          st = STATE_DISABLED;
+       else
+          st = STATE_NORMAL;
 
-       txt = atword(params, 7);
-       if (!txt)
+       if (l == 0)
           return;
 
        win = ECreateWinFromXwin(xwin);
        if (!win)
           return;
 
-       TextDraw(tc, win, None, 0, 0, state, txt, x, y, 99999, 99999, 17, 0);
+       TextDraw(tc, win, None, 0, 0, st, p, x, y, 99999, 99999, 17, 0);
        EDestroyWin(win);
      }
    else if (!strcmp(param2, "query_size"))
      {
        int                 w, h;
-       const char         *txt;
+
+       /* 3-:txt */
+
+       if (l == 0)
+          return;
 
        w = h = 0;
-       txt = atword(params, 3);
-       if (txt)
-          TextSize(tc, 0, 0, STATE_NORMAL, txt, &w, &h, 17);
+       TextSize(tc, 0, 0, STATE_NORMAL, p, &w, &h, 17);
        IpcPrintf("%i %i\n", w, h);
      }
    else if (!strcmp(param2, "query"))



-------------------------------------------------------------------------
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