changeset 3825:2fa6737082ae

Made ${?..:} (OP_EXISTS) work as reverse of as ${(empty)?..} (OP_IS_EMPTY), because that seems to be the only sensible way.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 20 Oct 2007 06:47:40 +0300
parents 9ecd41c7f348
children 53c5ec0aed0d
files src/audacious/tuple_compiler.c
diffstat 1 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/tuple_compiler.c	Sat Oct 20 06:37:38 2007 +0300
+++ b/src/audacious/tuple_compiler.c	Sat Oct 20 06:47:40 2007 +0300
@@ -652,14 +652,7 @@
             break;
         }
         break;
-      
-      case OP_EXISTS:
-        if (tf_get_fieldref(ctx->variables[curr->var[0]], tuple)) {
-          if (!tuple_formatter_eval_do(ctx, curr->children, tuple, res, resmax, reslen))
-            return FALSE;
-        }
-        break;
-      
+
       case OP_EQUALS:
       case OP_NOT_EQUALS:
       case OP_LT: case OP_LTEQ:
@@ -693,6 +686,15 @@
         }
         break;
       
+      case OP_EXISTS:
+#ifdef NO_EXISTS_HACK
+        if (tf_get_fieldref(ctx->variables[curr->var[0]], tuple)) {
+          if (!tuple_formatter_eval_do(ctx, curr->children, tuple, res, resmax, reslen))
+            return FALSE;
+        }
+        break;
+#endif
+
       case OP_IS_EMPTY:
         var0 = ctx->variables[curr->var[0]];
 
@@ -721,9 +723,16 @@
           }
         } else
           result = TRUE;
-        
+
+#ifdef NO_EXISTS_HACK        
         if (result && !tuple_formatter_eval_do(ctx, curr->children, tuple, res, resmax, reslen))
           return FALSE;
+#else
+        if ((curr->opcode == OP_EXISTS && !result) || (curr->opcode == OP_IS_EMPTY && result)) {
+          if (!tuple_formatter_eval_do(ctx, curr->children, tuple, res, resmax, reslen))
+            return FALSE;
+        }
+#endif
         break;
       
       default: