aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2011-05-13 06:04:21 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2011-05-13 06:04:21 +0000
commitd76e8d5af5bc66a10d7cfa79ae75e61e7df15024 (patch)
tree68a8061b18c9ea3f9373de492c95d05e20c4a42c
parenteb5d5e51e95f8caeee7231b445b0006f3cbe8351 (diff)
src/compose.c: removed some alloca() calls.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2877 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog1
-rw-r--r--src/compose.c29
2 files changed, 11 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 78874107..3d228f6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* src/textview.c: textview_make_clickable_parts(): removed alloca()
and use GSList.
+ * src/compose.c: removed some alloca() calls.
2011-05-12
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);