Signed-off-by: Paul Beckingham <paul@beckingham.net>

Bug #836

 - Make A3 use same the number representation as the user.
This commit is contained in:
Matt Kraai 2011-11-14 23:44:05 -05:00 committed by Paul Beckingham
parent 6473c9f39b
commit 3a4871e975
5 changed files with 25 additions and 9 deletions

View file

@ -203,6 +203,8 @@
to Matt Kraai). to Matt Kraai).
+ Fixed bug #831, which prevented some date fields from being properly parsed. + Fixed bug #831, which prevented some date fields from being properly parsed.
+ Fixed bug #835, which prevented hierarchical projects from being recognized. + 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' + 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 were used. This is an obsolete form, and should now be '1mo' (thanks to
Gour D). Gour D).

View file

@ -686,7 +686,6 @@ const A3 A3::tokenize (const A3& input) const
std::string s; std::string s;
int i; int i;
double d;
time_t t; time_t t;
while (! n.depleted ()) 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) if (found_sequence)
found_something_after_sequence = true; found_something_after_sequence = true;
} }
@ -1699,10 +1698,10 @@ bool A3::is_tag (Nibbler& n, std::string& result)
// <number> followed by either: \0, ), +, -, *, /, ' '. // <number> followed by either: \0, ), +, -, *, /, ' '.
// //
// This prevents the interpretation of '3M' as a number. // 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 (); n.save ();
if (n.getNumber (d)) if (n.getNumber (result))
{ {
char next = n.next (); char next = n.next ();
if (next == '\0' || if (next == '\0' ||

View file

@ -87,7 +87,7 @@ public:
static bool is_id (Nibbler&, std::string&); static bool is_id (Nibbler&, std::string&);
static bool is_uuid (Nibbler&, std::string&); static bool is_uuid (Nibbler&, std::string&);
static bool is_tag (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_integer (Nibbler&, int&);
static bool is_operator (std::vector <std::string>&, Nibbler&, std::string&); static bool is_operator (std::vector <std::string>&, Nibbler&, std::string&);

View file

@ -377,7 +377,7 @@ bool Nibbler::getUnsignedInt (int& result)
// e: // e:
// e|E (+|-)? // e|E (+|-)?
// //
bool Nibbler::getNumber (double& result) bool Nibbler::getNumber (std::string& result)
{ {
std::string::size_type i = _cursor; std::string::size_type i = _cursor;
@ -417,7 +417,7 @@ bool Nibbler::getNumber (double& result)
while (i < _length && isdigit (_input[i])) while (i < _length && isdigit (_input[i]))
++i; ++i;
result = strtof (_input.substr (_cursor, i - _cursor).c_str (), NULL); result = _input.substr (_cursor, i - _cursor);
_cursor = i; _cursor = i;
return true; return true;
} }
@ -425,7 +425,7 @@ bool Nibbler::getNumber (double& result)
return false; return false;
} }
result = strtof (_input.substr (_cursor, i - _cursor).c_str (), NULL); result = _input.substr (_cursor, i - _cursor);
_cursor = i; _cursor = i;
return true; return true;
} }
@ -433,6 +433,20 @@ bool Nibbler::getNumber (double& result)
return false; 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: // number:
// int frac? exp? // int frac? exp?

View file

@ -60,6 +60,7 @@ public:
bool getInt (int&); bool getInt (int&);
bool getHex (int&); bool getHex (int&);
bool getUnsignedInt (int&); bool getUnsignedInt (int&);
bool getNumber (std::string&);
bool getNumber (double&); bool getNumber (double&);
bool getUnsignedNumber (double&); bool getUnsignedNumber (double&);
bool getLiteral (const std::string&); bool getLiteral (const std::string&);