X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fdata-out.c;h=0585dc2bb24e98d4f68eeccc15c83cbc650e5fca;hb=1255b66223eac8ff1b0abf138ead22fd801c6633;hp=79c7042446abb453c2c1722b118303805dd5b217;hpb=a19b858e0ac3c69e4a28c0ca6d8674427268a863;p=pspp diff --git a/src/data/data-out.c b/src/data/data-out.c index 79c7042446..0585dc2bb2 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -25,6 +25,7 @@ #include #include #include "calendar.h" +#include #include #include "format.h" #include @@ -36,8 +37,6 @@ #include "gettext.h" #define _(msgid) gettext (msgid) - -#include /* Public functions. */ @@ -103,12 +102,10 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; case FMT_A: - assert (0); - abort (); + NOT_REACHED (); case FMT_AHEX: - assert (0); - abort (); + NOT_REACHED (); case FMT_IB: ok = convert_IB (s, fp, number); @@ -161,8 +158,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; default: - assert (0); - abort (); + NOT_REACHED (); } } else @@ -181,8 +177,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; default: - assert (0); - abort (); + NOT_REACHED (); } } @@ -397,7 +392,7 @@ convert_Z (char *dst, const struct fmt_spec *fp, double number) static int convert_A (char *dst, const struct fmt_spec *fp, const char *string) { - memcpy (dst, string, fp->w); + memcpy(dst, string, fp->w); return 1; } @@ -753,7 +748,7 @@ convert_date (char *dst, const struct fmt_spec *fp, double number) } break; default: - assert (0); + NOT_REACHED (); } if (buf[0] == 0) @@ -1065,6 +1060,7 @@ try_F (char *dst, const struct fmt_spec *fp, double number) avoids wasting too much time formatting more decimal places on the first try. */ int result = format_and_round (dst, number, fp, fp->d + 2); + if (result >= 0) return result; @@ -1145,7 +1141,7 @@ format_and_round (char *dst, double number, const struct fmt_spec *fp, digits of the fraction. Right-justify the integer part and sign. */ dst[0] = ' '; - memcpy (dst + 1, buf, fp->w); + memcpy (dst + 1, buf, fp->w - 1); return 1; }