From: Ralph Corderoy Date: Sat, 22 Oct 2016 18:43:12 +0000 (+0100) Subject: Add ToLower(s) and ToUpper(s). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/201663ffdecb6c21a2f48ad2e9b9eeaf85c029aa?hp=11f980e2651f72e75b9c19187a90ed3494c12ea4 Add ToLower(s) and ToUpper(s). --- diff --git a/h/utils.h b/h/utils.h index db563cb4..b57a4d88 100644 --- a/h/utils.h +++ b/h/utils.h @@ -65,6 +65,8 @@ char *nmh_strcasestr (const char *, const char *); bool EndsWithC(char *s, int c); void TrimSuffixC(char *s, int c); +void ToLower(char *s); +void ToUpper(char *s); /* * See if a string contains 8 bit characters (use isascii() for the test). diff --git a/sbr/utils.c b/sbr/utils.c index f5f20570..8f6ff76e 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -379,6 +379,26 @@ void TrimSuffixC(char *s, int c) } +/* ToLower runs all of s through tolower(3). */ +void ToLower(char *s) +{ + unsigned char *b; + + for (b = (unsigned char *)s; (*b = tolower(*b)); b++) + ; +} + + +/* ToUpper runs all of s through toupper(3). */ +void ToUpper(char *s) +{ + unsigned char *b; + + for (b = (unsigned char *)s; (*b = toupper(*b)); b++) + ; +} + + int nmh_init(const char *argv0, int read_context) { int status = OK;