bc: fix comment handling
No binary (build failed)
—
(log yok)
| @@ -7088,10 +7088,13 @@ static BC_STATUS zbc_vm_stdin(void) | |
| string++; | |
| if (c == '/' && *string == '*') { | |
| comment = true; | |
| - | break; |
| + | string++; |
| + | continue; |
| } | |
| - | if (c == '*' && *string == '/') |
| + | if (c == '*' && *string == '/') { |
| comment = false; | |
| + | string++; |
| + | } |
| } | |
| if (str || comment || string[-2] == '\\') { | |
| bc_vec_concat(&buffer, buf.v); | |
| @@ -4,6 +4,18 @@ | |
| . ./testing.sh | |
| + | # testing "test name" "command" "expected result" "file input" "stdin" |
| + | |
| + | testing "bc comment 1" \ |
| + | "bc" \ |
| + | "3\n" \ |
| + | "" "1 /* comment */ + 2" |
| + | |
| + | testing "bc comment 2: /*/ is not a closed comment" \ |
| + | "bc" \ |
| + | "4\n" \ |
| + | "" "1 /*/ + 2 */ + 3" |
| + | |
| tar xJf bc_large.tar.xz | |
| for f in bc*.bc; do | |