diff --git a/main.c b/main.c index 474aa42..b1eb159 100644 --- a/main.c +++ b/main.c @@ -40,6 +40,9 @@ #define ZX_CHAR_TOKEN_HIGH(c) \ (c >= 0xc0) +#define ZX_CHAR_TOKEN(c) \ + (ZX_CHAR_TOKEN_LOW(c) || ZX_CHAR_TOKEN_HIGH(c)) + #define ZX_BASIC_STATE_LEN 116 #define ZX_CHAR_TOKEN_INTEGRAL(c) \ @@ -268,7 +271,7 @@ static ssize_t zx_dump_basic(int fd) { while (1) { ssize_t readlen, len, i; zx_basic_line line; - uint8_t last = 0; + uint8_t last = 0xc0; if ((readlen = read(fd, &line, sizeof(line))) < 0) { goto error_io; @@ -276,27 +279,30 @@ static ssize_t zx_dump_basic(int fd) { break; } + len = le16toh(line.len); + + if (be16toh(line.num) == len) { + break; + } + if (printf("%d", (int)be16toh(line.num)) < 0) { goto error_io; } - len = le16toh(line.len); - if (read(fd, buf, len) < 0) { goto error_io; } for (i=0; i