Changeset 42165 for branches/eam_branches/ipp-20220316
- Timestamp:
- Apr 8, 2022, 5:01:57 PM (4 years ago)
- Location:
- branches/eam_branches/ipp-20220316/Ohana/src/opihi
- Files:
-
- 5 edited
-
cmd.basic/run_while.c (modified) (2 diffs)
-
include/dvomath.h (modified) (1 diff)
-
lib.shell/evaluate_stack.c (modified) (1 diff)
-
lib.shell/expand_vectors.c (modified) (1 diff)
-
lib.shell/stack_math.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.basic/run_while.c
r31667 r42165 72 72 // test the logic once before running the loop 73 73 logic_line = strcreate (argv[1]); 74 logic_line = expand_vars (logic_line); 74 logic_line = expand_vars (logic_line); // recalculates scalar elements 75 logic_line = expand_vectors (logic_line); // recalculates vector/matrix elements (e.g., vec[]) 75 76 val = dvomath (1, &logic_line, &size, 0); 76 77 free (logic_line); … … 90 91 91 92 logic_line = strcreate (argv[1]); 92 logic_line = expand_vars (logic_line); 93 logic_line = expand_vars (logic_line); // recalculates scalar elements 94 logic_line = expand_vectors (logic_line); // recalculates vector/matrix elements (e.g., vec[]) 93 95 val = dvomath (1, &logic_line, &size, 0); 94 96 free (logic_line); -
branches/eam_branches/ipp-20220316/Ohana/src/opihi/include/dvomath.h
r42083 r42165 125 125 int M_unary PROTO((StackVar *OUT, StackVar *V1, char *op)); 126 126 int W_unary PROTO((StackVar *OUT, StackVar *V1, char *op)); 127 int L_unary PROTO((StackVar *OUT, StackVar *V1, char *op)); 127 128 128 129 /* variable handling */ -
branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/evaluate_stack.c
r42080 r42165 67 67 if (stack[0].type == ST_VECTOR) { 68 68 /* need to make a copy so we set output value? */ 69 V_unary (&tmp_stack, &stack[0], "="); 69 if (stack->vector->type == OPIHI_STR) { 70 L_unary (&tmp_stack, &stack[0], "="); 71 } else { 72 V_unary (&tmp_stack, &stack[0], "="); 73 } 70 74 move_stack (&stack[0], &tmp_stack); 71 75 return (TRUE); -
branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/expand_vectors.c
r42080 r42165 28 28 ALLOCATE (newline, char, NLINE); 29 29 30 // special case: don't expand vectors in while () statement 31 char *V0 = thiscomm (line); 32 if (V0 && !strncmp ("while", V0, strlen(V0))) { 33 strcpy (newline, line); 34 free (line); 35 return (newline); 36 } 37 free (V0); 38 30 39 /* look for form fred[stuff] */ 31 /* skip first word (command) */ 32 L = nextword (line); 40 if (*line == '(') { 41 // if line is "(stuff)" then do not skip first word 42 L = line; 43 } else { 44 /* skip first word (command) */ 45 L = nextword (line); 46 } 33 47 if (L == NULL) { 34 48 free (newline); -
branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/stack_math.c
r42080 r42165 1706 1706 char line[512]; // this is only used to report an error 1707 1707 snprintf (line, 512, "error: op %s not defined as unary vector op!", op); 1708 push_error (line); 1709 return (FALSE); 1710 1711 escape: 1712 1713 if (V1[0].type == ST_VECTOR_TMP) { 1714 free (V1[0].vector[0].elements.Ptr); 1715 free (V1[0].vector); 1716 V1[0].vector = NULL; 1717 } 1718 1719 clear_stack (V1); 1720 return (TRUE); 1721 1722 } 1723 1724 // vector string operations 1725 int L_unary (StackVar *OUT, StackVar *V1, char *op) { 1726 1727 int Nx = V1[0].vector[0].Nelements; 1728 1729 OUT[0].vector = InitVector (); 1730 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 1731 1732 ResetVector (OUT[0].vector, OPIHI_STR, V1[0].vector[0].Nelements); 1733 char **Iv = V1[0].vector[0].elements.Str; 1734 char **Ov = OUT[0].vector[0].elements.Str; 1735 if (!strcmp (op, "=")) { 1736 for (int i = 0; i < Nx; i++) { 1737 Ov[i] = strcreate (Iv[i]); 1738 } 1739 goto escape; 1740 } 1741 1742 // free the temp vector if needed 1743 if (V1[0].type == ST_VECTOR_TMP) { 1744 // XXX this probably does not free the strings 1745 free (V1[0].vector[0].elements.Ptr); 1746 free (V1[0].vector); 1747 V1[0].vector = NULL; 1748 } 1749 1750 clear_stack (V1); 1751 1752 char line[512]; // this is only used to report an error 1753 snprintf (line, 512, "error: op %s not defined as unary string vector op!", op); 1708 1754 push_error (line); 1709 1755 return (FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.
