From ac8ba5a8281e3c544710fd2d4b2579b8ec01e776 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Tue, 11 Aug 2015 23:33:12 -0400 Subject: [PATCH 1/4] Documentation cleanup --- src/psl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 From c1b52ee2d8e3bc0a27e91c945caf5bb3fc155e3e Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Thu, 13 Aug 2015 18:02:11 -0400 Subject: [PATCH 2/4] Expect more from test_psl.txt There were some tests included in test_psl.txt that we were not covering because they didn't match our expectations. Cover all the tests in test_psl that we know about, and count unknown lines as failed tests. --- tests/test-registrable-domain.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/test-registrable-domain.c b/tests/test-registrable-domain.c index cb6ae9b..dc35283 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,8 @@ static void test_psl(void) { FILE *fp; const psl_ctx_t *psl; - char buf[256], domain[128], expected_regdom[128]; + char buf[256], domain[128], expected_regdom[128], semicolon[2]; + int er_is_null, d_is_null; psl = psl_builtin(); @@ -110,15 +111,26 @@ 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) + if (buf[0] == 0 || buf[0] == '\n' || (buf[0] == '/' && buf[1] == '/')) + continue; /* ignore comments and blank lines */ + er_is_null = 0; + d_is_null = 0; + if (sscanf(buf, " checkPublicSuffix ( '%127[^']' , '%127[^']' ) %1[;]", domain, expected_regdom, semicolon) != 3) { + if (sscanf(buf, " checkPublicSuffix ( '%127[^']' , null ) %1[;]", domain, semicolon) == 2) { + er_is_null = 1; + } else if (sscanf(buf, " checkPublicSuffix ( null , '%127[^']' ) %1[;]", expected_regdom, semicolon) == 2) { + d_is_null = 1; + } else if (sscanf(buf, " checkPublicSuffix ( null , null ) %1[;]", semicolon) == 1) { + d_is_null = 1; + er_is_null = 1; + } else { + failed++; + printf("unknown 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); From 7b72ac673be65f9158498497e4e74e96c1cde125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 14 Aug 2015 12:27:11 +0200 Subject: [PATCH 3/4] Skip leading whitespaces in tests_psl.txt --- tests/test-registrable-domain.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/test-registrable-domain.c b/tests/test-registrable-domain.c index dc35283..b263075 100644 --- a/tests/test-registrable-domain.c +++ b/tests/test-registrable-domain.c @@ -76,6 +76,7 @@ static void test_psl(void) { FILE *fp; const psl_ctx_t *psl; + const char *p; char buf[256], domain[128], expected_regdom[128], semicolon[2]; int er_is_null, d_is_null; @@ -111,21 +112,27 @@ static void test_psl(void) if ((fp = fopen(PSL_TESTFILE, "r"))) { while ((fgets(buf, sizeof(buf), fp))) { - if (buf[0] == 0 || buf[0] == '\n' || (buf[0] == '/' && buf[1] == '/')) + /* 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(buf, " checkPublicSuffix ( '%127[^']' , '%127[^']' ) %1[;]", domain, expected_regdom, semicolon) != 3) { - if (sscanf(buf, " checkPublicSuffix ( '%127[^']' , null ) %1[;]", domain, semicolon) == 2) { + + 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(buf, " checkPublicSuffix ( null , '%127[^']' ) %1[;]", expected_regdom, semicolon) == 2) { + } else if (sscanf(p, "checkPublicSuffix ( null , '%127[^']' ) %1[;]", expected_regdom, semicolon) == 2) { d_is_null = 1; - } else if (sscanf(buf, " checkPublicSuffix ( null , null ) %1[;]", semicolon) == 1) { + } else if (sscanf(p, "checkPublicSuffix ( null , null ) %1[;]", semicolon) == 1) { d_is_null = 1; er_is_null = 1; } else { failed++; - printf("unknown line from '" PSL_TESTFILE "': %s", buf); + printf("Malformed line from '" PSL_TESTFILE "': %s", buf); continue; } } From aa94d576999d52f8814efea7cca1ba8d22394799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 14 Aug 2015 17:05:43 +0200 Subject: [PATCH 4/4] Release v0.8.1 --- NEWS | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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])