From: Jo-Philipp Wich Date: Tue, 5 Mar 2013 14:48:04 +0000 (+0100) Subject: ignore trailing carriage returns in file parser X-Git-Url: http://git.openwrt.org/?p=project%2Fuci.git;a=commitdiff_plain;h=28608b5321bc48a25ded6f2b062db61cf8925f32 ignore trailing carriage returns in file parser --- 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; }