diff options
author | Werner Almesberger <werner@almesberger.net> | 2016-08-27 00:20:41 -0300 |
---|---|---|
committer | Werner Almesberger <werner@almesberger.net> | 2016-08-27 00:21:57 -0300 |
commit | 982523e0791e3902c6c6abefe5651b3b494e62f1 (patch) | |
tree | d9609d007983524ed9f6d15b2fd6e3642d52391f | |
parent | 0509840b201526851e33182b98fcf61edf70b626 (diff) | |
download | eeshow-982523e0791e3902c6c6abefe5651b3b494e62f1.tar.gz eeshow-982523e0791e3902c6c6abefe5651b3b494e62f1.tar.bz2 eeshow-982523e0791e3902c6c6abefe5651b3b494e62f1.zip |
non-interactive diff now exits with 0 if no differences, 1 if differences
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | gfx/diff.c | 13 | ||||
-rw-r--r-- | main.c | 5 |
3 files changed, 12 insertions, 7 deletions
@@ -34,7 +34,6 @@ Rendering: - support line thickness ? - ~ as overline (grep for ~ in out.fig) [ done for Cairo, FIG still missing ] - maybe let user set PNG size [we have zoom level] -- return indication of whether non-interactive diff found any differences - in diff, pass only options understood by cairo_png - find out why in Cairo PDF non-dashed lines disappear if CAIRO_LINE_CAP_ROUND - diff area algorithm will fill anything resembling a closed path, no matter @@ -370,7 +370,7 @@ static void merge_coord(int pos_a, int pos_b, int dim_a, int dim_b, static cairo_t *make_diff(cairo_t *cr, int cx, int cy, float scale, struct cro_ctx *old, struct cro_ctx *old_extra, struct cro_ctx *new, struct cro_ctx *new_extra, - const struct area *areas) + const struct area *areas, bool *changed) { int old_xmin, old_ymin, old_w, old_h; int new_xmin, new_ymin, new_w, new_h; @@ -420,7 +420,10 @@ static cairo_t *make_diff(cairo_t *cr, int cx, int cy, float scale, cairo_surface_flush(s); differences(&diff, img_old, img_new); show_areas(&diff, img_old); + if (changed) + *changed = diff.areas; free_areas(&diff.areas); + if (areas) { diff.areas = (struct area *) areas; show_areas(&diff, img_old); @@ -439,12 +442,14 @@ static int diff_end(void *ctx) struct diff *diff = ctx; cairo_t *old_cr; cairo_surface_t *s; + bool changed; assert(diff->gfx); assert(diff->new_gfx); old_cr = make_diff(NULL, 0, 0, diff->scale, - gfx_user(diff->gfx), NULL, gfx_user(diff->new_gfx), NULL, NULL); + gfx_user(diff->gfx), NULL, gfx_user(diff->new_gfx), NULL, NULL, + &changed); s = cairo_get_target(old_cr); cro_img_write(s, diff->output_name); @@ -452,7 +457,7 @@ static int diff_end(void *ctx) cairo_surface_destroy(s); cairo_destroy(old_cr); - return 0; + return changed; } @@ -468,7 +473,7 @@ void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale, cairo_surface_t *s; old_cr = make_diff(cr, cx, cy, scale, old, old_extra, new, new_extra, - areas); + areas, NULL); s = cairo_get_target(old_cr); cairo_set_source_surface(cr, s, 0, 0); @@ -141,6 +141,7 @@ int main(int argc, char **argv) char **gfx_argv; const struct gfx_ops **ops = ops_list; struct gfx *gfx; + int retval; if (argc > 1 && !strcmp(argv[1], "gdb")) { char **args; @@ -335,10 +336,10 @@ found: if (pl) pl_render(pl, gfx, sch_ctx.sheets, sch_ctx.sheets); } - gfx_end(gfx); + retval = gfx_end(gfx); sch_free(&sch_ctx); lib_free(&lib); - return 0; + return retval; } |