]> granicus.if.org Git - mutt/commitdiff
Convert buffer callers of mutt_get_field() to use buffer version.
authorKevin McCarthy <kevin@8t8.us>
Sun, 22 Sep 2019 21:16:56 +0000 (14:16 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sun, 22 Sep 2019 21:53:26 +0000 (14:53 -0700)
browser.c
curs_lib.c
muttlib.c
pattern.c
recvattach.c

index 4e45013d1248bc33ec5663fda93db5c87b6c58fe..eb212d3e2cc0200df4126d7513e561b8ea0d0547 100644 (file)
--- 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;
index 08aa80f2af3f68e95b76cc9d4710b999888c5037..35ee31afff9aa6e90111652e94fac4fbf7839bdf 100644 (file)
@@ -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);
   }
 
index 78b4376948fb98c0f34f5f8c2e8b29edda08efae..8f0b72f5dad689daa74418bf378202a51e784078 100644 (file)
--- 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);
index 5c4311b8f1d062040b7f3b44ab080a6027dfc1fb..f38cfd389ec1cdb22ed64729ccaa4682bb7af03a 100644 (file)
--- 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...");
 
index 1c3dddd16170816e2b5bcaf978d3caf453c9973d..975a9ca0039c290ec3c352bb7bf9848183e0995e 100644 (file)
@@ -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))