Merge branch 'blender-v3.4-release'
This commit is contained in:
commit
ed0125afe5
|
@ -51,6 +51,23 @@ static bool BLI_path_is_abs(const char *name);
|
|||
|
||||
// #define DEBUG_STRSIZE
|
||||
|
||||
/**
|
||||
* On UNIX it only makes sense to treat `/` as a path separator.
|
||||
* On WIN32 either may be used.
|
||||
*/
|
||||
static bool is_sep_native_compat(const char ch)
|
||||
{
|
||||
if (ch == SEP) {
|
||||
return true;
|
||||
}
|
||||
#ifdef WIN32
|
||||
if (ch == ALTSEP) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
/* implementation */
|
||||
|
||||
int BLI_path_sequence_decode(const char *string, char *head, char *tail, ushort *r_digits_len)
|
||||
|
@ -1522,7 +1539,7 @@ size_t BLI_path_join_array(char *__restrict dst,
|
|||
bool has_trailing_slash = false;
|
||||
if (ofs != 0) {
|
||||
size_t len = ofs;
|
||||
while ((len != 0) && (path[len - 1] == SEP)) {
|
||||
while ((len != 0) && is_sep_native_compat(path[len - 1])) {
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
|
@ -1536,18 +1553,18 @@ size_t BLI_path_join_array(char *__restrict dst,
|
|||
path = path_array[path_index];
|
||||
has_trailing_slash = false;
|
||||
const char *path_init = path;
|
||||
while (path[0] == SEP) {
|
||||
while (is_sep_native_compat(path[0])) {
|
||||
path++;
|
||||
}
|
||||
size_t len = strlen(path);
|
||||
if (len != 0) {
|
||||
while ((len != 0) && (path[len - 1] == SEP)) {
|
||||
while ((len != 0) && is_sep_native_compat(path[len - 1])) {
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
if (len != 0) {
|
||||
/* the very first path may have a slash at the end */
|
||||
if (ofs && (dst[ofs - 1] != SEP)) {
|
||||
if (ofs && !is_sep_native_compat(dst[ofs - 1])) {
|
||||
dst[ofs++] = SEP;
|
||||
if (ofs == dst_last) {
|
||||
break;
|
||||
|
@ -1570,7 +1587,7 @@ size_t BLI_path_join_array(char *__restrict dst,
|
|||
}
|
||||
|
||||
if (has_trailing_slash) {
|
||||
if ((ofs != dst_last) && (ofs != 0) && (dst[ofs - 1] != SEP)) {
|
||||
if ((ofs != dst_last) && (ofs != 0) && !is_sep_native_compat(dst[ofs - 1])) {
|
||||
dst[ofs++] = SEP;
|
||||
}
|
||||
}
|
||||
|
@ -1598,7 +1615,7 @@ static bool path_name_at_index_forward(const char *__restrict path,
|
|||
int i = 0;
|
||||
while (true) {
|
||||
const char c = path[i];
|
||||
if (ELEM(c, SEP, '\0')) {
|
||||
if ((c == '\0') || is_sep_native_compat(c)) {
|
||||
if (prev + 1 != i) {
|
||||
prev += 1;
|
||||
/* Skip '/./' (behave as if they don't exist). */
|
||||
|
@ -1633,7 +1650,7 @@ static bool path_name_at_index_backward(const char *__restrict path,
|
|||
int i = prev - 1;
|
||||
while (true) {
|
||||
const char c = i >= 0 ? path[i] : '\0';
|
||||
if (ELEM(c, SEP, '\0')) {
|
||||
if ((c == '\0') || is_sep_native_compat(c)) {
|
||||
if (prev - 1 != i) {
|
||||
i += 1;
|
||||
/* Skip '/./' (behave as if they don't exist). */
|
||||
|
|
Loading…
Reference in New Issue