X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fdata%2Fdata-out.c;h=6106fc3011f420f7080252db49c2c14f4c03ad0f;hb=e7d0a9f16192ceeff9243f0ede8e399ee1ef0d44;hp=78668b7aed96685b52b6934f277239e36dd92dab;hpb=77e551d23575da6b89f866612ab39c2b0497c9be;p=pspp-builds.git diff --git a/src/data/data-out.c b/src/data/data-out.c index 78668b7a..6106fc30 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 @@ -101,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); @@ -159,8 +158,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; default: - assert (0); - abort (); + NOT_REACHED (); } } else @@ -179,8 +177,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; default: - assert (0); - abort (); + NOT_REACHED (); } } @@ -351,7 +348,7 @@ convert_F_plus (char *dst, const struct fmt_spec *fp, double number) static int convert_Z (char *dst, const struct fmt_spec *fp, double number) { - static int warned = 0; + static bool warned = false; if (!warned) { @@ -395,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; } @@ -751,7 +748,7 @@ convert_date (char *dst, const struct fmt_spec *fp, double number) } break; default: - assert (0); + NOT_REACHED (); } if (buf[0] == 0) @@ -1063,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; @@ -1143,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; }