diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-12 20:51:51 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-12 20:51:51 +0400 |
commit | 5b678016c32b51441829dffbbd91b5aca7aefabd (patch) | |
tree | ee973a43294a29e0fde5e71165c314cd00123baa | |
parent | 32254596d4de9558b7af81bfe69db5d160a97769 (diff) |
fix for own error in datatoc.c - data wasn't NULL terminated, in some cases this is expected (broke GLSL shaders).
-rw-r--r-- | source/blender/datatoc/datatoc.c | 20 |
1 files changed, 6 insertions, 14 deletions
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); |