From: Ben Pfaff Date: Thu, 17 Feb 2011 05:42:13 +0000 (-0800) Subject: data-out: Reorganize output_Z() to be more easily understood. X-Git-Tag: v0.7.7~45 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=068a4cbf264102f4ede4c3805eecbacf15f0f2d8;p=pspp-builds.git data-out: Reorganize output_Z() to be more easily understood. It took me a minute to figure out what was going on here, so this commit slightly reorganizes it. --- diff --git a/src/data/data-out.c b/src/data/data-out.c index bb774374..1ed83bcb 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -215,11 +215,9 @@ output_Z (const union value *input, const struct fmt_spec *format, char buf[128]; if (input->f == SYSMIS) output_missing (format, output); - else if (fabs (number) >= power10 (format->w) - || sprintf (buf, "%0*.0f", format->w, - fabs (round (number))) != format->w) - output_overflow (format, output); - else + else if (fabs (number) < power10 (format->w) + && sprintf (buf, "%0*.0f", format->w, + fabs (round (number))) == format->w) { if (number < 0 && strspn (buf, "0") < format->w) { @@ -229,6 +227,8 @@ output_Z (const union value *input, const struct fmt_spec *format, memcpy (output, buf, format->w); output[format->w] = '\0'; } + else + output_overflow (format, output); } /* Outputs P format. */