Merge pull request #9499 from LazyBumHorse/fix_opti

fix path_relative_to()
This commit is contained in:
Twinaphex 2019-09-22 21:53:50 +02:00 committed by GitHub
commit b4e1ca8a2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 10 deletions

View File

@ -913,15 +913,8 @@ size_t path_relative_to(char *out,
/* Each segment of base turns into ".." */
out[0] = '\0';
for (i = 0; trimmed_base[i]; i++)
{
if (trimmed_base[i] == path_default_slash_c())
{
out[written++] = '.';
out[written++] = '.';
out[written++] = path_default_slash_c();
out[written++] = '\0';
}
}
STRLCAT_CONST_INCR(out, written, ".." path_default_slash(), size);
return strlcat(out, trimmed_path, size);
}

View File

@ -56,8 +56,8 @@ static INLINE bool string_is_equal(const char *a, const char *b)
STRLCPY_CONST((buf) + MIN((strlcpy_ret), (buf_size)-1 - STRLEN_CONST((str))), (str))
#define STRLCAT_CONST_INCR(buf, strlcpy_ret, str, buf_size) \
STRLCAT_CONST(buf, strlcpy_ret, str, buf_size); \
(strlcpy_ret) += STRLEN_CONST((str))
do { STRLCAT_CONST(buf, strlcpy_ret, str, buf_size); \
(strlcpy_ret) += STRLEN_CONST((str)); } while(0)
#define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0)
#define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0)