X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=edit.c;h=d8e3278065bff4922588d90ac446958e0f22e53d;hb=c38bc4bc5254bd5925d8567e7ff1554a7844b8c7;hp=9403975263bc1520a48031cc81eb0f1b2e943d9b;hpb=22b04d3544adcdcead47127d4de7826d18444ca2;p=pkg%2Fabook.git diff --git a/edit.c b/edit.c index 9403975..d8e3278 100644 --- a/edit.c +++ b/edit.c @@ -182,6 +182,21 @@ editor_print_data(int tab, int item) } } +/* + * function: change_field + * + * parameters: + * (char *msg) + * message to display as a prompt + * (char **field) + * a pointer to a pointer which will point a new string. if the latter + * pointer != NULL it will be freed (if user doesn't cancel) + * + * returns (int) + * a nonzero value if user has cancelled and zero if user has typed a + * valid string + */ + static int change_field(char *msg, char **field) { @@ -246,12 +261,9 @@ edit_emails(char c, int item) split_emailstr(item, emails); field = strdup(emails[email_num]); - if(change_field("E-mail: ", &field)) { -#ifdef DEBUG - fprintf(stderr, "change_field = TRUE\n"); -#endif - return; - } + if(change_field("E-mail: ", &field)) + return; /* user cancelled ( C-g ) */ + if(field) { strncpy(emails[email_num], field, MAX_EMAIL_LEN); fix_email_str(emails[email_num]);