MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / consume_comment

Function consume_comment

sql/sql_lex.cc:857–888  ·  view source on GitHub ↗

Given a stream that is advanced to the first contained character in an open comment, consume the comment. Optionally, if we are allowed, recurse so that we understand comments within this current comment. At this level, we do not support version-condition comments. We might have been called with having just passed one in the stream, though. In that case, we probably want to toler

Source from the content-addressed store, hash-verified

855 @retval Whether EOF reached before comment is closed.
856*/
857bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted)
858{
859 reg1 uchar c;
860 while (! lip->eof())
861 {
862 c= lip->yyGet();
863
864 if (remaining_recursions_permitted > 0)
865 {
866 if ((c == '/') && (lip->yyPeek() == '*'))
867 {
868 lip->yySkip(); /* Eat asterisk */
869 consume_comment(lip, remaining_recursions_permitted-1);
870 continue;
871 }
872 }
873
874 if (c == '*')
875 {
876 if (lip->yyPeek() == '/')
877 {
878 lip->yySkip(); /* Eat slash */
879 return FALSE;
880 }
881 }
882
883 if (c == '\n')
884 lip->yylineno++;
885 }
886
887 return TRUE;
888}
889
890
891/*

Callers 1

lex_one_tokenFunction · 0.85

Calls 4

yyGetMethod · 0.80
yyPeekMethod · 0.80
yySkipMethod · 0.80
eofMethod · 0.45

Tested by

no test coverage detected