From ed61bfca3e42461ae61ccd4cb4c8ed5e3fc34d00 Mon Sep 17 00:00:00 2001
From: JWu <j.wuttke@fz-juelich.de>
Date: Mon, 4 Mar 2013 10:10:47 +0100
Subject: [PATCH] bug fixed: now p0[1,2,3] raises error

---
 TODO             |  2 --
 pub/src/node.cpp | 14 ++++++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/TODO b/TODO
index 8df0ff44..9a2a30f0 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 == BUGS ==
 
-p1[k,0,0] should raise error
-
 expr.cpp: get_k, get_j should allow i dependence
   <= needs major modif in node.cpp
 
diff --git a/pub/src/node.cpp b/pub/src/node.cpp
index 67599774..6e1b7fa3 100644
--- a/pub/src/node.cpp
+++ b/pub/src/node.cpp
@@ -274,12 +274,12 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const
 
     // Return k-j-dependent reference (unless done above):
     if        ( var->typ == CVar::_J ) {
-        if ( ctx.i!=(uint)-1 )
+        if ( ref->ti )
             throw "J does not require 3 indices";
         ret.set_r( ctx.j );
         return;
     } else if ( var->typ == CVar::_Z ) {
-        if ( ctx.i!=(uint)-1 )
+        if ( ref->ti )
             throw "Z does not require 3 indices";
         if ( var->num>= f->nZ() )
             throw "invalid reference " + var->var_info();
@@ -377,13 +377,13 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const
     if ( fc ) {
         PCurve cj = fc->VC(j);
         if       ( var->typ == CVar::_CP ) {
-            if ( ctx.i!=(uint)-1 )
+            if ( ref->ti )
                 throw "P does not require 3 indices";
             if ( var->num>= fc->nP )
                 throw "invalid p ref(" + var->var_info() + ") in curve file";
             ret.set_r( cj->P[var->num] );
         } else if ( var->typ == CVar::_CQ ) {
-            if ( ctx.i!=(uint)-1 )
+            if ( ref->ti )
                 throw "Q does not require 3 indices";
             if ( var->num >= CCurve::mQuality )
                 throw "invalid fm ref(" + var->var_info() + ") in curve file";
@@ -442,8 +442,7 @@ void CNodeIva::set_coord( CCoord& ret, uint k_in ) const
             else if  ( var->typ == CVar::_NI )
                 ret = CCoord("#points", "");
             else
-                throw "reference " + var->var_info() +
-                    " not allowed in data file";
+                throw "data file has no " + var->var_info();
         } else if ( fc ) {
             if     ( var->typ == CVar::_CP ) {
                 if( var->num>=fc->nP )
@@ -454,8 +453,7 @@ void CNodeIva::set_coord( CCoord& ret, uint k_in ) const
             else if ( var->typ == CVar::_C )
                 ret = CCoord(fc->expr,"");
             else
-                throw "reference " + var->var_info() +
-                    " not allowed in curve file";
+                throw "curve file has no " + var->var_info();
         } else
             throw "BUG: ref->set_coord unexpected else";
     }
-- 
GitLab