py: Fix lexerunix, where not all data may be read from a file.

Addresses issue #526.
This commit is contained in:
Damien George 2014-04-28 11:43:28 +01:00
parent 0c8fcb9c49
commit 185f9c1c46
1 changed files with 2 additions and 1 deletions

View File

@ -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;