]> git.cworth.org Git - notmuch/commitdiff
tag-util: move out 'tag' command-line check
authorPeter Wang <novalazy@gmail.com>
Sun, 23 Jun 2013 04:23:54 +0000 (14:23 +1000)
committerDavid Bremner <bremner@debian.org>
Sat, 29 Jun 2013 17:36:07 +0000 (14:36 -0300)
Move an error condition specific to the 'tag' command out of
parse_tag_command_line so that parse_tag_command_line can be used for
the forthcoming 'insert' command.

notmuch-tag.c
tag-util.c

index 9a5d3e718422068411592c8ebbb1271db9ef0eaf..3b09df995ec58005b37db4269b428e9c996e03d1 100644 (file)
@@ -247,6 +247,11 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
            fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");
            return 1;
        }
+
+       if (*query_string == '\0') {
+           fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");
+           return 1;
+       }
     }
 
     if (notmuch_database_open (notmuch_config_get_database_path (config),
index c5f585950921af59659dddf8d635c95ae1853a2c..92e08a1d05030099b6439f0b56568bc6a8b40bc5 100644 (file)
@@ -190,9 +190,9 @@ parse_tag_command_line (void *ctx, int argc, char **argv,
 
     *query_str = query_string_from_args (ctx, argc - i, &argv[i]);
 
-    if (*query_str == NULL || **query_str == '\0') {
-       fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");
-       return TAG_PARSE_INVALID;
+    if (*query_str == NULL) {
+       fprintf (stderr, "Out of memory.\n");
+       return TAG_PARSE_OUT_OF_MEMORY;
     }
 
     return TAG_PARSE_SUCCESS;