Susumu Yata
null+****@clear*****
Mon Jul 3 00:56:12 JST 2017
Susumu Yata 2017-07-03 00:56:12 +0900 (Mon, 03 Jul 2017) New Revision: 2b9a71b77df10047d18aa3bb0d488ac2a05b1d87 https://github.com/groonga/groonga/commit/2b9a71b77df10047d18aa3bb0d488ac2a05b1d87 Message: str: support a typecast from Text to UInt64 GitHub: #722 Modified files: lib/str.c Modified: lib/str.c (+23 -12) =================================================================== --- lib/str.c 2017-07-03 00:52:03 +0900 (3b504a4) +++ lib/str.c 2017-07-03 00:56:12 +0900 (5e2716a) @@ -1766,18 +1766,29 @@ grn_aton(grn_ctx *ctx, const char *p, const char *end, const char **rest, grn_obj_reinit(ctx, res, GRN_DB_INT64, 0); GRN_INT64_SET(ctx, res, int64); } - } else if (rest_char == '.' || rest_char == 'e' || rest_char == 'E' || - (rest_char >= '0' && rest_char <= '9')) { - char *rest_float; - double d; - errno = 0; - d = strtod(p, &rest_float); - if (!errno && rest_float == end) { - grn_obj_reinit(ctx, res, GRN_DB_FLOAT, 0); - GRN_FLOAT_SET(ctx, res, d); - *rest = rest_float; - } else { - return GRN_INVALID_ARGUMENT; + } else { + if (*p != '-' && rest_char >= '0' && rest_char <= '9') { + uint64_t uint64 = grn_atoull(p, end, rest); + if (end == *rest) { + grn_obj_reinit(ctx, res, GRN_DB_UINT64, 0); + GRN_UINT64_SET(ctx, res, uint64); + } + } + if (end != *rest) { + if (rest_char == '.' || rest_char == 'e' || rest_char == 'E' || + (rest_char >= '0' && rest_char <= '9')) { + char *rest_float; + double d; + errno = 0; + d = strtod(p, &rest_float); + if (!errno && rest_float == end) { + grn_obj_reinit(ctx, res, GRN_DB_FLOAT, 0); + GRN_FLOAT_SET(ctx, res, d); + *rest = rest_float; + } else { + return GRN_INVALID_ARGUMENT; + } + } } } } -------------- next part -------------- HTML����������������������������... Descargar