From f00d7c4b4c37c07baff686d2b5793fd7180ad2c8 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Thu, 16 Jan 2020 13:09:42 +0100
Subject: [PATCH] macro processor: fix bug where command line arguments that
 began with an integer were being treated as integers even if they weren't
 (e.g. dates)

---
 src/macro/Driver.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/macro/Driver.cc b/src/macro/Driver.cc
index e408cc27..2a46d81f 100644
--- a/src/macro/Driver.cc
+++ b/src/macro/Driver.cc
@@ -35,8 +35,12 @@ Driver::parse(const string &file_arg, const string &basename_arg, istream &modfi
       for (const auto & [var, val] : defines)
         try
           {
-            stoi(val);
-            command_line_defines_with_endl << "@#define " << var << " = " << val << endl;
+            string::size_type pos;
+            stod(val, &pos);
+            if (pos == val.size())
+              command_line_defines_with_endl << "@#define " << var << " = " << val << endl;
+            else
+              command_line_defines_with_endl << "@#define " << var << R"( = ")" << val << R"(")" << endl;
           }
         catch (const invalid_argument &)
           {
-- 
GitLab