From f42fa8efa24ed192d44b622eafa7e56b958a54d5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 5 Mar 2021 18:05:08 -0800 Subject: [PATCH] abbreviate computation of len_swidth in gvmap C99 semantics allow us to avoid using an intermediate buffer for this operation. --- cmd/gvmap/make_map.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index dac318208..4e2ed2631 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -323,8 +323,7 @@ static void dot_polygon(char **sbuff, int *len, int *len_max, int np, float *xp, } else {/* line*/ assert(line_width >= 0); if (line_width > 0){ - sprintf(swidth,"%f",line_width); - len_swidth = strlen(swidth); + len_swidth = (size_t)snprintf(NULL, 0, "%f", line_width); sprintf(swidth,"S %zu -setlinewidth(%f)",len_swidth+14, line_width); ret += snprintf(NULL, 0, " c %zu -%s %s L %d ", strlen(cstring), cstring, swidth, np); } else { -- 2.40.0