From 587f2a002fa123aeabe5abaec8a6449e5474c246 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 13 Aug 2011 22:29:39 -0400 Subject: [PATCH] A3 Duration - When parsing duration literals, look-ahead now prevents an ordinal such as '31st' (August 31st) from being interpreted as two tokens '31s' (duration) and 't' (word). This is the same fix that was applied to A3::is_number. I'll be there are more that I missed. --- src/A3.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/A3.cpp b/src/A3.cpp index 910b7584d..eb5215de6 100644 --- a/src/A3.cpp +++ b/src/A3.cpp @@ -1456,6 +1456,9 @@ bool A3::is_dom (Nibbler& n, std::string& result) } //////////////////////////////////////////////////////////////////////////////// +// A duration may only be followed by '\0', ')' or ' '. +// +// This prevents the interpretation of '31st' as a duration ('31s'). bool A3::is_duration (Nibbler& n, std::string& result) { n.save (); @@ -1468,8 +1471,14 @@ bool A3::is_duration (Nibbler& n, std::string& result) if (n.getInt (quantity) && n.getOneOf (units, unit)) { - result = format (quantity) + unit; - return true; + char next = n.next (); + if (next == '\0' || + next == ')' || + next == ' ') + { + result = format (quantity) + unit; + return true; + } } n.restore ();