diff --git a/ZString.cpp b/ZString.cpp index b313f23..7ad4d11 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -311,6 +311,19 @@ namespace coreutils { return len; } + bool ZString::lineIsWhitespace() { + char *end = data + length; + char *temp = cursor; + while(temp < end) { + if(*temp == '\n') + return true; + if((*temp != ' ') && (*temp != '\t')) + return false; + ++temp; + } + return true; + } + ZString ZString::goeol() { bool set = false; char *temp = cursor; diff --git a/ZString.h b/ZString.h index e9fd32f..b3c56a5 100644 --- a/ZString.h +++ b/ZString.h @@ -293,6 +293,12 @@ namespace coreutils { /// int skipWhitespace(); + + /// + /// + /// + + bool lineIsWhitespace(); /// /// diff --git a/testing/mstring_test b/testing/mstring_test index c00ce26..7c926b8 100755 Binary files a/testing/mstring_test and b/testing/mstring_test differ diff --git a/testing/zstring_test b/testing/zstring_test index cf4878d..57912b8 100755 Binary files a/testing/zstring_test and b/testing/zstring_test differ diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index 7d15c8e..6d329a5 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -63,5 +63,12 @@ int main(int argc, char **argv) { coreutils::ZString test5 = "this is a test of the Exclude tokenization without\n a line end."; coreutils::ZString test6 = test5.getTokenExclude("\n"); std::cout << test6 << std::endl; + + coreutils::ZString test7 = "this is a line\n \nthis is another line\n "; + std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; + std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; + std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; + std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; + }