[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51779] trunk/blender/source/blender/ blenlib/intern/string_utf8.c:

Campbell Barton ideasman42 at gmail.com
Wed Oct 31 05:25:02 CET 2012


Revision: 51779
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51779
Author:   campbellbarton
Date:     2012-10-31 04:24:55 +0000 (Wed, 31 Oct 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/string_utf8.c

Modified: trunk/blender/source/blender/blenlib/intern/string_utf8.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string_utf8.c	2012-10-31 03:21:13 UTC (rev 51778)
+++ trunk/blender/source/blender/blenlib/intern/string_utf8.c	2012-10-31 04:24:55 UTC (rev 51779)
@@ -184,6 +184,8 @@
 {
 	char *dst_r = dst;
 
+	BLI_assert(maxncpy != 0);
+
 	/* note: currently we don't attempt to deal with invalid utf8 chars */
 	BLI_STR_UTF8_CPY(dst, src, maxncpy);
 
@@ -207,10 +209,13 @@
 /* --------------------------------------------------------------------------*/
 /* wchar_t / utf8 functions  */
 
-size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy)
+size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxncpy)
 {
 	size_t len = 0;
-	while (*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
+
+	BLI_assert(maxncpy != 0);
+
+	while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
 		len += BLI_str_utf8_from_unicode(*src++, dst + len);
 	}
 
@@ -280,7 +285,7 @@
 	return len;
 }
 
-size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxcpy)
+size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxncpy)
 {
 	int len = 0;
 
@@ -288,7 +293,7 @@
 		return 0;
 	}
 
-	while (*src_c && len < maxcpy) {
+	while (*src_c && len < maxncpy) {
 		size_t step = 0;
 		unsigned int unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step);
 		if (unicode != BLI_UTF8_ERR) {




More information about the Bf-blender-cvs mailing list