Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
4e7107a5
Commit
4e7107a5
authored
Nov 27, 2015
by
Damien George
Browse files
py: Change mp_print_strn_t func type to use size_t for the str length.
parent
fad7d931
Changes
6
Hide whitespace changes
Inline
Side-by-side
lib/utils/printf.c
View file @
4e7107a5
...
...
@@ -92,7 +92,7 @@ typedef struct _strn_print_env_t {
size_t
remain
;
}
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
;
if
(
len
>
strn_print_env
->
remain
)
{
len
=
strn_print_env
->
remain
;
...
...
py/emitglue.c
View file @
4e7107a5
...
...
@@ -606,8 +606,8 @@ void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) {
#include
<sys/stat.h>
#include
<fcntl.h>
STATIC
void
fd_print_strn
(
void
*
env
,
const
char
*
str
,
mp_uint
_t
len
)
{
int
fd
=
(
mp_
int_t
)
env
;
STATIC
void
fd_print_strn
(
void
*
env
,
const
char
*
str
,
size
_t
len
)
{
int
fd
=
(
int
ptr
_t
)
env
;
ssize_t
ret
=
write
(
fd
,
str
,
len
);
(
void
)
ret
;
}
...
...
py/mpprint.c
View file @
4e7107a5
...
...
@@ -43,7 +43,7 @@
static
const
char
pad_spaces
[]
=
" "
;
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
;
MP_PLAT_PRINT_STRN
(
str
,
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
};
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
)
{
print
->
print_strn
(
print
->
data
,
str
,
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
right_pad
=
0
;
int
pad
=
width
-
len
;
...
...
py/mpprint.h
View file @
4e7107a5
...
...
@@ -39,7 +39,7 @@
#define PF_FLAG_ADD_PERCENT (0x100)
#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
{
void
*
data
;
...
...
@@ -55,7 +55,7 @@ extern const mp_print_t mp_sys_stdout_print;
#endif
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
int
mp_print_float
(
const
mp_print_t
*
print
,
mp_float_t
f
,
char
fmt
,
int
flags
,
char
fill
,
int
width
,
int
prec
);
#endif
...
...
py/stream.c
View file @
4e7107a5
...
...
@@ -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
;
if
(
o
->
type
->
stream_p
==
NULL
||
o
->
type
->
stream_p
->
write
==
NULL
)
{
// CPython: io.UnsupportedOperation, OSError subclass
...
...
py/stream.h
View file @
4e7107a5
...
...
@@ -40,7 +40,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_tell_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_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
// TODO: This is POSIX-specific (but then POSIX is the only real thing,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment