Merge branch 'master' of https://secure.softndesign.org/git/calc
authorLaurent Mazet <mazet@softndesign.org>
Mon, 6 Mar 2023 20:54:42 +0000 (21:54 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Mon, 6 Mar 2023 20:54:42 +0000 (21:54 +0100)
calc.c
color.c
format.c
format.h

diff --git a/calc.c b/calc.c
index e351369c9d817dd550e9cdc8acdd901a31ebfa88..5014f3ef8e4c5342ce0eb278dc0b9be66a169e8a 100644 (file)
--- 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 2af7572896fbb2e3831bae5b51a5ca8a81cfb1f3..7aec785873cf1f28f7a0b03230b524dcb4f22137 100644 (file)
--- 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 */
index 77e3a18b3bfce0a8202a1d179b51c0aa042363da..60cb1d477e6055281b578070daf7cae63bfc75d0 100644 (file)
--- 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;
 }
index b18b92d728e8ccb99d9e18a684fcd452ab9ade02..3a376a0f58dc067e5758d360a58cce03fcb14f4b 100644 (file)
--- 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 ();