On Tue, 2016-07-05 at 13:47 -0700, Markus Mayer wrote: > This series introduces a family of generic string case conversion > functions. This kind of functionality is needed in several places in > the kernel. Right now, everybody seems to be implementing their own > copy of this functionality. > > Based on the discussion of the previous version of this series[1] and > the use cases found in the kernel, it does look like having several > flavours of case conversion functions is beneficial. The use cases fall > into three categories: > Â Â Â Â - copying a string and converting the case while specifying a > Â Â Â Â Â Â maximum length to mimic strncpy() > Â Â Â Â - copying a string and converting the case without specifying a > Â Â Â Â Â Â length to mimic strcpy() > Â Â Â Â - converting the case of a string in-place (i.e. modifying the > Â Â Â Â Â Â string that was passed in) > > Consequently, I am proposing these new functions: > Â Â Â Â char *strncpytoupper(char *dst, const char *src, size_t len); > Â Â Â Â char *strncpytolower(char *dst, const char *src, size_t len); > Â Â Â Â char *strcpytoupper(char *dst, const char *src); > Â Â Â Â char *strcpytolower(char *dst, const char *src); > Â Â Â Â char *strtoupper(char *s); > Â Â Â Â char *strtolower(char *s);
I think there isn't much value in anything other than strto<upper|lower>. Using str[n]cpy followed by strto<upper|lower> is pretty obvious and rarely used anyway.