diff options
author | Gavin Howard <yzena.tech@gmail.com> | 2021-03-31 15:06:22 -0600 |
---|---|---|
committer | Gavin Howard <yzena.tech@gmail.com> | 2021-03-31 15:06:22 -0600 |
commit | 40819fa16de926f67f709538ac4a6417af98f34f (patch) | |
tree | c2e588fe670f1dab497a154cd1e704bd518530ab | |
parent | ec26fd2f11e7676d65d62097fef26cb6eb57f7c8 (diff) | |
download | bc-40819fa16de926f67f709538ac4a6417af98f34f.tar.gz |
Ensure that the new stuff is only active when history is
-rw-r--r-- | src/file.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -89,20 +89,23 @@ BcStatus bc_file_flushErr(BcFile *restrict f, BcFlushType type) if (f->len) { #if BC_ENABLE_HISTORY - if (f->buf[f->len - 1] != '\n' && - (type == BC_FLUSH_SAVE_EXTRAS_CLEAR || - type == BC_FLUSH_SAVE_EXTRAS_NO_CLEAR)) - { - size_t i; + if (BC_TTY) { + if (f->buf[f->len - 1] != '\n' && + (type == BC_FLUSH_SAVE_EXTRAS_CLEAR || + type == BC_FLUSH_SAVE_EXTRAS_NO_CLEAR)) + { + size_t i; - for (i = f->len - 2; i < f->len && f->buf[i] != '\n'; --i); + for (i = f->len - 2; i < f->len && f->buf[i] != '\n'; --i); - i += 1; + i += 1; - bc_vec_string(&vm.history.extras, f->len - i, f->buf + i); + bc_vec_string(&vm.history.extras, f->len - i, f->buf + i); + } + else if (type >= BC_FLUSH_NO_EXTRAS_CLEAR) { + bc_vec_popAll(&vm.history.extras); + } } - else if (type >= BC_FLUSH_NO_EXTRAS_CLEAR) - bc_vec_popAll(&vm.history.extras); #endif // BC_ENABLE_HISTORY s = bc_file_output(f->fd, f->buf, f->len); |