Commit graph

74 commits

Author SHA1 Message Date
Paul Beckingham
be80bc4ea3 Converted to Lexer2. 2015-02-19 21:36:04 -08:00
Paul Beckingham
c11601e30e Cleanup
- Removed unused Nibbler::getHex.
2015-02-17 10:58:45 -05:00
Paul Beckingham
b7ad091d00 Updated copyright to 2015 2015-01-01 00:00:41 -05:00
Paul Beckingham
5413d3172b TW-230, TW-1329
- TW-230 Filter tasks on partial UUIDs (thanks to Paul Kishimoto).
- TW-1329 Short UUIDs (thanks to Benjamin Weber).
2014-07-01 23:56:53 -04:00
Paul Beckingham
6514bdfc4d TW-28, TW-271, TW-277, TW-752, TW-1265
- TW-1265 cannot add UDA with underscore (thanks to Jakub Wilk).
- Added unit tests for TW-1265.
- Added ChangeLog and AUTHOR entries for other fixed issues.
2014-05-31 11:11:53 -04:00
Paul Beckingham
74cfc972fc Code Cleanup
- Converted use of isspace (which doesn't know Unicode) to Lexer::is_ws.
2014-04-24 17:06:05 -04:00
Paul Beckingham
4cf0763845 Nibbler
- Merged libexpr changes.
2014-01-02 00:34:51 -05:00
Paul Beckingham
efae57d56b Merge from libexpr
- Incorporated Nibbler changes from libexpr.
2013-12-08 16:19:38 -05:00
Paul Beckingham
6f85dac5b8 Build Warning
- Eliminated a sign warning.
2013-09-01 15:02:31 -04:00
Paul Beckingham
663c82837c Nibbler::backN
- Added a method to support multi-byte backstep through a string.
- Added unit tests.
2013-08-31 16:02:51 -04:00
Paul Beckingham
1dccd29643 Copyright 2013
- Updated copyright notices.
2013-03-04 17:47:12 -05:00
Louis-Claude Canon
ec330921de Code Cleanup
- Factorize code for parsing date elements.
- Better order of blocks for parsing date elements.
- Add corresponding minimal-digit date parsing method for reading seconds,
  minutes and week.
- Update documentation and test.
2012-08-02 00:11:12 -04:00
Louis-Claude Canon
384be4b249 Code Cleanup
- Remove the code related to the format "day of year" (number of day starting
  from the January 1) as mktime does not allow to specify it with the field
  tm_yday.
- Cleaner check of the date (everything is done by Date::valid).
- Correct hour, minute and second is also checked.
2012-08-02 00:04:07 -04:00
Louis-Claude Canon
ee0a16f663 Enhancement
- Undefined variables are put to today in dates (if year and month is not
  specified, the current ones are considered). But if a global ones is
  specified, lower one are put to their default values (0 or 1).
2012-08-01 23:41:28 -04:00
Paul Beckingham
c20c025c8e Bug
- Fixed a bug that caused a commond dateformat (YDM-HN) to be misinterpreted
  as a UUID.  Solution is to increase minimum partial UUID length from 9 to
  14.
2012-07-17 18:30:58 -04:00
Owen Clarke
92adb5e266 Bug
- Added include util.h in Nibbler.cpp, forgot to add it to make the fix
  for bug #1030 compile on Solaris.
2012-07-16 23:43:12 +10:00
Owen Clarke
a655be823b Bug #1030
- Added portable implementation of timegm for non GNU/BSD platforms that
  don't have their own implementation
- Removed the use of tm_gmtoff on non GNU/BSD platforms that don't have
  it as part of the tm struct in time.h
- Added CMake tests HAVE_TIMEGM and HAVE_TM_GMTOFF
2012-07-16 22:45:11 +10:00
Paul Beckingham
9a6319a210 Parsing
- Use of broken 'isalpha' caused 'entrée' to be parsed by Nibbler::getName
  as 'entr'.  This is part of bug #1006, but only a small part.
2012-06-10 16:17:09 -04:00
Louis-Claude Canon
f656c2024d Bug
- Fix sanity check for the first digit of day in a date.

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2012-04-30 09:03:35 -04:00
Paul Beckingham
f4bfa1b2fd Bug #995
- Fixed bug #995, which mis-parsed UUIDs in filters as other elements (thanks
  to Bryce Harrington).
- Nibbler no longer permits 8-character UUID abbreviations, because too often
  they resemble other forms, such as '1111111d' which looks like a duration.
- Modified unit tests accordingly.
2012-04-29 00:28:28 -04:00
Paul Beckingham
d6d9fbd8e7 Code Propagation
- Took a patch to tw from the clog version of Nibbler.
2012-04-14 17:02:04 -04:00
Paul Beckingham
2c07837852 Bug
- Fixed bug where ISO dates were parsed and the TZ was modified, which should
  have no bearing on a Zulu time.
