From 907101b42159c3d2a8ee74540fb8e9259b36db7e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 28 Sep 2020 16:35:22 -0700 Subject: Fixes for captures and backrefs, and added block comments --- utils.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 6b9af5c..012c1eb 100644 --- a/utils.c +++ b/utils.c @@ -9,6 +9,7 @@ */ const char *after_spaces(const char *str) { + int block_comment_depth = 0; // Skip whitespace and comments: skip_whitespace: switch (*str) { @@ -17,7 +18,20 @@ const char *after_spaces(const char *str) goto skip_whitespace; } case '#': { - while (*str && *str != '\n') ++str; + if (str[1] == '(') { + ++block_comment_depth; + for (str += 2; *str && block_comment_depth > 0; ++str) { + if (str[0] == '#' && str[1] == '(') { + ++block_comment_depth; + ++str; + } else if (str[0] == ')' && str[1] == '#') { + --block_comment_depth; + ++str; + } + } + } else { + while (*str && *str != '\n') ++str; + } goto skip_whitespace; } } -- cgit v1.2.3