X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-lib%2Fbuffer.c;h=0a506bbef8b82f1a9e433dbd8ad6341cd9e8aa5b;hb=fdb93a08e305b8755260144807e4d45106a9cb9f;hp=2abfa391b0d14648fc91276bcbf682b78752195e;hpb=21595f98b7c8132f99abb9fee60ecdce31fc980f;p=apps%2Fmadmutt.git diff --git a/lib-lib/buffer.c b/lib-lib/buffer.c index 2abfa39..0a506bb 100644 --- a/lib-lib/buffer.c +++ b/lib-lib/buffer.c @@ -30,15 +30,14 @@ #include #include -#include -#include -#include -#include +#include "mem.h" +#include "str.h" +#include "ascii.h" +#include "buffer.h" +#include "file.h" #include "mutt.h" -#include "lib/debug.h" - /* * Creates and initializes a BUFFER*. If passed an existing BUFFER*, * just initializes. Frees anything already in the buffer. @@ -87,7 +86,7 @@ void mutt_buffer_free(BUFFER **p) /* dynamically grows a BUFFER to accomodate s, in increments of 128 bytes. * Always one byte bigger than necessary for the null terminator, and * the buffer is always null-terminated */ -void mutt_buffer_add(BUFFER *buf, const char *s, size_t len) +void mutt_buffer_add(BUFFER *buf, const char *s, ssize_t len) { size_t offset; @@ -111,7 +110,7 @@ int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags) /* reset the destination pointer to the beginning of the buffer */ dest->dptr = dest->data; - SKIPWS(tok->dptr); + tok->dptr = vskipspaces(tok->dptr); while ((ch = *tok->dptr)) { if (!qc) { if ((ISSPACE(ch) && !(flags & M_TOKEN_SPACE)) @@ -194,7 +193,7 @@ int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags) FILE *fp; pid_t pid; char *cmd, *ptr; - size_t expnlen; + ssize_t expnlen; BUFFER expn; int line = 0; @@ -207,13 +206,11 @@ int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags) } } while (pc && *pc != '`'); if (!pc) { - debug_print (1, ("mismatched backtics\n")); return (-1); } cmd = p_dupstr(tok->dptr, pc - tok->dptr); if ((pid = mutt_create_filter(cmd, NULL, &fp, NULL)) < 0) { - debug_print(1, ("unable to fork command: %s\n", cmd)); p_delete(&cmd); return -1; } @@ -258,7 +255,7 @@ int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags) if (*tok->dptr == '{') { tok->dptr++; if ((pc = strchr (tok->dptr, '}'))) { - var = str_substrdup (tok->dptr, pc); + var = p_dupstr(tok->dptr, pc - tok->dptr); tok->dptr = pc + 1; } } else { @@ -281,7 +278,7 @@ int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags) } } mutt_buffer_addch(dest, 0); /* terminate the string */ - SKIPWS(tok->dptr); + tok->dptr = vskipspaces(tok->dptr); return 0; }