Skip to content

Commit 0c78ba2

Browse files
committed
Fixed a crash when a comment contains regular text wrapped in <>.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 7623adc commit 0c78ba2

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/Generator/Passes/CleanCommentsPass.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,23 @@ public bool VisitParagraphCommand(ParagraphComment comment)
5757
{
5858
for (int i = 0; i < comment.Content.Count; i++)
5959
{
60-
if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment)
60+
if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment &&
61+
i + 1 < comment.Content.Count &&
62+
comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment)
6163
{
62-
if (i + 1 < comment.Content.Count &&
63-
comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment)
64-
{
65-
TextComment com = (TextComment) comment.Content[i + 1];
66-
com.Text = Helpers.RegexCommentCommandLeftover.Replace(com.Text, string.Empty);
67-
}
64+
var textComment = (TextComment) comment.Content[i + 1];
65+
textComment.Text = Helpers.RegexCommentCommandLeftover.Replace(
66+
textComment.Text, string.Empty);
6867
}
6968
}
70-
bool tag = false;
7169
foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment))
7270
{
73-
TextComment com = (TextComment) item;
74-
if (Helpers.RegexTag.IsMatch(com.Text))
75-
tag = true;
76-
else if (tag)
77-
com.Text = com.Text.Substring(1);
78-
79-
if (com.Text.StartsWith("<", StringComparison.Ordinal))
80-
com.Text = $"{com.Text}{">"}";
81-
else if (com.Text.StartsWith(">", StringComparison.Ordinal))
82-
com.Text = com.Text.Substring(1);
71+
var textComment = (TextComment) item;
72+
73+
if (textComment.Text.StartsWith("<", StringComparison.Ordinal))
74+
textComment.Text = $"{textComment.Text}{">"}";
75+
else if (textComment.Text.StartsWith(">", StringComparison.Ordinal))
76+
textComment.Text = textComment.Text.Substring(1);
8377
}
8478
return true;
8579
}

tests/Native/AST.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ class TestComments
189189
* @since Added in version 3.0. Replaces `glfwCloseWindow`.
190190
*/
191191
void glfwDestroyWindow(int* window);
192+
193+
/**
194+
195+
*/
196+
class LinphoneAddress {};
192197
};
193198

194199
template <typename T>

0 commit comments

Comments
 (0)