Susumu Yata
null+****@clear*****
Mon Jul 3 00:10:29 JST 2017
Susumu Yata 2017-07-03 00:10:29 +0900 (Mon, 03 Jul 2017) New Revision: 1a8a8d4ca706ddd4b8cc538272fd582bee1ecd9f https://github.com/groonga/groonga/commit/1a8a8d4ca706ddd4b8cc538272fd582bee1ecd9f Message: str: update grn_atoll to support INT64_MIN Modified files: lib/str.c Modified: lib/str.c (+18 -12) =================================================================== --- lib/str.c 2017-07-02 01:10:47 +0900 (9b395c4) +++ lib/str.c 2017-07-03 00:10:29 +0900 (3b504a4) @@ -1464,24 +1464,30 @@ grn_atoui(const char *nptr, const char *end, const char **rest) int64_t grn_atoll(const char *nptr, const char *end, const char **rest) { - /* FIXME: INT_MIN is not supported */ const char *p = nptr; - int n = 0, o = 0; - int64_t v = 0, t; + int o = 0; + int64_t v = 0; if (p < end && *p == '-') { p++; - n = 1; o = 1; - } - while (p < end && *p >= '0' && *p <= '9') { - t = v * 10 + (*p - '0'); - if (t < v) { v = 0; break; } - v = t; - o = 0; - p++; + while (p < end && *p >= '0' && *p <= '9') { + int64_t t = v * 10 - (*p - '0'); + if (t > v) { v = 0; break; } + v = t; + o = 0; + p++; + } + } else { + while (p < end && *p >= '0' && *p <= '9') { + int64_t t = v * 10 + (*p - '0'); + if (t < v) { v = 0; break; } + v = t; + o = 0; + p++; + } } if (rest) { *rest = o ? nptr : p; } - return n ? -v : v; + return v; } uint64_t -------------- next part -------------- HTML����������������������������... Download