2 * Eddie Kohler, Yandong Mao, Robert Morris
3 * Copyright (c) 2012-2013 President and Fellows of Harvard College
4 * Copyright (c) 2012-2013 Massachusetts Institute of Technology
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, subject to the conditions
9 * listed in the Masstree LICENSE file. These conditions include: you must
10 * preserve this copyright notice, and you cannot mention the copyright
11 * holders in advertising related to the Software without their permission.
12 * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
13 * notice is a summary of the Masstree LICENSE file; the license in that file
18 #include "kvthread.hh"
20 int clp_parse_suffixdouble(Clp_Parser *clp, const char *vstr,
24 if (*vstr == 0 || isspace((unsigned char) *vstr))
27 clp->val.d = strtod(vstr, (char **) &post);
28 if (vstr != post && (*post == 'K' || *post == 'k'))
29 clp->val.d *= 1000, ++post;
30 else if (vstr != post && (*post == 'M' || *post == 'm'))
31 clp->val.d *= 1000000, ++post;
32 else if (vstr != post && (*post == 'B' || *post == 'b' || *post == 'G' || *post == 'g'))
33 clp->val.d *= 1000000000, ++post;
34 if (*vstr != 0 && *post == 0)
37 return Clp_OptionError(clp, "%<%O%> expects a real number, not %<%s%>", vstr);