From: Jaakko Heinonen Date: Sat, 29 Sep 2001 16:50:15 +0000 (+0000) Subject: applied "quit and print" patch correctly X-Git-Tag: upstream/0.6.1~2^2~336 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=2a26341bf061714afb85b756397c0be5b77bb4c6;p=pkg%2Fabook.git applied "quit and print" patch correctly --- diff --git a/abook.c b/abook.c index de33318..af0d9d0 100644 --- a/abook.c +++ b/abook.c @@ -206,7 +206,7 @@ show_usage() extern list_item *database; static void -muttq_print_item(int item) +muttq_print_item(FILE *file, int item) { char emails[MAX_EMAILS][MAX_EMAIL_LEN]; int i; @@ -216,7 +216,7 @@ muttq_print_item(int item) for(i = 0; i < (options_get_int("mutt_return_all_emails") ? MAX_EMAILS : 1) ; i++) if( *emails[i] ) - printf("%s\t%s\t%s\n", emails[i], + fprintf(file, "%s\t%s\t%s\n", emails[i], database[item][NAME], database[item][NOTES] == NULL ? " " : database[item][NOTES] @@ -232,7 +232,7 @@ mutt_query(char *str) struct db_enumerator e = init_db_enumerator(ENUM_ALL); printf("All items\n"); db_enumerate_items(e) - muttq_print_item(e.item); + muttq_print_item(stdout, e.item); } else { int search_fields[] = {NAME, EMAIL, NICK, -1}; int i; @@ -242,7 +242,7 @@ mutt_query(char *str) } putchar('\n'); while(i >= 0) { - muttq_print_item(i); + muttq_print_item(stdout, i); i = find_item(str, i+1, search_fields); } } @@ -294,30 +294,17 @@ make_mailstr(int item) void print_stderr(int item) { - char *mailstr = NULL; + fprintf (stderr, "%c", '\n'); if( is_valid_item(item) ) - mailstr = make_mailstr(item); + muttq_print_item(stderr, item); else { struct db_enumerator e = init_db_enumerator(ENUM_SELECTED); - char *tmp = NULL; db_enumerate_items(e) { - tmp = mailstr; - mailstr = tmp ? - strconcat(tmp, ",", make_mailstr(e.item), NULL): - strconcat(make_mailstr(e.item), NULL); - free(tmp); + muttq_print_item(stderr, e.item); } } - fprintf(stderr, "%s", mailstr); - -#ifdef DEBUG - fprintf(stderr, "mailstr: %s\n", mailstr); -#endif - - free(mailstr); - } void @@ -484,4 +471,3 @@ convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile) exit(ret); } - diff --git a/help.h b/help.h index abb040e..3b7be8f 100644 --- a/help.h +++ b/help.h @@ -40,6 +40,7 @@ static char *mainhelp[] = { " Z move current item down\n", "\n", " m send mail with mutt\n", +" P print item(s) to stderr\n", " u view URL with www browser\n", NULL diff --git a/ui.c b/ui.c index 1af0ee3..7eeb7c7 100644 --- a/ui.c +++ b/ui.c @@ -483,6 +483,8 @@ get_commands() case 'u': launch_wwwbrowser(list_current_item()); refresh_screen(); break; + case 'P': print_stderr(selected_items() ? -1 : list_current_item()); + return; } } }