From 1b0682162a9aa896cca869ee16f85ae678d953a3 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Wed, 1 Feb 2023 10:23:05 +0100 Subject: [PATCH] remove unnecessary code --- calc.c | 2 +- parser.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/calc.c b/calc.c index b0356c8..869372f 100644 --- a/calc.c +++ b/calc.c @@ -377,7 +377,7 @@ int main (int argc, char *argv[]) // test: echo -e 'sto (3, pi)\nclr\ndisp' | calc.exe | grep -q "storage: 0 0 0 0 0 0 0 0 0 0" // test: echo -e 'mem (3)\nclr' | calc.exe -v 3 | grep -q Clear // test: echo -e 'prog (2, 2, {rcl (2) - rcl (1)})\nprog (1, 1, {cos (rcl (1)^2)})\ncall (1, pi/6)\nprog (2, 1, {rcl (1) * 3})\ncall (2, 1, 2)\nls' | calc.exe -// test: echo -e 'prog (1, 2, {rcl (2) - rcl (1)})\ncall (1, 2, 3)\nls\nedit (1)\ndel (1)' | calc.exe -v 3 |grep -q Program +// test: echo -e 'prog (1, 2, {rcl (2) - rcl (1)})\ncall (1, 2, 3)\nls\nedit (1)\nprog (1, 2, {rcl (2) + rcl (1)})\nedit (1)\ndel (1)' | calc.exe -v 3 |grep -q Program // test: echo -e 'prog (2, 2, {rcl (2) - rcl (1)})\nprog (3, 1, cos(rcl (1) * pi / 3))\ncall (1, 2, 3)\nls\nedit (1)\ndel (1)\n\ndel (2)\ncall (2, 1, 4)' | calc.exe | grep -c error | xargs test 4 = // Gauss sequence diff --git a/parser.c b/parser.c index 714ea87..ed39dd7 100644 --- a/parser.c +++ b/parser.c @@ -896,15 +896,16 @@ void savestring (int id, char *string) } } } - if (n == -1) { - VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id)); - return; - } - /* save program */ - if ((programs + n)->string) { - free ((programs + n)->string); - } + /* unnecesary code */ + //if (n == -1) { + // VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id)); + // return; + //} + //if ((programs + n)->string) { + // free ((programs + n)->string); + //} + (programs + n)->string = strdup (string); } -- 2.30.2