Cleanup: use string copy & printf macros
This commit is contained in:
parent
302137b14b
commit
b1a426eac7
|
@ -560,7 +560,7 @@ static bool delete_recursive(const char *dir)
|
|||
char path[FILE_MAXDIR];
|
||||
|
||||
/* dir listing produces dir path without trailing slash... */
|
||||
BLI_strncpy(path, fl->path, sizeof(path));
|
||||
STRNCPY(path, fl->path);
|
||||
BLI_path_slash_ensure(path, sizeof(path));
|
||||
|
||||
if (delete_recursive(path)) {
|
||||
|
@ -627,7 +627,7 @@ int BLI_path_move(const char *file, const char *to)
|
|||
* it has to be 'mv filepath filepath' and not
|
||||
* 'mv filepath destination_directory' */
|
||||
|
||||
BLI_strncpy(str, to, sizeof(str));
|
||||
STRNCPY(str, to);
|
||||
/* points 'to' to a directory ? */
|
||||
if (BLI_path_slash_rfind(str) == (str + strlen(str) - 1)) {
|
||||
if (BLI_path_slash_rfind(file) != NULL) {
|
||||
|
@ -658,7 +658,7 @@ int BLI_copy(const char *file, const char *to)
|
|||
* it has to be 'cp filepath filepath' and not
|
||||
* 'cp filepath destdir' */
|
||||
|
||||
BLI_strncpy(str, to, sizeof(str));
|
||||
STRNCPY(str, to);
|
||||
/* points 'to' to a directory ? */
|
||||
if (BLI_path_slash_rfind(str) == (str + strlen(str) - 1)) {
|
||||
if (BLI_path_slash_rfind(file) != NULL) {
|
||||
|
|
|
@ -112,7 +112,7 @@ bool BLI_windows_register_blend_extension(const bool background)
|
|||
&hkey,
|
||||
&dwd);
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
BLI_snprintf(buffer, sizeof(buffer), "\"%s\" \"%%1\"", BlPath);
|
||||
SNPRINTF(buffer, "\"%s\" \"%%1\"", BlPath);
|
||||
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ bool BLI_windows_register_blend_extension(const bool background)
|
|||
&hkey,
|
||||
&dwd);
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
BLI_snprintf(buffer, sizeof(buffer), "\"%s\", 1", BlPath);
|
||||
SNPRINTF(buffer, "\"%s\", 1", BlPath);
|
||||
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
@ -169,12 +169,10 @@ bool BLI_windows_register_blend_extension(const bool background)
|
|||
RegCloseKey(root);
|
||||
printf("success (%s)\n", usr_mode ? "user" : "system");
|
||||
if (!background) {
|
||||
BLI_snprintf(MBox,
|
||||
sizeof(MBox),
|
||||
"File extension registered for %s.",
|
||||
usr_mode ?
|
||||
"the current user. To register for all users, run as an administrator" :
|
||||
"all users");
|
||||
SNPRINTF(MBox,
|
||||
"File extension registered for %s.",
|
||||
usr_mode ? "the current user. To register for all users, run as an administrator" :
|
||||
"all users");
|
||||
MessageBox(0, MBox, "Blender", MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -335,7 +335,7 @@ static void polyfill_to_obj(const char *id,
|
|||
FILE *f;
|
||||
uint i;
|
||||
|
||||
BLI_snprintf(path, sizeof(path), "%s.obj", id);
|
||||
SNPRINTF(path, "%s.obj", id);
|
||||
|
||||
f = fopen(path, "w");
|
||||
if (!f) {
|
||||
|
|
|
@ -1063,7 +1063,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
|||
#ifdef WITH_BUILDINFO
|
||||
/* TODO(sergey): Add branch name to file as well? */
|
||||
fg.build_commit_timestamp = build_commit_timestamp;
|
||||
BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash));
|
||||
STRNCPY(fg.build_hash, build_hash);
|
||||
#else
|
||||
fg.build_commit_timestamp = 0;
|
||||
STRNCPY(fg.build_hash, "unknown");
|
||||
|
|
|
@ -2841,7 +2841,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
|
|||
else if (!can_create_dir(params->dir)) {
|
||||
const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
|
||||
if (lastdir) {
|
||||
BLI_strncpy(params->dir, lastdir, sizeof(params->dir));
|
||||
STRNCPY(params->dir, lastdir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -368,8 +368,8 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
|
|||
char grp_name_esc[sizeof(grp->name) * 2];
|
||||
BLI_str_escape(grp_name_esc, grp->name, sizeof(grp_name_esc));
|
||||
|
||||
BLI_snprintf(joint_path, sizeof(joint_path), "pose.bones[\"%s\"]", grp_name_esc);
|
||||
BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_quaternion", joint_path);
|
||||
SNPRINTF(joint_path, "pose.bones[\"%s\"]", grp_name_esc);
|
||||
SNPRINTF(rna_path, "%s.rotation_quaternion", joint_path);
|
||||
|
||||
FCurve *quatcu[4] = {
|
||||
create_fcurve(0, rna_path),
|
||||
|
|
|
@ -228,13 +228,12 @@ int DocumentExporter::exportCurrentScene()
|
|||
asset.getContributor().mAuthor = "Blender User";
|
||||
char version_buf[128];
|
||||
#ifdef WITH_BUILDINFO
|
||||
BLI_snprintf(version_buf,
|
||||
sizeof(version_buf),
|
||||
"Blender %s commit date:%s, commit time:%s, hash:%s",
|
||||
BKE_blender_version_string(),
|
||||
build_commit_date,
|
||||
build_commit_time,
|
||||
build_hash);
|
||||
SNPRINTF(version_buf,
|
||||
"Blender %s commit date:%s, commit time:%s, hash:%s",
|
||||
BKE_blender_version_string(),
|
||||
build_commit_date,
|
||||
build_commit_time,
|
||||
build_hash);
|
||||
#else
|
||||
SNPRINTF(version_buf, "Blender %s", BKE_blender_version_string());
|
||||
#endif
|
||||
|
|
|
@ -803,7 +803,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy)
|
|||
const char *filepath_rel = PyUnicode_AsUTF8(filepath_obj); /* can be relative */
|
||||
char filepath_abs[1024];
|
||||
|
||||
BLI_strncpy(filepath_abs, filepath_rel, sizeof(filepath_abs));
|
||||
STRNCPY(filepath_abs, filepath_rel);
|
||||
BLI_path_abs_from_cwd(filepath_abs, sizeof(filepath_abs));
|
||||
Py_DECREF(filepath_obj);
|
||||
|
||||
|
|
|
@ -361,8 +361,8 @@ int main(int argc,
|
|||
}
|
||||
else {
|
||||
const char *unknown = "date-unknown";
|
||||
BLI_strncpy(build_commit_date, unknown, sizeof(build_commit_date));
|
||||
BLI_strncpy(build_commit_time, unknown, sizeof(build_commit_time));
|
||||
STRNCPY(build_commit_date, unknown);
|
||||
STRNCPY(build_commit_time, unknown);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -136,13 +136,12 @@ static void sig_handle_crash(int signum)
|
|||
# ifndef BUILD_DATE
|
||||
SNPRINTF(header, "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG);
|
||||
# else
|
||||
BLI_snprintf(header,
|
||||
sizeof(header),
|
||||
"# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n",
|
||||
BLEND_VERSION_ARG,
|
||||
build_commit_date,
|
||||
build_commit_time,
|
||||
build_hash);
|
||||
SNPRINTF(header,
|
||||
"# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n",
|
||||
BLEND_VERSION_ARG,
|
||||
build_commit_date,
|
||||
build_commit_time,
|
||||
build_hash);
|
||||
# endif
|
||||
|
||||
/* open the crash log */
|
||||
|
|
Loading…
Reference in New Issue