MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / trim

Method trim

source/util/bstring.cpp:643–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641}
642
643BString BString::trim() {
644 if (isEmpty()) {
645 return *this;
646 }
647 int startIndex = 0;
648 int len = length();
649 int endIndex = len;
650 for (int i = 0; i < len; i++) {
651 if (std::isspace(data->str[i])) {
652 startIndex++;
653 } else {
654 break;
655 }
656 }
657 for (int i = len - 1; i > startIndex; i--) {
658 if (std::isspace(data->str[i])) {
659 endIndex--;
660 } else {
661 break;
662 }
663 }
664 if (startIndex == 0 && endIndex == len) {
665 return *this;
666 }
667 makeWritable(0);
668 data->len = endIndex - startIndex;
669 if (startIndex) {
670 memmove(data->str, data->str + startIndex, data->len);
671 }
672 data->str[data->len] = 0;
673 return *this;
674}
675
676BString BString::operator+(const BString& s) const {
677 if (isEmpty()) {

Callers 15

parseDependsMethod · 0.80
loadPackagesMethod · 0.80
getDependMethod · 0.80
parseParamMethod · 0.80
getEmscriptenEnvPropsFunction · 0.80
getDDrawOverridePathFunction · 0.80
getEnvPropFunction · 0.80
parseMethod · 0.80
parseMethod · 0.80
extractMethod · 0.80

Calls 1

lengthFunction · 0.85

Tested by

no test coverage detected