Index: trunk/Ohana/src/opihi/dvo/dbRPN.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dbRPN.c	(revision 13479)
+++ trunk/Ohana/src/opihi/dvo/dbRPN.c	(revision 20936)
@@ -21,78 +21,74 @@
     
     /* decide on priority of object */
-    type = 0;
+    type = DB_STACK_NONE;
     /* unary operations */
-    if (!strcmp (argv[i], "abs"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "int"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "exp"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "ten"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "log"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "ln"))     { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "sqrt"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "erf"))    { type = 9; goto gotit; }
-
-    if (!strcmp (argv[i], "sinh"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "cosh"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "asinh"))  { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "acosh"))  { type = 9; goto gotit; }
-
-    if (!strcmp (argv[i], "sin"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "cos"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "tan"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "dsin"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "dcos"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "dtan"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "asin"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "acos"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "atan"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "dasin"))  { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "dacos"))  { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "datan"))  { type = 9; goto gotit; }
-
-    if (!strcmp (argv[i], "lgamma")) { type = 9; goto gotit; }
-
-    if (!strcmp (argv[i], "rnd"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "xramp"))  { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "yramp"))  { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "ramp"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "zero"))   { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "--"))     { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "not"))    { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "isinf"))  { type = 9; goto gotit; }
-    if (!strcmp (argv[i], "isnan"))  { type = 9; goto gotit; }
+    if (!strcmp (argv[i], "abs"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "int"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "exp"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "ten"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "log"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "ln"))     { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "sqrt"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "erf"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "sinh"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "cosh"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "asinh"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "acosh"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "sin"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "cos"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "tan"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "dsin"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "dcos"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "dtan"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "asin"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "acos"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "atan"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "dasin"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "dacos"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "datan"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "lgamma")) { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "rnd"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "xramp"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "yramp"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "ramp"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "zero"))   { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "--"))     { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "not"))    { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "isinf"))  { type = DB_STACK_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "isnan"))  { type = DB_STACK_UNARY; goto gotit; }
 
     /* binary operations */
-    if (!strcmp (argv[i], "^"))      { type = 8; goto gotit; }
-
-    if (!strcmp (argv[i], "@"))      { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "/"))      { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "*"))      { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "%"))      { type = 7; goto gotit; }
-
-    if (!strcmp (argv[i], "+"))      { type = 6; goto gotit; }
-    if (!strcmp (argv[i], "-"))      { type = 6; goto gotit; }
+    if (!strcmp (argv[i], "^"))      { type = DB_STACK_POWER; goto gotit; }
+
+    if (!strcmp (argv[i], "@"))      { type = DB_STACK_MULTIPLY; goto gotit; }
+    if (!strcmp (argv[i], "/"))      { type = DB_STACK_MULTIPLY; goto gotit; }
+    if (!strcmp (argv[i], "*"))      { type = DB_STACK_MULTIPLY; goto gotit; }
+    if (!strcmp (argv[i], "%"))      { type = DB_STACK_MULTIPLY; goto gotit; }
+
+    if (!strcmp (argv[i], "+"))      { type = DB_STACK_SUM; goto gotit; }
+    if (!strcmp (argv[i], "-"))      { type = DB_STACK_SUM; goto gotit; }
 	
