From 148aa9d9249577e72213e8856d7d5e97fcf75db3 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 29 Jan 2020 14:52:01 +0100 Subject: [PATCH] macro processor: simplify handling of `@#define` --- src/macro/Driver.cc | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/macro/Driver.cc b/src/macro/Driver.cc index 9ab8d6e2..f54ff3c1 100644 --- a/src/macro/Driver.cc +++ b/src/macro/Driver.cc @@ -34,30 +34,7 @@ Driver::parse(const string &file_arg, const string &basename_arg, istream &modfi { stringstream command_line_defines_with_endl; for (const auto & [var, val] : defines) - try - { - string::size_type pos; - stod(val, &pos); - if (pos == val.size()) - command_line_defines_with_endl << "@#define " << var << " = " << val << endl; - else - { - // The following regex matches the range syntax: double:double(:double)? - regex colon_separated_doubles(R"(((((\d*\.\d+)|(\d+\.))([ed][-+]?\d+)?)|(\d+([ed][-+]?\d+)?)):((((\d*\.\d+)|(\d+\.))([ed][-+]?\d+)?)|(\d+([ed][-+]?\d+)?))(:((((\d*\.\d+)|(\d+\.))([ed][-+]?\d+)?)|(\d+([ed][-+]?\d+)?)))?)"); - if (regex_match(val, colon_separated_doubles)) - 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 &) - { - if (!val.empty() && val.at(0) == '[' && val.at(val.length()-1) == ']') - // If the input is an array. Issue #1578 - command_line_defines_with_endl << "@#define " << var << " = " << val << endl; - else - command_line_defines_with_endl << "@#define " << var << R"( = ")" << val << R"(")" << endl; - } + command_line_defines_with_endl << "@#define " << var << " = " << val << endl; Driver m(env, true); istream is(command_line_defines_with_endl.rdbuf()); m.parse("command_line_defines", "command_line_defines", is, output, debug, vector>{}, paths);