Changeset 27838 for branches/tap_branches/Ohana/src/opihi/cmd.basic/list.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/tap_branches/Ohana/src/opihi/cmd.basic/list.c
r16427 r27838 35 35 set_int_variable (line, i); 36 36 37 return (TRUE); 38 } 39 40 // return an error if -add is given with no other args 41 if ((argc > 2) && (!strcmp (argv[2], "-splitbychar"))) { 42 if (argc < 4) { 43 gprint (GP_ERR, "USAGE: list (root) -splitbychar (char) (word) [(word)...]\n"); 44 return (FALSE); 45 } 46 47 int j, nWords; 48 char splitter; 49 char *new, *word, *ptr; 50 51 nWords = 0; 52 splitter = argv[3][0]; 53 54 for (i = 0; i < argc - 3; i++) { 55 new = strcreate (argv[i+3]); 56 for (j = 0; new[j]; j++) { 57 if (new[j] == splitter) new[j] = ' '; 58 } 59 60 ptr = new; 61 while (ptr) { 62 word = thisword (ptr); 63 if (!word) break; 64 65 sprintf (line, "%s:%d", argv[1], nWords); 66 set_str_variable (line, word); 67 FREE (word); 68 ptr = nextword (ptr); 69 nWords ++; 70 } 71 FREE (new); 72 } 73 sprintf (line, "%s:n", argv[1]); 74 set_int_variable (line, nWords); 75 76 return (TRUE); 77 } 78 79 // return an error if -copy is given with no other args 80 if ((argc > 2) && (!strcmp (argv[2], "-copy"))) { 81 char *value; 82 if (argc == 3) { 83 gprint (GP_ERR, "USAGE: list (newlist) -copy (oldlist) ...\n"); 84 return (FALSE); 85 } 86 87 sprintf (line, "%s:n", argv[3]); 88 N = get_int_variable (line, &found); 89 sprintf (line, "%s:n", argv[1]); 90 set_int_variable (line, N); 91 for (i = 0; i < N; i++) { 92 sprintf (line, "%s:%d", argv[3], i); 93 value = get_variable (line); 94 sprintf (line, "%s:%d", argv[1], i); 95 set_str_variable (line, value); 96 } 37 97 return (TRUE); 38 98 }
Note:
See TracChangeset
for help on using the changeset viewer.
