summaryrefslogtreecommitdiff
path: root/pkg/bc/patch
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-03-05 23:58:15 -0800
committerMichael Forney <mforney@mforney.org>2019-03-06 01:38:57 -0800
commitc7d55edad461cbf326803b3ced8b8187470f5b6a (patch)
treef9e483fe44eabd096232b2d25129919db27998c3 /pkg/bc/patch
parent858cfd217f4db2613550379898561a41bc34e741 (diff)
bc: Replace with Gavin Howard's implementation
Diffstat (limited to 'pkg/bc/patch')
-rw-r--r--pkg/bc/patch/0001-Fix-a-bug.patch25
-rw-r--r--pkg/bc/patch/0001-Fix-use-of-uninitialized-f_void.patch25
-rw-r--r--pkg/bc/patch/0002-Fix-EOF-behavior-in-interactive-mode-with-history.patch34
3 files changed, 59 insertions, 25 deletions
diff --git a/pkg/bc/patch/0001-Fix-a-bug.patch b/pkg/bc/patch/0001-Fix-a-bug.patch
new file mode 100644
index 00000000..4fa20bef
--- /dev/null
+++ b/pkg/bc/patch/0001-Fix-a-bug.patch
@@ -0,0 +1,25 @@
+From b8e4f427c41a66b272a04ef2506020e64504b443 Mon Sep 17 00:00:00 2001
+From: Gavin Howard <yzena.tech@gmail.com>
+Date: Wed, 20 Feb 2019 09:27:30 -0700
+Subject: [PATCH] Fix a bug
+
+---
+ src/read.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/read.c b/src/read.c
+index 43fa8e12..45237397 100644
+--- a/src/read.c
++++ b/src/read.c
+@@ -118,7 +118,7 @@ BcStatus bc_read_line(BcVec *vec, const char *prompt) {
+ if (bc_read_binary(vec->v, vec->len - 1))
+ return bc_vm_verr(BC_ERROR_VM_BIN_FILE, bc_program_stdin_name);
+
+- return BC_STATUS_SUCCESS;
++ return s;
+ }
+
+ BcStatus bc_read_file(const char *path, char **buf) {
+--
+2.21.0
+
diff --git a/pkg/bc/patch/0001-Fix-use-of-uninitialized-f_void.patch b/pkg/bc/patch/0001-Fix-use-of-uninitialized-f_void.patch
deleted file mode 100644
index 2b91dc9b..00000000
--- a/pkg/bc/patch/0001-Fix-use-of-uninitialized-f_void.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 359f44a3a0605c94d57f35e4de39e6028dce018f Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Sun, 12 Jun 2016 20:12:28 -0700
-Subject: [PATCH] Fix use of uninitialized f_void
-
-See http://www.pixelbeat.org/programming/oss_bug_flow.html.
----
- bc/storage.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/bc/storage.c b/bc/storage.c
-index 699729a..37b4c6c 100644
---- a/bc/storage.c
-+++ b/bc/storage.c
-@@ -99,6 +99,7 @@ more_functions (VOID)
- {
- f = &functions[indx];
- f->f_defined = FALSE;
-+ f->f_void = FALSE;
- f->f_body = (char *) bc_malloc (BC_START_SIZE);
- f->f_body_size = BC_START_SIZE;
- f->f_code_size = 0;
---
-2.8.1
-
diff --git a/pkg/bc/patch/0002-Fix-EOF-behavior-in-interactive-mode-with-history.patch b/pkg/bc/patch/0002-Fix-EOF-behavior-in-interactive-mode-with-history.patch
new file mode 100644
index 00000000..e7fdefa7
--- /dev/null
+++ b/pkg/bc/patch/0002-Fix-EOF-behavior-in-interactive-mode-with-history.patch
@@ -0,0 +1,34 @@
+From bbaac8ed0fc40acc4349df837abed2af72276f52 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Wed, 6 Mar 2019 00:52:01 -0800
+Subject: [PATCH] Fix EOF behavior in interactive mode with history
+
+Previously, Ctrl-D would re-process the previous line, read one
+more line, then exit. This is because bc_history_line left the
+buffer untouched in case of EOF, and the bc_vm_stdin loop reads the
+next line before checking the `done` condition of the previous
+iteration.
+
+This fix also prevents reading passed the end of the buffer in case
+the first user input is EOF, since in that case, vec->len is still
+0, so (size_t)-1 is passed to bc_read_binary.
+---
+ src/history/history.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/history/history.c b/src/history/history.c
+index e9953ed5..d575256d 100644
+--- a/src/history/history.c
++++ b/src/history/history.c
+@@ -1229,7 +1229,7 @@ BcStatus bc_history_line(BcHistory *h, BcVec *vec, const char *prompt) {
+ if (BC_TTYIN && !vm->history.badTerm) {
+
+ s = bc_history_raw(h, prompt);
+- if (s) return s;
++ if (s && s != BC_STATUS_EOF) return s;
+
+ bc_vec_string(vec, BC_HISTORY_BUF_LEN(h), h->buf.v);
+
+--
+2.21.0
+