From e10fd04db0bdcdbc326fce6cddc8af1179a5de5c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jan 2012 12:33:51 +0000 Subject: use BLI_strncpy and BLI_snprintf when the size of the string is known. fix for sequencer unique naming which was missed with string length update. --- source/blender/editors/interface/interface_style.c | 6 +++--- source/blender/editors/interface/interface_templates.c | 9 ++++++--- source/blender/editors/interface/view2d.c | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/interface') diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 0e9dbaf3022..16b543737d0 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -180,7 +180,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, if (fs->kerning == 1) BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); - BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */ + BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable(fs->uifont_id, BLF_CLIPPING); if (fs->shadow) BLF_disable(fs->uifont_id, BLF_SHADOW); @@ -243,7 +243,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) if (fs->kerning == 1) BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); - BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */ + BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable(fs->uifont_id, BLF_ROTATION); BLF_disable(fs->uifont_id, BLF_CLIPPING); if (fs->shadow) @@ -291,7 +291,7 @@ void UI_DrawString(float x, float y, const char *str) uiStyleFontSet(&style->widget); BLF_position(style->widget.uifont_id, x, y, 0.0f); - BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */ + BLF_draw(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); if (style->widget.kerning == 1) BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ccca0c8f7cf..379a253a5c9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2471,12 +2471,15 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char int len= strlen(ot->name); /* display name for menu, can hold hotkey */ - BLI_strncpy(name, ot->name, 256); + BLI_strncpy(name, ot->name, sizeof(name)); /* check for hotkey */ - if(len < 256-6) { - if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1)) + if(len < sizeof(name)-6) { + if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, + &name[len+1], sizeof(name)-len-1)) + { name[len]= '|'; + } } if(0==uiSearchItemAdd(items, name, ot, 0)) diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 81ea3370331..b8201d762df 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1541,7 +1541,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power } /* draw it */ - BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)-1); + BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)); } /* Draw scrollbars in the given 2d-region */ @@ -2093,11 +2093,11 @@ void UI_view2d_text_cache_draw(ARegion *ar) } if(v2s->rect.xmin >= v2s->rect.xmax) - BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, 65535); + BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX); else { BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4); BLF_enable_default(BLF_CLIPPING); - BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, 65535); + BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable_default(BLF_CLIPPING); } } -- cgit v1.2.3