diff options
| author | Florian Westphal <fw@strlen.de> | 2006-03-24 23:25:38 +0000 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2006-03-24 23:25:38 +0000 |
| commit | bebfbedf3fdf801a028c17a5b4395f705391462d (patch) | |
| tree | 759275d87cd8fa73d3f93e38d0dda50160eb4b7f /src/tool | |
| parent | cba9270845a6a6b03b4e163eb7fd5d3b9df96a50 (diff) | |
| download | ngircd-bebfbedf3fdf801a028c17a5b4395f705391462d.tar.gz ngircd-bebfbedf3fdf801a028c17a5b4395f705391462d.zip | |
fix ngt_TrimStr(), fix format string
Diffstat (limited to 'src/tool')
| -rw-r--r-- | src/tool/tool.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/tool/tool.c b/src/tool/tool.c index effa640d..27051ced 100644 --- a/src/tool/tool.c +++ b/src/tool/tool.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: tool.c,v 1.4 2006/03/22 08:05:10 alex Exp $"; +static char UNUSED id[] = "$Id: tool.c,v 1.5 2006/03/24 23:25:39 fw Exp $"; #include "imp.h" #include <assert.h> @@ -43,16 +43,21 @@ ngt_TrimStr(char *String) while (*start == ' ' || *start == '\t') start++; + if (!*start) { + *String = 0; + return; + } /* ... and at the end: */ end = strchr(start, '\0'); + end--; while ((*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r') - && end >= start) + && end > start) end--; /* New trailing NULL byte */ *(++end) = '\0'; - memmove(String, start, (size_t)(end - start)); + memmove(String, start, (size_t)(end - start)+1); } /* ngt_TrimStr */ |