diff --git a/NEWS b/NEWS index e429792..12b430c 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ Copyright (C) 2014 Tim Rühsen +14.08.2015 Release V0.8.1 + * Fix documentation + * Add syntax checking of tests_psl.txt + 06.08.2015 Release V0.8.0 * Add https://github.com/publicsuffix as git submodule * Support Debian 'Reproducible Builds' diff --git a/configure.ac b/configure.ac index 9dac12c..fdf14e8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -AC_INIT([libpsl], [0.8.0], [tim.ruehsen@gmx.de], [libpsl], [http://github.com/rockdaboot/libpsl]) +AC_INIT([libpsl], [0.8.1], [tim.ruehsen@gmx.de], [libpsl], [http://github.com/rockdaboot/libpsl]) AC_PREREQ([2.59]) AM_INIT_AUTOMAKE([1.10 -Wall no-define foreign]) diff --git a/src/psl.c b/src/psl.c index 4cf1205..538252b 100644 --- a/src/psl.c +++ b/src/psl.c @@ -776,14 +776,12 @@ psl_ctx_t *psl_load_fp(FILE *fp) } /** - * psl_load_free: + * psl_free: * @psl: PSL context pointer * * This function frees the the PSL context that has been retrieved via * psl_load_fp() or psl_load_file(). * - * Returns: Pointer to a PSL context private or %NULL on failure. - * * Since: 0.1 */ void psl_free(psl_ctx_t *psl) @@ -827,8 +825,6 @@ const psl_ctx_t *psl_builtin(void) * This function returns number of public suffixes maintained by @psl. * The number of exceptions within the Public Suffix List are not included. * - * If the generation of built-in data has been disabled during compilation, 0 will be returned. - * * Returns: Number of public suffixes entries in PSL context. * * Since: 0.1 @@ -849,8 +845,6 @@ int psl_suffix_count(const psl_ctx_t *psl) * * This function returns number of public suffix exceptions maintained by @psl. * - * If the generation of built-in data has been disabled during compilation, 0 will be returned. - * * Returns: Number of public suffix exceptions in PSL context. * * Since: 0.1 diff --git a/tests/test-registrable-domain.c b/tests/test-registrable-domain.c index cb6ae9b..b263075 100644 --- a/tests/test-registrable-domain.c +++ b/tests/test-registrable-domain.c @@ -66,7 +66,7 @@ static void test(const psl_ctx_t *psl, const char *domain, const char *expected_ } else { failed++; printf("psl_registrable_domain(%s)=%s (expected %s)\n", - domain, result ? result : "NULL", expected_result ? expected_result : "NULL"); + domain ? domain : "NULL", result ? result : "NULL", expected_result ? expected_result : "NULL"); } free(lower); @@ -76,7 +76,9 @@ static void test_psl(void) { FILE *fp; const psl_ctx_t *psl; - char buf[256], domain[128], expected_regdom[128]; + const char *p; + char buf[256], domain[128], expected_regdom[128], semicolon[2]; + int er_is_null, d_is_null; psl = psl_builtin(); @@ -110,15 +112,32 @@ static void test_psl(void) if ((fp = fopen(PSL_TESTFILE, "r"))) { while ((fgets(buf, sizeof(buf), fp))) { - if (sscanf(buf, " checkPublicSuffix('%127[^']' , '%127[^']", domain, expected_regdom) != 2) { - if (sscanf(buf, " checkPublicSuffix('%127[^']' , %127[nul]", domain, expected_regdom) != 2) + /* advance over ASCII white space */ + for (p = buf; *p == ' ' || *p == '\t' || *p == '\r' || *p == '\n'; p++) + ; + + if (!*p || (*p == '/' && p[1] == '/')) + continue; /* ignore comments and blank lines */ + + er_is_null = 0; + d_is_null = 0; + + if (sscanf(p, "checkPublicSuffix ( '%127[^']' , '%127[^']' ) %1[;]", domain, expected_regdom, semicolon) != 3) { + if (sscanf(p, "checkPublicSuffix ( '%127[^']' , null ) %1[;]", domain, semicolon) == 2) { + er_is_null = 1; + } else if (sscanf(p, "checkPublicSuffix ( null , '%127[^']' ) %1[;]", expected_regdom, semicolon) == 2) { + d_is_null = 1; + } else if (sscanf(p, "checkPublicSuffix ( null , null ) %1[;]", semicolon) == 1) { + d_is_null = 1; + er_is_null = 1; + } else { + failed++; + printf("Malformed line from '" PSL_TESTFILE "': %s", buf); continue; + } } - if (!strcmp(expected_regdom, "null")) - test(psl, domain, NULL); - else - test(psl, domain, expected_regdom); + test(psl, d_is_null ? NULL : domain, er_is_null ? NULL : expected_regdom); } fclose(fp);