2012-04-09 00:16:09 -04:00
Paul Beckingham
7a45db4d0f Feature #891
- Added feature #891, which allows for leftmost partial matches of UUID values.
  Makes direct comparisons for full-length values, and regular expressions for
  partial values.  Note that there is a minimum length of 8 hex digits.
- Added safety parsing mechanism that fails a partial UUID if immediately
  followed by a hex digit.  This allows for numbers longer than 8 digits to not
  be misinterpreted as a UUID.
- Implemented Nibbler::getPartialUUID.
- Implemented unit tests.
@@ -1145,12 +1145,23 @@ const A3 A3::sequence (const A3& input) const

   for (unsigned int i = 0; i < uuids.size (); ++i)
   {
-    if (ids.size ())
+    if (ids.size () + i > 0)
       sequenced.push_back (Arg ("or", Arg::cat_op));

-    sequenced.push_back (Arg ("uuid",        Arg::type_string, Arg::cat_dom));
-    sequenced.push_back (Arg ("=",                             Arg::cat_op));
-    sequenced.push_back (Arg (uuids[i],      Arg::type_string, Arg::cat_literal));
+    // A full-length UUID requires a string comparison.
+    if (uuids[i].length () == 36)
+    {
+      sequenced.push_back (Arg ("uuid",         Arg::type_string, Arg::cat_dom));
+      sequenced.push_back (Arg ("=",                              Arg::cat_op));
+      sequenced.push_back (Arg (uuids[i],       Arg::type_string, Arg::cat_literal));
+    }
+    // A UUID fragment is a leftmost comparison.
+    else
+    {
+      sequenced.push_back (Arg ("uuid",         Arg::type_string, Arg::cat_dom));
+      sequenced.push_back (Arg ("~",                              Arg::cat_op));
+      sequenced.push_back (Arg ("^" + uuids[i], Arg::type_string, Arg::cat_rx));
+    }
   }

   sequenced.push_back (Arg (")", Arg::cat_op));
@@ -1674,11 +1685,11 @@ bool A3::is_uuid (Nibbler& n, std::string& result)
   n.save ();
   result = "";
   std::string uuid;
-  if (n.getUUID (uuid))
+  if (n.getPartialUUID (uuid))
   {
     result += uuid;
     while (n.skip (',') &&
-           n.getUUID (uuid))
+           n.getPartialUUID (uuid))
     {
       result += ',' + uuid;
     }
