Commit c07c58d7 authored by Lasse Karstensen's avatar Lasse Karstensen Committed by Pål Hermunn Johansen

Remove implicit line feed when using formatfile.

Fixes: #1967
parent d5a3959d
...@@ -1104,12 +1104,14 @@ read_format(const char *formatfile) ...@@ -1104,12 +1104,14 @@ read_format(const char *formatfile)
{ {
FILE *fmtfile; FILE *fmtfile;
size_t len = 0; size_t len = 0;
int fmtlen;
char *fmt = NULL; char *fmt = NULL;
fmtfile = fopen(formatfile, "r"); fmtfile = fopen(formatfile, "r");
if (fmtfile == NULL) if (fmtfile == NULL)
VUT_Error(1, "Can't open format file (%s)", strerror(errno)); VUT_Error(1, "Can't open format file (%s)", strerror(errno));
if (getline(&fmt, &len, fmtfile) == -1) { fmtlen = getline(&fmt, &len, fmtfile);
if (fmtlen == -1) {
free(fmt); free(fmt);
if (feof(fmtfile)) if (feof(fmtfile))
VUT_Error(1, "Empty format file"); VUT_Error(1, "Empty format file");
...@@ -1118,6 +1120,8 @@ read_format(const char *formatfile) ...@@ -1118,6 +1120,8 @@ read_format(const char *formatfile)
strerror(errno)); strerror(errno));
} }
fclose(fmtfile); fclose(fmtfile);
if (fmt[fmtlen - 1] == '\n')
fmt[fmtlen - 1] = '\0';
return (fmt); return (fmt);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment