All pastes #402168 Raw Edit

Stuff

public text v1 · immutable
·published 2007-03-19 19:17 UTC
rendered paste body
Index: source/blender/blenlib/BLI_blenlib.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/blenlib/BLI_blenlib.h,v
retrieving revision 1.24
diff -u -r1.24 BLI_blenlib.h
--- source/blender/blenlib/BLI_blenlib.h	28 Feb 2007 21:37:14 -0000	1.24
+++ source/blender/blenlib/BLI_blenlib.h	18 Mar 2007 19:57:33 -0000
@@ -69,6 +69,8 @@
 	because fillfacebase and fillvertbase are used outside */
 #include "DNA_listBase.h" 
 
+#include <stdlib.h>
+
 extern ListBase fillfacebase;
 extern ListBase fillvertbase;
 /**
@@ -195,6 +197,11 @@
 	 * @retval Returns dst
 	 */
 char* BLI_strncpy(char *dst, const char *src, int maxncpy);
+
+	/* 
+	 * Replacement for snprintf
+	 */
+int BLI_snprintf(char *buffer, size_t count, const char *format, ...);
 
 	/**
 	 * Compare two strings
Index: source/blender/src/editdeform.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editdeform.c,v
retrieving revision 1.40
diff -u -r1.40 editdeform.c
--- source/blender/src/editdeform.c	16 Mar 2007 11:29:40 -0000	1.40
+++ source/blender/src/editdeform.c	19 Mar 2007 19:15:27 -0000
@@ -217,14 +217,14 @@
 	if (!dg)
 		return;
 
-	snprintf (name, 32, "%s_copy", dg->name);
+	BLI_snprintf (name, 32, "%s_copy", dg->name);
 	while (get_named_vertexgroup (ob, name)) {
 		if ((strlen (name) + 6) > 32) {
 			error ("Error: the name for the new group is > 32 characters");
 			return;
 		}
 		strcpy (s, name);
-		snprintf (name, 32, "%s_copy", s);
+		BLI_snprintf (name, 32, "%s_copy", s);
 	}
 
 	cdg = copy_defgroup (dg);
Index: source/blender/blenlib/intern/util.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/blenlib/intern/util.c,v
retrieving revision 1.47
diff -u -r1.47 util.c
--- source/blender/blenlib/intern/util.c	17 Mar 2007 14:46:03 -0000	1.47
+++ source/blender/blenlib/intern/util.c	19 Mar 2007 18:45:29 -0000
@@ -40,6 +40,7 @@
 #include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "MEM_guardedalloc.h"
 
@@ -65,9 +66,16 @@
 
 #ifdef WIN32
 #include "BLI_winstuff.h"
+
+/* for duplicate_defgroup */
+#if !(defined vsnprintf)
+#define vsnprintf _vsnprintf
+#endif
+
 #endif
 
 
+
 #ifndef WIN32
 #include <sys/time.h>
 #endif
@@ -638,6 +646,24 @@
 	dst[cpylen]= '\0';
 	
 	return dst;
+}
+
+int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+{
+	int n;
+	va_list arg;
+
+	va_start(arg, format);
+	n = vsnprintf(buffer, count, format, arg);
+	
+	if (n != -1 && n < count) {
+		buffer[n] = '\0';
+	} else {
+		buffer[count-1] = '\0';
+	}
+	
+	va_end(arg);
+	return n;
 }