diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2012-11-16 16:23:09 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2012-11-16 16:23:09 +0000 |
commit | 26a0ed5b0aab2b4f6cf6b786379b465bf09c9ffb (patch) | |
tree | cc00d2e018909684dfea874a9534cbbca8d5b52b /lib/colorname.c | |
parent | c24cbbfced33dfd071f43105654743f81fb79eb0 (diff) | |
download | netpbm-mirror-26a0ed5b0aab2b4f6cf6b786379b465bf09c9ffb.tar.gz netpbm-mirror-26a0ed5b0aab2b4f6cf6b786379b465bf09c9ffb.tar.xz netpbm-mirror-26a0ed5b0aab2b4f6cf6b786379b465bf09c9ffb.zip |
Don't do overlapping strcpy()
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1759 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/colorname.c')
-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; } } } |