From: ellson Date: Mon, 13 Oct 2008 15:42:29 +0000 (+0000) Subject: report postscript interpreter errors through graphviz error handling X-Git-Tag: LAST_LIBGRAPH~32^2~3161 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f6615a0a24465bacafd0ee96998cc164c343186;p=graphviz report postscript interpreter errors through graphviz error handling convert gs error numbers to names. --- diff --git a/plugin/gs/gvloadimage_gs.c b/plugin/gs/gvloadimage_gs.c index 116b11638..f1ef79ecf 100644 --- a/plugin/gs/gvloadimage_gs.c +++ b/plugin/gs/gvloadimage_gs.c @@ -27,8 +27,8 @@ #ifdef HAVE_GS #ifdef HAVE_PANGOCAIRO #include +#include #include -#include #ifdef WIN32 #define NUL_FILE "nul" @@ -65,6 +65,12 @@ static int gs_writer(void *caller_handle, const char *str, int len) return len; } +static void gs_error(GVJ_t * job, const char *funstr, int err) +{ + assert (err < 0); + job->common->errorfn("%s() returned: %s\n", funstr, gs_error_names[-err - 1]); +} + static cairo_pattern_t* gvloadimage_gs_load(GVJ_t * job, usershape_t *us) { gs_t *gs = NULL; @@ -98,7 +104,7 @@ static cairo_pattern_t* gvloadimage_gs_load(GVJ_t * job, usershape_t *us) cairo_t *cr; /* temp cr for gs */ if (!gvusershape_file_access(us)) { - job->common->errorfn("Failure to access usershape file\n"); + job->common->errorfn("Failure to read shape file\n"); return NULL; } gs = (gs_t *)malloc(sizeof(gs_t)); @@ -126,12 +132,13 @@ static cairo_pattern_t* gvloadimage_gs_load(GVJ_t * job, usershape_t *us) } rc = gsapi_new_instance(&instance, (void*)job); if (rc) { - job->common->errorfn("gsapi_new_instance() returned %d\n", rc); + gs_error(job, "gsapi_new_instance", rc); return NULL; } rc = gsapi_set_stdio(instance, NULL, gs_writer, gs_writer); if (rc) { - job->common->errorfn("gsapi_set_stdio() returned %d\n", rc); + gs_error(job, "gsapi_set_stdio", rc); + gsapi_delete_instance(instance); return NULL; } sprintf(width_height, "-g%dx%d", us->x + us->w, us->y + us->h); @@ -141,17 +148,23 @@ static cairo_pattern_t* gvloadimage_gs_load(GVJ_t * job, usershape_t *us) rc = gsapi_init_with_args(instance, GS_ARGC, gs_args); cairo_destroy(cr); if (rc) { - job->common->errorfn("gsapi_init_with_args() returned %d\n", rc); + gs_error(job, "gsapi_init_with_args", rc); return NULL; } - rc = gsapi_run_file(instance, us->name, 0, &exit_code); + rc = gsapi_run_file(instance, us->name, -1, &exit_code); if (rc) { - job->common->errorfn("gsapi_run_file() returned %d\n", rc); + gs_error(job, "gsapi_run_file", rc); + rc = gsapi_exit(instance); + if (rc) { + gs_error(job, "gsapi_exit", rc); + return NULL; + } + gsapi_delete_instance(instance); return NULL; } rc = gsapi_exit(instance); if (rc) { - job->common->errorfn("gsapi_exit() returned %d\n", rc); + gs_error(job, "gsapi_exit", rc); return NULL; } gsapi_delete_instance(instance);