summaryrefslogtreecommitdiff
path: root/source/gprf
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-09-22 15:28:39 +0100
committerRobin Watts <robin.watts@artifex.com>2016-09-22 16:03:47 +0100
commit1c46ee8d0463c17cb2efd36e1151e6a8ad6c7c0f (patch)
tree1bfe9750159c5df651fe82406fdabb83b56e096d /source/gprf
parent1e03c06456d997435019fb3526fa2d4be7dbc6ec (diff)
downloadmupdf-1c46ee8d0463c17cb2efd36e1151e6a8ad6c7c0f.tar.xz
GProof: When invoking gs, redirect gs stdio to local stderr.
For android this means it will go to our logging. This moves the code out of gs.
Diffstat (limited to 'source/gprf')
-rw-r--r--source/gprf/gprf-doc.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c
index f5a6cbfd..ba00d909 100644
--- a/source/gprf/gprf-doc.c
+++ b/source/gprf/gprf-doc.c
@@ -36,9 +36,7 @@
extern GSDLLEXPORT int GSDLLAPI gsapi_new_instance(void **, void *);
extern GSDLLEXPORT int GSDLLAPI gsapi_init_with_args(void *, int, char *argv[]);
extern GSDLLEXPORT void GSDLLAPI gsapi_delete_instance(void *);
-#ifdef GS_API_NULL_STDIO
extern GSDLLEXPORT int GSDLLAPI gsapi_set_stdio(void *, int (GSDLLCALL *)(void *, char *, int), int (GSDLLCALL *)(void *, const char *, int), int (GSDLLCALL *)(void *, const char *, int));
-#endif /* GS_API_NULL_STDIO */
#endif /* HAVE_IAPI_H */
#endif /* USE_GS_API */
@@ -518,19 +516,49 @@ fz_system(fz_context *ctx, const char *cmd)
}
#endif
-#ifdef GS_API_NULL_STDIO
static int GSDLLCALL
gsdll_stdout(void *instance, const char *str, int len)
{
+#ifndef GS_API_NULL_STDIO
+ int remain = len;
+ char text[32];
+
+ while (remain)
+ {
+ int l = remain;
+ if (l > sizeof(text)-1)
+ l = sizeof(text)-1;
+ memcpy(text, str, l);
+ text[l] = 0;
+ fprintf(stdout, "%s", text);
+ remain -= l;
+ str += l;
+ }
+#endif
return len;
}
static int GSDLLCALL
gsdll_stderr(void *instance, const char *str, int len)
{
+#ifndef GS_API_NULL_STDIO
+ int remain = len;
+ char text[32];
+
+ while (remain)
+ {
+ int l = remain;
+ if (l > sizeof(text)-1)
+ l = sizeof(text)-1;
+ memcpy(text, str, l);
+ text[l] = 0;
+ fprintf(stderr, "%s", text);
+ remain -= l;
+ str += l;
+ }
+#endif
return len;
}
-#endif
static void
generate_page(fz_context *ctx, gprf_page *page)
@@ -609,9 +637,7 @@ generate_page(fz_context *ctx, gprf_page *page)
code = gsapi_new_instance(&instance, ctx);
if (code < 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "GS startup failed: %d", code);
-#ifdef GS_API_NULL_STDIO
gsapi_set_stdio(instance, NULL, gsdll_stdout, gsdll_stderr);
-#endif
#ifndef NDEBUG
{
int i;