Don't cleanup trailing spaces from open and personal messages.

This commit is contained in:
Mike Belopuhov 2014-03-10 11:22:15 +01:00
parent c102bbf4a0
commit b6c9dd34d7

20
icb.c
View File

@ -36,7 +36,7 @@ void icb_command(struct icb_session *, char *, char *);
void icb_groupmsg(struct icb_session *, char *); void icb_groupmsg(struct icb_session *, char *);
void icb_login(struct icb_session *, char *, char *, char *); void icb_login(struct icb_session *, char *, char *, char *);
int icb_dowho(struct icb_session *, struct icb_group *); int icb_dowho(struct icb_session *, struct icb_group *);
char *icb_nextfield(char **); char *icb_nextfield(char **, int);
/* /*
* icb_init: initializes pointers to callbacks * icb_init: initializes pointers to callbacks
@ -91,10 +91,10 @@ icb_input(struct icb_session *is)
case ICB_M_LOGIN: { case ICB_M_LOGIN: {
char *nick, *group, *client, *cmd; char *nick, *group, *client, *cmd;
client = icb_nextfield(&msg); client = icb_nextfield(&msg, 1);
nick = icb_nextfield(&msg); nick = icb_nextfield(&msg, 1);
group = icb_nextfield(&msg); group = icb_nextfield(&msg, 1);
cmd = icb_nextfield(&msg); cmd = icb_nextfield(&msg, 1);
if (strlen(cmd) > 0 && cmd[0] == 'w') { if (strlen(cmd) > 0 && cmd[0] == 'w') {
icb_error(is, "Command not implemented"); icb_error(is, "Command not implemented");
icb_drop(is, NULL); icb_drop(is, NULL);
@ -111,15 +111,15 @@ icb_input(struct icb_session *is)
case ICB_M_OPEN: { case ICB_M_OPEN: {
char *grpmsg; char *grpmsg;
grpmsg = icb_nextfield(&msg); grpmsg = icb_nextfield(&msg, 0);
icb_groupmsg(is, grpmsg); icb_groupmsg(is, grpmsg);
break; break;
} }
case ICB_M_COMMAND: { case ICB_M_COMMAND: {
char *cmd, *arg; char *cmd, *arg;
cmd = icb_nextfield(&msg); cmd = icb_nextfield(&msg, 1);
arg = icb_nextfield(&msg); arg = icb_nextfield(&msg, 0);
icb_command(is, cmd, arg); icb_command(is, cmd, arg);
break; break;
} }
@ -587,7 +587,7 @@ icb_pass(struct icb_group *ig, struct icb_session *from,
* cleans up trailing spaces * cleans up trailing spaces
*/ */
char * char *
icb_nextfield(char **buf) icb_nextfield(char **buf, int notrspace)
{ {
char *start = *buf; char *start = *buf;
char *end = NULL; char *end = NULL;
@ -600,7 +600,7 @@ icb_nextfield(char **buf)
(*buf)++; (*buf)++;
} else } else
end = *buf; end = *buf;
while (end && *(--end) == ' ' && end > start) while (notrspace && end && *(--end) == ' ' && end > start)
*end = '\0'; *end = '\0';
return (start); return (start);
} }