Browse Source

Deprecate serd_uri_to_path()

zrythm_meson
David Robillard 2 years ago
parent
commit
5c1130819c
  1. 3
      NEWS
  2. 12
      include/serd/serd.h
  3. 10
      src/serdi.c
  4. 9
      test/test_uri.c

3
NEWS

@ -1,5 +1,6 @@ @@ -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; @@ -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;

12
include/serd/serd.h

@ -56,6 +56,16 @@ @@ -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 = { @@ -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);

10
src/serdi.c

@ -35,6 +35,7 @@ @@ -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) @@ -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) @@ -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);

9
test/test_uri.c

@ -51,6 +51,11 @@ test_file_uri(const char* hostname, @@ -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) @@ -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)
{

Loading…
Cancel
Save