diff --git a/ChangeLog b/ChangeLog index b147ddfdf..01a4ee2aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -203,6 +203,8 @@ to Matt Kraai). + Fixed bug #831, which prevented some date fields from being properly parsed. + Fixed bug #835, which prevented hierarchical projects from being recognized. + + Fixed bug #836, which preserves numeric arguments as-is (thanks to Matt Kraai + for the patch). + Fixed bug #839, which caused problems when recurrence frequencies of '1m' were used. This is an obsolete form, and should now be '1mo' (thanks to Gour D). diff --git a/src/A3.cpp b/src/A3.cpp index 0840f324c..3cb4c67b5 100644 --- a/src/A3.cpp +++ b/src/A3.cpp @@ -686,7 +686,6 @@ const A3 A3::tokenize (const A3& input) const std::string s; int i; - double d; time_t t; while (! n.depleted ()) { @@ -815,9 +814,9 @@ const A3 A3::tokenize (const A3& input) const } } - else if (is_number (n, d)) + else if (is_number (n, s)) { - output.push_back (Arg (format (d), Arg::type_number, Arg::cat_literal)); + output.push_back (Arg (s, Arg::type_number, Arg::cat_literal)); if (found_sequence) found_something_after_sequence = true; } @@ -1699,10 +1698,10 @@ bool A3::is_tag (Nibbler& n, std::string& result) // followed by either: \0, ), +, -, *, /, ' '. // // This prevents the interpretation of '3M' as a number. -bool A3::is_number (Nibbler& n, double& d) +bool A3::is_number (Nibbler& n, std::string& result) { n.save (); - if (n.getNumber (d)) + if (n.getNumber (result)) { char next = n.next (); if (next == '\0' || diff --git a/src/A3.h b/src/A3.h index 516bf4c2f..a90b144fa 100644 --- a/src/A3.h +++ b/src/A3.h @@ -87,7 +87,7 @@ public: static bool is_id (Nibbler&, std::string&); static bool is_uuid (Nibbler&, std::string&); static bool is_tag (Nibbler&, std::string&); - static bool is_number (Nibbler&, double&); + static bool is_number (Nibbler&, std::string&); static bool is_integer (Nibbler&, int&); static bool is_operator (std::vector &, Nibbler&, std::string&); diff --git a/src/Nibbler.cpp b/src/Nibbler.cpp index 00c9833a5..a30f6efed 100644 --- a/src/Nibbler.cpp +++ b/src/Nibbler.cpp @@ -377,7 +377,7 @@ bool Nibbler::getUnsignedInt (int& result) // e: // e|E (+|-)? // -bool Nibbler::getNumber (double& result) +bool Nibbler::getNumber (std::string& result) { std::string::size_type i = _cursor; @@ -417,7 +417,7 @@ bool Nibbler::getNumber (double& result) while (i < _length && isdigit (_input[i])) ++i; - result = strtof (_input.substr (_cursor, i - _cursor).c_str (), NULL); + result = _input.substr (_cursor, i - _cursor); _cursor = i; return true; } @@ -425,7 +425,7 @@ bool Nibbler::getNumber (double& result) return false; } - result = strtof (_input.substr (_cursor, i - _cursor).c_str (), NULL); + result = _input.substr (_cursor, i - _cursor); _cursor = i; return true; } @@ -433,6 +433,20 @@ bool Nibbler::getNumber (double& result) return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Nibbler::getNumber (double &result) +{ + bool isnumber; + std::string s; + + isnumber = getNumber (s); + if (isnumber) + { + result = strtof (s.c_str (), NULL); + } + return isnumber; +} + //////////////////////////////////////////////////////////////////////////////// // number: // int frac? exp? diff --git a/src/Nibbler.h b/src/Nibbler.h index 5bef16fde..1919d653c 100644 --- a/src/Nibbler.h +++ b/src/Nibbler.h @@ -60,6 +60,7 @@ public: bool getInt (int&); bool getHex (int&); bool getUnsignedInt (int&); + bool getNumber (std::string&); bool getNumber (double&); bool getUnsignedNumber (double&); bool getLiteral (const std::string&);