private void AdjustDelimiterEnd(string query, MySqlTokenizer tokenizer) { int stopIndex = tokenizer.StopIndex; char c = query[stopIndex]; while (!char.IsWhiteSpace(c) && stopIndex < query.Length - 1) { c = query[++stopIndex]; } tokenizer.StopIndex = stopIndex; tokenizer.Position = stopIndex; }
private List <ScriptStatement> BreakIntoStatements(string query, bool ansiQuotes, bool noBackslashEscapes) { string str1 = this.delimiter; int num1 = 0; List <ScriptStatement> list = new List <ScriptStatement>(); List <int> lineNumbers = this.BreakScriptIntoLines(query); MySqlTokenizer tokenizer = new MySqlTokenizer(query); tokenizer.AnsiQuotes = ansiQuotes; tokenizer.BackslashEscapes = !noBackslashEscapes; for (string str2 = tokenizer.NextToken(); str2 != null; str2 = tokenizer.NextToken()) { if (!tokenizer.Quoted) { if (str2.ToLower(CultureInfo.InvariantCulture) == "delimiter") { tokenizer.NextToken(); this.AdjustDelimiterEnd(query, tokenizer); str1 = query.Substring(tokenizer.StartIndex, tokenizer.StopIndex - tokenizer.StartIndex + 1).Trim(); num1 = tokenizer.StopIndex; } else { if (str1.StartsWith(str2) && tokenizer.StartIndex + str1.Length <= query.Length && query.Substring(tokenizer.StartIndex, str1.Length) == str1) { str2 = str1; tokenizer.Position = tokenizer.StartIndex + str1.Length; tokenizer.StopIndex = tokenizer.Position; } int num2 = str2.IndexOf(str1, StringComparison.InvariantCultureIgnoreCase); if (num2 != -1) { int num3 = tokenizer.StopIndex - str2.Length + num2; if (tokenizer.StopIndex == query.Length - 1) { ++num3; } string str3 = query.Substring(num1, num3 - num1); ScriptStatement scriptStatement = new ScriptStatement(); scriptStatement.text = str3.Trim(); scriptStatement.line = FindLineNumber(num1, lineNumbers); scriptStatement.position = num1 - lineNumbers[scriptStatement.line]; list.Add(scriptStatement); num1 = num3 + str1.Length; } } } } if (num1 < query.Length - 1) { string str2 = query.Substring(num1).Trim(); if (!string.IsNullOrEmpty(str2)) { ScriptStatement scriptStatement = new ScriptStatement(); scriptStatement.text = str2; scriptStatement.line = FindLineNumber(num1, lineNumbers); scriptStatement.position = num1 - lineNumbers[scriptStatement.line]; list.Add(scriptStatement); } } return(list); }