@@ -1997,13 +2008,13 @@ bool A3::extract_uuid (
   Nibbler n (input);

   std::string uuid;
-  if (n.getUUID (uuid))
+  if (n.getPartialUUID (uuid))
   {
     sequence.push_back (uuid);

     while (n.skip (','))
     {
-      if (!n.getUUID (uuid))
+      if (!n.getPartialUUID (uuid))
         throw std::string (STRING_A3_UUID_AFTER_COMMA);

       sequence.push_back (uuid);
2012-02-19 22:27:40 -05:00
Paul Beckingham
cffc42484e Code Cleanup
- Removed non-STL Nibbler method, which makes way for a future optimization
  in the form of a non-copying Nibbler.
2012-02-05 15:28:09 -05:00
Paul Beckingham
2ce9322a28 Bug #917
- Fixed bug #917, which mis-encoded quotes (thanks to Uli Martens).
- Added unit tests.
- Minor unrelated edits.
2012-02-02 22:58:36 -05:00
Paul Beckingham
ec96d929a0 Bug 879 - Description/Annotation ending with Slash Causes Problems
- Backslashes actually.  The escaping mechanism in the low-level parser
  was eating leading \ characters when it should not.  Very hard bug to
  find, trivial to fix.
- Added unit tests to several components while narrowing this down.
2012-01-29 15:36:05 -05:00
Owen Clarke
7c90d1e8cc Bug - Default TZ not always UTC.
From Owen:

I tried mktime on Darwin an Linux; looks like they both default to UTC if the TZ
environment variable is unset but on Solaris it defaults to the local timezone.
I compiled and ran the tests and checked the behaviour by running:

date
TZ="" date
TZ="UTC" date

On Solaris the first two are in local time and the third is in UTC.
On Darwin and Linux the first one is in local time and the other two are in UTC.

Found this as a reference, too, which mentions the suggested implementation in
'man 3 timegm':

http://stackoverflow.com/questions/6467844/is-c-mktime-different-on-windows-and-gnu-linux

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2012-01-05 18:08:24 -05:00
Paul Beckingham
fb38dca1db Parsing
- Integrated modified Nibbler and test code from kronisk.  These
  changes make both test and Nibbler standalone objects, with configurable
  features.
2012-01-05 17:37:50 -05:00
Paul Beckingham
6580095002 Copyright
- Year change.
2012-01-02 23:32:10 -05:00
Matt Kraai
3a4871e975 Signed-off-by: Paul Beckingham <paul@beckingham.net>
Bug #836

 - Make A3 use same the number representation as the user.
2011-11-14 23:46:56 -05:00
Federico Hernandez
8116c6a103 License
- moving task from GPL to MIT license
  top level src directory
2011-10-08 00:04:01 +02:00
Paul Beckingham
966501f5da Parsing
- Implemented Nibbler::getUnsignedNumber.
2011-09-11 00:47:54 -04:00
Paul Beckingham
255af9e110 Nibbler
- Removed unnecessary addition of capturing parentheses to a regex.
2011-09-07 00:39:02 -04:00
Federico Hernandez
15c939c3d7 Nibbler
- using wrongly ispunct instead of isPunctuation
2011-09-05 22:36:57 +02:00
Paul Beckingham
dab06f8672 Code Cleanup
- All objects now use the same convention for naming members.  The
  consistency is a good thing.
2011-08-25 21:54:28 -04:00
Paul Beckingham
08fcb5362e Bug - Durations
- Duration were parsed as <int><unit> in A3, whereas <number><unit> is
  correct.
- Added Nibbler::str method for internal access.
- Nibbler::save, ::restore now return positions.  Useful for extracting
  substrings.
- Modified countdown.t to use the (now) correct units for durations.
2011-08-17 00:45:09 -04:00
Paul Beckingham
c244132476 Unit Tests
- Fixed bug in Nibbler::getN.
- Added unit test for Nibbler::getN.
2011-07-31 11:14:56 -04:00
Paul Beckingham
fde7ec107a Code Cleanup
- Removed obsolete Nibbler::getDOM.
2011-07-26 00:40:29 -04:00
Matt Kraai
0e2da7f1d4 Code Cleanup
- When compiling the 2.0.0 branch of Taskwarrior with GCC 4.6.1, the compiler
  generates a number of warnings.  This patch eliminates these warnings.

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2011-07-25 23:17:37 -04:00
Paul Beckingham
0ecf93553c Nibbler
- Implemented Nibbler::getN, which allows for faster extraction of
  compound tokens if the length is known.
2011-07-24 14:25:53 -04:00
Paul Beckingham
bfe5edd35d Nibbler
- Improved ::getDOM while it waits to be obsoleted.
2011-07-24 12:58:00 -04:00
Paul Beckingham
3fd83ca400 Nibbler
- Implemented Nibbler::getName to parse an alpha-numeric name.
- Added appropriate unit tests.
2011-07-24 01:00:24 -04:00
Paul Beckingham
09d94a0712 Expressions
- Eliminated the . prefix for DOM references to the current task - it is
  unnatural to state ".due < today".
- Prioritized parsing dates ahead of integers, which were masking all
  dates.
2011-07-19 00:25:26 -04:00
Paul Beckingham
ab6e230f10 Expressions
- Implemented Nibbler::getWord.
- Re-implemented Nibbler::getDOM.
- Modified DOM addressed for context-based attributes from "due" to ".due",
  the help disambiguate DOM references in expressions.  There is now a
  consistency:

      <id>.due         Task-specific
          .due         Contextual
    <uuid>.due         General

- Implemented associated unit tests.
2011-07-18 23:08:05 -04:00
Owen Clarke
2bc8dfbfe7 Bug #793
- Replaced timegm with equivalent code.

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2011-06-27 22:49:37 -04:00
Paul Beckingham
a7d6b91ad3 Cleanup
- Renamed RegX to RX.  Got sick of the RegX name - looked too much like GenX.
2011-06-21 18:15:58 -04:00
Paul Beckingham
8040ed5430 I18N
- More localization.
2011-06-21 18:06:27 -04:00
Paul Beckingham
b49523c06d Regex
- Implemented RegX class to maintain a separate compile, and match
  method, thereby allowing efficient re-use of the regex.  This is
  critical to Expression::eval, where an identical regex might be
  applied to every task.
- Obsoleted rx.{h,cpp}, which combined the compile and match steps
  into a single call, and is therefore not efficient when used in
  the context of filtering.
- Fixed some unit tests that weren't building.  Now they do.  They
  don't work of course (don't be silly) but that's a problem for
  another day.
- Modified all code that relies on rx.h to use RegX.h.
2011-06-21 01:43:57 -04:00
Paul Beckingham
4fca40fc69 Expressions
- Added Expression::eval short-circuit.
- Added int/number exlclusions for Nibbler::getDOM.
- Added Variant::boolean for exatracting filter results.
2011-06-16 20:30:48 -04:00
Paul Beckingham
d6670ba198 Expressions
- Reordered operator table so that longer operators match first, thus
  disambiguating between ! and !=.
- Eliminated Expression::expand_expression.
- Modified Nibbler to know what a DOM reference looks like.
- Removed alpha equivalent operators (lt, le, gt, ge, not, eq, ne) because
  these are common in descriptions (French: le, ne).
- Modified Arguments and Nibbler unit tests.
2011-06-13 00:45:06 -04:00