From 1d079fceeb1f91fc880ff7b31805beb5c626bb8d Mon Sep 17 00:00:00 2001 From: Tim Ruehsen Date: Wed, 26 Mar 2014 09:11:54 +0100 Subject: [PATCH] fixed indentation --- tests/test-is-public-all.c | 100 ++++++++++++++++----------------- tests/test-is-public-builtin.c | 34 +++++------ tests/test-is-public.c | 24 ++++---- 3 files changed, 79 insertions(+), 79 deletions(-) diff --git a/tests/test-is-public-all.c b/tests/test-is-public-all.c index 5c4d93a..8edf920 100644 --- a/tests/test-is-public-all.c +++ b/tests/test-is-public-all.c @@ -52,66 +52,66 @@ static void test_psl(void) unsigned it, result; char buf[256], domain[64], *linep, *p; - psl = psl_load_file(DATADIR "/effective_tld_names.dat"); + psl = psl_load_file(DATADIR "/effective_tld_names.dat"); - printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); + printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); - if ((fp = fopen(DATADIR "/effective_tld_names.dat", "r"))) { - while ((linep = fgets(buf, sizeof(buf), fp))) { - while (isspace(*linep)) linep++; // ignore leading whitespace - if (!*linep) continue; // skip empty lines + if ((fp = fopen(DATADIR "/effective_tld_names.dat", "r"))) { + while ((linep = fgets(buf, sizeof(buf), fp))) { + while (isspace(*linep)) linep++; // ignore leading whitespace + if (!*linep) continue; // skip empty lines - if (*linep == '/' && linep[1] == '/') - continue; // skip comments + if (*linep == '/' && linep[1] == '/') + continue; // skip comments - // parse suffix rule - for (p = linep; *linep && !isspace(*linep);) linep++; - *linep = 0; + // parse suffix rule + for (p = linep; *linep && !isspace(*linep);) linep++; + *linep = 0; - if (*p == '!') { // an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) - if (!(result = psl_is_public(psl, p + 1))) { - failed++; - printf("psl_is_public(%s)=%d (expected 1)\n", p, result); - } else ok++; + if (*p == '!') { // an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) + if (!(result = psl_is_public(psl, p + 1))) { + failed++; + printf("psl_is_public(%s)=%d (expected 1)\n", p, result); + } else ok++; - if ((result = psl_is_public(psl, strchr(p, '.') + 1))) { - failed++; - printf("psl_is_public(%s)=%d (expected 0)\n", strchr(p, '.') + 1, result); - } else ok++; - } - else if (*p == '*') { // a wildcard, e.g. *.ck - if ((result = psl_is_public(psl, p + 1))) { - failed++; - printf("psl_is_public(%s)=%d (expected 0)\n", p + 1, result); - } else ok++; - - *p = 'x'; - if ((result = psl_is_public(psl, p))) { - failed++; - printf("psl_is_public(%s)=%d (expected 0)\n", p, result); - } else ok++; - } - else { - if ((result = psl_is_public(psl, p))) { - failed++; - printf("psl_is_public(%s)=%d (expected 0)\n", p, result); - } else ok++; - - snprintf(domain, sizeof(domain), "xxxx.%s", p); - if (!(result = psl_is_public(psl, domain))) { - failed++; - printf("psl_is_public(%s)=%d (expected 1)\n", domain, result); - } else ok++; - } + if ((result = psl_is_public(psl, strchr(p, '.') + 1))) { + failed++; + printf("psl_is_public(%s)=%d (expected 0)\n", strchr(p, '.') + 1, result); + } else ok++; } + else if (*p == '*') { // a wildcard, e.g. *.ck + if ((result = psl_is_public(psl, p + 1))) { + failed++; + printf("psl_is_public(%s)=%d (expected 0)\n", p + 1, result); + } else ok++; - fclose(fp); - } else { - printf("Failed to open %s\n", DATADIR "/effective_tld_names.dat"); - failed++; + *p = 'x'; + if ((result = psl_is_public(psl, p))) { + failed++; + printf("psl_is_public(%s)=%d (expected 0)\n", p, result); + } else ok++; + } + else { + if ((result = psl_is_public(psl, p))) { + failed++; + printf("psl_is_public(%s)=%d (expected 0)\n", p, result); + } else ok++; + + snprintf(domain, sizeof(domain), "xxxx.%s", p); + if (!(result = psl_is_public(psl, domain))) { + failed++; + printf("psl_is_public(%s)=%d (expected 1)\n", domain, result); + } else ok++; + } } - psl_free(&psl); + fclose(fp); + } else { + printf("Failed to open %s\n", DATADIR "/effective_tld_names.dat"); + failed++; + } + + psl_free(&psl); } int main(int argc, const char * const *argv) diff --git a/tests/test-is-public-builtin.c b/tests/test-is-public-builtin.c index ff1dad4..f563038 100644 --- a/tests/test-is-public-builtin.c +++ b/tests/test-is-public-builtin.c @@ -72,30 +72,30 @@ static void test_psl(void) unsigned it; const psl_ctx_t *psl; - psl = psl_builtin(); + psl = psl_builtin(); - printf("have %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); + printf("have %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); - for (it = 0; it < countof(test_data); it++) { - const struct test_data *t = &test_data[it]; - int result = psl_is_public(psl, t->domain); + for (it = 0; it < countof(test_data); it++) { + const struct test_data *t = &test_data[it]; + int result = psl_is_public(psl, t->domain); - if (result == t->result) { - ok++; - } else { - failed++; - printf("psl_is_public(%s)=%d (expected %d)\n", t->domain, result, t->result); - } + if (result == t->result) { + ok++; + } else { + failed++; + printf("psl_is_public(%s)=%d (expected %d)\n", t->domain, result, t->result); } + } - printf("psl_builtin_compile_time()=%ld\n", psl_builtin_compile_time()); - psl_builtin_compile_time() == 0 ? failed++ : ok++; + printf("psl_builtin_compile_time()=%ld\n", psl_builtin_compile_time()); + psl_builtin_compile_time() == 0 ? failed++ : ok++; - printf("psl_builtin_file_time()=%ld\n", psl_builtin_file_time()); - psl_builtin_file_time() == 0 ? failed++ : ok++; + printf("psl_builtin_file_time()=%ld\n", psl_builtin_file_time()); + psl_builtin_file_time() == 0 ? failed++ : ok++; - printf("psl_builtin_sha1sum()=%s\n", psl_builtin_sha1sum()); - *psl_builtin_sha1sum() == 0 ? failed++ : ok++; + printf("psl_builtin_sha1sum()=%s\n", psl_builtin_sha1sum()); + *psl_builtin_sha1sum() == 0 ? failed++ : ok++; } int main(int argc, const char * const *argv) diff --git a/tests/test-is-public.c b/tests/test-is-public.c index 07c3df0..75c6f2a 100644 --- a/tests/test-is-public.c +++ b/tests/test-is-public.c @@ -70,23 +70,23 @@ static void test_psl(void) unsigned it; psl_ctx_t *psl; - psl = psl_load_file(DATADIR "/effective_tld_names.dat"); + psl = psl_load_file(DATADIR "/effective_tld_names.dat"); - printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); + printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); - for (it = 0; it < countof(test_data); it++) { - const struct test_data *t = &test_data[it]; - int result = psl_is_public(psl, t->domain); + for (it = 0; it < countof(test_data); it++) { + const struct test_data *t = &test_data[it]; + int result = psl_is_public(psl, t->domain); - if (result == t->result) { - ok++; - } else { - failed++; - printf("psl_is_public(%s)=%d (expected %d)\n", t->domain, result, t->result); - } + if (result == t->result) { + ok++; + } else { + failed++; + printf("psl_is_public(%s)=%d (expected %d)\n", t->domain, result, t->result); } + } - psl_free(&psl); + psl_free(&psl); } int main(int argc, const char * const *argv)