Make last_slash concatenation parts consistent (#18102)
This commit is contained in:
parent
ff652ce22d
commit
e011e710bd
|
@ -385,12 +385,15 @@ char *find_last_slash(const char *str)
|
|||
size_t fill_pathname_slash(char *s, size_t len)
|
||||
{
|
||||
char *last_slash = find_last_slash(s);
|
||||
if (!last_slash)
|
||||
return strlcat(s, PATH_DEFAULT_SLASH(), len);
|
||||
len = strlen(s);
|
||||
/* Try to preserve slash type. */
|
||||
if (last_slash != (s + len - 1))
|
||||
if (!last_slash)
|
||||
{
|
||||
s[ len] = PATH_DEFAULT_SLASH_C();
|
||||
s[++len] = '\0';
|
||||
}
|
||||
else if (last_slash != (s + len - 1))
|
||||
{
|
||||
/* Try to preserve slash type. */
|
||||
s[ len] = last_slash[0];
|
||||
s[++len] = '\0';
|
||||
}
|
||||
|
@ -993,20 +996,17 @@ size_t fill_pathname_join_special(char *s,
|
|||
if (*s)
|
||||
{
|
||||
char *last_slash = find_last_slash(s);
|
||||
if (last_slash)
|
||||
{
|
||||
/* Try to preserve slash type. */
|
||||
if (last_slash != (s + _len - 1))
|
||||
{
|
||||
s[ _len] = last_slash[0];
|
||||
s[++_len] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!last_slash)
|
||||
{
|
||||
s[ _len] = PATH_DEFAULT_SLASH_C();
|
||||
s[++_len] = '\0';
|
||||
}
|
||||
else if (last_slash != (s + _len - 1))
|
||||
{
|
||||
/* Try to preserve slash type. */
|
||||
s[ _len] = last_slash[0];
|
||||
s[++_len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
_len += strlcpy(s + _len, path, len - _len);
|
||||
|
@ -1327,14 +1327,14 @@ void path_basedir_wrapper(char *s)
|
|||
*last_slash = '\0';
|
||||
#endif
|
||||
last_slash = find_last_slash(s);
|
||||
if (last_slash)
|
||||
last_slash[1] = '\0';
|
||||
else
|
||||
if (!last_slash)
|
||||
{
|
||||
s[0] = '.';
|
||||
s[1] = PATH_DEFAULT_SLASH_C();
|
||||
s[2] = '\0';
|
||||
}
|
||||
else
|
||||
last_slash[1] = '\0';
|
||||
}
|
||||
|
||||
#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL)
|
||||
|
|
Loading…
Reference in New Issue