From 46db164377e0b6d8195bf430f3c17191be462787 Mon Sep 17 00:00:00 2001 From: paul-wu Date: Tue, 8 Mar 2016 02:15:35 -1000 Subject: [PATCH] fix the crash bug for expression y^x when y is not defined --- interpreter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/interpreter.cpp b/interpreter.cpp index 9d61ce3..597d450 100644 --- a/interpreter.cpp +++ b/interpreter.cpp @@ -516,6 +516,11 @@ void showcons(char * name) printf("Type: constant\n"); printf("Value: %lld\n",global_p); } + if(strcamp(name, "global_curve")){ + printf("Name: %s\n",name); + printf("Type: constant\n"); + printcurve(global_curve); + } } void statement(int header) @@ -566,7 +571,7 @@ void statement(int header) if(tokenlist[header]->type == 1 && strcamp(tokenlist[header]->vaule,"check")){ while(++header < tokenlen){ if(tokenlist[header]->type == 1){ - if(strcamp(tokenlist[header]->vaule,"global_p")){ + if(strcamp(tokenlist[header]->vaule,"global_p") || strcamp(tokenlist[header]->vaule,"global_curve")){ showcons(tokenlist[header]->vaule); return; } @@ -914,6 +919,8 @@ VALU * term(int * start) result = atom(start); + if(result == NULL)return result; + if(*start < tokenlen && checkchar(tokenlist[*start],'^')){ *start += 1; VALU * temp = atom(start);