Changeset 11119
- Timestamp:
- Jan 17, 2007, 3:39:12 PM (19 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 2 edited
-
cmd.basic/list.c (modified) (2 diffs)
-
lib.shell/ListOps.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.basic/list.c
r10647 r11119 5 5 int list (int argc, char **argv) { 6 6 7 int ThisList, depth, i, done ;7 int ThisList, depth, i, done, found; 8 8 char *input, line[1024]; 9 9 int N, Nbytes, NBYTES, Nread, status; … … 37 37 } 38 38 39 if ((argc > 2) && (!strcmp (argv[2], "-add"))) { 40 if (argc == 3) { 41 gprint (GP_ERR, "USAGE: list (root) -add (word) (word) ...\n"); 42 return (FALSE); 43 } 44 45 sprintf (line, "%s:n", argv[1]); 46 N = get_int_variable (line, &found); 47 for (i = 0; i < argc - 3; i++) { 48 sprintf (line, "%s:%d", argv[1], N + i); 49 set_str_variable (line, argv[i+3]); 50 } 51 sprintf (line, "%s:n", argv[1]); 52 set_int_variable (line, N + i); 53 54 return (TRUE); 55 } 56 39 57 if (argc != 2) { 40 gprint (GP_ERR, "USAGE: list (root) -- terminate with 'END'\n"); 58 gprint (GP_ERR, "USAGE: list (root) : supply list data, terminate with 'END'\n"); 59 gprint (GP_ERR, "USAGE: list (root) -x (command) : create list from shell output\n"); 60 gprint (GP_ERR, "USAGE: list (root) -split (words) : create list from words\n"); 61 gprint (GP_ERR, "USAGE: list (root) -add (words) : extend a list\n"); 41 62 return (FALSE); 42 63 } -
trunk/Ohana/src/opihi/lib.shell/ListOps.c
r11007 r11119 157 157 } 158 158 159 // list (word) : nested list 160 // list (word) -x : not nested list 161 // list (word) -split : not nested list 162 int is_list_data (char *line) { 163 164 char *comm, *temp; 165 166 temp = thisword (nextword (nextword (line))); 167 comm = thisword (line); 168 169 if (comm == NULL) goto escape; 170 171 if (strcmp (comm, "list")) goto escape; 172 173 /* if (cond) (command) does not define a complete block */ 174 if (temp != NULL) { 175 if (!strcmp (temp, "-x")) goto escape; 176 if (!strcmp (temp, "-split")) goto escape; 177 if (!strcmp (temp, "-add")) goto escape; 178 } 179 180 if (temp != NULL) free (temp); 181 if (comm != NULL) free (comm); 182 return (TRUE); 183 184 escape: 185 if (comm != NULL) free (comm); 186 if (temp != NULL) free (temp); 187 return (FALSE); 188 } 189 159 190 int is_loop (char *line) { 160 191 … … 216 247 status |= is_macro_create (line); 217 248 status |= is_for_loop (line); 249 status |= is_list_data (line); 218 250 status |= is_loop (line); 219 251 status |= is_task (line);
Note:
See TracChangeset
for help on using the changeset viewer.
