Commit 7b8348fe 7b8348fe32d5ecd4c422f75cc1c6dbbe21585b28 by Sergey Poznyakoff

(compose_header_set): COMPOSE_SINGLE_LINE part rewritten.

1 parent d8fd8973
...@@ -112,7 +112,7 @@ compose_header_set (compose_env_t *env, char *name, char *value, ...@@ -112,7 +112,7 @@ compose_header_set (compose_env_t *env, char *name, char *value,
112 { 112 {
113 int status; 113 int status;
114 char *old_value; 114 char *old_value;
115 115
116 if (!env->header 116 if (!env->header
117 && (status = header_create (&env->header, NULL, 0, NULL)) != 0) 117 && (status = header_create (&env->header, NULL, 0, NULL)) != 0)
118 { 118 {
...@@ -128,14 +128,16 @@ compose_header_set (compose_env_t *env, char *name, char *value, ...@@ -128,14 +128,16 @@ compose_header_set (compose_env_t *env, char *name, char *value,
128 break; 128 break;
129 129
130 case COMPOSE_SINGLE_LINE: 130 case COMPOSE_SINGLE_LINE:
131 if (!value || value[0] == 0)
132 return EINVAL;
133
131 if (header_aget_value (env->header, name, &old_value) == 0 134 if (header_aget_value (env->header, name, &old_value) == 0
132 && old_value[0]) 135 && old_value[0])
133 { 136 {
134 char *new_value = NULL; 137 status = util_merge_addresses (&old_value, value);
135 138 if (status == 0)
136 asprintf (&new_value, "%s,%s", old_value, value); 139 status = header_set_value (env->header, name, old_value, 1);
137 status = header_set_value (env->header, name, new_value, 1); 140 free (old_value);
138 free (new_value);
139 } 141 }
140 else 142 else
141 status = header_set_value (env->header, name, value, 1); 143 status = header_set_value (env->header, name, value, 1);
......