diff options
Diffstat (limited to 'source/blender/editors')
66 files changed, 435 insertions, 406 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 569125e1055..32e5fe82ed4 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -180,7 +180,7 @@ void ANIM_timecode_string_from_frame (char *str, Scene *scene, int power, short static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) { float xscale, yscale, x, y; - char str[32] = " t"; /* t is the character to start replacing from */ + char numstr[32] = " t"; /* t is the character to start replacing from */ short slen; /* because the frame number text is subject to the same scaling as the contents of the view */ @@ -193,10 +193,10 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) * but power = 1 is required for frames (to get integer frames) */ if (time) - ANIM_timecode_string_from_frame(&str[4], scene, 0, time, FRA2TIME(cfra)); + ANIM_timecode_string_from_frame(&numstr[4], scene, 0, time, FRA2TIME(cfra)); else - ANIM_timecode_string_from_frame(&str[4], scene, 1, time, cfra); - slen= (short)UI_GetStringWidth(str) - 1; + ANIM_timecode_string_from_frame(&numstr[4], scene, 1, time, cfra); + slen= (short)UI_GetStringWidth(numstr) - 1; /* get starting coordinates for drawing */ x= cfra * xscale; @@ -208,7 +208,7 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); - UI_DrawString(x-5, y+3, str); + UI_DrawString(x-5, y+3, numstr); /* restore view transform */ glScalef(xscale, 1.0, 1.0); 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.c b/source/blender/editors/armature/editarmature.c index 6369d4e3faf..d751bf89176 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3457,7 +3457,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); EditBone *bone; float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; - char name[32]; + char name[MAXBONENAME]; RNA_string_get(op->ptr, "name", name); @@ -3507,7 +3507,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "Bone", 32, "Name", "Name of the newly created bone"); + RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone"); } @@ -5499,7 +5499,7 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op) { Object *ob= CTX_data_edit_object(C); bArmature *arm; - char newname[32]; + char newname[MAXBONENAME]; short axis= RNA_enum_get(op->ptr, "type"); /* paranoia checks */ diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 451e672da7c..9ec27b69835 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -450,7 +450,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo { int i, j; - for (i = 0, j = 0; template_name[i] != '\0' && i < 31 && j < 31; i++) + for (i = 0, j = 0; template_name[i] != '\0' && i < (MAXBONENAME-1) && j < (MAXBONENAME-1); i++) { if (template_name[i] == '&') { @@ -485,7 +485,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string) { RigControl *ctrl; - char name[32]; + char name[MAXBONENAME]; ctrl = newRigControl(rg); @@ -541,7 +541,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * if (src_edge->bone != NULL) { - char name[32]; + char name[MAXBONENAME]; renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string); edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob); edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); @@ -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 6197b66656a..5c378da33df 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_memarena.h" +#include "BLI_string.h" #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" @@ -1617,7 +1618,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"); @@ -1719,7 +1720,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 efc8ffe4c7d..c28b688e377 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -523,28 +523,28 @@ static void pose_slide_reset (tPoseSlideOp *pso) /* draw percentage indicator in header */ static void pose_slide_draw_status (tPoseSlideOp *pso) { - char statusStr[32]; - char mode[32]; + char status_str[32]; + char mode_str[32]; switch (pso->mode) { case POSESLIDE_PUSH: - strcpy(mode, "Push Pose"); + strcpy(mode_str, "Push Pose"); break; case POSESLIDE_RELAX: - strcpy(mode, "Relax Pose"); + strcpy(mode_str, "Relax Pose"); break; case POSESLIDE_BREAKDOWN: - strcpy(mode, "Breakdown"); + strcpy(mode_str, "Breakdown"); break; default: // unknown - strcpy(mode, "Sliding-Tool"); + strcpy(mode_str, "Sliding-Tool"); break; } - sprintf(statusStr, "%s: %d %%", mode, (int)(pso->percentage*100.0f)); - ED_area_headerprint(pso->sa, statusStr); + BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f)); + ED_area_headerprint(pso->sa, status_str); } /* common code for invoke() methods */ 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/poseobject.c b/source/blender/editors/armature/poseobject.c index 832ee55997b..b14ce7e4690 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1777,7 +1777,7 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op) { Object *ob= object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; - char newname[32]; + char newname[MAXBONENAME]; short axis= RNA_enum_get(op->ptr, "axis"); /* paranoia checks */ diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 06225a38311..10a886edd7a 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -2036,10 +2036,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 db28b6b7fdf..22568cd676e 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/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 2e9186b6c2f..d345f16b768 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -62,7 +62,7 @@ typedef struct EditBone normal bones when leaving editmode. */ void *temp; /* Used to store temporary data */ - char name[32]; + char name[64]; /* MAX_NAME */ float roll; /* Roll along axis. We'll ultimately use the axis/angle method for determining the transformation matrix of the bone. The axis is tail-head while roll provides the angle. Refer to Graphics diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4948073f9c6..239dae7d236 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2920,7 +2920,7 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v) /* search if str matches the beginning of an ID struct */ if(str[0]) { - AutoComplete *autocpl= autocomplete_begin(str, 22); + AutoComplete *autocpl= autocomplete_begin(str, MAX_ID_NAME-2); ID *id; for(id= listb->first; id; id= id->next) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 84f0c61cd0c..5e42b06e1a7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1208,7 +1208,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s if(itemptr.type && RNA_struct_is_ID(itemptr.type)) { ID *id= itemptr.data; - char name_ui[32]; + char name_ui[MAX_ID_NAME]; #if 0 /* this name is used for a string comparison and can't be modified, TODO */ name_uiprefix_id(name_ui, id); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index c535f2c1ad0..973b43fca78 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2109,7 +2109,7 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu uiBut *but= arg_but; uiBlock *block; - block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS); + block= uiBeginBlock(C, handle->region, __func__, UI_EMBOSS); if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { @@ -2299,8 +2299,8 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut uiStyle *style= UI_GetStyle(); uiPopupBlockHandle *handle; uiPopupMenu *pup; - pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy"); - pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP); + pup= MEM_callocN(sizeof(uiPopupMenu), __func__); + pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); pup->but= but; @@ -2361,7 +2361,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; - pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP); + pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash= ui_popup_menu_hash(title); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); 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 2cf73eeea6d..44224c808cc 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -140,7 +140,7 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str, continue; if(BLI_strcasestr(id->name+2, str)) { - char name_ui[32]; + char name_ui[MAX_ID_NAME]; name_uiprefix_id(name_ui, id); iconid= ui_id_icon_get((bContext*)C, id, 1); @@ -413,11 +413,11 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str } if(id->us > 1) { - char str[32]; + char numstr[32]; - BLI_snprintf(str, sizeof(str), "%d", id->us); + BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); - but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, + but= uiDefBut(block, BUT, 0, numstr, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Display number of users of this data (click to make a single-user copy)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); @@ -1621,7 +1621,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu uiBut *bt; float width= 8*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); @@ -1680,7 +1680,7 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap uiBlock *block; short yco= 0, menuwidth=10*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); @@ -1702,7 +1702,7 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void uiBlock *block; short yco= 0, menuwidth=10*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); @@ -2281,7 +2281,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiBlock *block; uiBut *but; Panel *pa; - char *name, str[32]; + const char *name; + char numstr[32]; int rnaicon=0, icon=0, i= 0, activei= 0, len= 0, items, found, min, max; /* validate arguments */ @@ -2372,7 +2373,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiItemL(row, (name)? name: "", icon); if(name) - MEM_freeN(name); + MEM_freeN((void *)name); } i++; @@ -2385,8 +2386,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiItemL(row, "", ICON_NONE); /* next/prev button */ - BLI_snprintf(str, sizeof(str), "%d :", i); - but= uiDefIconTextButR_prop(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); + BLI_snprintf(numstr, sizeof(numstr), "%d :", i); + but= uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); if(i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } @@ -2470,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 57d46de9cb7..b8201d762df 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1507,7 +1507,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short static void scroll_printstr(Scene *scene, float x, float y, float val, int power, short unit, char dir) { int len; - char str[32]; + char timecode_str[32]; /* adjust the scale unit to work ok */ if (dir == 'v') { @@ -1522,10 +1522,10 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power } /* get string to print */ - ANIM_timecode_string_from_frame(str, scene, power, (unit == V2D_UNIT_SECONDS), val); + ANIM_timecode_string_from_frame(timecode_str, scene, power, (unit == V2D_UNIT_SECONDS), val); /* get length of string, and adjust printing location to fit it into the horizontal scrollbar */ - len= strlen(str); + len= strlen(timecode_str); if (dir == 'h') { /* seconds/timecode display has slightly longer strings... */ if (unit == V2D_UNIT_SECONDS) @@ -1536,12 +1536,12 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power /* Add degree sympbol to end of string for vertical scrollbar? */ if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) { - str[len]= 186; - str[len+1]= 0; + timecode_str[len]= 186; + timecode_str[len+1]= 0; } /* draw it */ - BLF_draw_default_ascii(x, y, 0.0f, str, sizeof(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/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 93ea76db569..8ba4bb15849 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -524,7 +524,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) Mesh *me; Object *obedit; int exitmode= 0; - char name[32]; + char name[MAX_ID_NAME-2]; /* Check context */ if(base==NULL || base->object->type!=OB_MESH) { @@ -593,7 +593,7 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Image name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 438d04ba69b..a2d73ac8b5d 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1922,7 +1922,7 @@ static int add_named_exec(bContext *C, wmOperator *op) Object *ob; int linked= RNA_boolean_get(op->ptr, "linked"); int dupflag= (linked)? 0: U.dupflag; - char name[32]; + char name[MAX_ID_NAME-2]; /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); @@ -1977,7 +1977,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data"); - RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add"); + RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add"); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 8266f3501c5..ac73f03c2d7 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -542,7 +542,7 @@ static int edit_constraint_poll(bContext *C) static void edit_constraint_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "constraint", "", 32, "Constraint", "Name of the constraint to edit"); + RNA_def_string(ot->srna, "constraint", "", MAX_NAME, "Constraint", "Name of the constraint to edit"); RNA_def_enum(ot->srna, "owner", constraint_owner_items, 0, "Owner", "The owner of this constraint"); } @@ -575,7 +575,7 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int type) { - char constraint_name[32]; + char constraint_name[MAX_NAME]; int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; ListBase *list=NULL; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 631dfce297a..ea39e857643 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1484,7 +1484,7 @@ static int game_property_new(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); bProperty *prop; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); prop= new_property(type); @@ -1517,7 +1517,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", gameproperty_type_items, 2, "Type", "Type of game property to add"); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the game property to add"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the game property to add"); } static int game_property_remove(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 74cf174d7b4..1b8c0fd0840 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -192,7 +192,7 @@ static int group_create_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Group *group= NULL; - char name[32]; /* id name */ + char name[MAX_ID_NAME-2]; /* id name */ RNA_string_get(op->ptr, "name", name); @@ -223,7 +223,7 @@ void GROUP_OT_create(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "Group", 32, "Name", "Name of the new group"); + RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME-2, "Name", "Name of the new group"); } /****************** properties window operators *********************/ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 925a59e8344..73bd8f433fd 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -432,7 +432,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o HookModifierData *hmd = NULL; float cent[3]; int tot, ok, *indexar; - char name[32]; + char name[MAX_NAME]; ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); @@ -752,7 +752,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) Object *ob=NULL; HookModifierData *hmd=NULL; float cent[3]; - char name[32]; + char name[MAX_NAME]; int *indexar, tot; if (ptr.data) { /* if modifier context is available, use that */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 069c211d639..1e7cd9f7624 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -740,7 +740,7 @@ static int edit_modifier_poll(bContext *C) static void edit_modifier_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "modifier", "", 32, "Modifier", "Name of the modifier to edit"); + RNA_def_string(ot->srna, "modifier", "", MAX_NAME, "Modifier", "Name of the modifier to edit"); } static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) @@ -762,7 +762,7 @@ static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) { - char modifier_name[32]; + char modifier_name[MAX_NAME]; ModifierData *md; RNA_string_get(op->ptr, "modifier", modifier_name); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 3daffe415d1..57c54f256d4 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -246,7 +246,7 @@ void ED_operatormacros_object(void) ot= WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { ot->description = "Add named object at cursor"; - RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add"); + RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add"); WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d"); WM_operatortype_macro_define(ot, "OBJECT_OT_add_named"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ca1293926bc..56fd1b4409a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -333,7 +333,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) if (ob) { Object *newob; Base *newbase, *oldbase= BASACT; - char name[32]; + char name[MAX_ID_NAME+4]; /* Add new object for the proxy */ newob= add_object(scene, OB_EMPTY); @@ -1888,7 +1888,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even Main *bmain= CTX_data_main(C); Base *base= ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; - char name[32]; + char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); ma= (Material *)find_id("MA", name); @@ -1921,5 +1921,5 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "Material", 24, "Name", "Material name to assign"); + RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME-2, "Name", "Material name to assign"); } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index b48b2e8718d..da69c2a0640 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -841,7 +841,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot) static int object_select_same_group_exec(bContext *C, wmOperator *op) { Group *group; - char group_name[32]; + char group_name[MAX_ID_NAME]; /* passthrough if no objects are visible */ if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH; @@ -882,7 +882,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "group", "", 32, "Group", "Name of the group to select"); + RNA_def_string(ot->srna, "group", "", MAX_ID_NAME, "Group", "Name of the group to select"); } /**************************** Select Mirror ****************************/ 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/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index e14ba9b8c4f..694485f51f2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -236,7 +236,7 @@ typedef struct StrokeCache { float vertex_rotation; - char saved_active_brush_name[24]; + char saved_active_brush_name[MAX_ID_NAME]; int alt_smooth; float plane_trim_squared; diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 619e76e9e50..309b455e2a2 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -119,7 +119,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) } } { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, "dopesheet channel buttons", UI_EMBOSS); + uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y= (float)ACHANNEL_FIRST; diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 1c352b1cb21..6777e2c2d85 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -108,7 +108,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) buttons_context_compute(C, sbuts); - block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetHandleFunc(block, do_buttons_buttons, NULL); xco= ED_area_header_switchbutton(C, block, yco); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 1593ecd7cb8..0d1c312792a 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -75,20 +75,20 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) { uiStyle *style= UI_GetStyle(); int fontid= style->widget.uifont_id; - char str[32]; + char numstr[32]; float font_dims[2] = {0.0f, 0.0f}; /* frame number */ BLF_size(fontid, 11.0f, U.dpi); - BLI_snprintf(str, sizeof(str), "%d", sc->user.framenr); + BLI_snprintf(numstr, sizeof(numstr), "%d", sc->user.framenr); - BLF_width_and_height(fontid, str, &font_dims[0], &font_dims[1]); + BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]); glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); UI_ThemeColor(TH_TEXT); BLF_position(fontid, x+2.0f, y+2.0f, 0.0f); - BLF_draw(fontid, str, sizeof(str)); + BLF_draw(fontid, numstr, sizeof(numstr)); } static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Scene *scene) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 41aae64445a..c84a9d10ab4 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -118,7 +118,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) const int separator = 4; /* Additional locals. */ - char name[32]; + char uiblockstr[32]; int loadbutton; int fnumbuttons; int min_x = 10; @@ -134,8 +134,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) ARegion* artmp; /* Initialize UI block. */ - sprintf(name, "win %p", (void *)ar); - block = uiBeginBlock(C, ar, name, UI_EMBOSS); + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); + block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_file_buttons, NULL); /* exception to make space for collapsed region icon */ @@ -450,7 +450,7 @@ void file_draw_list(const bContext *C, ARegion *ar) struct FileList* files = sfile->files; struct direntry *file; ImBuf *imb; - uiBlock *block = uiBeginBlock(C, ar, "FileNames", UI_EMBOSS); + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); int numfiles; int numfiles_layout; int sx, sy; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 288ff76d9ff..32fe8498eaf 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -970,7 +970,7 @@ int filelist_islibrary(struct FileList* filelist, char* dir, char* group) return BLO_is_a_library(filelist->dir, dir, group); } -static int groupname_to_code(char *group) +static int groupname_to_code(const char *group) { char buf[32]; char *lslash; @@ -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_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 7091fe094c6..7bdb37d9651 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1003,7 +1003,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) } } { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, "graph channel buttons", UI_EMBOSS); + uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y= (float)ACHANNEL_FIRST; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 8d8c79386c5..43bea1c311d 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -335,7 +335,7 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI return; } - block= uiBeginBlock(C, ar, "image_panel_preview", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc @@ -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_ops.c b/source/blender/editors/space_logic/logic_ops.c index ce6b7d2e910..b0f5e786eef 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -88,8 +88,8 @@ static int edit_actuator_poll(bContext *C) static void edit_sensor_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "sensor", "", 32, "Sensor", "Name of the sensor to edit"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the object the sensor belongs to"); + RNA_def_string(ot->srna, "sensor", "", MAX_NAME, "Sensor", "Name of the sensor to edit"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the sensor belongs to"); } static int edit_sensor_invoke_properties(bContext *C, wmOperator *op) @@ -113,14 +113,14 @@ static int edit_sensor_invoke_properties(bContext *C, wmOperator *op) static Object *edit_object_property_get(bContext *C, wmOperator *op) { - char ob_name[32]; + char ob_name[MAX_NAME]; Object *ob; RNA_string_get(op->ptr, "object", ob_name); /* if ob_name is valid try to find the object with this name otherwise gets the active object */ - if (BLI_strnlen(ob_name, 32) > 0) + if (BLI_strnlen(ob_name, MAX_NAME) > 0) ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); else ob= ED_object_active_context(C); @@ -130,7 +130,7 @@ static Object *edit_object_property_get(bContext *C, wmOperator *op) static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **ob) { - char sensor_name[32]; + char sensor_name[MAX_NAME]; bSensor *sens; RNA_string_get(op->ptr, "sensor", sensor_name); @@ -144,8 +144,8 @@ static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **o static void edit_controller_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "controller", "", 32, "Controller", "Name of the controller to edit"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the object the controller belongs to"); + RNA_def_string(ot->srna, "controller", "", MAX_NAME, "Controller", "Name of the controller to edit"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the controller belongs to"); } static int edit_controller_invoke_properties(bContext *C, wmOperator *op) @@ -169,7 +169,7 @@ static int edit_controller_invoke_properties(bContext *C, wmOperator *op) static bController *edit_controller_property_get(bContext *C, wmOperator *op, Object **ob) { - char controller_name[32]; + char controller_name[MAX_NAME]; bController *cont; RNA_string_get(op->ptr, "controller", controller_name); @@ -183,8 +183,8 @@ static bController *edit_controller_property_get(bContext *C, wmOperator *op, Ob static void edit_actuator_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "actuator", "", 32, "Actuator", "Name of the actuator to edit"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the object the actuator belongs to"); + RNA_def_string(ot->srna, "actuator", "", MAX_NAME, "Actuator", "Name of the actuator to edit"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the actuator belongs to"); } static int edit_actuator_invoke_properties(bContext *C, wmOperator *op) @@ -208,7 +208,7 @@ static int edit_actuator_invoke_properties(bContext *C, wmOperator *op) static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object **ob) { - char actuator_name[32]; + char actuator_name[MAX_NAME]; bActuator *act; RNA_string_get(op->ptr, "actuator", actuator_name); @@ -278,7 +278,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op) PointerRNA sens_ptr; PropertyRNA *prop; const char *sens_name; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); @@ -293,7 +293,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&sens_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if(BLI_strnlen(name, 32) < 1){ + if(BLI_strnlen(name, MAX_NAME) < 1){ RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name); BLI_strncpy(sens->name, sens_name, sizeof(sens->name)); } @@ -328,8 +328,8 @@ static void LOGIC_OT_sensor_add(wmOperatorType *ot) /* properties */ ot->prop= prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add"); RNA_def_enum_funcs(prop, rna_Sensor_type_itemf); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Sensor to add"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the Object to add the Sensor to"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Sensor to add"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Sensor to"); } /* ************* Add/Remove Controller Operator ************* */ @@ -382,7 +382,7 @@ static int controller_add_exec(bContext *C, wmOperator *op) PropertyRNA *prop; const char *cont_name; int bit; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); @@ -397,7 +397,7 @@ static int controller_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&cont_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if(BLI_strnlen(name, 32) < 1){ + if(BLI_strnlen(name, MAX_NAME) < 1){ RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name); BLI_strncpy(cont->name, cont_name, sizeof(cont->name)); } @@ -442,8 +442,8 @@ static void LOGIC_OT_controller_add(wmOperatorType *ot) /* properties */ ot->prop= RNA_def_enum(ot->srna, "type", controller_type_items, CONT_LOGIC_AND, "Type", "Type of controller to add"); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Controller to add"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the Object to add the Controller to"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Controller to add"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Controller to"); } /* ************* Add/Remove Actuator Operator ************* */ @@ -495,7 +495,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op) PointerRNA act_ptr; PropertyRNA *prop; const char *act_name; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); @@ -510,7 +510,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&act_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if (BLI_strnlen(name, 32) < 1){ + if (BLI_strnlen(name, MAX_NAME) < 1){ RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name); BLI_strncpy(act->name, act_name, sizeof(act->name)); } @@ -545,8 +545,8 @@ static void LOGIC_OT_actuator_add(wmOperatorType *ot) /* properties */ ot->prop= prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add"); RNA_def_enum_funcs(prop, rna_Actuator_type_itemf); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Actuator to add"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the Object to add the Actuator to"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Actuator to add"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Actuator to"); } /* ************* Move Logic Bricks Operator ************* */ diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index e5255448ae9..2c1e7a0c546 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1187,7 +1187,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short ts= sens->data; - /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */ + /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); */ uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); ///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); yco-= ysize; @@ -1216,11 +1216,11 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short if (cs->mode & SENS_COLLISION_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)), - (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, 31, 0, 0, + (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, MAX_NAME, 0, 0, "Only look for Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44), - (short)(0.6*(width-20)), 19, &cs->name, 0, 31, 0, 0, + (short)(0.6*(width-20)), 19, &cs->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); } @@ -1240,7 +1240,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short ns= sens->data; uiDefBut(block, TEX, 1, "Property:",(short)(10+xco),(short)(yco-44), (short)(width-20), 19, - &ns->name, 0, 31, 0, 0, "Only look for Objects with this property"); + &ns->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); uiDefButF(block, NUM, 1, "Dist",(short)(10+xco),(short)(yco-68),(short)((width-22)/2), 19, &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance"); uiDefButF(block, NUM, 1, "Reset",(short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19, @@ -1261,7 +1261,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short uiDefBut(block, TEX, 1, "Prop:", (short)(10+xco),(short)(yco-44), (short)(0.7 * (width-20)), 19, - &rs->name, 0, 31, 0, 0, + &rs->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); str = "Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5"; @@ -1316,14 +1316,14 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short /* line 4: toggle property for string logging mode */ uiDefBut(block, TEX, 1, "LogToggle: ", xco+10, yco-((ks->type&1) ? 68:92), (width-20), 19, - ks->toggleName, 0, 31, 0, 0, + ks->toggleName, 0, MAX_NAME, 0, 0, "Property that indicates whether to log " "keystrokes as a string"); /* line 5: target property for string logging mode */ uiDefBut(block, TEX, 1, "Target: ", xco+10, yco-((ks->type&1) ? 92:116), (width-20), 19, - ks->targetName, 0, 31, 0, 0, + ks->targetName, 0, MAX_NAME, 0, 0, "Property that receives the keystrokes in case " "a string is logged"); @@ -1349,21 +1349,21 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short if (ps->type != SENS_PROP_EXPRESSION) { uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-68,width-60, 19, - ps->name, 0, 31, 0, 0, "Property name"); + ps->name, 0, MAX_NAME, 0, 0, "Property name"); } if(ps->type == SENS_PROP_INTERVAL) { uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19, - ps->value, 0, 31, 0, 0, "check for min value"); + ps->value, 0, MAX_NAME, 0, 0, "check for min value"); uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19, - ps->maxvalue, 0, 31, 0, 0, "check for max value"); + ps->maxvalue, 0, MAX_NAME, 0, 0, "check for max value"); } else if(ps->type == SENS_PROP_CHANGED); else { uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-92,width-60, 19, - ps->value, 0, 31, 0, 0, "check for value"); + ps->value, 0, MAX_NAME, 0, 0, "check for value"); } yco-= ysize; @@ -1384,12 +1384,12 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short uiBlockBeginAlign(block); but = uiDefBut(block, TEX, 1, "Bone: ", (xco+10), (yco-44), (width-20)/2, 19, - arm->posechannel, 0, 31, 0, 0, + arm->posechannel, 0, MAX_NAME, 0, 0, "Bone on which you want to check a constraint"); uiButSetFunc(but, check_armature_sensor, but, arm); but = uiDefBut(block, TEX, 1, "Cons: ", (xco+10)+(width-20)/2, (yco-44), (width-20)/2, 19, - arm->constraint, 0, 31, 0, 0, + arm->constraint, 0, MAX_NAME, 0, 0, "Name of the constraint you want to control"); uiButSetFunc(but, check_armature_sensor, but, arm); uiBlockEndAlign(block); @@ -1420,7 +1420,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short as= sens->data; uiDefBut(block, TEX, 1, "Act: ", xco+30,yco-44,width-60, 19, - as->name, 0, 31, 0, 0, "Actuator name, actuator active state modifications will be detected"); + as->name, 0, MAX_NAME, 0, 0, "Actuator name, actuator active state modifications will be detected"); yco-= ysize; break; } @@ -1513,13 +1513,13 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short if (raySens->mode & SENS_COLLISION_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->matname, 0, 31, 0, 0, + &raySens->matname, 0, MAX_NAME, 0, 0, "Only look for Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->propname, 0, 31, 0, 0, + &raySens->propname, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); } @@ -1557,7 +1557,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short /* line 2: Subject filter */ uiDefBut(block, TEX, 1, "Subject: ", (xco+10), (yco-44), (width-20), 19, - mes->subject, 0, 31, 0, 0, + mes->subject, 0, MAX_NAME, 0, 0, "Optional subject filter: only accept messages with this subject" ", or empty for all"); @@ -1683,7 +1683,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco ec= cont->data; /* uiDefBut(block, BUT, 1, "Variables", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */ uiDefBut(block, TEX, 1, "Exp:", xco + 10 , yco-21, width-20, 19, - ec->str, 0, 127, 0, 0, + ec->str, 0, sizeof(ec->str), 0, 0, "Expression"); yco-= ysize; @@ -1704,7 +1704,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco if(pc->mode==0) uiDefIDPoinBut(block, test_scriptpoin_but, ID_TXT, 1, "", xco+70,yco-23,width-74, 19, &pc->text, "Blender textblock to run as a script"); else { - uiDefBut(block, TEX, 1, "", xco+70,yco-23,(width-70)-25, 19, pc->module, 0, 63, 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); + uiDefBut(block, TEX, 1, "", xco+70,yco-23,(width-70)-25, 19, pc->module, 0, sizeof(pc->module), 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); uiDefButBitI(block, TOG, CONT_PY_DEBUG, B_REDR, "D", (xco+width)-25, yco-23, 19, 19, &pc->flag, 0, 0, 0, 0, "Continuously reload the module from disk for editing external modules without restarting"); } uiBlockEndAlign(block); @@ -2032,7 +2032,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if(aa->type == ACT_ACTION_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); + uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Action position"); } else { @@ -2043,7 +2043,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending"); uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack"); - uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign the action's current frame number to this property"); + uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property"); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR @@ -2094,7 +2094,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if(ia->type==ACT_IPO_FROM_PROP) { uiDefBut(block, TEX, 0, "Prop: ", xco+10, yco-44, width-80, 19, - ia->name, 0.0, 31.0, 0, 0, + ia->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Ipo position"); } else { @@ -2113,7 +2113,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo "Update IPO on all children Objects as well"); uiDefBut(block, TEX, 0, "FrameProp: ", xco+10, yco-64, width-20, 19, - ia->frameProp, 0.0, 31.0, 0, 0, + ia->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property"); yco-= ysize; @@ -2131,7 +2131,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3"; uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); - uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); + uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, MAX_NAME, 0, 0, "Property name"); if(pa->type==ACT_PROP_TOGGLE) { @@ -2140,10 +2140,10 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo } else if(pa->type==ACT_PROP_COPY) { uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); - uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); + uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, MAX_NAME, 0, 0, "Copy this property"); } else { - uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, 31, 0, 0, "change with this value, use \"\" around strings"); + uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, MAX_NAME, 0, 0, "change with this value, use \"\" around strings"); } yco-= ysize; @@ -2175,7 +2175,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|" "Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,wval-20,19, - ((ID *)sa->sound)->name+2, 0.0, 21.0, 0, 0, ""); + ((ID *)sa->sound)->name+2, 0.0, MAX_ID_NAME-2, 0, 0, ""); uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->volume, @@ -2397,13 +2397,13 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if (coa->flag & ACT_CONST_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detects only Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detect only Objects with this property"); } uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, @@ -2456,13 +2456,13 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if (coa->flag & ACT_CONST_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detects only Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detect only Objects with this property"); } uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, @@ -2554,8 +2554,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo ysize = 48; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); -// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); +// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation"); } /* else if (gma->type == ACT_GAME_START) { @@ -2563,8 +2563,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); - uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this file"); + uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation"); } */ else if (ELEM4(gma->type, ACT_GAME_RESTART, ACT_GAME_QUIT, ACT_GAME_SAVECFG, ACT_GAME_LOADCFG)) { @@ -2592,11 +2592,11 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); if(ga->type==ACT_GROUP_SET) { - uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, 31.0, 0, 0, "This name defines groupkey to be set"); + uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, MAX_NAME, 0, 0, "This name defines groupkey to be set"); uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); } else if(ga->type==ACT_GROUP_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, 31.0, 0, 0, "Use this property to define the Group position"); + uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Group position"); } else { uiDefButI(block, NUM, 0, "State", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame"); @@ -2698,7 +2698,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo /* 3. property */ uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19, - &randAct->propname, 0, 31, 0, 0, + &randAct->propname, 0, MAX_NAME, 0, 0, "Assign the random value to this property"); /*4. and 5. arguments for the distribution*/ @@ -2789,13 +2789,13 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo /* line 1: To */ uiDefBut(block, TEX, 1, "To: ", (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->toPropName, 0, 31, 0, 0, + &ma->toPropName, 0, MAX_NAME, 0, 0, "Optional send message to objects with this name only, or empty to broadcast"); /* line 2: Message Subject */ uiDefBut(block, TEX, 1, "Subject: ", (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->subject, 0, 31, 0, 0, + &ma->subject, 0, MAX_NAME, 0, 0, "Optional message subject. This is what can be filtered on"); /* line 3: Text/Property */ @@ -2809,14 +2809,14 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo /* line 3: Message Body */ uiDefBut(block, TEX, 1, "Body: ", (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, - &ma->body, 0, 31, 0, 0, + &ma->body, 0, MAX_NAME, 0, 0, "Optional message body Text"); } else { /* line 3: Property body (set by property) */ uiDefBut(block, TEX, 1, "Propname: ", (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, - &ma->body, 0, 31, 0, 0, + &ma->body, 0, MAX_NAME, 0, 0, "The message body will be set by the Property Value"); } @@ -2923,12 +2923,12 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiBlockBeginAlign(block); but = uiDefBut(block, TEX, 1, "Bone: ", (xco+5), (yco-44), (width-10)/2, 19, - armAct->posechannel, 0, 31, 0, 0, + armAct->posechannel, 0, MAX_NAME, 0, 0, "Bone on which the constraint is defined"); uiButSetFunc(but, check_armature_actuator, but, armAct); but = uiDefBut(block, TEX, 1, "Cons: ", (xco+5)+(width-10)/2, (yco-44), (width-10)/2, 19, - armAct->constraint, 0, 31, 0, 0, + armAct->constraint, 0, MAX_NAME, 0, 0, "Name of the constraint you want to control"); uiButSetFunc(but, check_armature_actuator, but, armAct); uiBlockEndAlign(block); @@ -2999,7 +2999,7 @@ static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) uiBlock *block; int yco=0; - block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_sensor_menu, NULL); uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3048,7 +3048,7 @@ static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) uiBlock *block; int yco=0; - block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_controller_menu, NULL); uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3097,7 +3097,7 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) uiBlock *block; int xco=0; - block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_actuator_menu, NULL); uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3143,7 +3143,7 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c short yco = 12, xco = 0, stbit, offset; - block= uiBeginBlock(C, ar, "Controller state mask", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); @@ -3191,7 +3191,7 @@ static uiBlock *object_state_mask_menu(bContext *C, ARegion *ar, void *arg_obj) uiBlock *block; short xco = 0; - block= uiBeginBlock(C, ar, "obstatemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_object_state_menu, arg_obj); uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -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); @@ -4488,7 +4488,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiLayout *layout, *row, *box; uiBlock *block; uiBut *but; - char name[32]; + char uiblockstr[32]; short a, count; int xco, yco, width; @@ -4497,8 +4497,8 @@ 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(name, "buttonswin %p", (void *)ar); - block= uiBeginBlock(C, ar, name, UI_EMBOSS); + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar); + block= uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_logic_buts, NULL); /* loop over all objects and set visible/linked flags for the logic bricks */ @@ -4802,7 +4802,7 @@ void logic_buttons(bContext *C, ARegion *ar) int a, iact, stbit, offset; int xco, yco, width, ycoo; short count; - char name[32]; + char numstr[32]; /* pin is a bool used for actuator and sensor drawing with states * pin so changing states dosnt hide the logic brick */ char pin; @@ -4815,8 +4815,8 @@ void logic_buttons(bContext *C, ARegion *ar) if(ob==NULL) return; // uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - sprintf(name, "buttonswin %p", (void *)ar); - block= uiBeginBlock(C, ar, name, UI_EMBOSS); + BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); + block= uiBeginBlock(C, ar, numstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_logic_buts, NULL); RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); @@ -4932,13 +4932,13 @@ void logic_buttons(bContext *C, ARegion *ar) uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Controller settings"); uiDefIconButBitS(block, TOG, CONT_PRIO, B_REDR, ICON_BOOKMARKS, (short)(xco+width-66), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Mark controller for execution before all non-marked controllers (good for startup scripts)"); - sprintf(name, "%d", first_bit(cont->state_mask)+1); - uiDefBlockBut(block, controller_state_mask_menu, cont, name, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); + sprintf(numstr, "%d", first_bit(cont->state_mask)+1); + uiDefBlockBut(block, controller_state_mask_menu, cont, numstr, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); if(cont->flag & CONT_SHOW) { cont->otype= cont->type; uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 70, UI_UNIT_Y, &cont->type, 0, 0, 0, 0, "Controller type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, 31, 0, 0, "Controller name"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, MAX_NAME, 0, 0, "Controller name"); uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0); ycoo= yco; @@ -5030,7 +5030,7 @@ void logic_buttons(bContext *C, ARegion *ar) if(sens->flag & SENS_SHOW) { uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 80, UI_UNIT_Y, &sens->type, 0, 0, 0, 0, "Sensor type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, 31, 0, 0, "Sensor name"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, MAX_NAME, 0, 0, "Sensor name"); uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0); sens->otype= sens->type; @@ -5042,7 +5042,7 @@ void logic_buttons(bContext *C, ARegion *ar) glRecti(xco+22, yco, xco+width-22,yco+19); but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 80, UI_UNIT_Y, sens, 0, 0, 0, 0, ""); //uiButSetFunc(but, old_sca_move_sensor, sens, NULL); - but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, 31, 0, 0, ""); + but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, MAX_NAME, 0, 0, ""); //uiButSetFunc(but, old_sca_move_sensor, sens, NULL); uiBlockBeginAlign(block); @@ -5108,7 +5108,7 @@ void logic_buttons(bContext *C, ARegion *ar) if(act->flag & ACT_SHOW) { act->otype= act->type; uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, UI_UNIT_Y, &act->type, 0, 0, 0, 0, "Actuator type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, 31, 0, 0, "Actuator name"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, MAX_NAME, 0, 0, "Actuator name"); uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); ycoo= yco; diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 6af43e7618d..d7a1053f3c1 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -514,7 +514,7 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V { const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ const char col[4] = {220, 220, 220, 255}; /* light grey */ - char str[32] = ""; + char numstr[32] = ""; /* Always draw times above the strip, whereas sequencer drew below + above. @@ -524,12 +524,12 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V * while also preserving some accuracy, since we do use floats */ /* start frame */ - BLI_snprintf(str, sizeof(str), "%.1f", strip->start); - UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col); + BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start); + UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, numstr, col); /* end frame */ - BLI_snprintf(str, sizeof(str), "%.1f", strip->end); - UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, str, col); + BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end); + UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, numstr, col); } /* ---------------------- */ @@ -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; @@ -958,7 +958,7 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar) draw_nla_channel_list_gl(ac, &anim_data, v2d, y); } { /* second pass: UI widgets */ - uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS); + uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y= (float)(-NLACHANNEL_HEIGHT(snla)); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 6c0cc15559c..3f8d9a75244 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -132,7 +132,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) uiBlock *block; uiLayout *layout; - block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, UI_GetStyle()), 0); @@ -631,7 +631,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket * if (sock->flag & SOCK_DYNAMIC) { bt = uiDefBut(gnode->block, TEX, 0, "", sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY, - sock->name, 0, 31, 0, 0, ""); + sock->name, 0, sizeof(sock->name), 0, 0, ""); if (in_out==SOCK_IN) uiButSetFunc(bt, update_group_input_cb, snode, ngroup); else @@ -640,7 +640,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket * else { uiDefBut(gnode->block, LABEL, 0, sock->name, sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY, - NULL, 0, 31, 0, 0, ""); + NULL, 0, sizeof(sock->name), 0, 0, ""); } } @@ -1203,10 +1203,10 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ Scene *scene= CTX_data_scene(C); ImageUser *iuser= node->storage; - char tstr[32]; + char numstr[32]; const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); - BLI_snprintf(tstr, sizeof(tstr), "Frame: %d", framenr); - uiItemL(layout, tstr, ICON_NONE); + BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr); + uiItemL(layout, numstr, ICON_NONE); } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { @@ -2308,7 +2308,7 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int 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)); @@ -2317,14 +2317,14 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int #if 0 /* XXX no Z value in compo backdrop atm */ 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); @@ -2334,33 +2334,33 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int 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); @@ -2368,11 +2368,11 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int 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); @@ -2440,12 +2440,12 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int 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); @@ -2460,22 +2460,22 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int 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_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index da7f22b2030..a82ea9e9046 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -195,18 +195,18 @@ static void node_scaling_widget(int color_id, float aspect, float xmin, float ym static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) { bNode *node; - char str[32]; + char uiblockstr[32]; /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - for(node= ntree->nodes.first; node; node=node->next) { - /* ui block */ - sprintf(str, "node buttons %p", (void *)node); - node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); - uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); - - /* this cancels events for background nodes */ - uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS); + for (node= ntree->nodes.first; node; node= node->next) { + /* ui block */ + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); + node->block= uiBeginBlock(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); + uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); + + /* this cancels events for background nodes */ + uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS); } } @@ -673,7 +673,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if(node->flag & NODE_MUTED) - // sprintf(showname, "[%s]", showname); + // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - dont print into self! uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(rct->ymax-NODE_DY), (int)(iconofs - rct->xmin-18.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); @@ -835,7 +835,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if(node->flag & NODE_MUTED) - // sprintf(showname, "[%s]", showname); + // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - dont print into self! uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(centy-10), (int)(rct->xmax - rct->xmin-18.0f -12.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1fe754466f4..3523e6bd9ab 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -751,7 +751,7 @@ static int edit_node_poll(bContext *C) static void edit_node_properties(wmOperatorType *ot) { /* XXX could node be a context pointer? */ - RNA_def_string(ot->srna, "node", "", 32, "Node", ""); + RNA_def_string(ot->srna, "node", "", MAX_NAME, "Node", ""); RNA_def_int(ot->srna, "socket", 0, 0, MAX_SOCKET, "Socket", "", 0, MAX_SOCKET); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Side", ""); } @@ -779,7 +779,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r { bNode *node; bNodeSocket *sock=NULL; - char nodename[32]; + char nodename[MAX_NAME]; int sockindex; int in_out; @@ -889,7 +889,7 @@ static int node_group_socket_add_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); int in_out= -1; - char name[32]= ""; + char name[MAX_NAME]= ""; int type= SOCK_FLOAT; bNodeTree *ngroup= snode->edittree; /* bNodeSocket *sock; */ /* UNUSED */ @@ -932,7 +932,7 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Group socket name"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Group socket name"); RNA_def_enum(ot->srna, "type", node_socket_type_items, SOCK_FLOAT, "Type", "Type of the group socket"); } @@ -3451,7 +3451,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) } else if(RNA_property_is_set(op->ptr, "name")) { - char name[32]; + char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); ima= (Image *)find_id("IM", name); @@ -3517,7 +3517,7 @@ void NODE_OT_add_file(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path - RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Datablock name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign"); } /********************** New node tree operator *********************/ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f3bab197b3c..71cb83ad231 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1649,7 +1649,7 @@ void draw_outliner(const bContext *C) /* draw outliner stuff (background, hierachy lines and names) */ outliner_back(ar); - block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { 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_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 084e48c0d6e..a45b493ffb3 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1342,7 +1342,7 @@ static int outliner_filter_has_name(TreeElement *te, const char *name, int flags } else { char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; - sprintf(fn_name, "*%s*", name); + BLI_snprintf(fn_name, sizeof(fn_name), "*%s*", name); found= fnmatch(fn_name, te->name, fn_flag)==0; } return found; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2b59a02deae..176ffd91e3b 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -328,7 +328,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire float x1, x2, y1, y2; float handsize; float minhandle, maxhandle; - char str[32]; + char numstr[32]; unsigned int whichsel=0; x1= seq->startdisp; @@ -392,15 +392,15 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire if(G.moving || (seq->flag & whichsel)) { const char col[4]= {255, 255, 255, 255}; if (direction == SEQ_LEFTHANDLE) { - sprintf(str, "%d", seq->startdisp); + BLI_snprintf(numstr, sizeof(numstr),"%d", seq->startdisp); x1= rx1; y1 -= 0.45f; } else { - sprintf(str, "%d", seq->enddisp - 1); + BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); x1= x2 - handsize*0.75f; y1= y2 + 0.05f; } - UI_view2d_text_cache_add(v2d, x1, y1, str, col); + UI_view2d_text_cache_add(v2d, x1, y1, numstr, col); } } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 637c8fcdbcf..25b9c2f2864 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); } @@ -1766,7 +1766,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) else UI_ThemeColor(TH_TEXT); - sprintf(linenr, "%*d", st->linenrs_tot, i + linecount + 1); + BLI_snprintf(linenr, sizeof(linenr), "%*d", st->linenrs_tot, i + linecount + 1); /* itoa(i + linecount + 1, linenr, 10); */ /* not ansi-c :/ */ text_font_draw(st, TXT_OFFSET - 7, y, linenr); diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 1784d949761..638bf5b41a7 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -218,23 +218,23 @@ void draw_motion_path_instance(Scene *scene, col[3]= 255; for (i=0, mpv=mpv_start; i < len; i+=stepsize, mpv+=stepsize) { - char str[32]; + char numstr[32]; float co[3]; /* only draw framenum if several consecutive highlighted points don't occur on same point */ if (i == 0) { - sprintf(str, "%d", (i+sfra)); + sprintf(numstr, "%d", (i+sfra)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); } else if ((i > stepsize) && (i < len-stepsize)) { bMotionPathVert *mpvP = (mpv - stepsize); bMotionPathVert *mpvN = (mpv + stepsize); if ((equals_v3v3(mpv->co, mpvP->co)==0) || (equals_v3v3(mpv->co, mpvN->co)==0)) { - sprintf(str, "%d", (sfra+i)); + sprintf(numstr, "%d", (sfra+i)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); } } } @@ -293,11 +293,11 @@ void draw_motion_path_instance(Scene *scene, float mframe= (float)(sfra + i); if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) { - char str[32]; + char numstr[32]; - sprintf(str, "%d", (sfra+i)); + sprintf(numstr, "%d", (sfra+i)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); } } } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 8e65fc5a15c..f2c8fafb8b8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -576,7 +576,7 @@ static int draw_em_tf_mapped__set_draw(void *userData, int index) } } -static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r) +static int wpaint__setSolidDrawOptions_material(void *userData, int index, int *drawSmooth_r) { Mesh *me = (Mesh*)userData; @@ -591,6 +591,16 @@ static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmoot return 1; } +/* when face select is on, use face hidden flag */ +static int wpaint__setSolidDrawOptions_facemask(void *userData, int index, int *drawSmooth_r) +{ + Mesh *me = (Mesh*)userData; + MFace *mface = &me->mface[index]; + if (mface->flag & ME_HIDE) return 0; + *drawSmooth_r = 1; + return 1; +} + static void draw_mesh_text(Scene *scene, Object *ob, int glsl) { Mesh *me = ob->data; @@ -729,7 +739,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec } else if(draw_flags & DRAW_FACE_SELECT) { if(ob->mode & OB_MODE_WEIGHT_PAINT) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me, 1); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, 1); else dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me); } @@ -888,7 +898,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* weight paint mode exception */ int useColors= 1; - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_material, GPU_enable_material, NULL, ob->data, useColors); } else { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5c33a138ad9..e3f65bbafdf 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2719,7 +2719,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS { Mesh *me= ob->data; float v1[3], v2[3], v3[3], vmid[3], fvec[3]; - char val[32]; /* Stores the measurement display text here */ + char numstr[32]; /* Stores the measurement display text here */ const char *conv_float; /* Use a float conversion matching the grid size */ unsigned char col[4]= {0, 0, 0, 255}; /* color of the text to draw */ float area; /* area of the face */ @@ -2760,11 +2760,11 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_mat3_m4_v3(ob->obmat, v2); } if(unit->system) - bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); + bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); else - sprintf(val, conv_float, len_v3v3(v1, v2)); + sprintf(numstr, conv_float, len_v3v3(v1, v2)); - view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(vmid, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } } } @@ -2775,15 +2775,15 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS BMFace *f; int n; -#define DRAW_EM_MEASURE_STATS_FACEAREA()\ - if (BM_TestHFlag(f, BM_SELECT)) {\ - mul_v3_fl(vmid, 1.0/n);\ - if(unit->system)\ - bUnit_AsString(val, sizeof(val), area*unit->scale_length,\ - 3, unit->system, B_UNIT_LENGTH, do_split, FALSE);\ - else\ - sprintf(val, conv_float, area);\ - view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col);\ +#define DRAW_EM_MEASURE_STATS_FACEAREA() \ + if (BM_TestHFlag(f, BM_SELECT)) { \ + mul_v3_fl(vmid, 1.0/n); \ + if(unit->system) \ + bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length, \ + 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ + else \ + BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ + view3d_cached_text_draw_add(vmid, numstr, 0, V3D_CACHE_TEXT_ASCII, col); \ } UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); @@ -2851,11 +2851,12 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_mat3_m4_v3(ob->obmat, v3); } - if(BM_TestHFlag(efa, BM_SELECT) || - (do_moving && BM_TestHFlag(loop->v, BM_SELECT))){ - sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); + if ( (BM_TestHFlag(efa, BM_SELECT)) || + (do_moving && BM_TestHFlag(loop->v, BM_SELECT))) + { + BLI_snprintf(numstr, sizeof(numstr), "%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); interp_v3_v3v3(fvec, vmid, v2, 0.8f); - view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(fvec, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } } } @@ -2868,7 +2869,7 @@ static void draw_em_indices(BMEditMesh *em) BMFace *f; BMVert *v; int i; - char val[32]; + char numstr[32]; float pos[3]; unsigned char col[4]; @@ -2881,8 +2882,8 @@ static void draw_em_indices(BMEditMesh *em) UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(v, BM_SELECT)) { - sprintf(val, "%d", i); - view3d_cached_text_draw_add(v->co, val, 0, V3D_CACHE_TEXT_ASCII, col); + sprintf(numstr, "%d", i); + view3d_cached_text_draw_add(v->co, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } i++; } @@ -2893,9 +2894,9 @@ static void draw_em_indices(BMEditMesh *em) UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BM_TestHFlag(e, BM_SELECT)) { - sprintf(val, "%d", i); + sprintf(numstr, "%d", i); mid_v3_v3v3(pos, e->v1->co, e->v2->co); - view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(pos, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } i++; } @@ -2907,8 +2908,8 @@ static void draw_em_indices(BMEditMesh *em) BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(f, BM_SELECT)) { BM_Compute_Face_CenterMean(bm, f, pos); - sprintf(val, "%d", i); - view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col); + sprintf(numstr, "%d", i); + view3d_cached_text_draw_add(pos, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } i++; } @@ -4115,7 +4116,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0; int select=ob->flag&SELECT, create_cdata=0, need_v=0; GLint polygonmode[2]; - char val[32]; + char numstr[32]; unsigned char tcol[4]= {0, 0, 0, 255}; /* 1. */ @@ -4503,8 +4504,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0){ float vec_txt[3]; - char *val_pos= val; - val[0]= '\0'; + char *val_pos= numstr; + numstr[0]= '\0'; if(part->draw&PART_DRAW_NUM) { if(a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype==PART_PHYS_BOIDS)) { @@ -4523,7 +4524,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* in path drawing state.co is the end point */ /* use worldspace beause object matrix is already applied */ mul_v3_m4v3(vec_txt, ob->imat, state.co); - view3d_cached_text_draw_add(vec_txt, val, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); + view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); } } } @@ -4612,10 +4613,10 @@ 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(val, "%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, val, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); + 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_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 391b344df01..951aa1a5ebd 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1349,7 +1349,7 @@ static void view3d_panel_preview(bContext *C, ARegion *ar, short cntrl) // VIEW3 View3D *v3d= sa->spacedata.first; int ofsx, ofsy; - block= uiBeginBlock(C, ar, "view3d_panel_preview", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(VIEW3D_HANDLER_PREVIEW); // for close and esc diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3b355177852..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) @@ -2890,14 +2890,15 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha draw_viewport_name(ar, v3d); } if (grid_unit) { /* draw below the viewport name */ - char tstr[32]= ""; + char numstr[32]= ""; UI_ThemeColor(TH_TEXT_HI); if(v3d->grid != 1.0f) { - BLI_snprintf(tstr, sizeof(tstr), "%s x %.4g", grid_unit, v3d->grid); + 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, tstr[0]?tstr : grid_unit, sizeof(tstr)); /* 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/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index fa970f7f9d8..6e591a714e4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2960,7 +2960,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU View3D *v3d= CTX_wm_view3d(C); Image *ima= NULL; BGpic *bgpic; - char name[32]; + char name[MAX_ID_NAME-2]; /* check input variables */ if(RNA_property_is_set(op->ptr, "filepath")) { @@ -3007,7 +3007,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) ot->flag = 0; /* properties */ - RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Image name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 2ac7a520322..8a021922aa7 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2563,9 +2563,9 @@ static void headerResize(TransInfo *t, float vec[3], char *str) outputNumInput(&(t->num), tvec); } else { - sprintf(&tvec[0], "%.4f", vec[0]); - sprintf(&tvec[20], "%.4f", vec[1]); - sprintf(&tvec[40], "%.4f", vec[2]); + BLI_snprintf(&tvec[0], 20, "%.4f", vec[0]); + BLI_snprintf(&tvec[20], 20, "%.4f", vec[1]); + BLI_snprintf(&tvec[40], 20, "%.4f", vec[2]); } if (t->con.mode & CON_APPLY) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 44aaca6ff3f..090b12e401e 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -293,7 +293,7 @@ typedef struct TransInfo { char *undostr; /* if set, uses this string for undo */ float spacemtx[3][3]; /* orientation matrix of the current space */ - char spacename[32]; /* name of the current space */ + char spacename[64]; /* name of the current space, MAX_NAME */ struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ 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/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 90f95bea696..81a2b7158ee 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -268,7 +268,7 @@ static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot) static int create_orientation_exec(bContext *C, wmOperator *op) { - char name[36]; + char name[MAX_NAME]; int use = RNA_boolean_get(op->ptr, "use"); int overwrite = RNA_boolean_get(op->ptr, "overwrite"); @@ -301,7 +301,7 @@ static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot) ot->poll = ED_operator_areaactive; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "", 35, "Name", "Text to insert at the cursor position"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Text to insert at the cursor position"); RNA_def_boolean(ot->srna, "use", 0, "Use after creation", "Select orientation after its creation"); RNA_def_boolean(ot->srna, "overwrite", 0, "Overwrite previous", "Overwrite previously created orientation with same name"); } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 0fa38e016ed..0e3dfad7107 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -146,7 +146,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports) /* use object name if no name is given */ if (name[0] == 0) { - strncpy(name, ob->id.name+2, 35); + strncpy(name, ob->id.name+2, MAX_ID_NAME-2); } return addMatrixSpace(C, mat, name, overwrite); @@ -290,7 +290,7 @@ TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], { ts = MEM_callocN(sizeof(TransformOrientation), "UserTransSpace from matrix"); BLI_addtail(transform_spaces, ts); - strncpy(ts->name, name, 35); + strncpy(ts->name, name, sizeof(ts->name)); } /* copy matrix into transform space */ @@ -423,10 +423,11 @@ const char * BIF_menustringTransformOrientation(const bContext *C, const char *t TransformOrientation *ts; int i = V3D_MANIP_CUSTOM; char *str_menu, *p; + const int elem_size = MAX_NAME + 4; title = IFACE_(title); - str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + 40 * BIF_countTransformOrientation(C), TIP_("UserTransSpace from matrix")); + str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + elem_size * BIF_countTransformOrientation(C), TIP_("UserTransSpace from matrix")); p = str_menu; p += sprintf(str_menu, "%s", title); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 169135478f6..b46ca538896 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 6df7ce45a64..f3019448240 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -48,6 +48,7 @@ #include "BLI_uvproject.h" #include "BLI_utildefines.h" #include "BLI_rand.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -379,7 +380,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); } |