summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Bebenita <mbebenita@gmail.com>2016-03-15 10:38:48 -0700
committerMichael Bebenita <mbebenita@gmail.com>2016-03-15 10:38:48 -0700
commite35a06baa37f2b392fd4bb9796f71317665a0b08 (patch)
tree64869fabd6482ef0ce97983ae3a0666b133dff74 /src
parentac2a4a62dd903e11be089018bcd11d7a7584a973 (diff)
downloadbinaryen-e35a06baa37f2b392fd4bb9796f71317665a0b08.tar.gz
binaryen-e35a06baa37f2b392fd4bb9796f71317665a0b08.tar.bz2
binaryen-e35a06baa37f2b392fd4bb9796f71317665a0b08.zip
fix block comments
Diffstat (limited to 'src')
-rw-r--r--src/wasm-s-parser.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 2f2eeb937..bb3492e9a 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -164,7 +164,26 @@ private:
if (input[0] == ';' && input[1] == ';') {
while (input[0] && input[0] != '\n') input++;
} else if (input[0] == '(' && input[1] == ';') {
- input = strstr(input, ";)") + 2;
+ // Skip nested block comments.
+ input += 2;
+ int depth = 1;
+ while (1) {
+ if (input[0] == 0) {
+ return;
+ }
+ if (input[0] == '(' && input[1] == ';') {
+ input += 2;
+ depth++;
+ } else if (input[0] == ';' && input[1] == ')') {
+ input += 2;
+ --depth;
+ if (depth == 0) {
+ break;
+ }
+ } else {
+ input++;
+ }
+ }
} else {
return;
}