static int write_state_text(const struct am_state *state,
const char *name, const char *string)
{
- const char *fmt;
-
- if (*string && string[strlen(string) - 1] != '\n')
- fmt = "%s\n";
- else
- fmt = "%s";
- return write_file(am_path(state, name), fmt, string);
+ return write_file(am_path(state, name), "%s", string);
}
static int write_state_count(const struct am_state *state,
const char *name, int value)
{
- return write_file(am_path(state, name), "%d\n", value);
+ return write_file(am_path(state, name), "%d", value);
}
static int write_state_bool(const struct am_state *state,
return -1;
}
strbuf_vaddf(&sb, fmt, params);
+ strbuf_complete_line(&sb);
if (write_in_full(fd, sb.buf, sb.len) != sb.len) {
int err = errno;
close(fd);