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.
This commit is contained in:
parent
0379b55ab0
commit
2613ffde43
@ -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 {
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
1
py/strtonum.h
Normal file
1
py/strtonum.h
Normal file
@ -0,0 +1 @@
|
||||
long mp_strtonum(const char *restrict s, int base);
|
Loading…
x
Reference in New Issue
Block a user