index-of-nearest-104619 #2

Merged
Iliya Katushenock merged 62 commits from HooglyBoogly/blender:index-of-nearest-104619 into index_of_nearest 2023-04-20 21:19:53 +02:00
6 changed files with 7 additions and 8 deletions
Showing only changes of commit 5294758830 - Show all commits

View File

@ -399,7 +399,7 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
const int frame = (int)BKE_cachefile_time_offset(cache_file, (double)ctime, fps);
char ext[32];
BLI_path_frame_strip(r_filepath, ext);
BLI_path_frame_strip(r_filepath, ext, sizeof(ext));
BLI_path_frame(r_filepath, frame, frame_len);
BLI_path_extension_ensure(r_filepath, FILE_MAX, ext);

View File

@ -768,7 +768,7 @@ static void volume_filepath_get(const Main *bmain, const Volume *volume, char r_
int path_frame, path_digits;
if (volume->is_sequence && BLI_path_frame_get(r_filepath, &path_frame, &path_digits)) {
char ext[32];
BLI_path_frame_strip(r_filepath, ext);
BLI_path_frame_strip(r_filepath, ext, sizeof(ext));
BLI_path_frame(r_filepath, volume->runtime.frame, path_digits);
BLI_path_extension_ensure(r_filepath, FILE_MAX, ext);
}

View File

@ -416,7 +416,7 @@ bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_
* So: `/some/path_123.jpeg`
* Becomes: `/some/path_###` with `r_ext` set to `.jpeg`.
*/
void BLI_path_frame_strip(char *path, char *r_ext) ATTR_NONNULL();
void BLI_path_frame_strip(char *path, char *r_ext, size_t ext_maxlen) ATTR_NONNULL();
/**
* Check if we have '#' chars, usable for #BLI_path_frame, #BLI_path_frame_range
*/

View File

@ -771,7 +771,7 @@ bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len)
return true;
}
void BLI_path_frame_strip(char *path, char *r_ext)
void BLI_path_frame_strip(char *path, char *r_ext, const size_t ext_maxlen)
{
*r_ext = '\0';
if (*path == '\0') {
@ -791,8 +791,7 @@ void BLI_path_frame_strip(char *path, char *r_ext)
}
c++;
int suffix_length = file_len - (suffix - file);
memcpy(r_ext, suffix, suffix_length + 1);
BLI_strncpy(r_ext, suffix, ext_maxlen);
/* replace the number with the suffix and terminate the string */
while (digits_len--) {

View File

@ -655,7 +655,7 @@ TEST(path_util, SplitDirfile)
char path[FILE_MAX]; \
char ext[FILE_MAX]; \
BLI_strncpy(path, (input_path), FILE_MAX); \
BLI_path_frame_strip(path, ext); \
BLI_path_frame_strip(path, ext, sizeof(ext)); \
EXPECT_STREQ(path, expect_path); \
EXPECT_STREQ(ext, expect_ext); \
} \

View File

@ -1242,7 +1242,7 @@ void sequencer_image_seq_reserve_frames(
char ext[PATH_MAX];
char filename_stripped[PATH_MAX];
/* Strip the frame from filename and substitute with `#`. */
BLI_path_frame_strip(filename, ext);
BLI_path_frame_strip(filename, ext, sizeof(ext));
for (int i = 0; i < len; i++, se++) {
BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped));