From 89306c3c6b335e23a09bc2c3442d8b08e60cb328 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 18 Jul 2009 12:29:35 +0200 Subject: [PATCH] Improve code to trim leading spaces from numeric output. Ben Pfaff pointed out that the code to chomp the results of formated doubles was no longer correct. This change fixes that. --- src/output/table.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/output/table.c b/src/output/table.c index 7460fce3..04181e44 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -599,9 +599,7 @@ void tab_double (struct tab_table *table, int c, int r, unsigned char opt, double val, const struct fmt_spec *fmt) { - int w; - char *s, *cp; - + struct substring ss; union value double_value ; assert (table != NULL); @@ -631,16 +629,11 @@ tab_double (struct tab_table *table, int c, int r, unsigned char opt, #endif double_value.f = val; - s = data_out_pool (&double_value, LEGACY_NATIVE, fmt, table->container); + ss = ss_cstr (data_out_pool (&double_value, LEGACY_NATIVE, fmt, table->container)); - cp = s; - while (isspace ((unsigned char) *cp) && cp < s + fmt->w) - { - cp++; - } - w = fmt->w - (cp - s); - - table->cc[c + r * table->cf] = ss_buffer (cp, w); + ss_ltrim (&ss, ss_cstr (" ")); + + table->cc[c + r * table->cf] = ss; table->ct[c + r * table->cf] = opt; } -- 2.30.2