]> git.deb.at Git - pkg/abook.git/commitdiff
applied "quit and print" patch correctly
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Sat, 29 Sep 2001 16:50:15 +0000 (16:50 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Sat, 29 Sep 2001 16:50:15 +0000 (16:50 +0000)
abook.c
help.h
ui.c

diff --git a/abook.c b/abook.c
index de333180c757a91bfe6f2bc0b8165aa6400b6f1f..af0d9d03e20d16f9da94e152722184e360822d28 100644 (file)
--- 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 abb040e85e54e69bf578263589d94321c45b3bcd..3b7be8f54236878a5fb15ae3a33f058fd33140a2 100644 (file)
--- 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 1af0ee339be5d1457c15a6b6f4ee92c681eec8fc..7eeb7c7306d9b3c1b24c7f958aa1197316f045ca 100644 (file)
--- 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;
                }
        }
 }