mirror of https://github.com/swig/swig
Doxygen comment parsing fix for empty lines in code/verbatim blocks
Fix how end of paragraph is identified when parsing \code and \verbatim blocks that appear within a paragraph and contain an empty line. Previously this would generate a warning for unexpected end of doxygen comments, and it could generate a segfault due to dereferencing an invalid iterator value. The doxygen_basic_translate.i and doxygen_basic_translate_style2.i tests have been updated to serve as regression tests for this behavior. Prior to this fix, inclusion of the empty code block line in this context produced a segfault.
This commit is contained in:
parent
b55ce0cf84
commit
85a4c7ffc0
|
@ -57,6 +57,8 @@ void function3(int a, int b)
|
||||||
* \warning This may not work as expected
|
* \warning This may not work as expected
|
||||||
* \code
|
* \code
|
||||||
* int main() { while(true); }
|
* int main() { while(true); }
|
||||||
|
*
|
||||||
|
* // Test blank line in code block
|
||||||
* \endcode
|
* \endcode
|
||||||
* \endif
|
* \endif
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -55,6 +55,8 @@ void function3(int a, int b)
|
||||||
* \warning This may not work as expected
|
* \warning This may not work as expected
|
||||||
* \code
|
* \code
|
||||||
* int main() { while(true); }
|
* int main() { while(true); }
|
||||||
|
*
|
||||||
|
* // Test blank line in code block
|
||||||
* \endcode
|
* \endcode
|
||||||
* \endif
|
* \endif
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,6 +54,8 @@ public class doxygen_basic_translate_runme {
|
||||||
" \n" +
|
" \n" +
|
||||||
" {@code \n" +
|
" {@code \n" +
|
||||||
"int main() { while(true); } \n" +
|
"int main() { while(true); } \n" +
|
||||||
|
"\n" +
|
||||||
|
"// Test blank line in code block \n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" \n" +
|
" \n" +
|
||||||
|
|
|
@ -54,6 +54,8 @@ public class doxygen_basic_translate_style2_runme {
|
||||||
" \n" +
|
" \n" +
|
||||||
" {@code \n" +
|
" {@code \n" +
|
||||||
"int main() { while(true); } \n" +
|
"int main() { while(true); } \n" +
|
||||||
|
"\n" +
|
||||||
|
"// Test blank line in code block \n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" \n" +
|
" \n" +
|
||||||
|
|
|
@ -50,6 +50,8 @@ Warning: This may not work as expected
|
||||||
.. code-block:: c++
|
.. code-block:: c++
|
||||||
|
|
||||||
int main() { while(true); }
|
int main() { while(true); }
|
||||||
|
|
||||||
|
// Test blank line in code block
|
||||||
}"""
|
}"""
|
||||||
)
|
)
|
||||||
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5),
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5),
|
||||||
|
|
|
@ -48,6 +48,8 @@ Warning: This may not work as expected
|
||||||
.. code-block:: c++
|
.. code-block:: c++
|
||||||
|
|
||||||
int main() { while(true); }
|
int main() { while(true); }
|
||||||
|
|
||||||
|
// Test blank line in code block
|
||||||
}"""
|
}"""
|
||||||
)
|
)
|
||||||
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5),
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5),
|
||||||
|
|
|
@ -289,6 +289,18 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(const TokenList &to
|
||||||
TokenListCIt endOfParagraph = m_tokenListIt;
|
TokenListCIt endOfParagraph = m_tokenListIt;
|
||||||
|
|
||||||
while (endOfParagraph != tokList.end()) {
|
while (endOfParagraph != tokList.end()) {
|
||||||
|
// If \code or \verbatim is encountered within a paragraph, then
|
||||||
|
// go all the way to the end of that command, since the content
|
||||||
|
// could contain empty lines that would appear to be paragraph
|
||||||
|
// ends:
|
||||||
|
if (endOfParagraph->m_tokenType == COMMAND &&
|
||||||
|
(endOfParagraph->m_tokenString == "code" ||
|
||||||
|
endOfParagraph->m_tokenString == "verbatim")) {
|
||||||
|
const string theCommand = endOfParagraph->m_tokenString;
|
||||||
|
endOfParagraph = getEndCommand("end" + theCommand, tokList);
|
||||||
|
endOfParagraph++; // Move after the end command
|
||||||
|
return endOfParagraph;
|
||||||
|
}
|
||||||
if (endOfParagraph->m_tokenType == END_LINE) {
|
if (endOfParagraph->m_tokenType == END_LINE) {
|
||||||
endOfParagraph++;
|
endOfParagraph++;
|
||||||
if (endOfParagraph != tokList.end()
|
if (endOfParagraph != tokList.end()
|
||||||
|
|
Loading…
Reference in New Issue