Skip to content

Commit

Permalink
py: Fix lexerunix, where not all data may be read from a file.
Browse files Browse the repository at this point in the history
Addresses issue micropython#526.
  • Loading branch information
dpgeorge committed Apr 28, 2014
1 parent 0c8fcb9 commit 185f9c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion py/lexerunix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 185f9c1

Please sign in to comment.