Changeset 10647
- Timestamp:
- Dec 11, 2006, 10:15:41 PM (19 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 16 edited
-
cmd.basic/list.c (modified) (1 diff)
-
cmd.basic/run_for.c (modified) (2 diffs)
-
cmd.basic/run_if.c (modified) (2 diffs)
-
cmd.basic/run_while.c (modified) (1 diff)
-
cmd.basic/test/for.sh (modified) (2 diffs)
-
include/shell.h (modified) (4 diffs)
-
lib.shell/ListOps.c (modified) (3 diffs)
-
lib.shell/exec_loop.c (modified) (3 diffs)
-
lib.shell/macro_create.c (modified) (1 diff)
-
mana/opihi.c (modified) (1 diff)
-
pantasks/LocalJob.c (modified) (1 diff)
-
pantasks/scheduler.c (modified) (1 diff)
-
pantasks/task.c (modified) (1 diff)
-
pantasks/task_macros.c (modified) (1 diff)
-
pantasks/test/local.sh (modified) (1 diff)
-
pcontrol/pcontrol.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.basic/list.c
r7917 r10647 98 98 /* read in loop */ 99 99 depth = 0; 100 ThisList = Nlists;100 ThisList = current_list_depth(); 101 101 for (i = 0, done = FALSE; !done; ) { 102 102 -
trunk/Ohana/src/opihi/cmd.basic/run_for.c
r7917 r10647 27 27 /* read in loop */ 28 28 depth = 0; 29 ThisList = Nlists;29 ThisList = current_list_depth(); 30 30 for (i = 0, done = FALSE; !done; ) { 31 31 … … 104 104 105 105 /* 106 If we are entering at the keyboard ( Nlists== 0), use readline.106 If we are entering at the keyboard (ThisList == 0), use readline. 107 107 Otherwise, read from the current list, remove list lines. 108 108 execute when we hit the final "END" (the true END -- we count macro defines!!) -
trunk/Ohana/src/opihi/cmd.basic/run_if.c
r8178 r10647 26 26 nloop = 0; 27 27 depth = 0; 28 ThisList = Nlists;28 ThisList = current_list_depth(); 29 29 30 30 /* determine value of conditional expression */ … … 108 108 109 109 /* 110 If we are entering at the keyboard ( Nlists== 0), use readline.110 If we are entering at the keyboard (ThisList == 0), use readline. 111 111 Otherwise, read from the current list, remove list lines. 112 112 End when we hit the final "END" (the true END -- we count macro defines!!) -
trunk/Ohana/src/opihi/cmd.basic/run_while.c
r9844 r10647 25 25 /* read in loop */ 26 26 depth = 0; 27 ThisList = Nlists;27 ThisList = current_list_depth(); 28 28 for (i = 0, done = FALSE; !done; ) { 29 29 -
trunk/Ohana/src/opihi/cmd.basic/test/for.sh
r10311 r10647 8 8 memtest1 9 9 memtest2 10 memtest2a 10 11 memtest3 11 12 end … … 162 163 end 163 164 165 # check memleaks with many loop lines 166 macro memtest2a 167 168 local i N 169 170 list word -x "ps -p $PID -o rss" 171 $startmem = $word:1 172 173 output /dev/null 174 for i 0 10000 175 echo "test line in loop" 176 echo "test line in loop" 177 end 178 output stdout 179 180 list word -x "ps -p $PID -o rss" 181 $endmem = $word:1 182 183 $PASS = 1 184 185 if ($endmem - $startmem > 10) 186 $PASS = 0 187 echo "growth: {$endmem-$startmem}" 188 echo "kB/loop: {($endmem-$startmem)/10000}" 189 end 190 end 191 192 # check memleaks with many loop lines 193 macro memtest2b 194 195 local i N 196 197 list word -x "ps -p $PID -o rss" 198 $startmem = $word:1 199 200 output /dev/null 201 for i 0 1000 202 exec echo "test line in loop" > /dev/null 203 exec echo "test line in loop" > /dev/null 204 end 205 output stdout 206 207 list word -x "ps -p $PID -o rss" 208 $endmem = $word:1 209 210 $PASS = 1 211 212 if ($endmem - $startmem > 10) 213 $PASS = 0 214 echo "growth: {$endmem-$startmem}" 215 echo "kB/loop: {($endmem-$startmem)/1000}" 216 end 217 end 218 164 219 # check memleaks on break 165 220 macro memtest3 -
trunk/Ohana/src/opihi/include/shell.h
r9039 r10647 37 37 int n; 38 38 int Nlines; 39 int Nalloc; 39 40 } List; 40 41 … … 50 51 51 52 /*** globals used to track the shell language concepts ***/ 52 List *lists; /* variable to store the list of all lists */53 int Nlists; /* number of currently available lists */54 55 53 int interrupt; /* true if C-C has been pressed */ 56 54 int auto_break; /* if true, zero exit status forces macros to escape */ … … 82 80 int is_macro_create PROTO((char *line)); 83 81 void InitLists PROTO(()); 82 int current_list_depth (); 83 int increase_list_depth (); 84 int decrease_list_depth (); 85 char *get_next_listentry (int ThisList); 84 86 85 87 void InitCommands PROTO(()); … … 101 103 102 104 int exec_loop PROTO((Macro *loop)); 103 char *get_next_listentry PROTO((int ThisList)); 104 char *remove_listentry PROTO((int current)); 105 /* char *get_next_listentry PROTO((int ThisList)); */ 106 /* char *remove_listentry PROTO((int current)); */ 107 105 108 int ConfigInit PROTO((int *argc, char **argv)); 106 109 char *VarConfig PROTO((char *keyword, char *mode, void *ptr)); -
trunk/Ohana/src/opihi/lib.shell/ListOps.c
r4763 r10647 1 1 # include "opihi.h" 2 2 # include "macro.h" 3 4 /*** local static variables used to track the command lists ***/ 5 static List *lists; /* variable to store the list of all lists */ 6 static int Nlists; /* number of currently available lists */ 3 7 4 8 void InitLists () { … … 8 12 } 9 13 14 int current_list_depth () { 15 return Nlists; 16 } 17 18 int increase_list_depth () { 19 Nlists ++; 20 REALLOCATE (lists, List, MAX (Nlists + 1, 0) + 1); 21 ALLOCATE (lists[Nlists].line, char *, 16); 22 lists[Nlists].Nalloc = 16; 23 lists[Nlists].Nlines = 0; 24 lists[Nlists].n = 0; 25 return Nlists; 26 } 27 28 int decrease_list_depth () { 29 30 int i; 31 32 for (i = 0; i < lists[Nlists].Nlines; i++) { 33 free (lists[Nlists].line[i]); 34 } 35 free (lists[Nlists].line); 36 Nlists --; 37 REALLOCATE (lists, List, MAX (Nlists + 1, 0) + 1); 38 return Nlists; 39 } 40 10 41 /* return a new string consisting of the next line in the current list */ 11 42 char *get_next_listentry (int ThisList) { 12 43 44 int Nline; 13 45 char *output; 14 46 15 lists[ThisList].n++;16 17 if ( lists[ThisList].n >= lists[Nlists].Nlines)18 return ((char *) NULL); 19 20 output = lists[Nlists].line[lists[ThisList].n];47 Nline = lists[ThisList].n; 48 49 if (Nline >= lists[ThisList].Nlines) return (NULL); 50 51 output = strcreate (lists[ThisList].line[Nline]); 52 lists[ThisList].n ++; 21 53 22 54 return (output); 23 24 } 25 55 } 56 57 # if (0) 26 58 char *remove_listentry (int current) { 27 59 … … 41 73 return (output); 42 74 75 } 76 # endif 77 78 int add_listentry (int ThisList, char *line) { 79 80 int Nlines; 81 char *output; 82 83 Nlines = lists[ThisList].Nlines; 84 lists[ThisList].line[Nlines] = strcreate (line); 85 lists[ThisList].Nlines ++; 86 87 if (lists[ThisList].Nlines == lists[ThisList].Nalloc) { 88 lists[ThisList].Nalloc += 16; 89 REALLOCATE (lists[ThisList].line, char *, lists[ThisList].Nalloc); 90 } 91 92 return (lists[ThisList].Nlines); 43 93 } 44 94 -
trunk/Ohana/src/opihi/lib.shell/exec_loop.c
r9469 r10647 8 8 9 9 /* increase the shell level (Nlists) by one */ 10 Nlists ++; 11 ThisList = Nlists; 12 REALLOCATE (lists, List, MAX (ThisList, 0) + 1); 13 10 ThisList = increase_list_depth(); 11 if (ThisList == 0) abort(); 12 14 13 /* copy the macro to the current list */ 15 lists[ThisList].Nlines = loop[0].Nlines; 16 ALLOCATE (lists[ThisList].line, char *, MAX (lists[ThisList].Nlines, 1)); 17 for (j = 0; j < lists[ThisList].Nlines; j++) { 18 lists[ThisList].line[j] = strcreate (loop[0].line[j]); 14 for (j = 0; j < loop[0].Nlines; j++) { 15 add_listentry (ThisList, loop[0].line[j]); 19 16 } 20 17 … … 26 23 loop_continue = loop_break = FALSE; 27 24 status = TRUE; 28 Nlines = lists[ThisList].Nlines;29 for (n = 0; (n < Nlines) && !interrupt; n++) {30 lists[ThisList].n = n;31 line = lists[ThisList].line[n];32 25 26 while (!interrupt) { 27 line = get_next_listentry (ThisList); 28 if (line == NULL) break; 33 29 status = multicommand (line); 34 35 if (line != NULL) free (line); 36 n = lists[ThisList].n; 37 Nlines = lists[ThisList].Nlines; 30 free (line); 38 31 if (auto_break && !status) loop_break = TRUE; 39 32 if (loop_break || loop_continue) break; … … 42 35 43 36 /* free remaining lines on the list, free the list, decrement the shell level */ 44 for (n ++; n < Nlines; n ++) { 45 free (lists[ThisList].line[n]); 46 } 47 free (lists[ThisList].line); 48 Nlists --; 49 REALLOCATE (lists, List, MAX (Nlists, 0) + 1); 37 /*** can we free a list which is not the bottom lists? */ 38 decrease_list_depth(); 50 39 51 40 if (loop_break) return (FALSE); -
trunk/Ohana/src/opihi/lib.shell/macro_create.c
r7917 r10647 60 60 61 61 /* read in macro 62 If we are entering at the keyboard ( Nlists== 0), use readline.62 If we are entering at the keyboard (ThisList == 0), use readline. 63 63 Otherwise, read from the current list 64 64 End when we hit the final "END" (the true END -- we count macro defines!!) */ 65 65 66 66 depth = 0; 67 ThisList = Nlists;67 ThisList = current_list_depth(); 68 68 for (i = 0, done = FALSE; !done; ) { 69 69 -
trunk/Ohana/src/opihi/mana/opihi.c
r9040 r10647 20 20 21 21 auto_break = TRUE; 22 23 Nlists = 0;24 ALLOCATE (lists, List, 1);25 22 26 23 /* init functions required by libraries */ -
trunk/Ohana/src/opihi/pantasks/LocalJob.c
r8548 r10647 29 29 case 0: /* pipe is closed, change child state? **/ 30 30 default: /* data in pipe */ 31 // fprintf (stderr, "read %d bytes (Nblock: %d, Nbuffer: %d)\n", Nread, job[0].stdout.Nblock, job[0].stdout.Nbuffer); 31 32 break; 32 33 } -
trunk/Ohana/src/opihi/pantasks/scheduler.c
r9037 r10647 11 11 12 12 auto_break = TRUE; 13 14 Nlists = 0;15 ALLOCATE (lists, List, 1);16 13 17 14 /* init functions required by libraries */ -
trunk/Ohana/src/opihi/pantasks/task.c
r9037 r10647 45 45 /* allowed tokens: command, host, stderr, periods, trange, nmax, task.exit, task.exec, end */ 46 46 47 ThisList = Nlists;47 ThisList = current_list_depth(); 48 48 while (1) { 49 49 -
trunk/Ohana/src/opihi/pantasks/task_macros.c
r7917 r10647 105 105 depth = 0; 106 106 done = FALSE; 107 ThisList = Nlists;107 ThisList = current_list_depth(); 108 108 while (!done) { 109 109 -
trunk/Ohana/src/opihi/pantasks/test/local.sh
r9471 r10647 41 41 list word -x "ps -p $PID -o rss" 42 42 $endmem = $word:1 43 echo growth: {$endmem - $startmem}43 # echo growth: {$endmem - $startmem} 44 44 end 45 45 -
trunk/Ohana/src/opihi/pcontrol/pcontrol.c
r9473 r10647 65 65 66 66 void gotsignal (int signum) { 67 gprint (GP_ERR, "got signal : %d\n", signum); 67 // this message is lost if we are connected to a pantasks 68 fprintf (stderr, "got signal : %d\n", signum); 68 69 return; 69 70 }
Note:
See TracChangeset
for help on using the changeset viewer.
