From 382881ad669443b9fc072e87f592cfefee5d041b Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 8 Dec 2015 02:30:21 -0600 Subject: [PATCH 1/2] Support for FreeBSD get_app_path Fixes #889 Add support with and without procfs. See also: https://www.libsdl.org/tmp/SDL/src/filesystem/unix/SDL_sysfilesystem.c --- src/base/fs_unix.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/base/fs_unix.h b/src/base/fs_unix.h index 6c1f51e06..77e4e790d 100644 --- a/src/base/fs_unix.h +++ b/src/base/fs_unix.h @@ -16,6 +16,8 @@ #if __APPLE__ #include +#elif __FreeBSD__ +#include #endif #include "base/path.h" @@ -120,15 +122,16 @@ std::string get_app_path() std::vector path(MAXPATHLEN); #if __APPLE__ - uint32_t size = path.size(); while (_NSGetExecutablePath(&path[0], &size) == -1) path.resize(size); - -#else - +#elif __FreeBSD__ + size_t size = path.size(); + const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + while (sysctl(mib, 4, &path[0], &size, NULL, 0) == -1) + path.resize(size); +#else /* linux */ readlink("/proc/self/exe", &path[0], path.size()); - #endif return std::string(&path[0]); From 57db16efecf15adc553251e876711fdd37674232 Mon Sep 17 00:00:00 2001 From: "Ying Ruei Liang (KK)" Date: Wed, 9 Dec 2015 15:01:25 +0800 Subject: [PATCH 2/2] Correct usage of variable arguments --- src/app/log.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/log.cpp b/src/app/log.cpp index f9a41472c..d3ec160a2 100644 --- a/src/app/log.cpp +++ b/src/app/log.cpp @@ -68,6 +68,7 @@ void verbose_log(const char* format, ...) fflush(app::log_fileptr); #ifdef _DEBUG + va_start(ap, format); vfprintf(stderr, format, ap); fflush(stderr); #endif