diff options
Diffstat (limited to 'klib/toupper.c')
-rw-r--r-- | klib/toupper.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/klib/toupper.c b/klib/toupper.c new file mode 100644 index 0000000..807eb38 --- /dev/null +++ b/klib/toupper.c @@ -0,0 +1,26 @@ +#include "string.h" + +int +toupper(int c) +{ + if(c >= 'a' && c <= 'z') + c -= ('a' - 'A'); + return c; +} + +char* +stoupper(char *s) +{ + char *o = s; + for(; *s != 0; s++) + *s = toupper(*s); + return o; +} + +char* +sntoupper(char *s, size_t limit) +{ + for(size_t i = 0; i < limit; i++) + s[i] = toupper(s[i]); + return s; +} |