X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-search.c;h=bc9be4593ecc0a06b34e82bab62b9a034ffb9f40;hp=7c973b3d6666ac46eca508b1364b4a9b4eb04304;hb=4e2c351c588ad74f4800ca0344232be90387c54a;hpb=abeac48522ded66e2f0e9aae704482355cb46e6a diff --git a/notmuch-search.c b/notmuch-search.c index 7c973b3d..bc9be459 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -30,23 +30,6 @@ typedef enum { OUTPUT_TAGS } output_t; -static char * -sanitize_string (const void *ctx, const char *str) -{ - char *out, *loop; - - if (NULL == str) - return NULL; - - loop = out = talloc_strdup (ctx, str); - - for (; *loop; loop++) { - if ((unsigned char)(*loop) < 32) - *loop = '?'; - } - return out; -} - /* Return two stable query strings that identify exactly the matched * and unmatched messages currently in thread. If there are no * matched or unmatched messages, the returned buffers will be @@ -401,10 +384,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) }; opt_index = parse_arguments (argc, argv, options, 1); - - if (opt_index < 0) { - return 1; - } + if (opt_index < 0) + return EXIT_FAILURE; switch (format_sel) { case NOTMUCH_FORMAT_TEXT: @@ -413,7 +394,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) case NOTMUCH_FORMAT_TEXT0: if (output == OUTPUT_SUMMARY) { fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n"); - return 1; + return EXIT_FAILURE; } format = sprinter_text0_create (config, stdout); break; @@ -432,22 +413,22 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) if (notmuch_database_open (notmuch_config_get_database_path (config), NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) - return 1; + return EXIT_FAILURE; query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index); if (query_str == NULL) { fprintf (stderr, "Out of memory.\n"); - return 1; + return EXIT_FAILURE; } if (*query_str == '\0') { fprintf (stderr, "Error: notmuch search requires at least one search term.\n"); - return 1; + return EXIT_FAILURE; } query = notmuch_query_create (notmuch, query_str); if (query == NULL) { fprintf (stderr, "Out of memory\n"); - return 1; + return EXIT_FAILURE; } notmuch_query_set_sort (query, sort); @@ -491,5 +472,5 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) talloc_free (format); - return ret; + return ret ? EXIT_FAILURE : EXIT_SUCCESS; }