From 28608b5321bc48a25ded6f2b062db61cf8925f32 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 5 Mar 2013 15:48:04 +0100 Subject: [PATCH] ignore trailing carriage returns in file parser --- file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/file.c b/file.c index c2b0e72..c69a297 100644 --- a/file.c +++ b/file.c @@ -60,7 +60,10 @@ __private void uci_getln(struct uci_context *ctx, int offset) ofs += strlen(p); if (pctx->buf[ofs - 1] == '\n') { pctx->line++; - pctx->buf[ofs - 1] = 0; + if (ofs >= 2 && pctx->buf[ofs - 2] == '\r') + pctx->buf[ofs - 2] = 0; + else + pctx->buf[ofs - 1] = 0; return; } -- 2.11.0