summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-03-13 00:39:16 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-03-13 00:39:16 +0000
commit514472a071f8f49b48eaa460ce34452b87db2ca2 (patch)
tree17b58cc189b2d922c1e894c29f05122488af9c79 /lib
parentb81c839194e7f24524f7d9a27dadc10cb5d03d80 (diff)
downloadmailutils-514472a071f8f49b48eaa460ce34452b87db2ca2.tar.gz
mailutils-514472a071f8f49b48eaa460ce34452b87db2ca2.tar.bz2
(mime_context_fill): Remove leading whitespace
when preparing lists. (mime_context_get_content_type_value): Return integer code. (expand_string): Fixed expansion of %{name}
Diffstat (limited to 'lib')
-rw-r--r--lib/mailcap.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/mailcap.c b/lib/mailcap.c
index 8e0d65f97..d32df7f49 100644
--- a/lib/mailcap.c
+++ b/lib/mailcap.c
@@ -78,7 +78,11 @@ mime_context_fill (struct mime_context *ctx, const char *file,
list_create (&ctx->values);
while ((p = strtok_r (NULL, ";", &sp)))
+ {
+ while (*p && isspace (*p))
+ p++;
list_append (ctx->values, p);
+ }
if (no_ask)
{
@@ -86,9 +90,13 @@ mime_context_fill (struct mime_context *ctx, const char *file,
list_create (&ctx->no_ask_types);
for (p = strtok_r (ctx->no_ask_str, ",", &sp); p;
p = strtok_r (NULL, ",", &sp))
+ {
+ while (*p && isspace (*p))
+ p++;
list_append (ctx->no_ask_types, p);
}
}
+}
static void
mime_context_release (struct mime_context *ctx)
@@ -147,12 +155,13 @@ mime_context_get_input (struct mime_context *ctx, stream_t *pinput)
*pinput = ctx->input;
}
-static void
+static int
mime_context_get_content_type_value (struct mime_context *ctx,
char *name, size_t len,
char **ptr, size_t *plen)
{
iterator_t itr = NULL;
+ int rc = 1;
list_get_iterator (ctx->values, &itr);
for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr))
@@ -163,6 +172,7 @@ mime_context_get_content_type_value (struct mime_context *ctx,
p = strchr (item, '=');
if (p - item == len && strncasecmp (item, name, len) == 0)
{
+ rc = 0;
*ptr = ++p;
*plen = strlen (*ptr);
if (**ptr == '"')
@@ -174,6 +184,7 @@ mime_context_get_content_type_value (struct mime_context *ctx,
}
}
iterator_destroy (&itr);
+ return rc;
}
static void
@@ -239,10 +250,15 @@ expand_string (struct mime_context *ct, char **pstr)
case '{':
{
size_t n;
- char *q = ++p;
+ char *q;
+
+ p += 2;
+ q = p;
while (*p && *p != '}')
p++;
- mime_context_get_content_type_value (ct, q, p-q, &s, &n);
+ if (mime_context_get_content_type_value (ct,
+ q, p-q,
+ &s, &n) == 0)
obstack_grow (&expand_stack, s, n);
if (*p)
p++;

Return to:

Send suggestions and report system problems to the System administrator.