bc: simplify bc_vm_stdin()

function                                             old     new   delta
bc_vm_run                                           2020    2006     -14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-12-02 20:16:52 +01:00
parent 71e1fc6b37
commit a0c421c118

View File

@ -7005,11 +7005,10 @@ err:
static BcStatus bc_vm_stdin(void) static BcStatus bc_vm_stdin(void)
{ {
BcStatus s = BC_STATUS_SUCCESS; BcStatus s;
BcVec buf, buffer; BcVec buf, buffer;
char c;
size_t len, i, str = 0; size_t len, i, str = 0;
bool comment = false, notend; bool comment = false;
G.prog.file = bc_program_stdin_name; G.prog.file = bc_program_stdin_name;
bc_lex_file(&G.prs.l, 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 // 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 // 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. // 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; char *string = buf.v;
@ -7038,8 +7037,8 @@ static BcStatus bc_vm_stdin(void)
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
notend = len > i + 1; bool notend = len > i + 1;
c = string[i]; char c = string[i];
if (i - 1 > len || string[i - 1] != '\\') { if (i - 1 > len || string[i - 1] != '\\') {
if (G.sbgn == G.send) if (G.sbgn == G.send)