Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-11 16:33:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-11 16:33:51 +0400
commite10fd04db0bdcdbc326fce6cddc8af1179a5de5c (patch)
treea8f3a08b35101e30a0e5d4d1a94e0b2ef50c7122 /source/blender/editors
parentdcef7346eb3f16c27b3f952b6452396e66f5e996 (diff)
use BLI_strncpy and BLI_snprintf when the size of the string is known.
fix for sequencer unique naming which was missed with string length update.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c4
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c2
-rw-r--r--source/blender/editors/armature/meshlaplacian.c5
-rw-r--r--source/blender/editors/armature/poseSlide.c2
-rw-r--r--source/blender/editors/armature/poselib.c19
-rw-r--r--source/blender/editors/armature/reeb.c5
-rw-r--r--source/blender/editors/curve/editcurve.c20
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c4
-rw-r--r--source/blender/editors/interface/interface_style.c6
-rw-r--r--source/blender/editors/interface/interface_templates.c9
-rw-r--r--source/blender/editors/interface/view2d.c6
-rw-r--r--source/blender/editors/physics/physics_fluid.c2
-rw-r--r--source/blender/editors/screen/area.c4
-rw-r--r--source/blender/editors/space_file/file_draw.c2
-rw-r--r--source/blender/editors/space_file/filelist.c8
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c20
-rw-r--r--source/blender/editors/space_image/image_buttons.c4
-rw-r--r--source/blender/editors/space_image/image_draw.c42
-rw-r--r--source/blender/editors/space_info/info_ops.c6
-rw-r--r--source/blender/editors/space_logic/logic_window.c6
-rw-r--r--source/blender/editors/space_nla/nla_draw.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c4
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c31
-rw-r--r--source/blender/editors/transform/transform_constraints.c35
-rw-r--r--source/blender/editors/util/ed_util.c18
-rw-r--r--source/blender/editors/util/numinput.c19
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c3
29 files changed, 154 insertions, 138 deletions
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index 8c4e0065a19..169d6b94413 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -134,8 +134,8 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
char c= RNA_property_array_item_char(prop, fcu->array_index);
/* we need to write the index to a temp buffer (in py syntax) */
- if (c) sprintf(arrayindbuf, "%c ", c);
- else sprintf(arrayindbuf, "[%d]", fcu->array_index);
+ if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c);
+ else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index);
arrayname= &arrayindbuf[0];
}
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index a928976d695..9ec27b69835 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -1453,7 +1453,7 @@ static void RIG_printCtrl(RigControl *ctrl, char *indent)
printf("%sBone: %s\n", indent, ctrl->bone->name);
printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
- sprintf(text, "%soffset", indent);
+ BLI_snprintf(text, sizeof(text), "%soffset", indent);
print_v3(text, ctrl->offset);
printf("%sFlag: %i\n", indent, ctrl->flag);
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 502da1be8ac..e33b778a168 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -45,6 +45,7 @@
#include "BLI_edgehash.h"
#include "BLI_memarena.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_DerivedMesh.h"
#include "BKE_modifier.h"
@@ -1613,7 +1614,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
NLContext *context;
float vec[3], gridvec[3];
int a, b, x, y, z, totvar;
- char message[1024];
+ char message[256];
/* setup variable indices */
mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx");
@@ -1715,7 +1716,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
break;
}
- sprintf(message, "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert);
+ BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert);
progress_bar((float)(a+1)/(float)(mdb->totcagevert), message);
}
diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c
index 6a9323107d7..c28b688e377 100644
--- a/source/blender/editors/armature/poseSlide.c
+++ b/source/blender/editors/armature/poseSlide.c
@@ -543,7 +543,7 @@ static void pose_slide_draw_status (tPoseSlideOp *pso)
break;
}
- sprintf(status_str, "%s: %d %%", mode_str, (int)(pso->percentage*100.0f));
+ BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f));
ED_area_headerprint(pso->sa, status_str);
}
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 5cdb9c76396..dcddde207f0 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -977,7 +977,9 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
/* do header print - if interactively previewing */
if (pld->state == PL_PREVIEW_RUNNING) {
if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
- sprintf(pld->headerstr, "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again");
+ BLI_strncpy(pld->headerstr,
+ "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again",
+ sizeof(pld->headerstr));
ED_area_headerprint(pld->sa, pld->headerstr);
}
else if (pld->searchstr[0]) {
@@ -988,10 +990,10 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
/* get search-string */
index= pld->search_cursor;
- if (index >= 0 && index <= 64) {
+ if (index >= 0 && index <= sizeof(tempstr) - 1) {
memcpy(&tempstr[0], &pld->searchstr[0], index);
tempstr[index]= '|';
- memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);
+ memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index);
}
else {
BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
@@ -1000,11 +1002,18 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
/* get marker name */
BLI_strncpy(markern, pld->marker ? pld->marker->name : "No Matches", sizeof(markern));
- sprintf(pld->headerstr, "PoseLib Previewing Pose: Filter - [%s] | Current Pose - \"%s\" | Use ScrollWheel or PageUp/Down to change", tempstr, markern);
+ BLI_snprintf(pld->headerstr, sizeof(pld->headerstr),
+ "PoseLib Previewing Pose: Filter - [%s] | "
+ "Current Pose - \"%s\" | "
+ "Use ScrollWheel or PageUp/Down to change",
+ tempstr, markern);
ED_area_headerprint(pld->sa, pld->headerstr);
}
else {
- sprintf(pld->headerstr, "PoseLib Previewing Pose: \"%s\" | Use ScrollWheel or PageUp/Down to change", pld->marker->name);
+ BLI_snprintf(pld->headerstr, sizeof(pld->headerstr),
+ "PoseLib Previewing Pose: \"%s\" | "
+ "Use ScrollWheel or PageUp/Down to change",
+ pld->marker->name);
ED_area_headerprint(pld->sa, pld->headerstr);
}
}
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index 80278c95d05..fe9eb6dcd01 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -2035,10 +2035,9 @@ void REEB_exportGraph(ReebGraph *rg, int count)
if (count == -1)
{
- sprintf(filename, "test.txt");
+ strcpy(filename, "test.txt");
}
- else
- {
+ else {
sprintf(filename, "test%05i.txt", count);
}
f = fopen(filename, "w");
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 762564c1cc9..85ddc7ef14e 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1069,17 +1069,17 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
while (a--) {
keyIndex= getCVKeyIndex(editnurb, bezt);
if(keyIndex) {
- sprintf(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index);
- sprintf(orig_rna_path, "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
+ BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index);
+ BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
if(keyIndex->switched) {
char handle_path[64], orig_handle_path[64];
- sprintf(orig_handle_path, "%s.handle_left", orig_rna_path);
- sprintf(handle_path, "%s.handle_right", rna_path);
+ BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path);
+ BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path);
fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves);
- sprintf(orig_handle_path, "%s.handle_right", orig_rna_path);
- sprintf(handle_path, "%s.handle_left", rna_path);
+ BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_right", orig_rna_path);
+ BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_left", rna_path);
fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves);
}
@@ -1100,8 +1100,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
while (a--) {
keyIndex= getCVKeyIndex(editnurb, bp);
if(keyIndex) {
- sprintf(rna_path, "splines[%d].points[%d]", nu_index, pt_index);
- sprintf(orig_rna_path, "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
+ BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index);
+ BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
keyIndex->nu_index= nu_index;
@@ -1140,8 +1140,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
}
if(keyIndex) {
- sprintf(rna_path, "splines[%d]", nu_index);
- sprintf(orig_rna_path, "splines[%d]", keyIndex->nu_index);
+ BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index);
+ BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index);
fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
}
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index 760faf01b6c..53ef16a70a0 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -143,9 +143,9 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con
/* name */
if (gpl->flag & GP_LAYER_HIDE)
- sprintf(name, "%s (Hidden)", gpl->info);
+ BLI_snprintf(name, sizeof(name), "%s (Hidden)", gpl->info);
else
- sprintf(name, "%s (Locked)", gpl->info);
+ BLI_snprintf(name, sizeof(name), "%s (Locked)", gpl->info);
uiItemL(sub, name, ICON_NONE);
/* delete button (only if hidden but not locked!) */
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 0e9dbaf3022..16b543737d0 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -180,7 +180,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
+ BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
BLF_disable(fs->uifont_id, BLF_SHADOW);
@@ -243,7 +243,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
+ BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable(fs->uifont_id, BLF_ROTATION);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
@@ -291,7 +291,7 @@ void UI_DrawString(float x, float y, const char *str)
uiStyleFontSet(&style->widget);
BLF_position(style->widget.uifont_id, x, y, 0.0f);
- BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */
+ BLF_draw(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
if (style->widget.kerning == 1)
BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ccca0c8f7cf..379a253a5c9 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2471,12 +2471,15 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
int len= strlen(ot->name);
/* display name for menu, can hold hotkey */
- BLI_strncpy(name, ot->name, 256);
+ BLI_strncpy(name, ot->name, sizeof(name));
/* check for hotkey */
- if(len < 256-6) {
- if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1))
+ if(len < sizeof(name)-6) {
+ if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE,
+ &name[len+1], sizeof(name)-len-1))
+ {
name[len]= '|';
+ }
}
if(0==uiSearchItemAdd(items, name, ot, 0))
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 81ea3370331..b8201d762df 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1541,7 +1541,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
}
/* draw it */
- BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)-1);
+ BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str));
}
/* Draw scrollbars in the given 2d-region */
@@ -2093,11 +2093,11 @@ void UI_view2d_text_cache_draw(ARegion *ar)
}
if(v2s->rect.xmin >= v2s->rect.xmax)
- BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, 65535);
+ BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX);
else {
BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
BLF_enable_default(BLF_CLIPPING);
- BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, 65535);
+ BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable_default(BLF_CLIPPING);
}
}
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 5294e29d3d5..0bb5dbef0ea 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -1042,7 +1042,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
fsset->surfaceSmoothing = domainSettings->surfaceSmoothing;
fsset->surfaceSubdivs = domainSettings->surfaceSubdivs;
fsset->farFieldSize = domainSettings->farFieldSize;
- BLI_strncpy(fsset->outputPath, targetFile, 240);
+ BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath));
// domain channels
fsset->channelSizeFrameTime =
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 08833b335eb..e4088fe10c4 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -478,7 +478,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
UI_ThemeColor(TH_TEXT);
- BLF_draw_default(20, 8, 0.0f, ar->headerstr, 65535); /* XXX, use real length */
+ BLF_draw_default(20, 8, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
}
else if(at->draw) {
at->draw(C, ar);
@@ -1809,5 +1809,5 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
/* text */
UI_ThemeColor(TH_TEXT_HI);
BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
- BLF_draw(fontid, text, 256);
+ BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX);
}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 7517c0cd543..c84a9d10ab4 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -134,7 +134,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
ARegion* artmp;
/* Initialize UI block. */
- sprintf(uiblockstr, "win %p", (void *)ar);
+ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar);
block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS);
uiBlockSetHandleFunc(block, do_file_buttons, NULL);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 5b505004f49..32fe8498eaf 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1199,10 +1199,10 @@ void filelist_from_main(struct FileList *filelist)
if(idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) {
files->flags |= IMAGEFILE;
}
- if(id->lib && fake) sprintf(files->extra, "LF %d", id->us);
- else if(id->lib) sprintf(files->extra, "L %d", id->us);
- else if(fake) sprintf(files->extra, "F %d", id->us);
- else sprintf(files->extra, " %d", id->us);
+ if(id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us);
+ else if(id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us);
+ else if(fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us);
+ else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us);
if(id->lib) {
if(totlib==0) firstlib= files;
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index c1dfa97a508..9e1ff82c20d 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -647,7 +647,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
uiItemL(row, "Driver Value:", ICON_NONE);
- sprintf(valBuf, "%.3f", driver->curval);
+ BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
uiItemL(row, valBuf, ICON_NONE);
}
@@ -702,18 +702,18 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
graph_panel_driverVar__transChan(box, ale->id, dvar);
break;
}
-
- /* value of variable */
- if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
- char valBuf[32];
-
- box= uiLayoutBox(col);
- row= uiLayoutRow(box, 1);
+
+ /* value of variable */
+ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
+ char valBuf[32];
+
+ box= uiLayoutBox(col);
+ row= uiLayoutRow(box, 1);
uiItemL(row, "Value:", ICON_NONE);
- sprintf(valBuf, "%.3f", dvar->curval);
+ BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
uiItemL(row, valBuf, ICON_NONE);
- }
+ }
}
/* cleanup */
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 3aebc39bd0a..43bea1c311d 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -682,7 +682,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiButSetFunc(but, image_freecache_cb, ima, NULL);
if(iuser->frames)
- sprintf(str, "(%d) Frames:", iuser->framenr);
+ BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
else strcpy(str, "Frames:");
uiBlockBeginAlign(block);
uiDefButI(block, NUM, imagechanged, str, 10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
@@ -763,7 +763,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
col= uiLayoutColumn(split, 0);
- sprintf(str, "(%d) Frames", iuser->framenr);
+ BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr);
uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE);
if(ima->anim) {
block= uiLayoutGetBlock(col);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index dc712e286a1..21a4f35bcb8 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -139,7 +139,7 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
BLF_size(blf_mono_font, 11, 72);
glColor3ub(255, 255, 255);
- sprintf(str, "X:%-4d Y:%-4d |", x, y);
+ BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y);
// UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
@@ -147,14 +147,14 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
if(zp) {
glColor3ub(255, 255, 255);
- sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
+ BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
}
if(zpf) {
glColor3ub(255, 255, 255);
- sprintf(str, " Z:%-.3f |", *zpf);
+ BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
@@ -163,33 +163,33 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
if(channels >= 3) {
glColor3ubv(red);
if (fp)
- sprintf(str, " R:%-.4f", fp[0]);
+ BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]);
else if (cp)
- sprintf(str, " R:%-3d", cp[0]);
+ BLI_snprintf(str, sizeof(str), " R:%-3d", cp[0]);
else
- sprintf(str, " R:-");
+ BLI_snprintf(str, sizeof(str), " R:-");
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
glColor3ubv(green);
if (fp)
- sprintf(str, " G:%-.4f", fp[1]);
+ BLI_snprintf(str, sizeof(str), " G:%-.4f", fp[1]);
else if (cp)
- sprintf(str, " G:%-3d", cp[1]);
+ BLI_snprintf(str, sizeof(str), " G:%-3d", cp[1]);
else
- sprintf(str, " G:-");
+ BLI_snprintf(str, sizeof(str), " G:-");
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
glColor3ubv(blue);
if (fp)
- sprintf(str, " B:%-.4f", fp[2]);
+ BLI_snprintf(str, sizeof(str), " B:%-.4f", fp[2]);
else if (cp)
- sprintf(str, " B:%-3d", cp[2]);
+ BLI_snprintf(str, sizeof(str), " B:%-3d", cp[2]);
else
- sprintf(str, " B:-");
+ BLI_snprintf(str, sizeof(str), " B:-");
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
@@ -197,11 +197,11 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
if(channels == 4) {
glColor3ub(255, 255, 255);
if (fp)
- sprintf(str, " A:%-.4f", fp[3]);
+ BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]);
else if (cp)
- sprintf(str, " A:%-3d", cp[3]);
+ BLI_snprintf(str, sizeof(str), " A:%-3d", cp[3]);
else
- sprintf(str, "- ");
+ BLI_snprintf(str, sizeof(str), "- ");
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
@@ -269,12 +269,12 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
}
- sprintf(str, "V:%-.4f", val);
+ BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
- sprintf(str, " L:%-.4f", lum);
+ BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
@@ -289,22 +289,22 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
}
- sprintf(str, "H:%-.4f", hue);
+ BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
- sprintf(str, " S:%-.4f", sat);
+ BLI_snprintf(str, sizeof(str), " S:%-.4f", sat);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
- sprintf(str, " V:%-.4f", val);
+ BLI_snprintf(str, sizeof(str), " V:%-.4f", val);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
- sprintf(str, " L:%-.4f", lum);
+ BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index deff1c77912..2090b4eae0a 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -143,7 +143,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
Main *bmain= CTX_data_main(C);
uiPopupMenu *pup;
uiLayout *layout;
- char title[128];
+ char title[64];
int count = 0;
count = countPackedFiles(bmain);
@@ -155,9 +155,9 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
}
if(count == 1)
- sprintf(title, "Unpack 1 file");
+ strcpy(title, "Unpack 1 file");
else
- sprintf(title, "Unpack %d files", count);
+ BLI_snprintf(title, sizeof(title), "Unpack %d files", count);
pup= uiPupMenuBegin(C, title, ICON_NONE);
layout= uiPupMenuLayout(pup);
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 09a8ebc8770..2c1e7a0c546 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -3580,7 +3580,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i
bController *cont= (bController *)ptr->data;
char state[3];
- sprintf(state, "%d", RNA_int_get(ptr, "states"));
+ BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states"));
box= uiLayoutBox(layout);
row= uiLayoutRow(box, 0);
@@ -4497,7 +4497,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
- sprintf(uiblockstr, "buttonswin %p", (void *)ar);
+ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar);
block= uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS);
uiBlockSetHandleFunc(block, do_logic_buts, NULL);
@@ -4815,7 +4815,7 @@ void logic_buttons(bContext *C, ARegion *ar)
if(ob==NULL) return;
// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- sprintf(numstr, "buttonswin %p", (void *)ar);
+ BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar);
block= uiBeginBlock(C, ar, numstr, UI_EMBOSS);
uiBlockSetHandleFunc(block, do_logic_buts, NULL);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 9f13fd7bbb2..c7defdeb64b 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -715,7 +715,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie
}
sel = SEL_NLT(nlt);
- strcpy(name, nlt->name);
+ BLI_strncpy(name, nlt->name, sizeof(name));
// draw manually still
doDraw= 1;
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 9b1bd1d7b31..0ccbf9127c6 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -749,7 +749,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
TreeElement *last_find;
TreeStoreElem *tselem;
int ytop, xdelta, prevFound=0;
- char name[32];
+ char name[sizeof(soops->search_string)];
/* get last found tree-element based on stored search_tse */
last_find= outliner_find_tse(soops, &soops->search_tse);
@@ -803,7 +803,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
/* store selection */
soops->search_tse= *tselem;
- BLI_strncpy(soops->search_string, name, 33);
+ BLI_strncpy(soops->search_string, name, sizeof(soops->search_string));
soops->search_flags= flags;
/* redraw */
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 637c8fcdbcf..26bf25d281d 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -75,7 +75,7 @@ static void text_font_end(SpaceText *UNUSED(st))
static int text_font_draw(SpaceText *UNUSED(st), int x, int y, char *str)
{
BLF_position(mono, x, y, 0);
- BLF_draw(mono, str, 65535); /* XXX, use real length */
+ BLF_draw(mono, str, BLF_DRAW_STR_DUMMY_MAX);
return BLF_width(mono, str);
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 0066e9d799a..1f578455d10 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4539,7 +4539,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
for(a=0, pa=psys->particles; a<totpart; a++, pa++){
float vec_txt[3];
- sprintf(numstr, "%i", a);
+ BLI_snprintf(numstr, sizeof(numstr), "%i", a);
/* use worldspace beause object matrix is already applied */
mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0f08c1984ab..ad85ff6dea8 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -863,24 +863,24 @@ static void draw_selected_name(Scene *scene, Object *ob)
}
}
if(name && markern)
- sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern);
else if(name)
- sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, name);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, name);
else
- sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
+ BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2);
}
else if(ELEM3(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
Key *key= NULL;
KeyBlock *kb = NULL;
- char shapes[75];
+ char shapes[MAX_NAME + 10];
/* try to display active shapekey too */
- shapes[0] = 0;
+ shapes[0] = '\0';
key = ob_get_key(ob);
if(key){
kb = BLI_findlink(&key->block, ob->shapenr-1);
if(kb){
- sprintf(shapes, ": %s ", kb->name);
+ BLI_snprintf(shapes, sizeof(shapes), ": %s ", kb->name);
if(ob->shapeflag == OB_SHAPE_LOCK){
strcat(shapes, " (Pinned)");
}
@@ -888,16 +888,16 @@ static void draw_selected_name(Scene *scene, Object *ob)
}
if(markern)
- sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern);
else
- sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, shapes);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, shapes);
}
else {
/* standard object */
if (markern)
- sprintf(info, "(%d) %s <%s>", CFRA, ob->id.name+2, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name+2, markern);
else
- sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
+ BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2);
}
/* color depends on whether there is a keyframe */
@@ -909,9 +909,9 @@ static void draw_selected_name(Scene *scene, Object *ob)
else {
/* no object */
if (markern)
- sprintf(info, "(%d) <%s>", CFRA, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) <%s>", CFRA, markern);
else
- sprintf(info, "(%d)", CFRA);
+ BLI_snprintf(info, sizeof(info), "(%d)", CFRA);
/* color is always white */
UI_ThemeColor(TH_TEXT_HI);
@@ -920,7 +920,7 @@ static void draw_selected_name(Scene *scene, Object *ob)
if (U.uiflag & USER_SHOW_ROTVIEWICON)
offset = 14 + (U.rvisize * 2);
- BLF_draw_default(offset, 10, 0.0f, info, sizeof(info)-1);
+ BLF_draw_default(offset, 10, 0.0f, info, sizeof(info));
}
static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift, short no_zoom)
@@ -2623,7 +2623,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5f));
}
- BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable)-1);
+ BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable));
}
static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar)
@@ -2897,7 +2897,8 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
}
- BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, numstr[0]?numstr : grid_unit, sizeof(numstr)); /* XXX, use real length */
+ BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f,
+ numstr[0] ? numstr : grid_unit, sizeof(numstr));
}
}
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index b88e57e1861..bd34477c13f 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -59,6 +59,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
//#include "blendef.h"
//
@@ -552,7 +553,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
{
- strncpy(t->con.text + 1, text, 48);
+ BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1);
copy_m3_m3(t->con.mtx, space);
t->con.mode = mode;
getConstraintMatrix(t);
@@ -579,7 +580,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[])
setConstraint(t, t->data->axismtx, mode, text);
}
else {
- strncpy(t->con.text + 1, text, 48);
+ BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1);
copy_m3_m3(t->con.mtx, t->data->axismtx);
t->con.mode = mode;
getConstraintMatrix(t);
@@ -598,7 +599,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[])
/*
Set the constraint according to the user defined orientation
- ftext is a format string passed to sprintf. It will add the name of
+ ftext is a format string passed to BLI_snprintf. It will add the name of
the orientation where %s is (logically).
*/
void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[])
@@ -609,28 +610,28 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
case V3D_MANIP_GLOBAL:
{
float mtx[3][3]= MAT3_UNITY;
- sprintf(text, ftext, "global");
+ BLI_snprintf(text, sizeof(text), ftext, "global");
setConstraint(t, mtx, mode, text);
}
break;
case V3D_MANIP_LOCAL:
- sprintf(text, ftext, "local");
+ BLI_snprintf(text, sizeof(text), ftext, "local");
setLocalConstraint(t, mode, text);
break;
case V3D_MANIP_NORMAL:
- sprintf(text, ftext, "normal");
+ BLI_snprintf(text, sizeof(text), ftext, "normal");
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_VIEW:
- sprintf(text, ftext, "view");
+ BLI_snprintf(text, sizeof(text), ftext, "view");
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_GIMBAL:
- sprintf(text, ftext, "gimbal");
+ BLI_snprintf(text, sizeof(text), ftext, "gimbal");
setConstraint(t, t->spacemtx, mode, text);
break;
default: /* V3D_MANIP_CUSTOM */
- sprintf(text, ftext, t->spacename);
+ BLI_snprintf(text, sizeof(text), ftext, t->spacename);
setConstraint(t, t->spacemtx, mode, text);
break;
}
@@ -874,11 +875,11 @@ static void setNearestAxis2d(TransInfo *t)
/* no correction needed... just use whichever one is lower */
if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) {
t->con.mode |= CON_AXIS1;
- sprintf(t->con.text, " along Y axis");
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis");
}
else {
t->con.mode |= CON_AXIS0;
- sprintf(t->con.text, " along X axis");
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " along X axis");
}
}
@@ -929,31 +930,31 @@ static void setNearestAxis3d(TransInfo *t)
if (len[0] <= len[1] && len[0] <= len[2]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
t->con.mode |= (CON_AXIS1|CON_AXIS2);
- sprintf(t->con.text, " locking %s X axis", t->spacename);
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename);
}
else {
t->con.mode |= CON_AXIS0;
- sprintf(t->con.text, " along %s X axis", t->spacename);
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s X axis", t->spacename);
}
}
else if (len[1] <= len[0] && len[1] <= len[2]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
t->con.mode |= (CON_AXIS0|CON_AXIS2);
- sprintf(t->con.text, " locking %s Y axis", t->spacename);
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename);
}
else {
t->con.mode |= CON_AXIS1;
- sprintf(t->con.text, " along %s Y axis", t->spacename);
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Y axis", t->spacename);
}
}
else if (len[2] <= len[1] && len[2] <= len[0]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
t->con.mode |= (CON_AXIS0|CON_AXIS1);
- sprintf(t->con.text, " locking %s Z axis", t->spacename);
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename);
}
else {
t->con.mode |= CON_AXIS2;
- sprintf(t->con.text, " along %s Z axis", t->spacename);
+ BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Z axis", t->spacename);
}
}
}
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 1a1022a5c7f..73322a8292d 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -179,18 +179,18 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
BLI_strncpy(local_name, abs_name, sizeof(local_name));
BLI_splitdirstring(local_name, fi);
- sprintf(local_name, "//%s/%s", folder, fi);
+ BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
if(strcmp(abs_name, local_name)!=0) {
switch(checkPackedFile(local_name, pf)) {
case PF_NOFILE:
- sprintf(line, "Create %s", local_name);
+ BLI_snprintf(line, sizeof(line), "Create %s", local_name);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_EQUAL:
- sprintf(line, "Use %s (identical)", local_name);
+ BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
@@ -198,13 +198,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
break;
case PF_DIFFERS:
- sprintf(line, "Use %s (differs)", local_name);
+ BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
- sprintf(line, "Overwrite %s", local_name);
+ BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
@@ -216,27 +216,27 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
switch(checkPackedFile(abs_name, pf)) {
case PF_NOFILE:
- sprintf(line, "Create %s", abs_name);
+ BLI_snprintf(line, sizeof(line), "Create %s", abs_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_EQUAL:
- sprintf(line, "Use %s (identical)", abs_name);
+ BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_DIFFERS:
- sprintf(line, "Use %s (differs)", abs_name);
+ BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
- sprintf(line, "Overwrite %s", abs_name);
+ BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name);
//uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 6c8713aa03e..52422d37f29 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -31,9 +31,10 @@
#include <math.h> /* fabs */
-#include <stdio.h> /* for sprintf */
+#include <stdio.h> /* for size_t */
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "WM_types.h"
@@ -84,34 +85,34 @@ void outputNumInput(NumInput *n, char *str)
inv[0] = 0;
if( n->val[i] > 1e10f || n->val[i] < -1e10f )
- sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
else
switch (n->ctrl[i]) {
case 0:
- sprintf(&str[j*20], "%sNONE%c", inv, cur);
+ BLI_snprintf(&str[j*20], 20, "%sNONE%c", inv, cur);
break;
case 1:
case -1:
- sprintf(&str[j*20], "%s%.0f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.0f%c", inv, n->val[i], cur);
break;
case 10:
case -10:
- sprintf(&str[j*20], "%s%.f.%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.f.%c", inv, n->val[i], cur);
break;
case 100:
case -100:
- sprintf(&str[j*20], "%s%.1f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.1f%c", inv, n->val[i], cur);
break;
case 1000:
case -1000:
- sprintf(&str[j*20], "%s%.2f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.2f%c", inv, n->val[i], cur);
break;
case 10000:
case -10000:
- sprintf(&str[j*20], "%s%.3f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.3f%c", inv, n->val[i], cur);
break;
default:
- sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
}
}
}
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 830dc224c94..840e094980c 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -46,6 +46,7 @@
#include "BLI_editVert.h"
#include "BLI_uvproject.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
@@ -334,7 +335,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact
param_flush(ms->handle);
if(sa) {
- sprintf(str, "Minimize Stretch. Blend %.2f", ms->blend);
+ BLI_snprintf(str, sizeof(str), "Minimize Stretch. Blend %.2f", ms->blend);
ED_area_headerprint(sa, str);
}