diff options
author | David Robillard <d@drobilla.net> | 2020-11-14 12:31:02 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-14 12:39:38 +0100 |
commit | 5c1130819c60f52a3ab1a27711f4d8cca7a4cd14 (patch) | |
tree | 5ffa0df21d30d58e3e442bd9607e32981adbd5a4 | |
parent | 2bf875e89f98c64164f563a8d1fae2851d9c023c (diff) | |
download | serd-5c1130819c60f52a3ab1a27711f4d8cca7a4cd14.tar.gz serd-5c1130819c60f52a3ab1a27711f4d8cca7a4cd14.tar.bz2 serd-5c1130819c60f52a3ab1a27711f4d8cca7a4cd14.zip |
Deprecate serd_uri_to_path()
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | include/serd/serd.h | 12 | ||||
-rw-r--r-- | src/serdi.c | 10 | ||||
-rw-r--r-- | test/test_uri.c | 9 |
4 files changed, 30 insertions, 4 deletions
@@ -1,5 +1,6 @@ serd (0.30.7) unstable; + * Deprecate serd_uri_to_path() * Fix potential memory error when serialising URIs * Move headers to an include directory * Refuse to write relative URI references to NTriples @@ -7,7 +8,7 @@ serd (0.30.7) unstable; * Split up and reorganize unit tests * Use aligned allocation via C11 or Windows API where possible - -- David Robillard <d@drobilla.net> Sat, 14 Nov 2020 10:53:36 +0000 + -- David Robillard <d@drobilla.net> Sat, 14 Nov 2020 11:25:26 +0000 serd (0.30.6) stable; diff --git a/include/serd/serd.h b/include/serd/serd.h index c7da9fc7..6d822643 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -56,6 +56,16 @@ #define SERD_PURE_API SERD_API SERD_PURE_FUNC #define SERD_CONST_API SERD_API SERD_CONST_FUNC +#ifndef SERD_DISABLE_DEPRECATED +# if defined(__clang__) +# define SERD_DEPRECATED_BY(rep) __attribute__((deprecated("", rep))) +# elif defined(__GNUC__) +# define SERD_DEPRECATED_BY(rep) __attribute__((deprecated("Use " rep))) +# else +# define SERD_DEPRECATED_BY(rep) +# endif +#endif + #ifdef __cplusplus extern "C" { # if defined(__GNUC__) @@ -352,7 +362,7 @@ static const SerdURI SERD_URI_NULL = { encoding and other issues are not handled, to properly convert a file URI to a path, use serd_file_uri_parse(). */ -SERD_API +SERD_API SERD_DEPRECATED_BY("serd_file_uri_parse") const uint8_t* SERD_NULLABLE serd_uri_to_path(const uint8_t* SERD_NONNULL uri); diff --git a/src/serdi.c b/src/serdi.c index c4f0d681..189692dd 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -35,6 +35,7 @@ #include <stdbool.h> #include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #define SERDI_ERROR(msg) fprintf(stderr, "serdi: " msg) @@ -268,11 +269,15 @@ main(int argc, char** argv) _setmode(_fileno(stdout), _O_BINARY); #endif - const uint8_t* input = (const uint8_t*)argv[a++]; + uint8_t* input_path = NULL; + const uint8_t* input = (const uint8_t*)argv[a++]; if (from_file) { in_name = in_name ? in_name : input; if (!in_fd) { - input = serd_uri_to_path(in_name); + if (!strncmp((const char*)input, "file:", 5)) { + input_path = serd_file_uri_parse(input, NULL); + input = input_path; + } if (!input || !(in_fd = serd_fopen((const char*)input, "rb"))) { return 1; } @@ -344,6 +349,7 @@ main(int argc, char** argv) serd_writer_free(writer); serd_env_free(env); serd_node_free(&base); + free(input_path); if (from_file) { fclose(in_fd); diff --git a/test/test_uri.c b/test/test_uri.c index 50fc311d..0328a413 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -51,6 +51,11 @@ test_file_uri(const char* hostname, serd_node_free(&node); } +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + static void test_uri_to_path(void) { @@ -79,6 +84,10 @@ test_uri_to_path(void) assert(!strcmp((const char*)serd_uri_to_path(uri), "C|/Windows/Sucks")); } +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + static void test_uri_parsing(void) { |