Skip to content

Commit 33720c0

Browse files
committed
Simplifying search for closing sequence
1 parent 901fe95 commit 33720c0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

source/load.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,12 @@ auto process_cpp_line(
243243
}
244244
}
245245
else if (in_raw_string_literal) {
246-
auto d_char_seq_len = d_char_sequence.size();
247-
switch (line[i]) {
248-
break;case '\"': if ( i > d_char_seq_len && peek(-d_char_seq_len-1) == ')') {
249-
in_raw_string_literal = (d_char_sequence != line.substr(i-d_char_seq_len, d_char_seq_len));
250-
}
251-
break;default: ;
246+
auto end_pos = line.find(d_char_sequence, i);
247+
if (end_pos == std::string::npos) {
248+
return r;
252249
}
250+
in_raw_string_literal = false;
251+
i = end_pos+d_char_sequence.size()-1;
253252
}
254253
else {
255254
r.all_comment_line = false;
@@ -260,7 +259,7 @@ auto process_cpp_line(
260259
i+=2;
261260
if (i < ssize(line) - 1) {
262261
if (auto paren_pos = line.find("(", i); paren_pos != std::string::npos) {
263-
d_char_sequence = line.substr(i, paren_pos-i);
262+
d_char_sequence = ")"+line.substr(i, paren_pos-i)+"\"";
264263
in_raw_string_literal = true;
265264
}
266265
}

0 commit comments

Comments
 (0)