IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 22, 2004, 1:23:23 PM (22 years ago)
Author:
eugene
Message:

fixing dvomath for strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r2598 r2792  
    2626      return (TRUE);
    2727    }
    28     fprintf (stderr, "syntax error!\n");
     28    push_error ("syntax error!");
    2929    free (tmp_stack.name);
    3030    return (FALSE);
     
    5454        return (FALSE);
    5555      }
     56
     57      /* this could be macro generated... */
     58      # define TWO_OP(A,B,FUNC) \
     59      if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \
     60        status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     61
     62      TWO_OP ("M","M",MM_binary);
     63      TWO_OP ("M","V",MV_binary);
     64      TWO_OP ("M","S",MS_binary);
     65      TWO_OP ("V","M",VM_binary);
     66      TWO_OP ("V","V",VV_binary);
     67      TWO_OP ("V","S",VS_binary);
     68      TWO_OP ("S","M",SM_binary);
     69      TWO_OP ("S","V",SV_binary);
     70      TWO_OP ("S","S",SS_binary);     
     71      TWO_OP ("W","W",WW_binary);     
     72     
     73      /*
    5674      if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "V", 1))
    5775        status = VV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     
    7290      if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "S", 1))
    7391        status = SS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     92      if (!strncasecmp (&stack[i - 2].type, "X", 1) && !strncasecmp (&stack[i - 1].type, "X", 1))
     93        status = XX_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     94      */
     95
     96      /* string op number is not valid */
     97      if (!strncasecmp (&stack[i - 2].type, "W", 1) && strncasecmp (&stack[i - 1].type, "W", 1)) {
     98        free (tmp_stack.name);
     99        return (FALSE);
     100      }
     101      if (strncasecmp (&stack[i - 2].type, "W", 1) && !strncasecmp (&stack[i - 1].type, "W", 1)) {
     102        free (tmp_stack.name);
     103        return (FALSE);
     104      }
     105
    74106      if (!status) {
    75107        free (tmp_stack.name);
     
    102134      if (!strncasecmp (&stack[i - 1].type, "S", 1))
    103135        S_unary (&tmp_stack, &stack[i - 1], stack[i].name);
     136
     137      /* there are no valid unary string operators */
     138      if (!strncasecmp (&stack[i - 1].type, "W", 1)) {
     139        fprintf (stderr, "syntax error\n");
     140        free (tmp_stack.name);
     141        return (FALSE);
     142      }
    104143
    105144      move_stack (&stack[i-1], &tmp_stack);
Note: See TracChangeset for help on using the changeset viewer.