aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Howard <yzena.tech@gmail.com>2021-03-31 15:06:22 -0600
committerGavin Howard <yzena.tech@gmail.com>2021-03-31 15:06:22 -0600
commit40819fa16de926f67f709538ac4a6417af98f34f (patch)
treec2e588fe670f1dab497a154cd1e704bd518530ab
parentec26fd2f11e7676d65d62097fef26cb6eb57f7c8 (diff)
downloadbc-40819fa16de926f67f709538ac4a6417af98f34f.tar.gz
Ensure that the new stuff is only active when history is
-rw-r--r--src/file.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/file.c b/src/file.c
index aa5307b9..c58b026f 100644
--- a/src/file.c
+++ b/src/file.c
@@ -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);