From a0c421c118abde7636d4d2b9bee93ca78e656d30 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 2 Dec 2018 20:16:52 +0100 Subject: [PATCH] bc: simplify bc_vm_stdin() function old new delta bc_vm_run 2020 2006 -14 Signed-off-by: Denys Vlasenko --- miscutils/bc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/miscutils/bc.c b/miscutils/bc.c index 63b745dc7..78c64355b 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -7005,11 +7005,10 @@ err: static BcStatus bc_vm_stdin(void) { - BcStatus s = BC_STATUS_SUCCESS; + BcStatus s; BcVec buf, buffer; - char c; size_t len, i, str = 0; - bool comment = false, notend; + bool comment = false; G.prog.file = bc_program_stdin_name; bc_lex_file(&G.prs.l, bc_program_stdin_name); @@ -7022,7 +7021,7 @@ static BcStatus bc_vm_stdin(void) // with a backslash to the parser. The reason for that is because the parser // treats a backslash+newline combo as whitespace, per the bc spec. In that // case, and for strings and comments, the parser will expect more stuff. - for (s = bc_read_line(&buf, ">>> "); !s; s = bc_read_line(&buf, ">>> ")) { + while ((s = bc_read_line(&buf, ">>> ")) == BC_STATUS_SUCCESS) { char *string = buf.v; @@ -7038,8 +7037,8 @@ static BcStatus bc_vm_stdin(void) for (i = 0; i < len; ++i) { - notend = len > i + 1; - c = string[i]; + bool notend = len > i + 1; + char c = string[i]; if (i - 1 > len || string[i - 1] != '\\') { if (G.sbgn == G.send)