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
2012-02-19 18:59:28 -05:00
2011-08-09 22:46:41 -04:00
2012-01-02 23:32:10 -05:00
Lua
2012-01-15 11:39:53 -05:00
2012-02-19 22:27:40 -05:00
2012-02-19 22:27:40 -05:00
2011-04-23 16:41:37 -04:00
2012-02-19 18:59:28 -05:00
2012-02-19 22:27:40 -05:00
2011-09-14 01:10:52 +02:00
2011-05-28 00:02:04 -04:00
2012-01-02 23:32:10 -05:00
2012-01-12 01:06:26 -05:00
2011-12-18 12:37:09 -05:00
2012-01-02 23:32:10 -05:00
2012-01-02 22:33:25 -05:00
2011-10-08 00:09:34 +02:00

Thank you for taking a look at taskwarrior!

Taskwarrior is a GTD, todo list, task management, command line utility with a
multitude of features.  It is a portable, well supported, very active project,
and it is Open Source.  Taskwarrior has binary distributions, online
documentation, demonstration movies, and you'll find all the details at:

    http://taskwarrior.org

At the site you'll find a wiki, discussion forums, downloads, news and more.

Your contributions are especially welcome.  Whether it comes in the form of
code patches, ideas, discussion, bug reports, encouragement or criticism, your
input is needed.

Please send your support questions and code patches to:

    support@taskwarrior.org

Consider joining taskwarrior.org and participating in the future of taskwarrior.

---

taskwarrior is released under the MIT license. For details check the LICENSE
file.
Description
No description provided
Readme MIT 40 MiB
2.6-dev Latest
2026-01-28 20:05:37 +01:00
Languages
C++ 62.8%
Python 33.3%
Shell 2.2%
CMake 0.8%
Vim Script 0.5%
Other 0.4%