Mercurial > dovecot > core-2.2
view src/lib-mail/test-message-search.c @ 21389:59437f8764c6
global: Replaced all instances of memset(p, 0, sizeof(*p)) with the new i_zero() macro.
Used the following script:
C_FILES=`git ls-files *.c`
H_FILES=`git ls-files *.h`
for F in "$C_FILES $H_FILES"; do
echo "$F"
perl -p -i -e 's/safe_memset\(&\(?([^,]*)\)?,\s*0,\s*sizeof\(\g1\)\)/i_zero_safe(&$1)/g' $F
perl -p -i -e 's/safe_memset\(([^,]*),\s*0,\s*sizeof\(\*\g1\)\)/i_zero_safe($1)/g' $F
perl -p -i -e 's/memset\(&\(?([^,]*)\)?,\s*0,\s*sizeof\(\g1\)\)/i_zero(&$1)/g' $F
perl -p -i -e 's/memset\(([^,]*),\s*0,\s*sizeof\(\*\g1\)\)/i_zero($1)/g' $F
done
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Wed, 11 Jan 2017 01:57:46 +0100 |
parents | 7bad1104baf0 |
children | 2e2563132d5f |
line wrap: on
line source
/* Copyright (c) 2016 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "str.h" #include "unichar.h" #include "message-parser.h" #include "message-search.h" #include "test-common.h" static void test_message_search_more_get_decoded(void) { const char input[] = "p\xC3\xB6\xC3\xB6"; const unsigned char text_plain[] = "text/plain; charset=utf-8"; struct message_search_context *ctx1, *ctx2; struct message_block raw_block, decoded_block; struct message_header_line hdr; struct message_part part; unsigned int i; test_begin("message_search_more_get_decoded()"); ctx1 = message_search_init("p\xC3\xA4\xC3\xA4", NULL, 0); ctx2 = message_search_init("p\xC3\xB6\xC3\xB6", NULL, 0); i_zero(&raw_block); raw_block.part = ∂ /* feed the Content-Type header */ i_zero(&hdr); hdr.name = "Content-Type"; hdr.name_len = strlen(hdr.name); hdr.value = hdr.full_value = text_plain; hdr.value_len = hdr.full_value_len = sizeof(text_plain)-1; raw_block.hdr = &hdr; test_assert(!message_search_more_get_decoded(ctx1, &raw_block, &decoded_block)); test_assert(!message_search_more_decoded(ctx2, &decoded_block)); /* EOH */ raw_block.hdr = NULL; test_assert(!message_search_more_get_decoded(ctx1, &raw_block, &decoded_block)); test_assert(!message_search_more_decoded(ctx2, &decoded_block)); /* body */ raw_block.size = 1; for (i = 0; input[i] != '\0'; i++) { raw_block.data = (const void *)&input[i]; test_assert(!message_search_more_get_decoded(ctx1, &raw_block, &decoded_block)); test_assert(message_search_more_decoded(ctx2, &decoded_block) == (input[i+1] == '\0')); } message_search_deinit(&ctx1); message_search_deinit(&ctx2); test_end(); } int main(void) { static void (*test_functions[])(void) = { test_message_search_more_get_decoded, NULL }; return test_run(test_functions); }