diff --git a/src/kstd/CString.cc b/src/kstd/CString.cc new file mode 100644 index 0000000..8732f59 --- /dev/null +++ b/src/kstd/CString.cc @@ -0,0 +1,35 @@ +/* CString.cc + * vim: set tw=80: + * Eryn Wells + */ +/** + * Implementation of some utilities for dealing with C strings. + */ + +#include "CString.hh" +#include "ASCII.hh" + +namespace kstd { +namespace CString { + +size_t +length(char *str) +{ + char *end = str; + while (end++ != '\0') { } + return end - str; +} + + +void +uppercase(char *str) +{ + for (char *p = str; *p != '\0'; p++) { + if (Char::isLower(*p)) { + *p = Char::toUpper(*p); + } + } +} + +} /* namespace CString */ +} /* namespace kernel */ diff --git a/src/kstd/CString.hh b/src/kstd/CString.hh new file mode 100644 index 0000000..79f6660 --- /dev/null +++ b/src/kstd/CString.hh @@ -0,0 +1,21 @@ +/* CString.hh + * vim: set tw=80: + * Eryn Wells + */ +/** + * Utilities for dealing with C strings. + */ + +#include + +namespace kstd { +namespace CString { + +/** Find the length of a C string. */ +size_t length(char *str); + +/** Destructively convert an ASCII C String to uppercase. */ +void uppercase(char *str); + +} /* namespace CString */ +} /* namespace kstd */