diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2014-11-22 01:48:26 +0000 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2014-12-03 13:06:05 +0000 |
commit | 92ece51dc8197918a0586226a4b393006ecd136c (patch) | |
tree | 8cc9ede7900a988c19ac9332461f3f07f1665cdb /tests/util/piglit-util.h | |
parent | 75490f79aa1490d3a491e07401ef9983cfb99ea6 (diff) |
util: move string wrapper no piglit-util.h
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'tests/util/piglit-util.h')
-rwxr-xr-x | tests/util/piglit-util.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h index 2b52b00f7..811fbfaa3 100755 --- a/tests/util/piglit-util.h +++ b/tests/util/piglit-util.h @@ -174,6 +174,33 @@ streq(const char *a, const char *b) } /** + * Wrapper for strtod() which also handles +/-inf with MSVC. + * Note: we only check for "inf" and not "INF". + */ +static inline double +strtod_inf(const char *nptr, char **endptr) +{ +#if defined(_MSC_VER) + /* skip spaces and tabs */ + while (*nptr == ' ' || *nptr == '\t') + nptr++; + + if (nptr[0] == 'i' && nptr[1] == 'n' && nptr[2] == 'f') { + /* +infinity */ + *endptr = (char *) (nptr + 3); + return INFINITY; + } + else if (nptr[0] == '-' && nptr[1] == 'i' && nptr[2] == 'n' && nptr[3] == 'f') { + /* -infinity */ + *endptr = (char *) (nptr + 4); + return -INFINITY; + } + /* fall-through */ +#endif + return strtod(nptr, endptr); +} + +/** * Determine if an extension is listed in an extension string * * \param haystack List of all extensions to be searched |