Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: groups.c menus-misc.c menus.c parse.c parse.h Log Message: Eliminate use of word() and atword() + fixups. =================================================================== RCS file: /cvs/e/e16/e/src/groups.c,v retrieving revision 1.90 retrieving revision 1.91 diff -u -3 -r1.90 -r1.91 --- groups.c 17 Jan 2007 01:10:43 -0000 1.90 +++ groups.c 26 Feb 2007 04:16:29 -0000 1.91 @@ -28,7 +28,6 @@ #include "emodule.h" #include "ewins.h" #include "groups.h" -#include "parse.h" #include "settings.h" #include "snaps.h" #include "timers.h" @@ -508,68 +507,55 @@ while (fgets(s, sizeof(s), f)) { - char ss[1024]; + char ss[128]; + int ii; if (strlen(s) > 0) s[strlen(s) - 1] = 0; - word(s, 1, ss); + ii = 0; + sscanf(s, "%100s %d", ss, &ii); if (!strcmp(ss, "NEW:")) { g = GroupCreate(); if (g) - { - word(s, 2, ss); - g->index = atoi(ss); - } + g->index = ii; + continue; } - else if (!strcmp(ss, "ICONIFY:")) + if (!g) + continue; + + if (!strcmp(ss, "ICONIFY:")) { - word(s, 2, ss); - if (g) - g->cfg.iconify = (char)atoi(ss); + g->cfg.iconify = ii; } else if (!strcmp(ss, "KILL:")) { - word(s, 2, ss); - if (g) - g->cfg.kill = (char)atoi(ss); + g->cfg.kill = ii; } else if (!strcmp(ss, "MOVE:")) { - word(s, 2, ss); - if (g) - g->cfg.move = (char)atoi(ss); + g->cfg.move = ii; } else if (!strcmp(ss, "RAISE:")) { - word(s, 2, ss); - if (g) - g->cfg.raise = (char)atoi(ss); + g->cfg.raise = ii; } else if (!strcmp(ss, "SET_BORDER:")) { - word(s, 2, ss); - if (g) - g->cfg.set_border = (char)atoi(ss); + g->cfg.set_border = ii; } else if (!strcmp(ss, "STICK:")) { - word(s, 2, ss); - if (g) - g->cfg.stick = (char)atoi(ss); + g->cfg.stick = ii; } else if (!strcmp(ss, "SHADE:")) { - word(s, 2, ss); - if (g) - g->cfg.shade = (char)atoi(ss); + g->cfg.shade = ii; } else if (!strcmp(ss, "MIRROR:")) { - word(s, 2, ss); - if (g) - g->cfg.mirror = (char)atoi(ss); + g->cfg.mirror = ii; } } fclose(f); @@ -1140,13 +1126,10 @@ if (params) { - char groupid[FILEPATH_LEN_MAX]; int gix; - groupid[0] = 0; - word(params, 1, groupid); - sscanf(groupid, "%d", &gix); - + gix = -1; + sscanf(params, "%d", &gix); group = GroupFind(gix); if (group) GroupShow(group); @@ -1164,10 +1147,10 @@ IPC_GroupOps(const char *params, Client * c __UNUSED__) { Group *group = Mode_groups.current; - char groupid[FILEPATH_LEN_MAX]; + char windowid[128]; + char operation[128]; + char groupid[128]; int gix; - char windowid[FILEPATH_LEN_MAX]; - char operation[FILEPATH_LEN_MAX]; unsigned int win; EWin *ewin; @@ -1177,11 +1160,12 @@ return; } - windowid[0] = 0; - operation[0] = 0; - word(params, 1, windowid); + windowid[0] = operation[0] = groupid[0] = '\0'; + sscanf(params, "%100s %100s %100s", windowid, operation, groupid); + win = 0; sscanf(windowid, "%x", &win); - word(params, 2, operation); + gix = -1; + sscanf(groupid, "%d", &gix); if (!operation[0]) { @@ -1206,40 +1190,19 @@ } else if (!strcmp(operation, "add")) { - groupid[0] = 0; - word(params, 3, groupid); - - if (groupid[0]) - { - sscanf(groupid, "%d", &gix); - group = GroupFind(gix); - } + group = GroupFind(gix); AddEwinToGroup(ewin, group); IpcPrintf("add %8x", win); } else if (!strcmp(operation, "del")) { - groupid[0] = 0; - word(params, 3, groupid); - - if (groupid[0]) - { - sscanf(groupid, "%d", &gix); - group = GroupFind(gix); - } + group = GroupFind(gix); RemoveEwinFromGroup(ewin, group); IpcPrintf("del %8x", win); } else if (!strcmp(operation, "break")) { - groupid[0] = 0; - word(params, 3, groupid); - - if (groupid[0]) - { - sscanf(groupid, "%d", &gix); - group = GroupFind(gix); - } + group = GroupFind(gix); BreakWindowGroup(ewin, group); IpcPrintf("break %8x", win); } @@ -1259,12 +1222,12 @@ static void IPC_Group(const char *params, Client * c __UNUSED__) { - char groupid[FILEPATH_LEN_MAX]; - char operation[FILEPATH_LEN_MAX]; - char param1[FILEPATH_LEN_MAX]; + char groupid[128]; + char operation[128]; + char param1[128]; int gix; Group *group; - int onoff = -1; + int onoff; if (!params) { @@ -1272,12 +1235,10 @@ return; } - groupid[0] = 0; - operation[0] = 0; - param1[0] = 0; - word(params, 1, groupid); + groupid[0] = operation[0] = param1[0] = '\0'; + sscanf(params, "%100s %100s %100s", groupid, operation, param1); + gix = -1; sscanf(groupid, "%d", &gix); - word(params, 2, operation); if (!operation[0]) { @@ -1293,13 +1254,13 @@ return; } - word(params, 3, param1); - if (param1[0]) + if (!param1[0]) { IpcPrintf("Error: no mode specified"); return; } + onoff = -1; if (!strcmp(param1, "on")) onoff = 1; else if (!strcmp(param1, "off")) =================================================================== RCS file: /cvs/e/e16/e/src/menus-misc.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -3 -r1.41 -r1.42 --- menus-misc.c 25 Feb 2007 01:38:30 -0000 1.41 +++ menus-misc.c 26 Feb 2007 04:16:29 -0000 1.42 @@ -68,7 +68,7 @@ { Progressbar *p = NULL; Menu *mm; - int i, num; + int i, num, len; const char *dir; char **list, s[4096], ss[4096], cs[4096]; const char *ext; @@ -120,36 +120,30 @@ return 1; while (fgets(s, sizeof(s), f)) { + char s2[4096]; + s[strlen(s) - 1] = 0; - word(s, 1, ss); + len = 0; + sscanf(s, "%1000s %1000s %n", ss, s2, &len); if (!strcmp(ss, "BG")) { - char s2[4096], s3[512]; - - word(s, 2, s2); - word(s, 3, s3); - Esnprintf(s, sizeof(s), "%s/%s", dir, s2); - mi = MenuItemCreateFromBackground(s3, s); - if (mi) - MenuAddItem(m, mi); + Esnprintf(ss, sizeof(ss), "%s/%s", dir, s2); + mi = MenuItemCreateFromBackground(s + len, ss); + MenuAddItem(m, mi); } else if (!strcmp(ss, "EXE")) { - word(s, 2, ss); - Esnprintf(s, sizeof(s), "exec %s/%s", dir, ss); - mi = MenuItemCreate(NULL, NULL, s, NULL); + Esnprintf(ss, sizeof(ss), "exec %s/%s", dir, s2); + mi = MenuItemCreate(NULL, NULL, ss, NULL); MenuAddItem(m, mi); } else if (!strcmp(ss, "DIR")) { - char tmp[4096]; - - word(s, 2, tmp); - Esnprintf(s, sizeof(s), "%s/%s:%s", dir, tmp, + Esnprintf(s, sizeof(s), "%s/%s:%s", dir, s2, MenuGetName(m)); - Esnprintf(ss, sizeof(ss), "%s/%s", dir, tmp); + Esnprintf(ss, sizeof(ss), "%s/%s", dir, s2); mm = MenuCreateFromDirectory(s, m, NULL, ss); - mi = MenuItemCreate(tmp, NULL, NULL, mm); + mi = MenuItemCreate(s2, NULL, NULL, mm); MenuAddItem(m, mi); } } @@ -351,7 +345,7 @@ } if ((act) && (!strcmp(act, "exec")) && (params)) { - word(params, 1, wd); + sscanf(params, "%4000s", wd); if (path_canexec(wd)) { Esnprintf(s, sizeof(s), "exec %s", params); =================================================================== RCS file: /cvs/e/e16/e/src/menus.c,v retrieving revision 1.271 retrieving revision 1.272 diff -u -3 -r1.271 -r1.272 --- menus.c 25 Feb 2007 20:44:22 -0000 1.271 +++ menus.c 26 Feb 2007 04:16:29 -0000 1.272 @@ -641,6 +641,8 @@ void MenuAddItem(Menu * m, MenuItem * item) { + if (!item) + return; m->num++; m->items = EREALLOC(MenuItem *, m->items, m->num); m->items[m->num - 1] = item; @@ -1930,7 +1932,7 @@ if (MenuIsEmpty(mm)) break; #endif - mi = MenuItemCreate(s + len2, ic, NULL, mm); + mi = MenuItemCreate(s + len + len2, ic, NULL, mm); MenuAddItem(m, mi); break; default: =================================================================== RCS file: /cvs/e/e16/e/src/parse.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- parse.c 13 Jan 2007 19:14:28 -0000 1.2 +++ parse.c 26 Feb 2007 04:16:29 -0000 1.3 @@ -26,6 +26,8 @@ #include "parse.h" #include "util.h" +#if 0 /* Unused */ + const char * atword(const char *s, int num) { @@ -112,6 +114,8 @@ *wd = 0; } } + +#endif /* Unused */ /* gets word number [num] in the string [s] and copies it into [wd] */ /* wd is NULL terminated. If word [num] does not exist wd = "" */ =================================================================== RCS file: /cvs/e/e16/e/src/parse.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- parse.h 13 Jan 2007 19:14:28 -0000 1.2 +++ parse.h 26 Feb 2007 04:16:29 -0000 1.3 @@ -23,8 +23,6 @@ #ifndef _PARSE_H_ #define _PARSE_H_ -const char *atword(const char *s, int num); -void word(const char *s, int num, char *wd); char *field(char *s, int fieldno); void fword(char *s, int num, char *wd); ------------------------------------------------------------------------- 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