Merge pull request #3624 from cold-brewed/path-get-slash

Fixing up path_get_slash return value
This commit is contained in:
Miran Grča
2023-08-23 20:45:27 +02:00
committed by GitHub
4 changed files with 5 additions and 11 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -310,7 +310,7 @@ path_slash(char *path)
path_normalize(path);
}
char *
const char *
path_get_slash(char *path)
{
char *ret = "";

View File

@@ -747,7 +747,7 @@ path_slash(char *path)
}
/* Return a trailing (back)slash if necessary. */
char *
const char *
path_get_slash(char *path)
{
char *ret = "";