Mercurial > octave
changeset 23555:9151922777e2
Pick correct help text when shebang is present (bug #51191).
* lex.ll (looks_like_shebang): New function
* lex.ll (base_lexer::finish_comment): Check that comment isn't actually
shebang sequence before setting help text equal to comment text.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 07 Jun 2017 12:11:33 -0700 |
parents | b075b1629c26 |
children | 31b1ef1ee585 |
files | libinterp/parse-tree/lex.ll |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Fri Jun 02 09:16:02 2017 -0400 +++ b/libinterp/parse-tree/lex.ll Wed Jun 07 12:11:33 2017 -0700 @@ -2235,12 +2235,19 @@ { size_t offset = s.find_first_not_of (" \t"); - retval = (s.substr (offset, 9) == "Copyright" || s.substr (offset, 6) == "Author"); + retval = (s.substr (offset, 9) == "Copyright" + || s.substr (offset, 6) == "Author"); } return retval; } +static bool +looks_like_shebang (const std::string& s) +{ + return ((! s.empty ()) && (s[0] == '!')); +} + namespace octave { void @@ -2898,8 +2905,8 @@ { bool copyright = looks_like_copyright (comment_text); - if (nesting_level.none () && help_text.empty () - && ! comment_text.empty () && ! copyright) + if (nesting_level.none () && help_text.empty () && ! comment_text.empty () + && ! copyright && ! looks_like_shebang (comment_text)) help_text = comment_text; if (copyright)