bool Lex_input_stream::get_text(Lex_string_with_metadata_st *dst, uint sep,
                                int pre_skip, int post_skip)
{
  uchar c;
  uint found_escape=0;
  CHARSET_INFO *cs= m_thd->charset();
  bool is_8bit= false;

  while (! eof())
  {
    c= yyGet();
    if (c & 0x80)
      is_8bit= true;
#ifdef USE_MB
    {
      int l;
      if (use_mb(cs) &&
          (l = my_ismbchar(cs,
                           get_ptr() -1,
                           get_end_of_query()))) {
        skip_binary(l-1);
        continue;
      }
    }
#endif
    if (c == '\\' &&
        !(m_thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES))
    {                                        // Escaped character
      found_escape=1;
      if (eof())
        return true;
      yySkip();
    }
    else if (c == sep)
    {
      if (c == yyGet())                 // Check if two separators in a row
      {
        found_escape=1;                 // duplicate. Remember for delete
        continue;
      }
      else
        yyUnget();

      /* Found end. Unescape and return string */
      const char *str, *end;
      char *to;

      str= m_tok_start;
      end= get_ptr();
      /* Extract the text from the token */
      str += pre_skip;
      end -= post_skip;
      DBUG_ASSERT(end >= str);

      if (!(to= (char*) m_thd->alloc((uint) (end - str) + 1)))
      {
        dst->set(&empty_clex_str, 0, '\0');
        return true;                   // Sql_alloc has set error flag
      }

      m_cpp_text_start= m_cpp_tok_start + pre_skip;
      m_cpp_text_end= get_cpp_ptr() - post_skip;

      if (!found_escape)
      {
        size_t len= (end - str);
        memcpy(to, str, len);
        to[len]= '\0';
        dst->set(to, len, is_8bit, '\0');
      }
      else
      {
        size_t len= unescape(cs, to, str, end, sep);
        dst->set(to, len, is_8bit, '\0');
      }
      return false;
    }
  }
  return true;                         // unexpected end of query
}
bool Lex_input_stream::get_text(Lex_string_with_metadata_st *dst, uint sep,
                                int pre_skip, int post_skip)
{
  uchar c;
  uint found_escape=0;
  CHARSET_INFO *cs= m_thd->charset();
  bool is_8bit= false;

  while (! eof())
  {
    c= yyGet();
    if (c & 0x80)
      is_8bit= true;
#ifdef USE_MB
    {
      int l;
      if (use_mb(cs) &&
          (l = my_ismbchar(cs,
                           get_ptr() -1,
                           get_end_of_query()))) {
        skip_binary(l-1);
        continue;
      }
    }
#endif
    if (c == '\\' &&
        !(m_thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES))
    {                                         
      found_escape=1;
      if (eof())
        return true;
      yySkip();
    }
    else if (c == sep)
    {
      if (c == yyGet())                  
      {
        found_escape=1;                  
        continue;
      }
      else
        yyUnget();

       
      const char *str, *end;
      char *to;

      str= m_tok_start;
      end= get_ptr();
       
      str += pre_skip;
      end -= post_skip;
      DBUG_ASSERT(end >= str);

      if (!(to= (char*) m_thd->alloc((uint) (end - str) + 1)))
      {
        dst->set(&empty_clex_str, 0, '\0');
        return true;                    
      }

      m_cpp_text_start= m_cpp_tok_start + pre_skip;
      m_cpp_text_end= get_cpp_ptr() - post_skip;

      if (!found_escape)
      {
        size_t len= (end - str);
        memcpy(to, str, len);
        to[len]= '\0';
        dst->set(to, len, is_8bit, '\0');
      }
      else
      {
        size_t len= unescape(cs, to, str, end, sep);
        dst->set(to, len, is_8bit, '\0');
      }
      return false;
    }
  }
  return true;                          
}