diff options
| author | 2011-10-08 19:27:36 +0200 | |
|---|---|---|
| committer | 2012-03-19 01:45:30 +0100 | |
| commit | 38171bc2332dc68b86ea627e50c482e2ace4e342 (patch) | |
| tree | 1eef052f2b23fe1e2d14da5a782db139f1208a84 | |
| parent | 6e092c84d060fe4e0e9ddea8801c42425cd59afa (diff) | |
| download | libimobiledevice-38171bc2332dc68b86ea627e50c482e2ace4e342.tar.gz libimobiledevice-38171bc2332dc68b86ea627e50c482e2ace4e342.tar.bz2 | |
userprefs: fix 0x0d,0x0a config file parsing on win32
| -rw-r--r-- | src/userpref.c | 16 |
1 files 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) | |||
| 264 | char line[256]; | 264 | char line[256]; |
| 265 | fseek(fd, 0, SEEK_SET); | 265 | fseek(fd, 0, SEEK_SET); |
| 266 | while (fgets(line, 256, fd)) { | 266 | while (fgets(line, 256, fd)) { |
| 267 | size_t llen = strlen(line)-1; | 267 | char *p = &line[0]; |
| 268 | while ((llen > 0) && ((line[llen] == '\n') || (line[llen] == '\r'))) { | 268 | size_t llen = strlen(p)-1; |
| 269 | line[llen] = '\0'; | 269 | while ((llen > 0) && ((p[llen] == '\n') || (p[llen] == '\r'))) { |
| 270 | p[llen] = '\0'; | ||
| 271 | llen--; | ||
| 270 | } | 272 | } |
| 271 | if (!strncmp(line, "HostID=", 7)) { | 273 | if (llen == 0) continue; |
| 274 | while ((p[0] == '\n') || (p[0] == '\r')) { | ||
| 275 | p++; | ||
| 276 | } | ||
| 277 | if (!strncmp(p, "HostID=", 7)) { | ||
| 272 | plist = plist_new_dict(); | 278 | plist = plist_new_dict(); |
| 273 | plist_dict_insert_item(plist, "HostID", plist_new_string(line+7)); | 279 | plist_dict_insert_item(plist, "HostID", plist_new_string(p+7)); |
| 274 | break; | 280 | break; |
| 275 | } | 281 | } |
| 276 | } | 282 | } |
