From a072ee2b846a02d68c25f24a30b0dbe241b2b806 Mon Sep 17 00:00:00 2001 From: Plankp Date: Sat, 28 Nov 2015 20:51:37 -0500 Subject: [PATCH] Fixed calculator bugs with + and / --- kernel/apps/calc.c | 3 ++- kernel/apps/calc.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/apps/calc.c b/kernel/apps/calc.c index cba3907..41242cd 100644 --- a/kernel/apps/calc.c +++ b/kernel/apps/calc.c @@ -79,6 +79,7 @@ void calc(string args) print("\nUse calc -h for help\n> ", 0x0F); readStr(calcInput, CALCSIZE); + strcat(calcInput, "+0"); // Unary related hack! do not delete for(int i = 0; i < CALCSIZE; i++) { @@ -87,7 +88,7 @@ void calc(string args) else { int pInput = ctoi(calcInput[i]); - if (pInput != -1) + if ((pInput != -1) && (pInput != 62) && (pInput != 63)) tempNum = concat(tempNum, pInput); else { // Properly check for math operator diff --git a/kernel/apps/calc.h b/kernel/apps/calc.h index 7f3671e..4b674fb 100644 --- a/kernel/apps/calc.h +++ b/kernel/apps/calc.h @@ -13,7 +13,7 @@ #endif // math storage variables -char calcInput[CALCSIZE]; +char calcInput[CALCSIZE + 2]; // For `+0` int mathOp[CALCSIZE]; int tempNum; double strNum[CALCSIZE];