url-parser.c

URL parsing library
git clone git://git.finwo.net/lib/url-parser.c
Log | Files | Refs | README | LICENSE

commit a02e951fa36667732f027ae152833138c79289dd
parent e8b86f0d1557b265a856c14dee2ec90610469da5
Author: finwo <finwo@pm.me>
Date:   Tue,  3 Mar 2026 13:04:29 +0100

Fix warnings

Diffstat:
Mpackage.ini | 4++--
Msrc/url-parser.c | 1-
Mtest/test.h | 14++++++++++----
3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/package.ini b/package.ini @@ -1,7 +1,7 @@ [export] config.mk=config.mk -include/scyphus/url-parser.h=src/url-parser.h +include/finwo/url-parser.h=src/url-parser.h [package] deps=lib -name=scyphus/url-parser +name=finwo/url-parser diff --git a/src/url-parser.c b/src/url-parser.c @@ -88,7 +88,6 @@ parse_url(const char *url) const char *curstr; int len; int i; - int userpass_flag; int bracket_flag; int is_path; diff --git a/test/test.h b/test/test.h @@ -55,6 +55,15 @@ #include <string.h> /// +/// Helper function for string comparison to avoid NULL warnings +/// +static inline int _string_equals(const char *a, const char *b) { + if (a == NULL && b == NULL) return 1; + if (a == NULL || b == NULL) return 0; + return strcmp(a, b) == 0; +} + +/// /// API /// --- /// @@ -90,10 +99,7 @@ /// /// Perform an equal string assertion ///< -#define ASSERT_STRING_EQUALS(expected, actual) ASSERT((#actual), ( \ - ((expected) == NULL && (actual) == NULL) || \ - ((expected) != NULL && (actual) != NULL && strcmp((expected),(actual)) == 0) \ -)) +#define ASSERT_STRING_EQUALS(expected, actual) ASSERT((#actual), _string_equals((expected),(actual))) ///> /// </details>