diff options
| author | jvoisin | 2018-01-03 14:23:29 +0100 |
|---|---|---|
| committer | jvoisin | 2018-01-03 14:24:05 +0100 |
| commit | bc55f1ccd1c995f7ab502323c96f5a44352a5a80 (patch) | |
| tree | 7cc46d06068e3d05e8e7ef25397c70af56ce7c50 /src/sp_config.c | |
| parent | ba4cf621c33de08680d851b549eaaa009d5785f4 (diff) | |
Handle correctly configuration files with Windows EOL
Thanks to @fr33tux for the bug report ♥
Diffstat (limited to 'src/sp_config.c')
| -rw-r--r-- | src/sp_config.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sp_config.c b/src/sp_config.c index aeadd9d..4d95062 100644 --- a/src/sp_config.c +++ b/src/sp_config.c | |||
| @@ -175,7 +175,11 @@ int sp_parse_config(const char *conf_file) { | |||
| 175 | while (getline(&lineptr, &n, fd) > 0) { | 175 | while (getline(&lineptr, &n, fd) > 0) { |
| 176 | /* We trash the terminal `\n`. This simplify the display of logs. */ | 176 | /* We trash the terminal `\n`. This simplify the display of logs. */ |
| 177 | if (lineptr[strlen(lineptr) - 1] == '\n') { | 177 | if (lineptr[strlen(lineptr) - 1] == '\n') { |
| 178 | lineptr[strlen(lineptr) - 1] = '\0'; | 178 | if (lineptr[strlen(lineptr) - 2] == '\r') { |
| 179 | lineptr[strlen(lineptr) - 2] = '\0'; | ||
| 180 | } else { | ||
| 181 | lineptr[strlen(lineptr) - 1] = '\0'; | ||
| 182 | } | ||
| 179 | } | 183 | } |
| 180 | if (parse_line(lineptr) == -1) { | 184 | if (parse_line(lineptr) == -1) { |
| 181 | fclose(fd); | 185 | fclose(fd); |
