parse_tag_command_line checked for two error conditions which are
specific to the 'tag' command.  It can be reused for the forthcoming
notmuch 'insert' command if we move the checks out, into notmuch-tag.c.
---
 notmuch-tag.c | 5 +++++
 tag-util.c    | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/notmuch-tag.c b/notmuch-tag.c
index 9a5d3e7..3b09df9 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -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),
diff --git a/tag-util.c b/tag-util.c
index c5f5859..92e08a1 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -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;
-- 
1.7.12.1

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to