diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/colorname.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/colorname.c b/lib/colorname.c index 11df31c8..5c371e84 100644 --- a/lib/colorname.c +++ b/lib/colorname.c @@ -26,17 +26,20 @@ static int lineNo; + + void -pm_canonstr(char * const str) { - - char * p; - for (p = str; *p; ) { - if (ISSPACE(*p)) { - strcpy(p, &(p[1])); - } else { - if (ISUPPER(*p)) - *p = tolower(*p); - ++p; +pm_canonstr(char * const arg) { +/*---------------------------------------------------------------------------- + Modify string 'arg' to canonical form: lower case, no white space. +-----------------------------------------------------------------------------*/ + const char * srcCursor; + char * dstCursor; + + for (srcCursor = arg, dstCursor = arg; *srcCursor; ++srcCursor) { + if (!ISSPACE(*srcCursor)) { + *dstCursor++ = + ISUPPER(*srcCursor) ? tolower(*srcCursor) : *srcCursor; } } } |