Permalink
Browse files

Optimize remove_crlf()

Patch by: michaelortmann
  • Loading branch information...
michaelortmann authored and vanosg committed Oct 28, 2018
1 parent fe6e2eb commit 489b8405b321d63c8351ee641fd52c5cd23fdec7
Showing with 10 additions and 9 deletions.
  1. +9 −7 src/misc.c
  2. +1 −2 src/mod/server.mod/server.c
@@ -260,14 +260,16 @@ char *splitnick(char **blah)
void remove_crlf(char **line)
{
char *p;
char *p = *line;
p = strchr(*line, '\n');
if (p != NULL)
*p = 0;
p = strchr(*line, '\r');
if (p != NULL)
*p = 0;
while (*p) {
if (*p == '\r' || *p == '\n')
{
*p = 0;
break;
}
p++;
}
}
char *newsplit(char **rest)
@@ -810,10 +810,9 @@ static void queue_server(int which, char *msg, int len)
/* Remove \r\n. We will add these back when we send the text to the server.
* - Wcc [01/09/2004]
*/
strncpy(buf, msg, sizeof buf);
strlcpy(buf, msg, sizeof buf);
msg = buf;
remove_crlf(&msg);
buf[510] = 0;
len = strlen(buf);
/* No queue for PING and PONG - drummer */

0 comments on commit 489b840

Please sign in to comment.