[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49844] trunk/blender/source/blender/ datatoc/datatoc.c: fix for own error in datatoc.c - data wasn' t NULL terminated, in some cases this is expected (broke GLSL shaders).

Campbell Barton ideasman42 at gmail.com
Sun Aug 12 18:51:52 CEST 2012


Revision: 49844
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49844
Author:   campbellbarton
Date:     2012-08-12 16:51:51 +0000 (Sun, 12 Aug 2012)
Log Message:
-----------
fix for own error in datatoc.c - data wasn't NULL terminated, in some cases this is expected (broke GLSL shaders).

Modified Paths:
--------------
    trunk/blender/source/blender/datatoc/datatoc.c

Modified: trunk/blender/source/blender/datatoc/datatoc.c
===================================================================
--- trunk/blender/source/blender/datatoc/datatoc.c	2012-08-12 16:19:37 UTC (rev 49843)
+++ trunk/blender/source/blender/datatoc/datatoc.c	2012-08-12 16:51:51 UTC (rev 49844)
@@ -81,19 +81,6 @@
 
 	sprintf(sizest, "%d", (int)size);
 
-#ifdef VERBOSE
-	printf("Input filesize is %d, Output size should be %d\n",
-	       (int)size,
-	       (int)(((int)size) * 4 +
-	             strlen("/* DataToC output of file <> */\n\n") +
-	             strlen("char datatoc_[] = {\"") +
-	             strlen("\"};\n") +
-	             (strlen(argv[1]) * 3) +
-	             strlen(sizest) +
-	             strlen("int datatoc__size = ;\n") +
-	             (((int)(size / 256) + 1) * 5)));
-#endif
-
 	fpout = fopen(argv[2], "w");
 	if (!fpout) {
 		fprintf(stderr, "Unable to open output <%s>\n", argv[2]);
@@ -104,6 +91,8 @@
 	fprintf(fpout, "int datatoc_%s_size = %s;\n", argv[1], sizest);
 	fprintf(fpout, "char datatoc_%s[] = {\n", argv[1]);
 	while (size--) {
+		/* if we want to open in an editor
+		 * this is nicer to avoid very long lines */
 #ifdef VERBOSE
 		if (size % 32 == 31) {
 			fprintf(fpout, "\n");
@@ -114,7 +103,10 @@
 		fprintf(fpout, "%3d,", getc(fpin));
 	}
 
-	fprintf(fpout, "\n};\n\n");
+	/* trailing NULL terminator, this isnt needed in some cases and
+	 * won't be taken into account by the size variable, but its useful when dealing with
+	 * NULL terminated string data */
+	fprintf(fpout, "0\n};\n\n");
 
 	fclose(fpin);
 	fclose(fpout);




More information about the Bf-blender-cvs mailing list