@@ -1460,19 +1460,34 @@ namespace attributes {
1460
1460
// Parse the text of a function signature from the specified line
1461
1461
std::string SourceFileAttributesParser::parseSignature (size_t lineNumber) {
1462
1462
1463
- // Look for the next {
1463
+ // Look for the signature termination ({ or ; not inside quotes)
1464
+ // on this line and then subsequent lines if necessary
1464
1465
std::string signature;
1465
1466
for (int i = lineNumber; i<lines_.size (); i++) {
1466
1467
std::string line;
1467
1468
line = lines_[i];
1468
- std::string::size_type end = line.find_first_of (" {;" );
1469
- if (end == std::string::npos) {
1470
- signature.append (line);
1471
- signature.push_back (' ' );
1472
- } else {
1473
- signature.append (line.substr (0 , end));
1474
- return signature;
1469
+ bool insideQuotes = false ;
1470
+ char prevChar = 0 ;
1471
+ // scan for { or ; not inside quotes
1472
+ for (size_t c = 0 ; c < line.length (); ++c) {
1473
+ // alias character
1474
+ char ch = line.at (c);
1475
+ // update quotes state
1476
+ if (ch == ' "' && prevChar != ' \\ ' )
1477
+ insideQuotes = !insideQuotes;
1478
+ // found signature termination, append and return
1479
+ if (!insideQuotes && ((ch == ' {' ) || (ch == ' ;' ))) {
1480
+ signature.append (line.substr (0 , c));
1481
+ return signature;
1482
+ }
1483
+ // record prev char (used to check for escaped quote i.e. \")
1484
+ prevChar = ch;
1475
1485
}
1486
+
1487
+ // if we didn't find a terminator on this line then just append the line
1488
+ // and move on to the next line
1489
+ signature.append (line);
1490
+ signature.push_back (' ' );
1476
1491
}
1477
1492
1478
1493
// Not found
0 commit comments