summaryrefslogtreecommitdiffstatshomepage
path: root/py/lexerunix.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-30 11:46:05 +0100
committerDamien George <damien.p.george@gmail.com>2014-07-30 11:46:05 +0100
commit94fbe9711a1179b3c4d0eb2e9822787d90231719 (patch)
tree8a925d2f40d088c8f8d2d0919212e64cb4426a4b /py/lexerunix.c
parent07133415d26d740b866f4542222bb92c06c863d1 (diff)
downloadmicropython-94fbe9711a1179b3c4d0eb2e9822787d90231719.tar.gz
micropython-94fbe9711a1179b3c4d0eb2e9822787d90231719.zip
py: Change lexer stream API to return bytes not chars.
Lexer is now 8-bit clean inside strings.
Diffstat (limited to 'py/lexerunix.c')
-rw-r--r--py/lexerunix.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/py/lexerunix.c b/py/lexerunix.c
index 51bc915b22..9d669f2bfe 100644
--- a/py/lexerunix.c
+++ b/py/lexerunix.c
@@ -41,20 +41,20 @@
typedef struct _mp_lexer_file_buf_t {
int fd;
- char buf[20];
- uint len;
- uint pos;
+ byte buf[20];
+ mp_uint_t len;
+ mp_uint_t pos;
} mp_lexer_file_buf_t;
-STATIC unichar file_buf_next_char(mp_lexer_file_buf_t *fb) {
+STATIC mp_uint_t file_buf_next_byte(mp_lexer_file_buf_t *fb) {
if (fb->pos >= fb->len) {
if (fb->len == 0) {
- return MP_LEXER_CHAR_EOF;
+ return MP_LEXER_EOF;
} else {
int n = read(fb->fd, fb->buf, sizeof(fb->buf));
if (n <= 0) {
fb->len = 0;
- return MP_LEXER_CHAR_EOF;
+ return MP_LEXER_EOF;
}
fb->len = n;
fb->pos = 0;
@@ -78,7 +78,7 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
int n = read(fb->fd, fb->buf, sizeof(fb->buf));
fb->len = n;
fb->pos = 0;
- return mp_lexer_new(qstr_from_str(filename), fb, (mp_lexer_stream_next_char_t)file_buf_next_char, (mp_lexer_stream_close_t)file_buf_close);
+ return mp_lexer_new(qstr_from_str(filename), fb, (mp_lexer_stream_next_byte_t)file_buf_next_byte, (mp_lexer_stream_close_t)file_buf_close);
}
#endif // MICROPY_HELPER_LEXER_UNIX