* find the colon following a 'case' statement * * @param line a reference to the line. * @param caseIndex the line index of the case statement. * @return the line index of the colon. */
| 203 | * @return the line index of the colon. |
| 204 | */ |
| 205 | size_t ASEnhancer::findCaseColon(const string& line, size_t caseIndex) const |
| 206 | { |
| 207 | size_t i = caseIndex; |
| 208 | bool isInQuote_ = false; |
| 209 | char quoteChar_ = ' '; |
| 210 | for (; i < line.length(); i++) |
| 211 | { |
| 212 | if (isInQuote_) |
| 213 | { |
| 214 | if (line[i] == '\\') |
| 215 | { |
| 216 | i++; |
| 217 | continue; |
| 218 | } |
| 219 | else if (line[i] == quoteChar_) // check ending quote |
| 220 | { |
| 221 | isInQuote_ = false; |
| 222 | quoteChar_ = ' '; |
| 223 | continue; |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | continue; // must close quote before continuing |
| 228 | } |
| 229 | } |
| 230 | if (line[i] == '"' // check opening quote |
| 231 | || (line[i] == '\'' && !isDigitSeparator(line, i))) |
| 232 | { |
| 233 | isInQuote_ = true; |
| 234 | quoteChar_ = line[i]; |
| 235 | continue; |
| 236 | } |
| 237 | if (line[i] == ':') |
| 238 | { |
| 239 | if ((i + 1 < line.length()) && (line[i + 1] == ':')) |
| 240 | i++; // bypass scope resolution operator |
| 241 | else |
| 242 | break; // found it |
| 243 | } |
| 244 | } |
| 245 | return i; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * indent a line by a given number of tabsets |