From 5b678016c32b51441829dffbbd91b5aca7aefabd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Aug 2012 16:51:51 +0000 Subject: fix for own error in datatoc.c - data wasn't NULL terminated, in some cases this is expected (broke GLSL shaders). --- source/blender/datatoc/datatoc.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'source/blender/datatoc') diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c index d074917a545..a7da037ff16 100644 --- a/source/blender/datatoc/datatoc.c +++ b/source/blender/datatoc/datatoc.c @@ -81,19 +81,6 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) 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); -- cgit v1.2.3