IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3318


Ignore:
Timestamp:
Feb 24, 2005, 3:44:00 PM (21 years ago)
Author:
eugene
Message:

allow quoted strings in math

Location:
trunk/Ohana/src/opihi/lib.shell
Files:
3 edited

Legend:

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

    r2843 r3318  
    7272      TWO_OP ("S","S",SS_binary);     
    7373      TWO_OP ("W","W",WW_binary);     
     74      TWO_OP ("W","S",WW_binary);     
     75      TWO_OP ("S","W",WW_binary);     
    7476     
    7577      /*
     
    9698      */
    9799
    98       /* string op number is not valid */
     100      /* string op number is not valid
    99101      if (!strncasecmp (&stack[i - 2].type, "W", 1) && strncasecmp (&stack[i - 1].type, "W", 1)) {
    100102        free (tmp_stack.name);
     
    104106        free (tmp_stack.name);
    105107        return (FALSE);
    106       }
     108      } */
    107109
    108110      if (!status) {
  • trunk/Ohana/src/opihi/lib.shell/isolate_elements.c

    r3029 r3318  
    8989      /* operators */
    9090      if (negate || minus || posate || plus || (IsAnOp (&in[i][j]) && !SciNotation)) {
    91         if (posate) goto skip3;
     91        if (posate) continue;
    9292        EndOfString ();
    9393        /* copy operator to out[Nout] */
     
    100100        }
    101101        EndOfString ();
     102        continue;
     103      }
     104      /* quoted string */
     105      if (in[i][j] == '"') {
     106        InsertValue (in[i][j]);
     107        j++;
     108        while ((j < strlen(in[i])) && (in[i][j] != '"')) {
     109          InsertValue (in[i][j]);
     110          j++;
     111        }
     112        if (in[i][j] != '"') continue;
     113        /*
     114          fprintf (stderr, "mismatched quotes\n");
     115          return (FALSE);
     116        }
     117        */
     118        InsertValue (in[i][j]);
     119        EndOfString ();
     120        continue;
     121      }
     122      /* not an operator, not a quoted string */
     123      if (!whitespace (in[i][j])) {
     124        InsertValue (in[i][j]);
    102125      } else {
    103         if (!whitespace (in[i][j])) {
    104           InsertValue (in[i][j]);
    105         } else {
    106           EndOfString ();
    107         }
    108       }
    109     skip3:
    110       continue;
     126        EndOfString ();
     127      }
    111128    }
    112129    EndOfString ();
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r3029 r3318  
    11161116  char line[512];
    11171117
     1118  /* evaluate stack will only call WW_binary with one numerical value,
     1119     and only in the case that the string did not parse to a number
     1120     thus: string == number -> false */
     1121  if (!strncasecmp (&V1[0].type, "S", 1)) {
     1122    value = (op[0] == 'N');
     1123    goto escape;
     1124  }
     1125  if (!strncasecmp (&V2[0].type, "S", 1)) {
     1126    value = (op[0] == 'N');
     1127    goto escape;
     1128  }
     1129
    11181130  switch (op[0]) {
    11191131  case 'E':
     
    11241136    break;
    11251137  default:
    1126     sprintf (line, "error: op %c not defined!", op[0]);
     1138    sprintf (line, "error: op %c not defined for string operations!", op[0]);
    11271139    push_error (line);
    11281140    return (FALSE);
    11291141  }
    11301142
     1143escape:
    11311144  strcpy (OUT[0].name, "tmp");
    11321145  OUT[0].Float = value;
Note: See TracChangeset for help on using the changeset viewer.