aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-01-16 18:21:53 +0000
committerDavid Robillard <d@drobilla.net>2012-01-16 18:21:53 +0000
commit2d724f0e199f74201307cc161031afbd8dba4eb5 (patch)
treeb6db75dbfa6e3d29823d64b9207232e61cfcc070 /src/uri.c
parent80a8bad6790dd510577d0922287b8a3f60d89252 (diff)
downloadserd-2d724f0e199f74201307cc161031afbd8dba4eb5.tar.gz
serd-2d724f0e199f74201307cc161031afbd8dba4eb5.tar.bz2
serd-2d724f0e199f74201307cc161031afbd8dba4eb5.zip
Support compilation as C++ under MSVC++
git-svn-id: http://svn.drobilla.net/serd/trunk@291 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/uri.c')
-rw-r--r--src/uri.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/uri.c b/src/uri.c
index 3d0e35af..58609ba4 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -22,12 +22,21 @@
// #define URI_DEBUG 1
+static inline bool
+is_windows_path(const uint8_t* path)
+{
+ return is_alpha(path[0]) && (path[1] == ':' || path[1] == '|')
+ && (path[2] == '/' || path[2] == '\\');
+}
+
SERD_API
const uint8_t*
serd_uri_to_path(const uint8_t* uri)
{
- const uint8_t* path = NULL;
- if (serd_uri_string_has_scheme(uri)) {
+ const uint8_t* path = uri;
+ if (uri[0] == '/' || is_windows_path(uri)) {
+ return uri;
+ } else if (serd_uri_string_has_scheme(uri)) {
if (strncmp((const char*)uri, "file:", 5)) {
fprintf(stderr, "Non-file URI `%s'\n", uri);
return NULL;
@@ -39,12 +48,9 @@ serd_uri_to_path(const uint8_t* uri)
fprintf(stderr, "Invalid file URI `%s'\n", uri);
return NULL;
}
- // Special case for awful Windows file URIs
- if (is_alpha(path[1]) && path[2] == ':' && path[3] == '/') {
+ if (is_windows_path(path + 1)) {
++path; // Special case for terrible Windows file URIs
}
- } else {
- path = uri;
}
return path;
}