[git commit branch/1_30_stable] bc: in xc_read_line(), check ^C on NUL input bytes too

Denys Vlasenko vda.linux at googlemail.com
Thu Feb 14 13:40:57 UTC 2019


commit: https://git.busybox.net/busybox/commit/?id=c3de036da92777d69ea0a9725130085d546c366a
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/1_30_stable

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 miscutils/bc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/miscutils/bc.c b/miscutils/bc.c
index febf51cfd..23b3521d4 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2509,7 +2509,7 @@ static void xc_read_line(BcVec *vec, FILE *fp)
 		i = 0;
 		for (;;) {
 			char c = line_buf[i++];
-			if (!c) break;
+			if (c == '\0') break;
 			if (bad_input_byte(c)) goto again;
 		}
 		bc_vec_string(vec, n, line_buf);
@@ -2522,14 +2522,16 @@ static void xc_read_line(BcVec *vec, FILE *fp)
 		bool bad_chars = 0;
 
 		do {
+ get_char:
 #if ENABLE_FEATURE_BC_INTERACTIVE
 			if (G_interrupt) {
 				// ^C was pressed: ignore entire line, get another one
-				bc_vec_pop_all(vec);
-				goto intr;
+				goto again;
 			}
 #endif
-			do c = fgetc(fp); while (c == '\0');
+			c = fgetc(fp);
+			if (c == '\0')
+				goto get_char;
 			if (c == EOF) {
 				if (ferror(fp))
 					bb_perror_msg_and_die("input error");


More information about the busybox-cvs mailing list