* check for SQL "BEGIN DECLARE SECTION". * must compare case insensitive and allow any spacing between words. * * @param line a reference to the line to indent. * @param index the current line index. * @return true if a hit. */
| 383 | * @return true if a hit. |
| 384 | */ |
| 385 | bool ASEnhancer::isBeginDeclareSectionSQL(string& line, size_t index) const |
| 386 | { |
| 387 | string word; |
| 388 | size_t hits = 0; |
| 389 | size_t i; |
| 390 | for (i = index; i < line.length(); i++) |
| 391 | { |
| 392 | i = line.find_first_not_of(" \t", i); |
| 393 | if (i == string::npos) |
| 394 | return false; |
| 395 | if (line[i] == ';') |
| 396 | break; |
| 397 | if (!isCharPotentialHeader(line, i)) |
| 398 | continue; |
| 399 | word = getCurrentWord(line, i); |
| 400 | for (size_t j = 0; j < word.length(); j++) |
| 401 | word[j] = (char) toupper(word[j]); |
| 402 | if (word == "EXEC" || word == "SQL") |
| 403 | { |
| 404 | i += word.length() - 1; |
| 405 | continue; |
| 406 | } |
| 407 | if (word == "DECLARE" || word == "SECTION") |
| 408 | { |
| 409 | hits++; |
| 410 | i += word.length() - 1; |
| 411 | continue; |
| 412 | } |
| 413 | if (word == "BEGIN") |
| 414 | { |
| 415 | hits++; |
| 416 | i += word.length() - 1; |
| 417 | continue; |
| 418 | } |
| 419 | return false; |
| 420 | } |
| 421 | if (hits == 3) |
| 422 | return true; |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * check for SQL "END DECLARE SECTION". |