Fix warning and errors reported by gcc

This commit is contained in:
Abdelrahman Said 2023-11-04 14:24:32 +00:00
parent 6fb5418314
commit 076b1310e3

View File

@ -7,7 +7,7 @@
#if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__) #if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__)
INTERNAL char path_sep = '/'; INTERNAL char path_sep = '/';
#elif defined(_WIN32) || defined(_WIN64) #elif defined(_WIN32) || defined(_WIN64)
INTERNAL char path_sep = '\'; INTERNAL char path_sep = '\\';
#endif #endif
void join_root_and_leaf(const char *root, const char *leaf, char *dst); void join_root_and_leaf(const char *root, const char *leaf, char *dst);
@ -70,7 +70,9 @@ void join_root_and_leaf(const char *root, const char *leaf, char *dst) {
++leaf_start; ++leaf_start;
} }
strncpy(dst, root, ++root_end); memcpy(dst, root, ++root_end);
dst[root_end] = path_sep; dst[root_end] = path_sep;
strncpy(&(dst[++root_end]), &(leaf[leaf_start]), leaf_length - leaf_start);
memcpy(&(dst[++root_end]), &(leaf[leaf_start]), leaf_length - leaf_start);
} }