From: Guus Sliepen Date: Sat, 21 Jul 2012 13:02:44 +0000 (+0200) Subject: Add a newline to a configuration file if it is missing. X-Git-Tag: import-tinc-1.1~339 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=1d322d2eda8223f21b0c00381af34b94054f251a;p=meshlink Add a newline to a configuration file if it is missing. --- diff --git a/src/tincctl.c b/src/tincctl.c index b944e5c4..a3688eca 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -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...