From 38171bc2332dc68b86ea627e50c482e2ace4e342 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sat, 8 Oct 2011 19:27:36 +0200 Subject: userprefs: fix 0x0d,0x0a config file parsing on win32 --- src/userpref.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/userpref.c b/src/userpref.c index d9dcaec..9b7a0a8 100644 --- a/src/userpref.c +++ b/src/userpref.c @@ -264,13 +264,19 @@ static int config_read(const char *cfgfile, plist_t *dict) char line[256]; fseek(fd, 0, SEEK_SET); while (fgets(line, 256, fd)) { - size_t llen = strlen(line)-1; - while ((llen > 0) && ((line[llen] == '\n') || (line[llen] == '\r'))) { - line[llen] = '\0'; + char *p = &line[0]; + size_t llen = strlen(p)-1; + while ((llen > 0) && ((p[llen] == '\n') || (p[llen] == '\r'))) { + p[llen] = '\0'; + llen--; } - if (!strncmp(line, "HostID=", 7)) { + if (llen == 0) continue; + while ((p[0] == '\n') || (p[0] == '\r')) { + p++; + } + if (!strncmp(p, "HostID=", 7)) { plist = plist_new_dict(); - plist_dict_insert_item(plist, "HostID", plist_new_string(line+7)); + plist_dict_insert_item(plist, "HostID", plist_new_string(p+7)); break; } } -- cgit v1.1-32-gdbae