fprintf (fid, "usage: %s\n", progname);
fprintf (fid, " -h : help message\n");
fprintf (fid, " -b : in/out-put base (%s)\n", show_base ());
+ fprintf (fid, " -i : input prompt (%s)\n", oprompt);
fprintf (fid, " -n : no readline mode (%s)\n", mode ? "yes" : "no");
fprintf (fid, " -n : no readline mode (%s)\n", mode ? "yes" : "no");
fprintf (fid, " -o : output prompt (%s)\n", oprompt);
if (mode) {
free (buffer);
+ buffer = NULL;
} else {
memset (buffer, 0, BUFFER_SIZE);
}
fflush (stdout);
}
- clean_read_line (buffer);
+ if (mode) {
+ clean_read_line (buffer);
+ }
free_format ();
// test: calc.exe -p 2>&1 | grep -q 'missing precision'
// test: calc.exe -v 2>&1 | grep -q 'missing verbose'
// test: echo "1 + 1" | calc.exe -i '# ' | grep -q '# 1 + 1'
+// test: echo "1 + 1" | calc.exe -i '# ' -i 'x ' | grep -q 'x 1 + 1'
// test: echo "1 + 1" | calc.exe -o '# ' | grep -q '# 2'
// test: echo "1 + 1" | calc.exe -o '# ' -o 'x ' | grep -q 'x 2'
// test: echo "1 + 2" | calc.exe | grep -q '=> 3'
// test: echo -e 'set (0, -1)\nset (1, 2, 3, 3.11, pi, 4)\nlen' | calc.exe | grep -q '=> 6'
// test: echo -e 'set (1, 2)\npop\npush (3)\nput (5, -1)\nlen\nshow\nget (3)\nquit' | calc.exe -n -v 3 | grep -q bye
// test: echo -e 'put\nget\nget (1)\npop\nput (0)' | calc.exe | grep -c 'error' | xargs test 5 =
-// test: echo -e 'push (2)' | calc.exe | grep -q '=> 2'
+// test: echo -e 'push (1)\npush (2)' | calc.exe | grep -q '=> 2'
// test: echo -e 'prog (1, {set (1, 2), push (arg (1)), show})\ncall (1, 10)\nprog (1, {mem (1), sto (1, cos (arg (1)))})\ncall (1, pi / 2)\ndel (1)' | calc.exe -n | grep -q 'stack: 1 2 10'
// test: echo -e 'prog (1, {set (1, 2), push (arg (1)), show});\ncall (1, 10);\nshow\ndel (1)' | calc.exe -n | grep -q 'stack:$'
// test: echo -e 'prog (1, {set (1, 2), push (arg (1)), show});\ncall (1, 10);\nlen' | calc.exe -n | grep -q '=> 0'