diff options
| author | mattip <matti.picus@gmail.com> | 2018-09-13 18:09:03 +0300 |
|---|---|---|
| committer | mattip <matti.picus@gmail.com> | 2018-09-13 18:09:03 +0300 |
| commit | ea4c8a1ca7bc69873d20340073fb54fb2f2eca2a (patch) | |
| tree | 74b3f4315717d629ef498ef18a50b4ce1a588810 /numpy/core/src/common | |
| parent | 31a0d21d7ada4bbaebe02a54a6c4062662e4e2d0 (diff) | |
| download | numpy-ea4c8a1ca7bc69873d20340073fb54fb2f2eca2a.tar.gz | |
MAINT: refactor to share npy_strto{u}ll
Diffstat (limited to 'numpy/core/src/common')
| -rw-r--r-- | numpy/core/src/common/convert.c | 30 | ||||
| -rw-r--r-- | numpy/core/src/common/convert.h | 13 |
2 files changed, 43 insertions, 0 deletions
diff --git a/numpy/core/src/common/convert.c b/numpy/core/src/common/convert.c new file mode 100644 index 000000000..aec925ae2 --- /dev/null +++ b/numpy/core/src/common/convert.c @@ -0,0 +1,30 @@ +#include <numpy/ndarraytypes.h> +#include "convert.h" + +NPY_NO_EXPORT npy_longlong +npy_strtoll(const char *str, char **endptr, int base) +{ +#if defined HAVE_STRTOLL + return strtoll(str, endptr, base); +#elif defined _MSC_VER + return _strtoi64(str, endptr, base); +#else + /* ok on 64 bit posix */ + return PyOS_strtol(str, endptr, base); +#endif +} + +NPY_NO_EXPORT npy_ulonglong +npy_strtoull(const char *str, char **endptr, int base) +{ +#if defined HAVE_STRTOULL + return strtoull(str, endptr, base); +#elif defined _MSC_VER + return _strtoui64(str, endptr, base); +#else + /* ok on 64 bit posix */ + return PyOS_strtoul(str, endptr, base); +#endif +} + + diff --git a/numpy/core/src/common/convert.h b/numpy/core/src/common/convert.h new file mode 100644 index 000000000..6106b1d13 --- /dev/null +++ b/numpy/core/src/common/convert.h @@ -0,0 +1,13 @@ +#ifndef _COMMON_CONVERT_H +#define _COMMON_CONVERT_H + + +/* Convert a string to an int in an arbitrary base */ +NPY_NO_EXPORT npy_longlong +npy_strtoll(const char *str, char **endptr, int base); + +/* Convert a string to an int in an arbitrary base */ +NPY_NO_EXPORT npy_ulonglong +npy_strtoull(const char *str, char **endptr, int base); + +#endif |
