From: Laurent Mazet Date: Mon, 6 Mar 2023 20:54:42 +0000 (+0100) Subject: Merge branch 'master' of https://secure.softndesign.org/git/calc X-Git-Tag: v1.2~2 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=84ce2fab59a4b70efcce5abb1045005288816c15;hp=8fbd465183a1657cc20a75caa4c2f00010f38c2d;p=calc.git Merge branch 'master' of https://secure.softndesign.org/git/calc --- diff --git a/calc.c b/calc.c index e351369..5014f3e 100644 --- a/calc.c +++ b/calc.c @@ -240,6 +240,7 @@ int main (int argc, char *argv[]) // 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 -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 "1 - 2" | calc.exe | grep -q '=> -1' // test: echo "2 * 3" | calc.exe | grep -q '=> 6' @@ -366,8 +367,8 @@ int main (int argc, char *argv[]) // test: echo -e 'clr\nsto (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\nquit' | calc.exe -v 3 | grep -q Clear // test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (1, {cos (arg (1)^2)})\ncall (1, pi/6)\nprog (2, {arg (1) * 3})\ncall (2, 1, 2)\nls' | calc.exe | grep -q 'programs: 2 1' -// test: echo -e 'prog (1, {arg (2) - arg (1)})\ncall (1, 2, 3)\nls\nedit (1)\nprog (1, {arg (2) + arg (1)})\nedit (1)\ndel (1)\nquit' | calc.exe -v 3 | grep -q bye -// test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (3, cos(arg (1) * pi / 3))\ncall (1, 2, 3)\ncall (2, 1)\nls\nedit (1)\ndel (1)\ndel (3)\ndel (2)\ncall (2, 1, 4)' | calc.exe | grep -c error | xargs test 5 = +// test: echo -e 'prog (1, {arg (2) - arg (1)})\ncall (1, 2, 3)\nls\nedit (1)\n\nprog (1, {arg (2) + arg (1)})\nedit (1)\n\ndel (1)\nquit' | calc.exe -v 3 | grep -q bye +// test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (3, cos(arg (1) * pi / 3))\ncall (1, 2, 3)\ncall (2, 1)\nls\nedit (1)\n\ndel (1)\ndel (3)\ndel (2)\ncall (2, 1, 4)' | calc.exe | grep -c error | xargs test 5 = // test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (3, cos(arg (1) * pi / 3))\ndel (2)\ndel (3)\nls' | calc.exe | grep -q '^programs:$' // test: echo -e 'erf (1)\nerfc (1)\nquit' | calc.exe -v 3 | grep -q bye // test: echo -e 'erf ()\nerfc ()' | calc.exe | grep -c error | xargs test 2 = @@ -398,6 +399,7 @@ int main (int argc, char *argv[]) // test: echo -e '255' | calc.exe -b 10,16 | grep -q '=> ff' // test: echo -e 'base (-2)\nbase (16, 0)' | calc.exe | grep -c error | xargs test 2 = // test: echo -e 'base (10, 16)\n255' | calc.exe | grep -q '=> ff' +// test: echo -e 'base (10, 16)\nsto (2, 255)\ndisp' | calc.exe | grep -q 'storage: 0 ff 0 0 0 0 0 0 0 0' // test: echo -e 'base' | calc.exe | grep -q 'base (I/O): 10/10' // test: echo -e 'deg\nacos (-1)\ngrad\nacos (-1)\nrad\nacos (-1)' | calc.exe | awk 'BEGIN { split("180 200 3.14159", v) } /=>/ { for (i in v) if ($2 == v[i]) n++ } END { exit n != 3 }' // test: echo -e 'format\nbase\ndeg\ngrad\nrad\nquit' | calc.exe -v 3 | grep -q bye diff --git a/color.c b/color.c index 2af7572..7aec785 100644 --- a/color.c +++ b/color.c @@ -16,7 +16,7 @@ void color_set (FILE *fid, color_e color) if (init == 0) { CONSOLE_SCREEN_BUFFER_INFO info; GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info); - init = info.attr; + init = info.wAttributes; } /* default attribute */ diff --git a/format.c b/format.c index 77e3a18..60cb1d4 100644 --- a/format.c +++ b/format.c @@ -76,11 +76,6 @@ void set_base (int in, int out) _obase = out; } -int is_input_decimal () -{ - return (_ibase == 10); -} - char *show_base () { static char str[16] = {0}; @@ -93,7 +88,9 @@ int get_ibase () return _ibase; } -char *itoa (unsigned long value) +/* multi base integer to ascii function */ + +char *mbitoa (unsigned long value) { static char str[8 * sizeof (long) + 1]; @@ -121,7 +118,7 @@ double print (double value) if (_obase == 10) { printf (_format ? _format : DEFAULT_FORMAT, value); } else { - printf ("%s%s\n", (_prompt) ? _prompt : DEFAULT_PROMPT, itoa ((unsigned int)value)); + printf ("%s%s\n", (_prompt) ? _prompt : DEFAULT_PROMPT, mbitoa ((unsigned int)value)); } return value; } @@ -131,7 +128,7 @@ double printl (double value) if (_obase == 10) { printf (_minform ? _minform : DEFAULT_MINFORM, value); } else { - printf ("%s%s", (_prompt) ? _prompt : DEFAULT_PROMPT, itoa ((unsigned int)value)); + printf ("%s", mbitoa ((unsigned int)value)); } return value; } diff --git a/format.h b/format.h index b18b92d..3a376a0 100644 --- a/format.h +++ b/format.h @@ -13,7 +13,6 @@ void set_format (); void free_format (); void set_base (int in, int out); -int is_input_decimal (); char *show_base (); int get_ibase ();