From def2023228aeeb21e381a26be13d9638fdf89e80 Mon Sep 17 00:00:00 2001 From: kofta999 Date: Tue, 3 Jun 2025 19:32:58 +0300 Subject: [PATCH] fix nested block comments with a slash in between --- src/scanner.c | 3 +++ test/corpus/source_files.txt | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/scanner.c b/src/scanner.c index 269f6b2a..a0ec91cb 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -214,6 +214,9 @@ typedef struct { static inline void process_left_forward_slash(BlockCommentProcessing *processing, char current) { if (current == '*') { processing->nestingDepth += 1; + } else if (current == '/') { + processing->state = LeftForwardSlash; + return; } processing->state = Continuing; }; diff --git a/test/corpus/source_files.txt b/test/corpus/source_files.txt index a7a000e2..dd76f1de 100644 --- a/test/corpus/source_files.txt +++ b/test/corpus/source_files.txt @@ -48,6 +48,13 @@ Nested block comments // --- +/* + nested with extra slash between two nested block comments + /**///**/ +*/ + +// --- + ---- (source_file @@ -56,6 +63,8 @@ Nested block comments (block_comment) (line_comment) (block_comment) + (line_comment) + (block_comment) (line_comment)) ============================================