]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Support true (1) and false (0).
authorToni Wilen <twilen@winuae.net>
Thu, 10 Sep 2015 15:43:35 +0000 (18:43 +0300)
committerToni Wilen <twilen@winuae.net>
Thu, 10 Sep 2015 15:43:35 +0000 (18:43 +0300)
calc.cpp

index c2c1acdec1edfa553746268cc2e8ee8b7078a159..da06292a157ead490d1b5d5ee2b1292a6ac9a9f2 100644 (file)
--- a/calc.cpp
+++ b/calc.cpp
@@ -385,6 +385,13 @@ static bool execution_order(const TCHAR *input, double *outval)
                return ok;
 }
 
+static bool is_separator(TCHAR c)
+{
+       if (is_operator(c))
+               return true;
+       return c == 0 || c == ')' || c == ' ';
+}
+
 static bool parse_values(const TCHAR *ins, TCHAR *out)
 {
        int ident = 0;
@@ -401,6 +408,18 @@ static bool parse_values(const TCHAR *ins, TCHAR *out)
        }
        while (*in) {
                TCHAR *instart = in;
+               if (!_tcsncmp(in, _T("true"), 4) && is_separator(in[4])) {
+                       in[0] = '1';
+                       in[1] = ' ';
+                       in[2] = ' ';
+                       in[3] = ' ';
+               } else if (!_tcsncmp(in, _T("false"), 5) && is_separator(in[5])) {
+                       in[0] = '0';
+                       in[1] = ' ';
+                       in[2] = ' ';
+                       in[3] = ' ';
+                       in[4] = ' ';
+               }
                if (_istdigit (*in)) {
                        if (ident >= MAX_VALUES)
                                return false;