| 625 | */ |
| 626 | |
| 627 | static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip) |
| 628 | { |
| 629 | reg1 uchar c,sep; |
| 630 | uint found_escape=0; |
| 631 | const CHARSET_INFO *cs= lip->m_thd->charset(); |
| 632 | |
| 633 | lip->tok_bitmap= 0; |
| 634 | sep= lip->yyGetLast(); // String should end with this |
| 635 | while (! lip->eof()) |
| 636 | { |
| 637 | c= lip->yyGet(); |
| 638 | lip->tok_bitmap|= c; |
| 639 | #ifdef USE_MB |
| 640 | { |
| 641 | int l; |
| 642 | if (use_mb(cs) && |
| 643 | (l = my_ismbchar(cs, |
| 644 | lip->get_ptr() -1, |
| 645 | lip->get_end_of_query()))) { |
| 646 | lip->skip_binary(l-1); |
| 647 | continue; |
| 648 | } |
| 649 | } |
| 650 | #endif |
| 651 | if (c == '\\' && |
| 652 | !(lip->m_thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)) |
| 653 | { // Escaped character |
| 654 | found_escape=1; |
| 655 | if (lip->eof()) |
| 656 | return 0; |
| 657 | lip->yySkip(); |
| 658 | } |
| 659 | else if (c == sep) |
| 660 | { |
| 661 | if (c == lip->yyGet()) // Check if two separators in a row |
| 662 | { |
| 663 | found_escape=1; // duplicate. Remember for delete |
| 664 | continue; |
| 665 | } |
| 666 | else |
| 667 | lip->yyUnget(); |
| 668 | |
| 669 | /* Found end. Unescape and return string */ |
| 670 | const char *str, *end; |
| 671 | char *start; |
| 672 | |
| 673 | str= lip->get_tok_start(); |
| 674 | end= lip->get_ptr(); |
| 675 | /* Extract the text from the token */ |
| 676 | str += pre_skip; |
| 677 | end -= post_skip; |
| 678 | DBUG_ASSERT(end >= str); |
| 679 | |
| 680 | if (!(start= (char*) lip->m_thd->alloc((uint) (end-str)+1))) |
| 681 | return (char*) ""; // Sql_alloc has set error flag |
| 682 | |
| 683 | lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip; |
| 684 | lip->m_cpp_text_end= lip->get_cpp_ptr() - post_skip; |
no test coverage detected