On Thu, 24 Jan 2013, Peter Wang <novalazy@gmail.com> wrote: > 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. FYI, this patch no longer applies to master. Jani. > --- > notmuch-tag.c | 10 ++++++++++ > tag-util.c | 11 +++-------- > 2 files changed, 13 insertions(+), 8 deletions(-) > > diff --git a/notmuch-tag.c b/notmuch-tag.c > index d9daf8f..a901dad 100644 > --- a/notmuch-tag.c > +++ b/notmuch-tag.c > @@ -234,6 +234,16 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) > if (parse_tag_command_line (ctx, argc - opt_index, argv + opt_index, > &query_string, tag_ops)) > return 1; > + > + if (tag_op_list_size (tag_ops) == 0) { > + 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; > + } > } > > config = notmuch_config_open (ctx, NULL, NULL); > diff --git a/tag-util.c b/tag-util.c > index 701d329..743d591 100644 > --- a/tag-util.c > +++ b/tag-util.c > @@ -188,16 +188,11 @@ parse_tag_command_line (void *ctx, int argc, char **argv, > tag_op_list_append (tag_ops, argv[i] + 1, is_remove); > } > > - if (tag_op_list_size (tag_ops) == 0) { > - fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n"); > - return TAG_PARSE_INVALID; > - } > - > *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