Skip to content

Commit

Permalink
lib-mail: message_header_hash_more() - refactor to use switch()
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Jun 23, 2017
1 parent fde1442 commit afad849
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/lib-mail/message-header-hash.c
Expand Up @@ -30,14 +30,20 @@ void message_header_hash_more(struct message_header_hash_context *ctx,
remove any repeated '?', which hopefully will satisfy everybody.
*/
for (i = start = 0; i < size; i++) {
if ((data[i] < 0x20 || data[i] >= 0x7f || data[i] == '?') &&
(data[i] != '\t' && data[i] != '\n')) {
/* remove repeated '?' */
if (start < i || (i == 0 && !ctx->prev_was_questionmark)) {
method->loop(context, data + start, i-start);
method->loop(context, "?", 1);
switch (data[i]) {
case '\t':
case '\n':
break;
default:
if (data[i] < 0x20 || data[i] >= 0x7f || data[i] == '?') {
/* remove repeated '?' */
if (start < i || (i == 0 && !ctx->prev_was_questionmark)) {
method->loop(context, data + start, i-start);
method->loop(context, "?", 1);
}
start = i+1;
}
start = i+1;
break;
}
}
ctx->prev_was_questionmark = start == i;
Expand Down

0 comments on commit afad849

Please sign in to comment.