From 0caadb6ceed0de07fc0b778b77674c06cd115175 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 31 Dec 2008 06:12:29 +0000 Subject: handle config files with (DOS line ending) ported from volker_dev (r826) git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@920 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- cfg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cfg.c b/cfg.c index cef48d4..d712db9 100644 --- a/cfg.c +++ b/cfg.c @@ -132,15 +132,19 @@ static char *strip(char *s, const int strip_comments) if (*p == '"') do p++; - while (*p && *p != '\n' && *p != '"'); + while (*p && *p != '\n' && *p != '\r' && *p != '"'); if (*p == '\'') do p++; - while (*p && *p != '\n' && *p != '\''); + while (*p && *p != '\n' && *p != '\r' && *p != '\''); if (*p == '\n' || (strip_comments && *p == '#' && (p == s || *(p - 1) != '\\'))) { *p = '\0'; break; } + if (*p == '\r' && *(p + 1) == '\n') { + /* replace from DOS with blank */ + *p = ' '; + } } for (p--; p > s && isblank(*p); p--) -- cgit v1.2.3