* trim removes the white space surrounding a line. * * @return the trimmed line. * @param str the line to trim. */
| 1467 | * @param str the line to trim. |
| 1468 | */ |
| 1469 | string ASBeautifier::trim(const string& str) const |
| 1470 | { |
| 1471 | int start = 0; |
| 1472 | int end = str.length() - 1; |
| 1473 | |
| 1474 | while (start < end && isWhiteSpace(str[start])) |
| 1475 | start++; |
| 1476 | |
| 1477 | while (start <= end && isWhiteSpace(str[end])) |
| 1478 | end--; |
| 1479 | |
| 1480 | // don't trim if it ends in a continuation |
| 1481 | if (end > -1 && str[end] == '\\') |
| 1482 | end = str.length() - 1; |
| 1483 | |
| 1484 | string returnStr(str, start, end + 1 - start); |
| 1485 | return returnStr; |
| 1486 | } |
| 1487 | |
| 1488 | /** |
| 1489 | * rtrim removes the white space from the end of a line. |
no test coverage detected