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 | |
| parent | cba9270845a6a6b03b4e163eb7fd5d3b9df96a50 (diff) | |
| download | ngircd-bebfbedf3fdf801a028c17a5b4395f705391462d.tar.gz ngircd-bebfbedf3fdf801a028c17a5b4395f705391462d.zip | |
fix ngt_TrimStr(), fix format string
| -rw-r--r-- | src/ngircd/client.c | 10 | ||||
| -rw-r--r-- | src/tool/tool.c | 11 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/ngircd/client.c b/src/ngircd/client.c index b317b5be..30e214c4 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -17,7 +17,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: client.c,v 1.89 2006/03/11 10:43:49 fw Exp $"; +static char UNUSED id[] = "$Id: client.c,v 1.90 2006/03/24 23:25:38 fw Exp $"; #include "imp.h" #include <assert.h> @@ -321,11 +321,9 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit ) { if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt ); else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt ); - } - else - { - if( c->id[0] ) Log( LOG_WARNING, "Unregistered unknown client \"%s\": %s", c->id, txt ); - else Log( LOG_WARNING, "Unregistered unknown client: %s", c->id, txt ); + } else { + Log(LOG_WARNING, "Unregistered unknown client \"%s\": %s", + c->id[0] ? c->id : "(No Nick)", txt ); } } 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 */ |