diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/sord_validate.c | 26 | ||||
-rw-r--r-- | src/sordi.c | 14 |
3 files changed, 15 insertions, 28 deletions
@@ -4,8 +4,9 @@ sord (0.16.17) unstable; urgency=medium * Enable clang nullability checks * Fix build as C with MSVC * Fix library current_version on MacOS + * Replace more platform-specific code with use of zix - -- David Robillard <d@drobilla.net> Wed, 13 Nov 2024 16:38:32 +0000 + -- David Robillard <d@drobilla.net> Wed, 11 Dec 2024 20:13:16 +0000 sord (0.16.16) stable; urgency=medium diff --git a/src/sord_validate.c b/src/sord_validate.c index 4951534..13fc16f 100644 --- a/src/sord_validate.c +++ b/src/sord_validate.c @@ -8,6 +8,7 @@ #include <serd/serd.h> #include <sord/sord.h> +#include <zix/filesystem.h> #if USE_PCRE2 # if defined(__clang__) @@ -23,10 +24,6 @@ # endif #endif -#ifdef _WIN32 -# include <windows.h> -#endif - #include <inttypes.h> #include <stdarg.h> #include <stdbool.h> @@ -120,18 +117,6 @@ print_usage(const char* name, bool error) return error ? 1 : 0; } -static uint8_t* -absolute_path(const uint8_t* path) -{ -#ifdef _WIN32 - char* out = (char*)malloc(MAX_PATH); - GetFullPathName((const char*)path, MAX_PATH, out, NULL); - return (uint8_t*)out; -#else - return (uint8_t*)realpath((const char*)path, NULL); -#endif -} - SORD_LOG_FUNC(2, 3) static int errorf(const SordQuad quad, const char* fmt, ...) { @@ -734,7 +719,7 @@ main(int argc, char** argv) for (; a < argc; ++a) { const uint8_t* input = (const uint8_t*)argv[a]; uint8_t* rel_in_path = serd_file_uri_parse(input, NULL); - uint8_t* in_path = absolute_path(rel_in_path); + char* in_path = zix_canonical_path(NULL, (char*)rel_in_path); free(rel_in_path); if (!in_path) { @@ -744,16 +729,17 @@ main(int argc, char** argv) SerdURI base_uri; SerdNode base_uri_node = - serd_node_new_file_uri(in_path, NULL, &base_uri, true); + serd_node_new_file_uri((const uint8_t*)in_path, NULL, &base_uri, true); serd_env_set_base_uri(env, &base_uri_node); - const SerdStatus st = serd_reader_read_file(reader, in_path); + const SerdStatus st = + serd_reader_read_file(reader, (const uint8_t*)in_path); if (st) { fprintf(stderr, "error reading %s: %s\n", in_path, serd_strerror(st)); } serd_node_free(&base_uri_node); - free(in_path); + zix_free(NULL, in_path); } serd_reader_free(reader); serd_env_free(env); diff --git a/src/sordi.c b/src/sordi.c index 8e15e90..6e3092d 100644 --- a/src/sordi.c +++ b/src/sordi.c @@ -5,10 +5,7 @@ #include <serd/serd.h> #include <sord/sord.h> - -#ifdef _WIN32 -# include <windows.h> -#endif +#include <zix/filesystem.h> #include <stdbool.h> #include <stdint.h> @@ -140,10 +137,13 @@ main(int argc, char** argv) SerdURI base_uri = SERD_URI_NULL; SerdNode base = SERD_NODE_NULL; if (a < argc) { // Base URI given on command line - base = - serd_node_new_uri_from_string((const uint8_t*)argv[a], NULL, &base_uri); + const uint8_t* const base_uri_string = (const uint8_t*)argv[a]; + base = serd_node_new_uri_from_string(base_uri_string, NULL, &base_uri); } else if (from_file && in_fd != stdin) { // Use input file URI - base = serd_node_new_file_uri(input, NULL, &base_uri, true); + char* const abs_path = zix_canonical_path(NULL, (const char*)input); + base = + serd_node_new_file_uri((const uint8_t*)abs_path, NULL, &base_uri, true); + zix_free(NULL, abs_path); } SordWorld* world = sord_world_new(); |