forked from bartvdbraak/blender
use BLI_strncpy_rlen() rather then BLI_snprintf() when no formatting is needed.
also replace sprintf with strcpy when no formatting is done.
This commit is contained in:
parent
cf3b3a1ba2
commit
ffc8ecc587
@ -718,7 +718,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste
|
||||
|
||||
/* print the alt_name */
|
||||
if (unit->name_alt)
|
||||
len_name = BLI_snprintf(str, len_max, "%s", unit->name_alt);
|
||||
len_name = BLI_strncpy_rlen(str, unit->name_alt, len_max);
|
||||
else
|
||||
len_name = 0;
|
||||
|
||||
|
@ -786,7 +786,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
|
||||
|
||||
fmt->audio_codec = ffmpeg_audio_codec;
|
||||
|
||||
BLI_snprintf(of->filename, sizeof(of->filename), "%s", name);
|
||||
BLI_strncpy(of->filename, name, sizeof(of->filename));
|
||||
/* set the codec to the user's selection */
|
||||
switch (ffmpeg_type) {
|
||||
case FFMPEG_AVI:
|
||||
|
@ -57,7 +57,7 @@ bool ExtraHandler::textData(const char *text, size_t textLength)
|
||||
|
||||
if (currentElement.length() == 0 || currentExtraTags == 0) return false;
|
||||
|
||||
BLI_snprintf(buf, textLength + 1, "%s", text);
|
||||
BLI_strncpy(buf, text, textLength + 1);
|
||||
currentExtraTags->addTag(currentElement, std::string(buf));
|
||||
return true;
|
||||
}
|
||||
|
@ -409,11 +409,11 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo
|
||||
for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) {
|
||||
if (template_name[i] == '&') {
|
||||
if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') {
|
||||
j += sprintf(name + j, "%s", side_string);
|
||||
j += BLI_strncpy_rlen(name + j, side_string, MAXBONENAME);
|
||||
i++;
|
||||
}
|
||||
else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') {
|
||||
j += sprintf(name + j, "%s", num_string);
|
||||
j += BLI_strncpy_rlen(name + j, num_string, MAXBONENAME);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
|
@ -170,16 +170,16 @@ const char *BIF_listTemplates(const bContext *UNUSED(C))
|
||||
GHashIterator ghi;
|
||||
const char *menu_header = IFACE_("Template %t|None %x0|");
|
||||
char *p;
|
||||
const size_t template_size = (BLI_ghash_size(TEMPLATES_HASH) * 32 + 30);
|
||||
|
||||
if (TEMPLATES_MENU != NULL) {
|
||||
MEM_freeN(TEMPLATES_MENU);
|
||||
}
|
||||
|
||||
TEMPLATES_MENU = MEM_callocN(sizeof(char) * (BLI_ghash_size(TEMPLATES_HASH) * 32 + 30), "skeleton template menu");
|
||||
TEMPLATES_MENU = MEM_callocN(sizeof(char) * template_size, "skeleton template menu");
|
||||
|
||||
p = TEMPLATES_MENU;
|
||||
|
||||
p += sprintf(TEMPLATES_MENU, "%s", menu_header);
|
||||
p += BLI_strncpy_rlen(p, menu_header, template_size);
|
||||
|
||||
BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ static void vgroup_duplicate(Object *ob)
|
||||
BLI_snprintf(name, sizeof(name), "%s_copy", dg->name);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(name, sizeof(name), "%s", dg->name);
|
||||
BLI_strncpy(name, dg->name, sizeof(name));
|
||||
}
|
||||
|
||||
cdg = defgroup_duplicate(dg);
|
||||
|
@ -404,7 +404,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C)
|
||||
}
|
||||
|
||||
/* create button */
|
||||
BLI_snprintf(name, UI_MAX_NAME_STR, "%s", user->name);
|
||||
BLI_strncpy(name, user->name, UI_MAX_NAME_STR);
|
||||
|
||||
if (user->icon) {
|
||||
but = uiDefIconTextMenuBut(block, template_texture_user_menu, NULL,
|
||||
|
@ -944,7 +944,7 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
if (state[0])
|
||||
BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state);
|
||||
else
|
||||
BLI_snprintf(str, sizeof(str), "%s", track->name);
|
||||
BLI_strncpy(str, track->name, sizeof(str));
|
||||
|
||||
BLF_position(fontid, pos[0], pos[1], 0.0f);
|
||||
BLF_draw(fontid, str, sizeof(str));
|
||||
|
@ -82,17 +82,18 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
|
||||
return;
|
||||
|
||||
if (ibuf == NULL) {
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_("Can't Load Image"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Can't Load Image"), len - ofs);
|
||||
}
|
||||
else {
|
||||
if (ima->source == IMA_SRC_MOVIE) {
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_("Movie"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Movie"), len - ofs);
|
||||
if (ima->anim)
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_(" %d frs"),
|
||||
IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN));
|
||||
}
|
||||
else
|
||||
ofs += BLI_snprintf(str, len - ofs, "%s", IFACE_("Image"));
|
||||
else {
|
||||
ofs += BLI_strncpy_rlen(str, IFACE_("Image"), len - ofs);
|
||||
}
|
||||
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_(": size %d x %d,"), ibuf->x, ibuf->y);
|
||||
|
||||
@ -101,18 +102,18 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_("%d float channel(s)"), ibuf->channels);
|
||||
}
|
||||
else if (ibuf->planes == R_IMF_PLANES_RGBA)
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_(" RGBA float"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA float"), len - ofs);
|
||||
else
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_(" RGB float"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB float"), len - ofs);
|
||||
}
|
||||
else {
|
||||
if (ibuf->planes == R_IMF_PLANES_RGBA)
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_(" RGBA byte"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA byte"), len - ofs);
|
||||
else
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_(" RGB byte"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB byte"), len - ofs);
|
||||
}
|
||||
if (ibuf->zbuf || ibuf->zbuf_float)
|
||||
ofs += BLI_snprintf(str + ofs, len - ofs, "%s", IFACE_(" + Z"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" + Z"), len - ofs);
|
||||
|
||||
if (ima->source == IMA_SRC_SEQUENCE) {
|
||||
const char *file = BLI_last_slash(ibuf->name);
|
||||
|
@ -384,7 +384,7 @@ static void stats_string(Scene *scene)
|
||||
|
||||
if (scene->obedit) {
|
||||
if (BKE_keyblock_from_object(scene->obedit))
|
||||
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, "%s", IFACE_("(Key) "));
|
||||
ofs += BLI_strncpy_rlen(s + ofs, IFACE_("(Key) "), MAX_INFO_LEN - ofs);
|
||||
|
||||
if (scene->obedit->type == OB_MESH) {
|
||||
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs,
|
||||
@ -400,7 +400,7 @@ static void stats_string(Scene *scene)
|
||||
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%d/%d"), stats->totvertsel, stats->totvert);
|
||||
}
|
||||
|
||||
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, "%s", memstr);
|
||||
ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs);
|
||||
}
|
||||
else if (ob && (ob->mode & OB_MODE_POSE)) {
|
||||
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Bones:%d/%d %s"),
|
||||
|
@ -695,10 +695,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
|
||||
|
||||
special = ICON_ACTION;
|
||||
|
||||
if (act)
|
||||
BLI_snprintf(name, sizeof(name), "%s", act->id.name + 2);
|
||||
else
|
||||
BLI_strncpy(name, "<No Action>", sizeof(name));
|
||||
BLI_strncpy(name, act ? act->id.name + 2 : "<No Action>", sizeof(name));
|
||||
|
||||
/* draw manually still */
|
||||
do_draw = TRUE;
|
||||
|
@ -4112,7 +4112,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
||||
applyNumInput(&t->num, &distance);
|
||||
|
||||
/* header print for NumInput */
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%s", IFACE_("Shrink/Fatten:"));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Shrink/Fatten:"), MAX_INFO_LEN - ofs);
|
||||
if (hasNumInput(&t->num)) {
|
||||
char c[NUM_STR_REP_LEN];
|
||||
outputNumInput(&(t->num), c);
|
||||
@ -6481,12 +6481,12 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||
}
|
||||
|
||||
/* header string */
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%s", IFACE_("Vert Slide: "));
|
||||
ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Vert Slide: "), MAX_INFO_LEN - ofs);
|
||||
if (hasNumInput(&t->num)) {
|
||||
char c[NUM_STR_REP_LEN];
|
||||
applyNumInput(&t->num, &final);
|
||||
outputNumInput(&(t->num), c);
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%s", &c[0]);
|
||||
ofs += BLI_strncpy_rlen(str + ofs, &c[0], MAX_INFO_LEN - ofs);
|
||||
}
|
||||
else {
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%.4f ", final);
|
||||
|
@ -409,14 +409,16 @@ const char *BIF_menustringTransformOrientation(const bContext *C, const char *ti
|
||||
int i = V3D_MANIP_CUSTOM;
|
||||
char *str_menu, *p;
|
||||
const int elem_size = MAX_NAME + 4;
|
||||
size_t str_menu_size;
|
||||
|
||||
title = IFACE_(title);
|
||||
|
||||
str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + elem_size * BIF_countTransformOrientation(C), "UserTransSpace from matrix");
|
||||
p = str_menu;
|
||||
str_menu_size = strlen(menu) + strlen(title) + 1 + (elem_size * BIF_countTransformOrientation(C));
|
||||
str_menu = MEM_callocN(str_menu_size, "UserTransSpace from matrix");
|
||||
|
||||
p += sprintf(str_menu, "%s", title);
|
||||
p += sprintf(p, "%s", menu);
|
||||
p = str_menu;
|
||||
p += BLI_strncpy_rlen(p, title, str_menu_size);
|
||||
p += BLI_strncpy_rlen(p, menu, str_menu_size - (p - str_menu));
|
||||
|
||||
for (ts = transform_spaces->first; ts; ts = ts->next) {
|
||||
p += sprintf(p, "|%s %%x%d", ts->name, i++);
|
||||
|
@ -491,7 +491,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
|
||||
rv->of = avformat_alloc_context();
|
||||
rv->of->oformat = av_guess_format("avi", NULL, NULL);
|
||||
|
||||
BLI_snprintf(rv->of->filename, sizeof(rv->of->filename), "%s", fname);
|
||||
BLI_strncpy(rv->of->filename, fname, sizeof(rv->of->filename));
|
||||
|
||||
fprintf(stderr, "Starting work on proxy: %s\n", rv->of->filename);
|
||||
|
||||
|
@ -559,7 +559,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
|
||||
#ifdef __APPLE__
|
||||
EnterMoviesOnThread(0);
|
||||
sprintf(theFullPath, "%s", name);
|
||||
strcpy(theFullPath, name);
|
||||
|
||||
/* hack: create an empty file to make FSPathMakeRef() happy */
|
||||
myFile = open(theFullPath, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRUSR | S_IWUSR);
|
||||
@ -575,7 +575,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
qtname = get_valid_qtname(name);
|
||||
sprintf(theFullPath, "%s", qtname);
|
||||
strcpy(theFullPath, qtname);
|
||||
strcpy(name, qtname);
|
||||
MEM_freeN(qtname);
|
||||
|
||||
|
@ -210,13 +210,13 @@ int anim_is_quicktime(const char *name)
|
||||
if (QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
|
||||
|
||||
#ifdef __APPLE__
|
||||
sprintf(theFullPath, "%s", name);
|
||||
strcpy(theFullPath, name);
|
||||
|
||||
err = FSPathMakeRef(theFullPath, &myRef, 0);
|
||||
err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
|
||||
#else
|
||||
qtname = get_valid_qtname(name);
|
||||
sprintf(theFullPath, "%s", qtname);
|
||||
strcpy(theFullPath, qtname);
|
||||
MEM_freeN(qtname);
|
||||
|
||||
CopyCStringToPascal(theFullPath, dst);
|
||||
@ -461,13 +461,13 @@ int startquicktime(struct anim *anim)
|
||||
if (QTIME_DEBUG) printf("qt: attempting to load as movie %s\n", anim->name);
|
||||
|
||||
#ifdef __APPLE__
|
||||
sprintf(theFullPath, "%s", anim->name);
|
||||
strcpy(theFullPath, anim->name);
|
||||
|
||||
err = FSPathMakeRef(theFullPath, &myRef, 0);
|
||||
err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
|
||||
#else
|
||||
qtname = get_valid_qtname(anim->name);
|
||||
sprintf(theFullPath, "%s", qtname);
|
||||
strcpy(theFullPath, qtname);
|
||||
MEM_freeN(qtname);
|
||||
|
||||
CopyCStringToPascal(theFullPath, dst);
|
||||
@ -592,7 +592,7 @@ int imb_is_a_quicktime(char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(theFullPath, "%s", name);
|
||||
strcpy(theFullPath, name);
|
||||
#ifdef __APPLE__
|
||||
err = FSPathMakeRef(theFullPath, &myRef, 0);
|
||||
err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
|
||||
|
@ -836,7 +836,7 @@ int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
|
||||
}
|
||||
|
||||
strcat(buf, WM_key_event_string(kmi->type));
|
||||
return BLI_snprintf(str, len, "%s", buf);
|
||||
return BLI_strncpy_rlen(str, buf, len);
|
||||
}
|
||||
|
||||
static wmKeyMapItem *wm_keymap_item_find_handlers(
|
||||
|
Loading…
Reference in New Issue
Block a user