Commit 4e7107a5 authored by Damien George's avatar Damien George
Browse files

py: Change mp_print_strn_t func type to use size_t for the str length.

parent fad7d931
...@@ -92,7 +92,7 @@ typedef struct _strn_print_env_t { ...@@ -92,7 +92,7 @@ typedef struct _strn_print_env_t {
size_t remain; size_t remain;
} strn_print_env_t; } strn_print_env_t;
STATIC void strn_print_strn(void *data, const char *str, mp_uint_t len) { STATIC void strn_print_strn(void *data, const char *str, size_t len) {
strn_print_env_t *strn_print_env = data; strn_print_env_t *strn_print_env = data;
if (len > strn_print_env->remain) { if (len > strn_print_env->remain) {
len = strn_print_env->remain; len = strn_print_env->remain;
......
...@@ -606,8 +606,8 @@ void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) { ...@@ -606,8 +606,8 @@ void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) {
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
STATIC void fd_print_strn(void *env, const char *str, mp_uint_t len) { STATIC void fd_print_strn(void *env, const char *str, size_t len) {
int fd = (mp_int_t)env; int fd = (intptr_t)env;
ssize_t ret = write(fd, str, len); ssize_t ret = write(fd, str, len);
(void)ret; (void)ret;
} }
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
static const char pad_spaces[] = " "; static const char pad_spaces[] = " ";
static const char pad_zeroes[] = "0000000000000000"; static const char pad_zeroes[] = "0000000000000000";
STATIC void plat_print_strn(void *env, const char *str, mp_uint_t len) { STATIC void plat_print_strn(void *env, const char *str, size_t len) {
(void)env; (void)env;
MP_PLAT_PRINT_STRN(str, len); MP_PLAT_PRINT_STRN(str, len);
} }
...@@ -51,14 +51,14 @@ STATIC void plat_print_strn(void *env, const char *str, mp_uint_t len) { ...@@ -51,14 +51,14 @@ STATIC void plat_print_strn(void *env, const char *str, mp_uint_t len) {
const mp_print_t mp_plat_print = {NULL, plat_print_strn}; const mp_print_t mp_plat_print = {NULL, plat_print_strn};
int mp_print_str(const mp_print_t *print, const char *str) { int mp_print_str(const mp_print_t *print, const char *str) {
mp_uint_t len = strlen(str); size_t len = strlen(str);
if (len) { if (len) {
print->print_strn(print->data, str, len); print->print_strn(print->data, str, len);
} }
return len; return len;
} }
int mp_print_strn(const mp_print_t *print, const char *str, mp_uint_t len, int flags, char fill, int width) { int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) {
int left_pad = 0; int left_pad = 0;
int right_pad = 0; int right_pad = 0;
int pad = width - len; int pad = width - len;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#define PF_FLAG_ADD_PERCENT (0x100) #define PF_FLAG_ADD_PERCENT (0x100)
#define PF_FLAG_SHOW_OCTAL_LETTER (0x200) #define PF_FLAG_SHOW_OCTAL_LETTER (0x200)
typedef void (*mp_print_strn_t)(void *data, const char *str, mp_uint_t len); typedef void (*mp_print_strn_t)(void *data, const char *str, size_t len);
typedef struct _mp_print_t { typedef struct _mp_print_t {
void *data; void *data;
...@@ -55,7 +55,7 @@ extern const mp_print_t mp_sys_stdout_print; ...@@ -55,7 +55,7 @@ extern const mp_print_t mp_sys_stdout_print;
#endif #endif
int mp_print_str(const mp_print_t *print, const char *str); int mp_print_str(const mp_print_t *print, const char *str);
int mp_print_strn(const mp_print_t *print, const char *str, mp_uint_t len, int flags, char fill, int width); int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width);
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec); int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
#endif #endif
......
...@@ -174,7 +174,7 @@ STATIC mp_obj_t stream_read(mp_uint_t n_args, const mp_obj_t *args) { ...@@ -174,7 +174,7 @@ STATIC mp_obj_t stream_read(mp_uint_t n_args, const mp_obj_t *args) {
} }
} }
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len) { mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len) {
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in; struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in;
if (o->type->stream_p == NULL || o->type->stream_p->write == NULL) { if (o->type->stream_p == NULL || o->type->stream_p->write == NULL) {
// CPython: io.UnsupportedOperation, OSError subclass // CPython: io.UnsupportedOperation, OSError subclass
......
...@@ -40,7 +40,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_tell_obj); ...@@ -40,7 +40,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_tell_obj);
// Iterator which uses mp_stream_unbuffered_readline_obj // Iterator which uses mp_stream_unbuffered_readline_obj
mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len); mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len);
#if MICROPY_STREAMS_NON_BLOCK #if MICROPY_STREAMS_NON_BLOCK
// TODO: This is POSIX-specific (but then POSIX is the only real thing, // TODO: This is POSIX-specific (but then POSIX is the only real thing,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment