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

Method isOneLineBlockReached

other_src/astyle/src/ASEnhancer.cpp:483–548  ·  view source on GitHub ↗

* check if a one-line bracket has been reached, * i.e. if the currently reached '{' character is closed * with a complimentry '}' elsewhere on the current line, *. * @return false = one-line bracket has not been reached. * true = one-line bracket has been reached. */

Source from the content-addressed store, hash-verified

481 * true = one-line bracket has been reached.
482 */
483bool ASEnhancer::isOneLineBlockReached(string& line, int startChar) const
484{
485 assert(line[startChar] == '{');
486
487 bool isInComment_ = false;
488 bool isInQuote_ = false;
489 int _bracketCount = 1;
490 int lineLength = line.length();
491 char quoteChar_ = ' ';
492 char ch = ' ';
493
494 for (int i = startChar + 1; i < lineLength; ++i)
495 {
496 ch = line[i];
497
498 if (isInComment_)
499 {
500 if (line.compare(i, 2, "*/") == 0)
501 {
502 isInComment_ = false;
503 ++i;
504 }
505 continue;
506 }
507
508 if (ch == '\\')
509 {
510 ++i;
511 continue;
512 }
513
514 if (isInQuote_)
515 {
516 if (ch == quoteChar_)
517 isInQuote_ = false;
518 continue;
519 }
520
521 if (ch == '"' || ch == '\'')
522 {
523 isInQuote_ = true;
524 quoteChar_ = ch;
525 continue;
526 }
527
528 if (line.compare(i, 2, "//") == 0)
529 break;
530
531 if (line.compare(i, 2, "/*") == 0)
532 {
533 isInComment_ = true;
534 ++i;
535 continue;
536 }
537
538 if (ch == '{')
539 ++_bracketCount;
540 else if (ch == '}')

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected