8000 py: Fix lexerunix, where not all data may be read from a file. · lurch/micropython@185f9c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 185f9c1

Browse files
committed
py: Fix lexerunix, where not all data may be read from a file.
Addresses issue micropython#526.
1 parent 0c8fcb9 commit 185f9c1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

py/lexerunix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ typedef struct _mp_lexer_file_buf_t {
2222

2323
STATIC unichar file_buf_next_char(mp_lexer_file_buf_t *fb) {
2424
if (fb->pos >= fb->len) {
25-
if (fb->len < sizeof(fb->buf)) {
25+
if (fb->len == 0) {
2626
return MP_LEXER_CHAR_EOF;
2727
} else {
2828
int n = read(fb->fd, fb->buf, sizeof(fb->buf));
2929
if (n <= 0) {
30+
fb->len = 0;
3031
return MP_LEXER_CHAR_EOF;
3132
}
3233
fb->len = n;

0 commit comments

Comments
 (0)
0