MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / findCaseColon

Method findCaseColon

other_src/astyle/src/ASEnhancer.cpp:305–345  ·  view source on GitHub ↗

* find the colon following a 'case' statement * * @param line a reference to the line. * @param i the line index of the case statement. * @return the line index of the colon. */

Source from the content-addressed store, hash-verified

303 * @return the line index of the colon.
304 */
305size_t ASEnhancer::findCaseColon(string& line, size_t caseIndex) const
306{
307 size_t i = caseIndex;
308 bool isInQuote_ = false;
309 char quoteChar_ = ' ';
310 for (; i < line.length(); i++)
311 {
312 if (isInQuote_)
313 {
314 if (line[i] == '\\')
315 {
316 i++;
317 continue;
318 }
319 else if (line[i] == quoteChar_) // check ending quote
320 {
321 isInQuote_ = false;
322 quoteChar_ = ' ';
323 continue;
324 }
325 else
326 {
327 continue; // must close quote before continuing
328 }
329 }
330 if (line[i] == '\'' || line[i] == '\"') // check opening quote
331 {
332 isInQuote_ = true;
333 quoteChar_ = line[i];
334 continue;
335 }
336 if (line[i] == ':')
337 {
338 if ((i + 1 < line.length()) && (line[i + 1] == ':'))
339 i++; // bypass scope resolution operator
340 else
341 break; // found it
342 }
343 }
344 return i;
345}
346
347/**
348 * indent a line by a given number of tabsets

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected