added trim operand function.

This commit is contained in:
Brad Arant committed 2025-01-16 13:38:35 -08:00
1 parent 5fd02a7a44
commit c40e288a67
5 files changed
+40 -2

No files matched your search

+21
View File
@@ -362,6 +362,12 @@ namespace coreutils {
return cursor >= data + length;
}
int ZString::goeod() {
char *temp = cursor;
cursor = data + length;
return cursor - temp;
}
bool ZString::startsWith(const char *value) {
return strncmp(cursor, value, strlen(value)) == 0;
}
@@ -455,6 +461,19 @@ namespace coreutils {
return len;
}
int ZString::trimTrailingWhitespace() {
goeod();
int len = 0;
--cursor;
while((cursor > data) && ((*cursor == ' ') || (*cursor == '\n') || (*cursor == '\t'))) {
--cursor;
--length;
++len;
}
++cursor;
return len;
}
bool ZString::lineIsWhitespace() {
char *end = data + length;
char *temp = cursor;
@@ -496,6 +515,8 @@ namespace coreutils {
}
ZString ZString::trim() {
trimTrailingWhitespace();
reset();
skipWhitespace();
return unparsed();
}