From ea7b73aac55177d1d556d0c9dba04b0870d3aaf6 Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 16 Sep 2025 20:49:49 -0400 Subject: Allow short reads from read_func --- pom.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'pom.c') diff --git a/pom.c b/pom.c index 99102da..b41b9d4 100644 --- a/pom.c +++ b/pom.c @@ -170,8 +170,6 @@ struct parser { size_t count; } items; bool - // last call to read_func returned eof) return false; uint8_t utf8_state = parser->utf8_state; - if (parser->short_read) { // last read was short, so we're at EOF - // EOF reached. - eof: + char *buf = parser->buf; + size_t read_count = parser->read_func(parser->userdata, buf, sizeof parser->buf - 1); + parser->buf_pos = 0; + if (read_count == 0) { if (utf8_state) { parser_error(parser, ERROR_INVALID_UTF8); } parser->eof = true; return false; } - char *buf = parser->buf; - size_t read_count = parser->read_func(parser->userdata, buf, sizeof parser->buf - 1); - parser->buf_pos = 0; - if (read_count == 0) - goto eof; - if (read_count < sizeof parser->buf - 1) - parser->short_read = true; if (parser->leftover_cr && buf[0] != '\n') parser_error(parser, ERROR_ASCII_CONTROL, '\r'); size_t in = 0, out = 0; -- cgit v1.2.3