-    if (!strcmp (argv[i], "&"))      { type = 5; goto gotit; }
-    if (!strcmp (argv[i], "|"))      { type = 5; goto gotit; }
-
-    if (!strcmp (argv[i], "<"))      { type = 4; goto gotit; }
-    if (!strcmp (argv[i], ">"))      { type = 4; goto gotit; }
-    if (!strcmp (argv[i], "=="))     { type = 4; strcpy (argv[i], "E"); goto gotit; }
-    if (!strcmp (argv[i], "!="))     { type = 4; strcpy (argv[i], "N"); goto gotit; }
-    if (!strcmp (argv[i], "<="))     { type = 4; strcpy (argv[i], "L"); goto gotit; }
-    if (!strcmp (argv[i], ">="))     { type = 4; strcpy (argv[i], "G"); goto gotit; }
-    if (!strcmp (argv[i], ">>"))     { type = 4; strcpy (argv[i], "U"); goto gotit; }
-    if (!strcmp (argv[i], "<<"))     { type = 4; strcpy (argv[i], "D"); goto gotit; }
-
-    if (!strcmp (argv[i], "&&"))     { type = 3; strcpy (argv[i], "A"); goto gotit; }
-    if (!strcmp (argv[i], "||"))     { type = 3; strcpy (argv[i], "O"); goto gotit; }
-
-    if (!strcmp (argv[i], "("))      { type = 2; goto gotit; }
-    if (!strcmp (argv[i], ")"))      { type = 1; goto gotit; }
+    if (!strcmp (argv[i], "&"))      { type = DB_STACK_BITWISE; goto gotit; }
+    if (!strcmp (argv[i], "|"))      { type = DB_STACK_BITWISE; goto gotit; }
+
+    if (!strcmp (argv[i], "<"))      { type = DB_STACK_COMPARE; goto gotit; }
+    if (!strcmp (argv[i], ">"))      { type = DB_STACK_COMPARE; goto gotit; }
+    if (!strcmp (argv[i], "=="))     { type = DB_STACK_COMPARE; strcpy (argv[i], "E"); goto gotit; }
+    if (!strcmp (argv[i], "!="))     { type = DB_STACK_COMPARE; strcpy (argv[i], "N"); goto gotit; }
+    if (!strcmp (argv[i], "<="))     { type = DB_STACK_COMPARE; strcpy (argv[i], "L"); goto gotit; }
+    if (!strcmp (argv[i], ">="))     { type = DB_STACK_COMPARE; strcpy (argv[i], "G"); goto gotit; }
+    if (!strcmp (argv[i], ">>"))     { type = DB_STACK_COMPARE; strcpy (argv[i], "U"); goto gotit; }
+    if (!strcmp (argv[i], "<<"))     { type = DB_STACK_COMPARE; strcpy (argv[i], "D"); goto gotit; }
+
+    if (!strcmp (argv[i], "&&"))     { type = DB_STACK_LOGIC; strcpy (argv[i], "A"); goto gotit; }
+    if (!strcmp (argv[i], "||"))     { type = DB_STACK_LOGIC; strcpy (argv[i], "O"); goto gotit; }
+
+    if (!strcmp (argv[i], "("))      { type = DB_STACK_OPEN_PAR; goto gotit; }
+    if (!strcmp (argv[i], ")"))      { type = DB_STACK_CLOSE_PAR; goto gotit; }
 
   gotit:
     /* choose how to deal with object */
     switch (type) {
-      case 8:  /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */
+      case DB_STACK_POWER:  /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */
 	/* pop previous, higher operators from OP stack to stack */
 	for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) {
@@ -107,10 +103,10 @@
 	Nop_stack ++;
 	break;
-      case 9: /* unary OPs */
-      case 7: /* binary OPs */
-      case 6:
-      case 5: 
-      case 4: 
-      case 3: 
+      case DB_STACK_UNARY: /* unary OPs */
+      case DB_STACK_MULTIPLY: /* binary OPs */
+      case DB_STACK_SUM:
+      case DB_STACK_BITWISE: 
+      case DB_STACK_COMPARE: 
+      case DB_STACK_LOGIC: 
 	/* pop previous, higher or equal operators from OP stack to stack */
 	for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type >= type); j--) {
@@ -125,5 +121,5 @@
 	Nop_stack ++;
 	break;
-      case 2:  
+      case DB_STACK_OPEN_PAR:  
 	/* push operator on OP stack */
 	op_stack[Nop_stack].name = strcreate (argv[i]);
@@ -131,7 +127,7 @@
 	Nop_stack ++;
 	break;
-      case 1: 
+      case DB_STACK_CLOSE_PAR: 
 	/* pop rest of operators from OP stack to stack, looking for '(' */
-	for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != 2); j--) {
+	for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != DB_STACK_OPEN_PAR); j--) {
 	  stack[Nstack] = op_stack[j];
 	  op_stack[j].name = NULL;
@@ -139,5 +135,5 @@
 	  Nop_stack --;
 	}
-	if ((j == -1) || (op_stack[j].type != 2)) {
+	if ((j == -1) || (op_stack[j].type != DB_STACK_OPEN_PAR)) {
 	  push_error ("syntax error: mismatched parenthesis");
 	  Nstack = 0;
@@ -150,5 +146,5 @@
 	/* value of 'X' is used as sentinel until we sort out values */
 	stack[Nstack].name = strcreate (argv[i]);
-	stack[Nstack].type = 'X';
+	stack[Nstack].type = DB_STACK_VALUE;
 	Nstack ++;
 	break;
@@ -156,7 +152,7 @@
   }
 
-  /* dump remaining operators on stack, checking for ')' */
+  /* dump remaining operators on stack, checking for '(' */
   for (j = Nop_stack - 1; j >= 0; j--) {
-    if (op_stack[j].type == 2) {
+    if (op_stack[j].type == DB_STACK_OPEN_PAR) {
       push_error ("syntax error: mismatched parenthesis");
       Nstack = 0;
