diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-05-13 06:04:21 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-05-13 06:04:21 +0000 |
commit | d76e8d5af5bc66a10d7cfa79ae75e61e7df15024 (patch) | |
tree | 68a8061b18c9ea3f9373de492c95d05e20c4a42c /src | |
parent | eb5d5e51e95f8caeee7231b445b0006f3cbe8351 (diff) |
src/compose.c: removed some alloca() calls.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2877 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r-- | src/compose.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/compose.c b/src/compose.c index 79e1fce9..b24b1d0f 100644 --- a/src/compose.c +++ b/src/compose.c @@ -4536,27 +4536,15 @@ static gint compose_write_attach(Compose *compose, FILE *fp, return 0; } -#define QUOTE_IF_REQUIRED(out, str) \ -{ \ - if (*str != '"' && strpbrk(str, ",.[]<>")) { \ - gchar *__tmp; \ - gint len; \ - \ - len = strlen(str) + 3; \ - Xalloca(__tmp, len, return -1); \ - g_snprintf(__tmp, len, "\"%s\"", str); \ - out = __tmp; \ - } else { \ - Xstrdup_a(out, str, return -1); \ - } \ -} +#define QUOTE_REQUIRED(str) \ + (*str != '"' && strpbrk(str, ",.[]<>") != NULL) #define PUT_RECIPIENT_HEADER(header, str) \ { \ if (*str != '\0') { \ gchar *dest; \ \ - Xstrdup_a(dest, str, return -1); \ + dest = g_strdup(str); \ g_strstrip(dest); \ if (*dest != '\0') { \ compose->to_list = address_list_append \ @@ -4566,6 +4554,7 @@ static gint compose_write_attach(Compose *compose, FILE *fp, strlen(header) + 2, TRUE, charset); \ fprintf(fp, "%s: %s\n", header, buf); \ } \ + g_free(dest); \ } \ } @@ -4581,7 +4570,6 @@ static gint compose_write_headers(Compose *compose, FILE *fp, gchar buf[BUFFSIZE]; const gchar *entry_str; gchar *str; - gchar *name; g_return_val_if_fail(fp != NULL, -1); g_return_val_if_fail(charset != NULL, -1); @@ -4599,9 +4587,12 @@ static gint compose_write_headers(Compose *compose, FILE *fp, compose_convert_header (compose, buf, sizeof(buf), compose->account->name, strlen("From: "), TRUE, charset); - QUOTE_IF_REQUIRED(name, buf); - fprintf(fp, "From: %s <%s>\n", - name, compose->account->address); + if (QUOTE_REQUIRED(buf)) + fprintf(fp, "From: \"%s\" <%s>\n", + buf, compose->account->address); + else + fprintf(fp, "From: %s <%s>\n", + buf, compose->account->address); } else fprintf(fp, "From: %s\n", compose->account->address); |