Add a newline to a configuration file if it is missing.
This commit is contained in:
parent
dea722c4ac
commit
1d322d2eda
1 changed files with 8 additions and 0 deletions
|
@ -1234,6 +1234,14 @@ static int cmd_config(int argc, char *argv[]) {
|
|||
fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Add newline if it is missing...
|
||||
if(*buf1 && buf1[strlen(buf1) - 1] != '\n') {
|
||||
if(fputc('\n', tf) < 0) {
|
||||
fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we read everything...
|
||||
|
|
Loading…
Reference in a new issue