summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--platform/win32/generate.bat2
-rw-r--r--scripts/hexdump.c66
3 files changed, 44 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index efd7d1f7..edbf5450 100644
--- a/Makefile
+++ b/Makefile
@@ -278,7 +278,7 @@ JAVASCRIPT_GEN := generated/pdf-js-util.c
JAVASCRIPT_OBJ := $(JAVASCRIPT_GEN:%.c=$(OUT)/%.o)
$(JAVASCRIPT_GEN) : $(JAVASCRIPT_SRC) | generated
- $(QUIET_GEN) $(HEXDUMP_EXE) $@ $(JAVASCRIPT_SRC)
+ $(QUIET_GEN) $(HEXDUMP_EXE) -0 $@ $(JAVASCRIPT_SRC)
ifneq "$(CROSSCOMPILE)" "yes"
$(JAVASCRIPT_GEN) : $(HEXDUMP_EXE)
diff --git a/platform/win32/generate.bat b/platform/win32/generate.bat
index 22407fc8..502cc35a 100644
--- a/platform/win32/generate.bat
+++ b/platform/win32/generate.bat
@@ -22,7 +22,7 @@ if not exist generated/pdf-cmap-extra.c cmapdump.exe generated/pdf-cmap-extra.c
if not exist generated/pdf-cmap-utf8.c cmapdump.exe generated/pdf-cmap-utf8.c resources\cmaps\utf8\*
if not exist generated/pdf-cmap-utf32.c cmapdump.exe generated/pdf-cmap-utf32.c resources\cmaps\utf32\*
-if not exist generated/pdf-js-util.c hexdump.exe generated/pdf-js-util.c source/pdf/pdf-js-util.js
+if not exist generated/pdf-js-util.c hexdump.exe -0 generated/pdf-js-util.c source/pdf/pdf-js-util.js
if not exist generated/DroidSansFallback.c hexdump.exe generated/DroidSansFallback.c resources/fonts/droid/DroidSansFallback.ttf
if not exist generated/DroidSansFallbackFull.c hexdump.exe generated/DroidSansFallbackFull.c resources/fonts/droid/DroidSansFallbackFull.ttf
diff --git a/scripts/hexdump.c b/scripts/hexdump.c
index 728afc33..c75e97bc 100644
--- a/scripts/hexdump.c
+++ b/scripts/hexdump.c
@@ -33,29 +33,37 @@ main(int argc, char **argv)
char *basename;
char *p;
int i, size;
+ int zero;
if (argc < 3)
{
- fprintf(stderr, "usage: hexdump output.c input.dat\n");
+ fprintf(stderr, "usage: hexdump [-0] output.c input.dat\n");
return 1;
}
- fo = fopen(argv[1], "wb");
+ zero = 0;
+ if (!strcmp(argv[1], "-0"))
+ zero = 1;
+
+ fo = fopen(argv[zero+1], "wb");
if (!fo)
{
- fprintf(stderr, "hexdump: could not open output file '%s'\n", argv[1]);
+ fprintf(stderr, "hexdump: could not open output file '%s'\n", argv[zero+1]);
return 1;
}
- fprintf(fo, "#ifndef __STRICT_ANSI__\n");
- fprintf(fo, "#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)\n");
- fprintf(fo, "#if !defined(__ICC) && !defined(__ANDROID__)\n");
- fprintf(fo, "#define HAVE_INCBIN\n");
- fprintf(fo, "#endif\n");
- fprintf(fo, "#endif\n");
- fprintf(fo, "#endif\n");
+ if (!zero)
+ {
+ fprintf(fo, "#ifndef __STRICT_ANSI__\n");
+ fprintf(fo, "#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)\n");
+ fprintf(fo, "#if !defined(__ICC) && !defined(__ANDROID__)\n");
+ fprintf(fo, "#define HAVE_INCBIN\n");
+ fprintf(fo, "#endif\n");
+ fprintf(fo, "#endif\n");
+ fprintf(fo, "#endif\n");
+ }
- for (i = 2; i < argc; i++)
+ for (i = zero+2; i < argc; i++)
{
fi = fopen(argv[i], "rb");
if (!fi)
@@ -92,22 +100,32 @@ main(int argc, char **argv)
size = ftell(fi);
fseek(fi, 0, SEEK_SET);
- fprintf(fo, "\n#ifdef HAVE_INCBIN\n");
- fprintf(fo, "const int fz_%s_size = %d;\n", filename, size);
- fprintf(fo, "extern const char fz_%s[];\n", filename);
- fprintf(fo, "asm(\".section .rodata\");\n");
- fprintf(fo, "asm(\".global fz_%s\");\n", filename);
- fprintf(fo, "asm(\".type fz_%s STT_OBJECT\");\n", filename);
- fprintf(fo, "asm(\".size fz_%s, %d\");\n", filename, size);
- fprintf(fo, "asm(\".balign 64\");\n");
- fprintf(fo, "asm(\"fz_%s:\");\n", filename);
- fprintf(fo, "asm(\".incbin \\\"%s\\\"\");\n", argv[i]);
- fprintf(fo, "#else\n");
+ if (!zero)
+ {
+ fprintf(fo, "\n#ifdef HAVE_INCBIN\n");
+ fprintf(fo, "const int fz_%s_size = %d;\n", filename, size);
+ fprintf(fo, "extern const char fz_%s[];\n", filename);
+ fprintf(fo, "asm(\".section .rodata\");\n");
+ fprintf(fo, "asm(\".global fz_%s\");\n", filename);
+ fprintf(fo, "asm(\".type fz_%s STT_OBJECT\");\n", filename);
+ fprintf(fo, "asm(\".size fz_%s, %d\");\n", filename, size);
+ fprintf(fo, "asm(\".balign 64\");\n");
+ fprintf(fo, "asm(\"fz_%s:\");\n", filename);
+ fprintf(fo, "asm(\".incbin \\\"%s\\\"\");\n", argv[i]);
+ fprintf(fo, "#else\n");
+ }
fprintf(fo, "const int fz_%s_size = %d;\n", filename, size);
fprintf(fo, "const char fz_%s[] = {\n", filename);
hexdump(fo, fi);
- fprintf(fo, "0};\n"); /* zero-terminate so we can hexdump text files into C strings */
- fprintf(fo, "#endif\n");
+ if (!zero)
+ {
+ fprintf(fo, "};\n");
+ fprintf(fo, "#endif\n");
+ }
+ else
+ {
+ fprintf(fo, "0};\n"); /* zero-terminate so we can hexdump text files into C strings */
+ }
fclose(fi);
}