changeset 4032:0f2bb0baf6f0 libavcodec

fix -a^b which was interpreted as (-a)^b
author michael
date Mon, 16 Oct 2006 19:06:56 +0000
parents edda4c177c59
children f7a6b2bb3a2f
files eval.c
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/eval.c	Mon Oct 16 18:36:44 2006 +0000
+++ b/eval.c	Mon Oct 16 19:06:56 2006 +0000
@@ -209,19 +209,22 @@
     return d;
 }
 
-static double evalPow(Parser *p){
-    int sign= (*p->s == '+') - (*p->s == '-');
-    p->s += sign&1;
-    return (sign|1) * evalPrimary(p);
+static double evalPow(Parser *p, int *sign){
+    *sign= (*p->s == '+') - (*p->s == '-');
+    p->s += *sign&1;
+    return evalPrimary(p);
 }
 
 static double evalFactor(Parser *p){
-    double ret= evalPow(p);
+    int sign, sign2;
+    double ret, e;
+    ret= evalPow(p, &sign);
     while(p->s[0]=='^'){
         p->s++;
-        ret= pow(ret, evalPow(p));
+        e= evalPow(p, &sign2);
+        ret= pow(ret, (sign2|1) * e);
     }
-    return ret;
+    return (sign|1) * ret;
 }
 
 static double evalTerm(Parser *p){