From 41fa8181f588767839f368f6b64371e73d0b1a11 Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Fri, 7 Oct 2016 14:22:30 -0700 Subject: [PATCH] Update for new waveflag semantics. Previously our copy of waveflag took just an input and output filename. Upstream takes a prefix and one or more input filenames, and concatenates the prefix to the input filename as the output. The makefile is changed to pass a prefix and the input filename, instead of the input filename and the output filename as it formerly did. Unfortunately for us, our inputs have a directory prefix since they're not in the current directory, and we don't want this prefix in the output file path. So we tweak our copy of waveflag.c to call basename on the input file path before we append it to the prefix. We also make the tool a little less noisy by putting more printfs under the debug flag. --- Makefile | 2 +- waveflag.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1f0a66507..847051df7 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ $(EMOJI_DIR)/%.png: $(EMOJI_SRC_DIR)/%.png | $(EMOJI_DIR) @convert -extent 136x128 -gravity center -background none "$<" "$@" $(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag $(PNGQUANT) | $(FLAGS_DIR) - @./waveflag "$<" "$@" + @./waveflag $(FLAGS_DIR)/ "$<" $(RESIZED_FLAGS_DIR)/%.png: $(FLAGS_DIR)/%.png | $(RESIZED_FLAGS_DIR) @convert -extent 136x128 -gravity center -background none "$<" "$@" diff --git a/waveflag.c b/waveflag.c index 8e0cb07b3..6a9459a24 100644 --- a/waveflag.c +++ b/waveflag.c @@ -17,6 +17,7 @@ */ #include +#include // basename #include #include #include @@ -269,7 +270,7 @@ wave_flag (const char *filename, const char *out_prefix) cairo_surface_t *scaled_flag, *waved_flag; cairo_t *cr; - printf ("Processing %s\n", filename); + if (debug) printf ("Processing %s\n", filename); scaled_flag = load_scaled_flag (filename, &aspect); @@ -277,7 +278,7 @@ wave_flag (const char *filename, const char *out_prefix) aspect = sqrt (aspect); // Discount the effect if (.9 <= aspect && aspect <= 1.1) { - printf ("Standard aspect ratio\n"); + if (debug) printf ("Standard aspect ratio\n"); aspect = 1.; } @@ -335,7 +336,7 @@ wave_flag (const char *filename, const char *out_prefix) } else { - printf ("Transparent border\n"); + if (debug) printf ("Transparent border\n"); cairo_new_path (cr); } @@ -410,7 +411,7 @@ wave_flag (const char *filename, const char *out_prefix) *out = '\0'; strcat (out, out_prefix); - strcat (out, filename); + strcat (out, basename(filename)); cairo_surface_write_to_png (cairo_get_target (cr), out); cairo_destroy (cr);