X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=calc.c;h=bd816b982b0a7a2d2c58ea659e858628f54360b4;hb=e2a309f921968691af1566000dd694f191eca857;hp=cd5defb646aaf2c99ff7ff6fc323857219d03612;hpb=a41b348e4d97a6edd5420041f8b093fa585b5867;p=calc.git diff --git a/calc.c b/calc.c index cd5defb..bd816b9 100644 --- a/calc.c +++ b/calc.c @@ -1,6 +1,6 @@ /* depend: */ /* cflags: */ -/* linker: alloc.o argument.o debug.o element.o format.o parser.o program.o stack.o storage.o tabular.o workspace.o -lm -lreadline */ +/* linker: alloc.o argument.o color.o debug.o element.o format.o parser.o program.o stack.o storage.o tabular.o workspace.o -lm -lreadline */ #include #include @@ -130,7 +130,7 @@ int main (int argc, char *argv[]) VERBOSE (ERROR, fprintf (stderr, "%s: missing output prompt\n", progname); usage (1)); return 1; } - oprompt = arg; + set_prompt (oprompt = arg); break; case 'p': arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL; @@ -138,7 +138,7 @@ int main (int argc, char *argv[]) VERBOSE (ERROR, fprintf (stderr, "%s: missing precision\n", progname); usage (1)); return 1; } - precision = atoi (arg); + set_precision (precision = atoi (arg)); break; case 'v': arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL; @@ -155,7 +155,7 @@ int main (int argc, char *argv[]) } /* set format */ - set_format (oprompt, precision); + set_format (); /* completion list*/ completion_list = generate_completion_list (); @@ -404,6 +404,12 @@ int main (int argc, char *argv[]) // test: echo -e 'set (1, 2, -5, 6, -8, 9, -2, 23, 4)\nmin (5, -3)\nmax (-1)\nmin\nmean\nmed\nmax\nord\nprod\nsum\nvar\nquit' | calc.exe -n -v 3 | grep -q bye // test: echo -e 'min\nmean\nmed\nmax\nprod\nsum\nvar\nord\nset (1)\nord' | calc.exe -n | grep -c error | xargs test 9 = // test: echo -e 'prog (1, cos(pi * arg (1))) / 4' | calc.exe | grep -c error | xargs test 1 = +// test: echo -e 'format\n.12345678901' | calc.exe | grep -n '=> 6' +// test: echo -e 'format (8)\n.12345678901' | calc.exe | grep -n '=> 0.12345679' +// test: echo -e 'format (12)\n.12345678901' | calc.exe | grep -n '=> 0.12345678901' +// test: echo -e 'format (4)\n.12345678901\format' | calc.exe | grep -n '=> 4' +// test: echo -e 'format (0)' | calc.exe | grep -n 'error' + // Gauss sequence // test: echo -e '{sto (1, 0), sto (10, 0), while (inc (10) <= 100, {sto (1, rcl (1) + rcl (10)), print (rcl (1))})};' | calc.exe | grep -q '=> 5050'