diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-28 11:43:28 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-28 11:43:28 +0100 |
commit | 185f9c1c4652cfe44b8c4df12f524933dbe04dc5 (patch) | |
tree | 90010c2d125de166cbbe720953f0277cd2cf8b6d /py/lexerunix.c | |
parent | 0c8fcb9c498966bc330150a50ed31bf6874d79d2 (diff) | |
download | micropython-185f9c1c4652cfe44b8c4df12f524933dbe04dc5.tar.gz micropython-185f9c1c4652cfe44b8c4df12f524933dbe04dc5.zip |
py: Fix lexerunix, where not all data may be read from a file.
Addresses issue #526.
Diffstat (limited to 'py/lexerunix.c')
-rw-r--r-- | py/lexerunix.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/lexerunix.c b/py/lexerunix.c index 46c66f41d9..1bb1a759dc 100644 --- a/py/lexerunix.c +++ b/py/lexerunix.c @@ -22,11 +22,12 @@ typedef struct _mp_lexer_file_buf_t { STATIC unichar file_buf_next_char(mp_lexer_file_buf_t *fb) { if (fb->pos >= fb->len) { - if (fb->len < sizeof(fb->buf)) { + if (fb->len == 0) { return MP_LEXER_CHAR_EOF; } else { int n = read(fb->fd, fb->buf, sizeof(fb->buf)); if (n <= 0) { + fb->len = 0; return MP_LEXER_CHAR_EOF; } fb->len = n; |