X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Ffloat-format.c;h=ee2d1228aa1bb09a076550d69dacfe8c1e414084;hb=46d5b8be272fca7206f3f1cb280a90dca1785744;hp=03f9411613938addd72905bb1dae5ab48c28760d;hpb=03791bf340ec2044c118b5ec8ab9332282e5e806;p=pspp diff --git a/src/libpspp/float-format.c b/src/libpspp/float-format.c index 03f9411613..ee2d1228aa 100644 --- a/src/libpspp/float-format.c +++ b/src/libpspp/float-format.c @@ -167,22 +167,22 @@ float_identify (double expected_value, const void *number, size_t length, FLOAT_Z_SHORT, FLOAT_Z_LONG, }; - const size_t candidate_cnt = sizeof candidates / sizeof *candidates; + const size_t n_candidates = sizeof candidates / sizeof *candidates; enum float_format *p; - int match_cnt; + int n_matches; - match_cnt = 0; - for (p = candidates; p < candidates + candidate_cnt; p++) + n_matches = 0; + for (p = candidates; p < candidates + n_candidates; p++) if (float_get_size (*p) == length) { char tmp[8]; assert (sizeof tmp >= float_get_size (*p)); float_convert (FLOAT_NATIVE_DOUBLE, &expected_value, *p, tmp); - if (!memcmp (tmp, number, length) && match_cnt++ == 0) + if (!memcmp (tmp, number, length) && n_matches++ == 0) *best_guess = *p; } - return match_cnt; + return n_matches; } /* Returns the double value that is just greater than -DBL_MAX, @@ -203,14 +203,14 @@ float_get_lowest (void) return x; } -/* Returns CNT bits in X starting from the given bit OFS. */ +/* Returns N bits in X starting from the given bit OFS. */ static inline uint64_t -get_bits (uint64_t x, int ofs, int cnt) +get_bits (uint64_t x, int ofs, int n) { assert (ofs >= 0 && ofs < 64); - assert (cnt > 0 && cnt < 64); - assert (ofs + cnt <= 64); - return (x >> ofs) & ((UINT64_C(1) << cnt) - 1); + assert (n > 0 && n < 64); + assert (ofs + n <= 64); + return (x >> ofs) & ((UINT64_C(1) << n) - 1); } /* Returns NATIVE converted to a form that, when stored in @@ -480,11 +480,7 @@ extract_hex (const char *s, struct fp *fp) if (fp->fraction == 0) fp->class = ZERO; else if (*s == 'p') - { - char *tail; - fp->exponent += strtol (s + 1, &tail, 10); - s = tail; - } + fp->exponent += strtol (s + 1, NULL, 10); } } }