vere: trim trailing whitespace from pace file

This commit is contained in:
Joe Bryan 2022-05-27 12:27:14 -04:00
parent 95eda1e8ab
commit dbc61c360b

View File

@ -2,6 +2,7 @@
**
** the main loop of the daemon process
*/
#include <ctype.h>
#include "all.h"
#include "ur/ur.h"
#include "vere/ivory.h"
@ -321,16 +322,21 @@ _king_get_pace(void)
len_w = buf_u.st_size;
pat_c = c3_malloc(len_w + 1);
red_w = read(fid_i, pat_c, len_w);
pat_c[len_w] = 0;
close(fid_i);
if ( len_w != red_w ) {
c3_free(pat_c);
u3l_log("unable to read pace file, "
"falling back to default (\"live\")\n");
return strdup("live");
}
// XX trim pat_c ?
//
pat_c[len_w] = 0;
while ( len_w-- && isspace(pat_c[len_w]) ) {
pat_c[len_w] = 0;
}
return pat_c;
}