From: Kevin McCarthy Date: Sun, 22 Sep 2019 21:16:56 +0000 (-0700) Subject: Convert buffer callers of mutt_get_field() to use buffer version. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5da50b4d5d0d87f6eb0d78351ec70113e630428e;p=mutt Convert buffer callers of mutt_get_field() to use buffer version. --- diff --git a/browser.c b/browser.c index 4e45013d..eb212d3e 100644 --- a/browser.c +++ b/browser.c @@ -1121,10 +1121,9 @@ void _mutt_buffer_select_file (BUFFER *f, int flags, char ***files, int *numfile } /* buf comes from the buffer pool, so defaults to size LONG_STRING */ - if (mutt_get_field (_("Chdir to: "), buf->data, buf->dsize, MUTT_FILE) == 0 && - mutt_b2s (buf)[0]) + if ((mutt_buffer_get_field (_("Chdir to: "), buf, MUTT_FILE) == 0) && + mutt_buffer_len (buf)) { - mutt_buffer_fix_dptr (buf); buffy = 0; mutt_buffer_expand_path (buf); #ifdef USE_IMAP @@ -1183,17 +1182,15 @@ void _mutt_buffer_select_file (BUFFER *f, int flags, char ***files, int *numfile mutt_buffer_strcpy (buf, NONULL(Mask.pattern)); /* buf comes from the buffer pool, so defaults to size LONG_STRING */ - if (mutt_get_field (_("File Mask: "), buf->data, buf->dsize, 0) == 0) + if (mutt_buffer_get_field (_("File Mask: "), buf, 0) == 0) { regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); const char *s = mutt_b2s (buf); int not = 0, err; - mutt_buffer_fix_dptr (buf); - buffy = 0; /* assume that the user wants to see everything */ - if (!(mutt_b2s (buf)[0])) + if (!(mutt_buffer_len (buf))) mutt_buffer_strcpy (buf, "."); SKIPWS (s); if (*s == '!') @@ -1336,9 +1333,8 @@ void _mutt_buffer_select_file (BUFFER *f, int flags, char ***files, int *numfile mutt_buffer_printf (buf, "%s/", mutt_b2s (LastDir)); /* buf comes from the buffer pool, so defaults to size LONG_STRING */ - if (mutt_get_field (_("New file name: "), buf->data, buf->dsize, MUTT_FILE) == 0) + if (mutt_buffer_get_field (_("New file name: "), buf, MUTT_FILE) == 0) { - /* we're about to bail, so no need to fix buf->dptr */ mutt_buffer_strcpy (f, mutt_b2s (buf)); destroy_state (&state); goto bail; diff --git a/curs_lib.c b/curs_lib.c index 08aa80f2..35ee31af 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -1040,12 +1040,10 @@ int _mutt_buffer_enter_fname (const char *prompt, BUFFER *fname, int buffy, mutt_unget_event (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); mutt_buffer_increase_size (fname, LONG_STRING); - if (_mutt_get_field (pc, fname->data, fname->dsize, - (buffy ? MUTT_EFILE : MUTT_FILE) | MUTT_CLEAR, - multiple, files, numfiles) != 0) + if (_mutt_buffer_get_field (pc, fname, + (buffy ? MUTT_EFILE : MUTT_FILE) | MUTT_CLEAR, + multiple, files, numfiles) != 0) mutt_buffer_clear (fname); - else - mutt_buffer_fix_dptr (fname); FREE (&pc); } diff --git a/muttlib.c b/muttlib.c index 78b43769..8f0b72f5 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1200,14 +1200,9 @@ int mutt_check_overwrite (const char *attname, const char *path, tmp = mutt_buffer_pool_get (); mutt_buffer_strcpy (tmp, mutt_basename (NONULL (attname))); - if (mutt_get_field (_("File under directory: "), tmp->data, tmp->dsize, - MUTT_FILE | MUTT_CLEAR) != 0) - { - mutt_buffer_pool_release (&tmp); - return -1; - } - mutt_buffer_fix_dptr (tmp); - if (!mutt_buffer_len (tmp)) + if ((mutt_buffer_get_field (_("File under directory: "), tmp, + MUTT_FILE | MUTT_CLEAR) != 0) || + !mutt_buffer_len (tmp)) { mutt_buffer_pool_release (&tmp); return (-1); diff --git a/pattern.c b/pattern.c index 5c4311b8..f38cfd38 100644 --- a/pattern.c +++ b/pattern.c @@ -1497,13 +1497,12 @@ int mutt_pattern_func (int op, char *prompt) buf = mutt_buffer_pool_get (); mutt_buffer_strcpy (buf, NONULL (Context->pattern)); - if (mutt_get_field (prompt, buf->data, buf->dsize, MUTT_PATTERN | MUTT_CLEAR) != 0 || - !(mutt_b2s (buf)[0])) + if ((mutt_buffer_get_field (prompt, buf, MUTT_PATTERN | MUTT_CLEAR) != 0) || + !mutt_buffer_len (buf)) { mutt_buffer_pool_release (&buf); return (-1); } - mutt_buffer_fix_dptr (buf); mutt_message _("Compiling search pattern..."); diff --git a/recvattach.c b/recvattach.c index 1c3dddd1..975a9ca0 100644 --- a/recvattach.c +++ b/recvattach.c @@ -447,13 +447,8 @@ static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr, char * prompt = _("Save to file: "); while (prompt) { - if (mutt_get_field (prompt, buf->data, buf->dsize, MUTT_FILE | MUTT_CLEAR) != 0) - { - mutt_clear_error (); - goto cleanup; - } - mutt_buffer_fix_dptr (buf); - if (!mutt_buffer_len (buf)) + if ((mutt_buffer_get_field (prompt, buf, MUTT_FILE | MUTT_CLEAR) != 0) || + !mutt_buffer_len (buf)) goto cleanup; prompt = NULL; @@ -541,12 +536,10 @@ void mutt_save_attachment_list (ATTACH_CONTEXT *actx, FILE *fp, int tag, BODY *t mutt_buffer_strcpy (buf, mutt_basename (NONULL (top->filename))); prepend_curdir (buf); - if (mutt_get_field (_("Save to file: "), buf->data, buf->dsize, - MUTT_FILE | MUTT_CLEAR) != 0) - goto cleanup; - mutt_buffer_fix_dptr (buf); - if (!mutt_buffer_len (buf)) - goto cleanup; + if ((mutt_buffer_get_field (_("Save to file: "), buf, + MUTT_FILE | MUTT_CLEAR) != 0) || + !mutt_buffer_len (buf)) + goto cleanup; mutt_buffer_expand_path (buf); if (mutt_check_overwrite (top->filename, mutt_b2s (buf), tfile, &append, NULL))