* parse characters in the current line to determine if an indent * or unindent is needed. */
| 455 | * or unindent is needed. |
| 456 | */ |
| 457 | void ASEnhancer::parseCurrentLine(string &line, bool isInPreprocessor, bool isInSQL) |
| 458 | { |
| 459 | bool isSpecialChar = false; // is a backslash escape character |
| 460 | |
| 461 | for (size_t i = 0; i < line.length(); i++) |
| 462 | { |
| 463 | char ch = line[i]; |
| 464 | |
| 465 | // bypass whitespace |
| 466 | if (isWhiteSpace(ch)) |
| 467 | continue; |
| 468 | |
| 469 | // handle special characters (i.e. backslash+character such as \n, \t, ...) |
| 470 | if (isSpecialChar) |
| 471 | { |
| 472 | isSpecialChar = false; |
| 473 | continue; |
| 474 | } |
| 475 | if (!(isInComment) && line.compare(i, 2, "\\\\") == 0) |
| 476 | { |
| 477 | i++; |
| 478 | continue; |
| 479 | } |
| 480 | if (!(isInComment) && ch == '\\') |
| 481 | { |
| 482 | isSpecialChar = true; |
| 483 | continue; |
| 484 | } |
| 485 | |
| 486 | // handle quotes (such as 'x' and "Hello Dolly") |
| 487 | if (!isInComment && (ch == '"' || ch == '\'')) |
| 488 | { |
| 489 | if (!isInQuote) |
| 490 | { |
| 491 | quoteChar = ch; |
| 492 | isInQuote = true; |
| 493 | } |
| 494 | else if (quoteChar == ch) |
| 495 | { |
| 496 | isInQuote = false; |
| 497 | continue; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | if (isInQuote) |
| 502 | continue; |
| 503 | |
| 504 | // handle comments |
| 505 | |
| 506 | if (!(isInComment) && line.compare(i, 2, "//") == 0) |
| 507 | { |
| 508 | // check for windows line markers |
| 509 | if (line.compare(i + 2, 1, "\xf0") > 0) |
| 510 | lineNumber--; |
| 511 | // unindent if not in case brackets |
| 512 | if (line.find_first_not_of(" \t") == i |
| 513 | && sw.switchBracketCount == 1 |
| 514 | && sw.unindentCase) |
nothing calls this directly
no outgoing calls
no test coverage detected