[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43284] trunk/blender/source: minor cleanup for string use - no functional changes

Campbell Barton ideasman42 at gmail.com
Wed Jan 11 10:33:56 CET 2012


Revision: 43284
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43284
Author:   campbellbarton
Date:     2012-01-11 09:33:44 +0000 (Wed, 11 Jan 2012)
Log Message:
-----------
minor cleanup for string use - no functional changes
- use more logical names for strings, noticed too many strings called `str` when reviewing name patch.
- pass __func__ macro to uiBeginBlock(), quite a few names were wrong (copy/paste error).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/editors/animation/anim_draw.c
    trunk/blender/source/blender/editors/armature/poseSlide.c
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/interface/view2d.c
    trunk/blender/source/blender/editors/space_action/action_draw.c
    trunk/blender/source/blender/editors/space_buttons/buttons_header.c
    trunk/blender/source/blender/editors/space_clip/clip_draw.c
    trunk/blender/source/blender/editors/space_file/file_draw.c
    trunk/blender/source/blender/editors/space_file/filelist.c
    trunk/blender/source/blender/editors/space_graph/graph_draw.c
    trunk/blender/source/blender/editors/space_image/image_buttons.c
    trunk/blender/source/blender/editors/space_logic/logic_window.c
    trunk/blender/source/blender/editors/space_nla/nla_draw.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_node/node_draw.c
    trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
    trunk/blender/source/blender/editors/space_view3d/drawanimviz.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/gpu/GPU_extensions.h
    trunk/blender/source/blender/gpu/intern/gpu_extensions.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c
    trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -1202,14 +1202,14 @@
 	}
 	
 	if (scene->r.stamp & R_STAMP_FRAME) {
-		char format[32];
+		char fmtstr[32];
 		int digits= 1;
 		
 		if(scene->r.efra>9)
 			digits= 1 + (int) log10(scene->r.efra);
 
-		BLI_snprintf(format, sizeof(format), do_prefix ? "Frame %%0%di":"%%0%di", digits);
-		BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), format, scene->r.cfra);
+		BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di":"%%0%di", digits);
+		BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra);
 	} else {
 		stamp_data->frame[0] = '\0';
 	}

Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/blenkernel/intern/library.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -991,7 +991,7 @@
 		ID *id;
 		
 		for (i=0, id= lb->first; id; id= id->next, i++) {
-			char buf[32];
+			char numstr[32];
 			
 			if (nr && id==link) *nr= i+1;
 
@@ -1002,12 +1002,12 @@
 					if ( ((Image *)id)->source==IMA_SRC_VIEWER )
 						continue;
 			
-			get_flags_for_id(id, buf);
+			get_flags_for_id(id, numstr);
 				
-			BLI_dynstr_append(pupds, buf);
+			BLI_dynstr_append(pupds, numstr);
 			BLI_dynstr_append(pupds, id->name+2);
-			BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1);
-			BLI_dynstr_append(pupds, buf);
+			BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i+1);
+			BLI_dynstr_append(pupds, numstr);
 			
 			/* icon */
 			switch(GS(id->name))
@@ -1017,8 +1017,8 @@
 			case ID_IM: /* fall through */
 			case ID_WO: /* fall through */
 			case ID_LA: /* fall through */
-				BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) );
-				BLI_dynstr_append(pupds, buf);
+				BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id) );
+				BLI_dynstr_append(pupds, numstr);
 				break;
 			default:
 				break;

Modified: trunk/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_draw.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/editors/animation/anim_draw.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -180,7 +180,7 @@
 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 @@
 	 *	  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 @@
 	
 	/* 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);

Modified: trunk/blender/source/blender/editors/armature/poseSlide.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseSlide.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/editors/armature/poseSlide.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -523,28 +523,28 @@
 /* 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);
+	sprintf(status_str, "%s: %d %%", mode_str, (int)(pso->percentage*100.0f));
+	ED_area_headerprint(pso->sa, status_str);
 }
 
 /* common code for invoke() methods */

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -2109,7 +2109,7 @@
 	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 @@
 	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 *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);

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -413,11 +413,11 @@
 		}
 
 		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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 					uiItemL(row, (name)? name: "", icon);
 
 					if(name)
-						MEM_freeN(name);
+						MEM_freeN((void *)name);
 				}
 
 				i++;
@@ -2385,8 +2386,8 @@
 			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);
 	}

Modified: trunk/blender/source/blender/editors/interface/view2d.c
===================================================================
--- trunk/blender/source/blender/editors/interface/view2d.c	2012-01-11 08:51:06 UTC (rev 43283)
+++ trunk/blender/source/blender/editors/interface/view2d.c	2012-01-11 09:33:44 UTC (rev 43284)
@@ -1507,7 +1507,7 @@
 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 @@
 	}
 	
 	/* get string to print */
-	ANIM_timecode_string_from_frame(str, scene, power, (unit == V2D_UNIT_SECONDS), val);

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list