[Bf-blender-cvs] [db54b99ee14] master: BLI_path_util: support both forward and back slashes for WIN32
Campbell Barton
noreply at git.blender.org
Tue Dec 6 03:29:24 CET 2022
Commit: db54b99ee147f9357ad9146a7d827692faeb3420
Author: Campbell Barton
Date: Tue Dec 6 13:19:36 2022 +1100
Branches: master
https://developer.blender.org/rBdb54b99ee147f9357ad9146a7d827692faeb3420
BLI_path_util: support both forward and back slashes for WIN32
The following functions only supported back slashes on WIN32,
which can use both forward and back slashes.
- BLI_path_append
- BLI_path_append_dir
- BLI_path_slash_ensure
- BLI_path_slash_rstrip
Follow up to [0] which is a more limited bug-fix.
[0]: a16ef95ff6ce617009c942264c64c7214c6e9eb7
===================================================================
M source/blender/blenlib/intern/path_util.c
===================================================================
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index d1e084915b6..cba2377161a 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1467,7 +1467,7 @@ size_t BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__
size_t dirlen = BLI_strnlen(dst, maxlen);
/* Inline #BLI_path_slash_ensure. */
- if ((dirlen > 0) && (dst[dirlen - 1] != SEP)) {
+ if ((dirlen > 0) && !is_sep_native_compat(dst[dirlen - 1])) {
dst[dirlen++] = SEP;
dst[dirlen] = '\0';
}
@@ -1484,7 +1484,7 @@ size_t BLI_path_append_dir(char *__restrict dst, const size_t maxlen, const char
size_t dirlen = BLI_path_append(dst, maxlen, dir);
if (dirlen + 1 < maxlen) {
/* Inline #BLI_path_slash_ensure. */
- if ((dirlen > 0) && (dst[dirlen - 1] != SEP)) {
+ if ((dirlen > 0) && !is_sep_native_compat(dst[dirlen - 1])) {
dst[dirlen++] = SEP;
dst[dirlen] = '\0';
}
@@ -1749,7 +1749,7 @@ int BLI_path_slash_ensure(char *string, size_t string_maxlen)
{
int len = strlen(string);
BLI_assert(len < string_maxlen);
- if (len == 0 || string[len - 1] != SEP) {
+ if (len == 0 || !is_sep_native_compat(string[len - 1])) {
/* Avoid unlikely buffer overflow. */
if (len + 1 < string_maxlen) {
string[len] = SEP;
@@ -1764,7 +1764,7 @@ void BLI_path_slash_rstrip(char *string)
{
int len = strlen(string);
while (len) {
- if (string[len - 1] == SEP) {
+ if (is_sep_native_compat(string[len - 1])) {
string[len - 1] = '\0';
len--;
}
More information about the Bf-blender-cvs
mailing list