Merge branch 'master' of https://secure.softndesign.org/git/calc v1.1
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Tue, 21 Feb 2023 09:31:36 +0000 (10:31 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Tue, 21 Feb 2023 09:31:36 +0000 (10:31 +0100)
calc.c
storage.c

diff --git a/calc.c b/calc.c
index 08ff10c14308c34769a49fb69af5111c367033a9..cd5defb646aaf2c99ff7ff6fc323857219d03612 100644 (file)
--- a/calc.c
+++ b/calc.c
@@ -373,6 +373,7 @@ int main (int argc, char *argv[])
 // test: echo -e '\t\t' | calc.exe | grep -q 'print'
 // test: echo -e '1 + 1;\nans + 1' | calc.exe | grep -qv 2
 // test: echo -e 'mem\nmem (3)\nsto (4, pi)' | calc.exe | grep -q "error out of bound"
+// test: echo -e 'mem (-1)' | calc.exe | grep -q "error"
 // test: echo -e 'sto (2, 3)\nmem (2)\ndisp' | calc.exe | grep -q 'storage: 0 3$'
 // test: echo -e 'disp' | calc.exe | grep -q "storage: 0 0 0 0 0 0 0 0 0 0"
 // test: echo -e 'sto (3, 10)\ndisp' | calc.exe | grep -q "storage: 0 0 10 0 0 0 0 0 0 0"
index 4a559f27433086ceda169ce7f734afffd8450157..54815e2d98e69c299e208920ad4350128ce3b03c 100644 (file)
--- a/storage.c
+++ b/storage.c
@@ -21,7 +21,7 @@ int memory (int nb)
     if ((nb != -1) && (nb != size_tab (storage))) {
         storage = resize_tab (storage, nb);
     }
-    if (size_tab (storage) == -1) {
+    if (nb == -1) {
         memory (DEFAULT_STORAGE_SIZE);
     }
     return size_tab (storage);