summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parser/clang/parsing.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/parser/clang/parsing.rs b/src/parser/clang/parsing.rs
index 82f0a94..f772d4f 100644
--- a/src/parser/clang/parsing.rs
+++ b/src/parser/clang/parsing.rs
@@ -265,6 +265,7 @@ pub fn parse_comment(raw: String) -> String {
265 let mut result = String::new(); 265 let mut result = String::new();
266 266
267 'parse_loop: loop { 267 'parse_loop: loop {
268 // After the beginning of line comment delimiter / embellishment
268 let maybe_space = chars.next(); 269 let maybe_space = chars.next();
269 let mut empty_line = false; 270 let mut empty_line = false;
270 match maybe_space { 271 match maybe_space {
@@ -278,9 +279,12 @@ pub fn parse_comment(raw: String) -> String {
278 Some(ch) => result.push(ch), 279 Some(ch) => result.push(ch),
279 } 280 }
280 281
282 // After the whitespace following the comment delimiter / embellishment
281 if !empty_line { 283 if !empty_line {
282 let rest = chars.as_str(); 284 let rest = chars.as_str();
283 match rest.find('\n') { 285 // Not using .find() here because it returns the byte offset instead of the character
286 // offset
287 match rest.chars().position(|c| c == '\n') {
284 None => { 288 None => {
285 result.push_str(rest); 289 result.push_str(rest);
286 break; 290 break;
@@ -302,7 +306,7 @@ pub fn parse_comment(raw: String) -> String {
302 } 306 }
303 }; 307 };
304 308
305 // `chars` is right after the first non whitespace character 309 // `chars` is right after the first non whitespace character of the line
306 match style { 310 match style {
307 CommentStyle::Starred if first_non_ws_ch == '*' => { 311 CommentStyle::Starred if first_non_ws_ch == '*' => {
308 if &chars.as_str()[..1] == "/" { 312 if &chars.as_str()[..1] == "/" {