* additional formatting for line of source code. * every line of source code in a source code file should be sent * one after the other to this function. * indents event tables * unindents the case blocks * * @param line the original formatted line will be updated if necessary. */
| 106 | * @param line the original formatted line will be updated if necessary. |
| 107 | */ |
| 108 | void ASEnhancer::enhance(string& line, bool isInPreprocessor, bool isInSQL) |
| 109 | { |
| 110 | bool isSpecialChar = false; // is a backslash escape character |
| 111 | shouldIndentLine = true; |
| 112 | lineNumber++; |
| 113 | |
| 114 | // check for beginning of event table |
| 115 | if (nextLineIsEventIndent) |
| 116 | { |
| 117 | isInEventTable = true; |
| 118 | nextLineIsEventIndent = false; |
| 119 | } |
| 120 | |
| 121 | // check for beginning of SQL declare section |
| 122 | if (nextLineIsDeclareIndent) |
| 123 | { |
| 124 | isInDeclareSection = true; |
| 125 | nextLineIsDeclareIndent = false; |
| 126 | } |
| 127 | |
| 128 | if (line.length() == 0 |
| 129 | && ! isInEventTable |
| 130 | && ! isInDeclareSection |
| 131 | && ! emptyLineFill) |
| 132 | return; |
| 133 | |
| 134 | // test for unindent on attached brackets |
| 135 | if (unindentNextLine) |
| 136 | { |
| 137 | sw.unindentDepth++; |
| 138 | sw.unindentCase = true; |
| 139 | unindentNextLine = false; |
| 140 | } |
| 141 | |
| 142 | // parse characters in the current line. |
| 143 | |
| 144 | for (size_t i = 0; i < line.length(); i++) |
| 145 | { |
| 146 | char ch = line[i]; |
| 147 | |
| 148 | // bypass whitespace |
| 149 | if (isWhiteSpace(ch)) |
| 150 | continue; |
| 151 | |
| 152 | // handle special characters (i.e. backslash+character such as \n, \t, ...) |
| 153 | if (isSpecialChar) |
| 154 | { |
| 155 | isSpecialChar = false; |
| 156 | continue; |
| 157 | } |
| 158 | if (!(isInComment) && line.compare(i, 2, "\\\\") == 0) |
| 159 | { |
| 160 | i++; |
| 161 | continue; |
| 162 | } |
| 163 | if (!(isInComment) && ch == '\\') |
| 164 | { |
| 165 | isSpecialChar = true; |