From: John Darrington Date: Sat, 18 Jul 2009 10:29:35 +0000 (+0200) Subject: Improve code to trim leading spaces from numeric output. X-Git-Tag: build37~53^2~2 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89306c3c6b335e23a09bc2c3442d8b08e60cb328;p=pspp-builds.git 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. --- 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; }