From f37474246b6107fc6e149bf188e8f5fa14114013 Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Tue, 22 Aug 2023 15:11:37 -0400 Subject: [PATCH] Fixed up path_get_slash return value --- src/include/86box/path.h | 2 +- src/qt/qt_platform.cpp | 10 ++-------- src/unix/unix.c | 2 +- src/win/win.c | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/include/86box/path.h b/src/include/86box/path.h index 41ef5e65e..f1c5e4177 100644 --- a/src/include/86box/path.h +++ b/src/include/86box/path.h @@ -3,6 +3,6 @@ extern char *path_get_filename(char *s); extern char *path_get_extension(char *s); extern void path_append_filename(char *dest, const char *s1, const char *s2); extern void path_slash(char *path); -extern char *path_get_slash(char *path); +extern const char *path_get_slash(char *path); extern void path_normalize(char *path); extern int path_abs(char *path); \ No newline at end of file diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index a8f9591d7..3a9db0310 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -304,16 +304,10 @@ path_slash(char *path) path_normalize(path); } -char * +const char * path_get_slash(char *path) { - auto len = strlen(path); - std::string ret = ""; - - if (path[len - 1] != '/') - ret = "/"; - - return (char *) ret.c_str(); + return QString(path).endsWith("/") ? "" : "/"; } void diff --git a/src/unix/unix.c b/src/unix/unix.c index 770822919..59b21790d 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -310,7 +310,7 @@ path_slash(char *path) path_normalize(path); } -char * +const char * path_get_slash(char *path) { char *ret = ""; diff --git a/src/win/win.c b/src/win/win.c index 7314370ce..d4d479087 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -739,7 +739,7 @@ path_slash(char *path) } /* Return a trailing (back)slash if necessary. */ -char * +const char * path_get_slash(char *path) { char *ret = "";