summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-22 17:49:15 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-22 17:49:15 +0000
commit2613ffde431594f3fe0562042c32105623fbe4dc (patch)
tree7b12ffbe18867132e665b66a44f6f72bfcc72e6f
parent0379b55ab036921eaee96f07385d2329d8de97fd (diff)
downloadmicropython-2613ffde431594f3fe0562042c32105623fbe4dc.tar.gz
micropython-2613ffde431594f3fe0562042c32105623fbe4dc.zip
py: Rename strtonum to mp_strtonum.
strtonum clashes with BSD function of same name, and our version is different so warrants a unique name. Addresses Issue #305.
-rw-r--r--py/misc.h2
-rw-r--r--py/objint.c5
-rw-r--r--py/strtonum.c5
-rw-r--r--py/strtonum.h1
4 files changed, 7 insertions, 6 deletions
diff --git a/py/misc.h b/py/misc.h
index 989650c17a..278d59d4fa 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -60,8 +60,6 @@ bool unichar_isxdigit(unichar c);
#define streq(s1, s2) (strcmp((s1), (s2)) == 0)
*/
-long strtonum(const char *restrict s, int base);
-
/** variable string *********************************************/
typedef struct _vstr_t {
diff --git a/py/objint.c b/py/objint.c
index 775e5644d0..82bab9ea18 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -5,6 +5,7 @@
#include "nlr.h"
#include "misc.h"
+#include "strtonum.h"
#include "mpconfig.h"
#include "qstr.h"
#include "obj.h"
@@ -24,7 +25,7 @@ STATIC mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
// a string, parse it
uint l;
const char *s = mp_obj_str_get_data(args[0], &l);
- return MP_OBJ_NEW_SMALL_INT(strtonum(s, 0));
+ return MP_OBJ_NEW_SMALL_INT(mp_strtonum(s, 0));
} else {
return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(args[0]));
}
@@ -35,7 +36,7 @@ STATIC mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
// TODO proper error checking of argument types
uint l;
const char *s = mp_obj_str_get_data(args[0], &l);
- return MP_OBJ_NEW_SMALL_INT(strtonum(s, mp_obj_get_int(args[1])));
+ return MP_OBJ_NEW_SMALL_INT(mp_strtonum(s, mp_obj_get_int(args[1])));
}
default:
diff --git a/py/strtonum.c b/py/strtonum.c
index e83b9751dc..4a62756512 100644
--- a/py/strtonum.c
+++ b/py/strtonum.c
@@ -5,12 +5,13 @@
#include <stdlib.h>
#include "misc.h"
+#include "strtonum.h"
#include "mpconfig.h"
#include "qstr.h"
#include "nlr.h"
#include "obj.h"
-long strtonum(const char *restrict s, int base) {
+long mp_strtonum(const char *restrict s, int base) {
int c, neg = 0;
const char *p = s;
char *num;
@@ -89,7 +90,7 @@ value_error:
#else /* defined(UNIX) */
-long strtonum(const char *restrict s, int base) {
+long mp_strtonum(const char *restrict s, int base) {
// TODO port strtol to stm
return 0;
}
diff --git a/py/strtonum.h b/py/strtonum.h
new file mode 100644
index 0000000000..10b6732edb
--- /dev/null
+++ b/py/strtonum.h
@@ -0,0 +1 @@
+long mp_strtonum(const char *restrict s, int base);