summaryrefslogtreecommitdiff
path: root/psi/psapi.c
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2020-06-26 16:12:33 +0100
committerRobin Watts <Robin.Watts@artifex.com>2020-06-26 16:14:41 +0100
commit622f4ea8ecc9b677165121d0c093632b9ea00c67 (patch)
treeca99265d683fdd9f68975c0514e170b075a27202 /psi/psapi.c
parent4f886898e23483e82866148d6b564faf281490ba (diff)
downloadghostpdl-622f4ea8ecc9b677165121d0c093632b9ea00c67.tar.gz
Don't let psapi_new_instance trample libctx->stdio functions.
For GS builds this doesn't matter, as psapi_new_instance is called before users of the API get to set their own versions. With GPDL builds, the call to psapi_new_instance is deferred to the point where the API user may have already set their own functions.
Diffstat (limited to 'psi/psapi.c')
-rw-r--r--psi/psapi.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/psi/psapi.c b/psi/psapi.c
index c51f7e418..9dbbacad3 100644
--- a/psi/psapi.c
+++ b/psi/psapi.c
@@ -101,13 +101,12 @@ psapi_new_instance(gs_lib_ctx_t **pinstance,
mem->gs_lib_ctx->core->default_caller_handle = caller_handle;
mem->gs_lib_ctx->core->custom_color_callback = NULL;
#ifdef METRO
- mem->gs_lib_ctx->core->stdin_fn = metro_stdin;
- mem->gs_lib_ctx->core->stdout_fn = metro_stdout;
- mem->gs_lib_ctx->core->stderr_fn = metro_stderr;
-#else
- mem->gs_lib_ctx->core->stdin_fn = NULL;
- mem->gs_lib_ctx->core->stdout_fn = NULL;
- mem->gs_lib_ctx->core->stderr_fn = NULL;
+ if (mem->gs_lib_ctx->core->stdin_fn == NULL)
+ mem->gs_lib_ctx->core->stdin_fn = metro_stdin;
+ if (mem->gs_lib_ctx->core->stdout_fn == NULL)
+ mem->gs_lib_ctx->core->stdout_fn = metro_stdout;
+ if (mem->gs_lib_ctx->core->stderr_fn == NULL)
+ mem->gs_lib_ctx->core->stderr_fn = metro_stderr;
#endif
mem->gs_lib_ctx->core->poll_fn = NULL;