Browse Source

ignore trailing carriage returns in file parser

Jo-Philipp Wich 11 years ago
parent
commit
28608b5321
1 changed files with 4 additions and 1 deletions
  1. 4 1
      file.c

+ 4 - 1
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;
 		}