]> git.deb.at Git - pkg/abook.git/blobdiff - abook.c
autotools: pre-release autoreconf update
[pkg/abook.git] / abook.c
diff --git a/abook.c b/abook.c
index 05ec4293d37290d4644ddd22b74782528864d93a..7410f6b50747f53b074f819c3be3a87168192764 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -390,8 +390,8 @@ parse_command_line(int argc, char **argv)
                                selected_item_filter = select_output_item_filter(outformat);
                                break;
                        case OPT_OUTFORMAT_STR:
-                               strncpy(custom_format, optarg, FORMAT_STRING_LEN - 1);
-                               custom_format[FORMAT_STRING_LEN] = 0;
+                               strncpy(custom_format, optarg, FORMAT_STRING_LEN);
+                               custom_format[FORMAT_STRING_LEN - 1] = 0;
                                break;
                        case OPT_INFILE:
                                set_convert_var(infile);
@@ -420,8 +420,8 @@ parse_command_line(int argc, char **argv)
                        fprintf(stderr, _("Invalid custom format string\n"));
                        exit(EXIT_FAILURE);
                }
-               parsed_custom_format = (char *)malloc(FORMAT_STRING_LEN * sizeof(char*));
-               custom_format_fields = (enum field_types *)malloc(FORMAT_STRING_MAX_FIELDS * sizeof(enum field_types *));
+               parsed_custom_format = (char *)malloc(FORMAT_STRING_LEN);
+               custom_format_fields = (enum field_types *)malloc(FORMAT_STRING_MAX_FIELDS * sizeof(enum field_types));
                parse_custom_format(custom_format, parsed_custom_format, custom_format_fields);
        }
        if(optind < argc) {
@@ -704,7 +704,7 @@ convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile)
  * --add-email handling
  */
 
-static int add_email_count = 0;
+static int add_email_count = 0, add_email_found = 0;
 
 static void
 quit_add_email()
@@ -715,7 +715,7 @@ quit_add_email()
                        exit(EXIT_FAILURE);
                }
                printf(_("%d item(s) added to %s\n"), add_email_count, datafile);
-       } else {
+       } else if (add_email_found == 0) {
                puts(_("Valid sender address not found"));
        }
 
@@ -814,6 +814,7 @@ add_email(int quiet)
        do {
                line = getaline(stdin);
                if(line && !strncasecmp("From:", line, 5) ) {
+                       add_email_found++;
                        getname(line, &name, &email);
                        add_email_count += add_email_add_item(quiet,
                                        name, email);