Browse Source

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.
pull/316/head
Damien George 11 years ago
parent
commit
2613ffde43
  1. 2
      py/misc.h
  2. 5
      py/objint.c
  3. 5
      py/strtonum.c
  4. 1
      py/strtonum.h

2
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 {

5
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:

5
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;
}

1
py/strtonum.h

@ -0,0 +1 @@
long mp_strtonum(const char *restrict s, int base);
Loading…
Cancel
Save