diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/util.c | 18 |
2 files changed, 16 insertions, 5 deletions
@@ -16,10 +16,11 @@ lilv (0.21.3) unstable; * Preserve absolute paths in state if no link directory is given * Fix a few minor/unlikely memory errors * Configure based on compiler target OS for cross-compilation + * Fix lilv_realpath() on pre-POSIX-2008 systems * Windows fixes (thanks John Emmas) * Minor documentation improvements - -- David Robillard <d@drobilla.net> Mon, 16 Mar 2015 03:24:05 -0400 + -- David Robillard <d@drobilla.net> Thu, 13 Aug 2015 19:55:27 -0400 lilv (0.20.0) stable; @@ -14,8 +14,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _POSIX_C_SOURCE 1 /* for fileno */ -#define _BSD_SOURCE 1 /* for realpath, symlink */ +#define _POSIX_C_SOURCE 200809L /* for fileno */ +#define _BSD_SOURCE 1 /* for realpath, symlink */ #ifdef __APPLE__ # define _DARWIN_C_SOURCE 1 /* for flock */ @@ -430,13 +430,23 @@ lilv_get_latest_copy(const char* path, const char* copy_path) char* lilv_realpath(const char* path) { -#ifdef _WIN32 +#if defined(_WIN32) char* out = (char*)malloc(MAX_PATH); GetFullPathName(path, MAX_PATH, out, NULL); return out; -#else +#elif _POSIX_VERSION >= 200809L char* real_path = realpath(path, NULL); return real_path ? real_path : lilv_strdup(path); +#else + // OSX <= 105, if anyone cares. I sure don't. + char* out = (char*)malloc(PATH_MAX); + char* real_path = realpath(path, out); + if (!real_path) { + free(out); + return lilv_strdup(path); + } else { + return real_path; + } #endif } |