[git commit] bc: fix comment handling
Denys Vlasenko
vda.linux at googlemail.com
Thu Dec 13 16:43:23 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=766f67250f01dc5458093c31ec0d2ec09cad65a2
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
bc_vm_run 514 513 -1
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/bc.c | 7 +++++--
testsuite/bc.tests | 12 ++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 9c7e69fc1..dc9a7da8e 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -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);
diff --git a/testsuite/bc.tests b/testsuite/bc.tests
index 32460092b..4f0d50f73 100755
--- a/testsuite/bc.tests
+++ b/testsuite/bc.tests
@@ -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
More information about the busybox-cvs
mailing list