X-Git-Url: http://git.droids-corp.org/?p=libcmdline.git;a=blobdiff_plain;f=src%2Flib%2Fcmdline_parse_num.c;h=f6eeb8b44866364e6abc21560e880c6c9ace5829;hp=1332efca95da2cf6b57ae5ea72dda7aa21680c3b;hb=e5ca055e8b19eaa2335d554357f04e4a6fddb38a;hpb=090c2ba0d6b66390c9c770dba1c7f987cd9ca1e1 diff --git a/src/lib/cmdline_parse_num.c b/src/lib/cmdline_parse_num.c index 1332efc..f6eeb8b 100644 --- a/src/lib/cmdline_parse_num.c +++ b/src/lib/cmdline_parse_num.c @@ -102,22 +102,22 @@ enum num_parse_state_t { /* Keep it sync with enum in .h */ static const char * num_help[] = { - "UINT8", "UINT16", "UINT32", - "INT8", "INT16", "INT32", + "UINT8", "UINT16", "UINT32", "UINT64", + "INT8", "INT16", "INT32", "INT64", #ifdef CMDLINE_HAVE_FLOAT "FLOAT", #endif }; static inline int -add_to_res(unsigned int c, uint32_t *res, unsigned int base) +add_to_res(unsigned int c, uint64_t *res, unsigned int base) { /* overflow */ - if ( (UINT32_MAX - c) / base < *res ) { + if ( (UINT64_MAX - c) / base < *res ) { return -1; } - *res = *res * base + c ; + *res = (uint64_t) (*res * base + c); return 0; } @@ -130,9 +130,9 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res) enum num_parse_state_t st = START; const char * buf = srcbuf; char c = *buf; - uint32_t res1 = 0; + uint64_t res1 = 0; #ifdef CMDLINE_HAVE_FLOAT - uint32_t res2 = 0, res3 = 1; + uint64_t res2 = 0, res3 = 1; #endif memcpy(&nd, &((struct cmdline_token_num *)tk)->num_data, sizeof(nd)); @@ -389,6 +389,11 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res) *(uint32_t *)res = (uint32_t) res1; return (buf-srcbuf); } + else if ( nd.type == UINT64 ) { + if (res) + *(uint64_t *)res = res1; + return (buf-srcbuf); + } #ifdef CMDLINE_HAVE_FLOAT else if ( nd.type == FLOAT ) { if (res)