Skip to content

Commit

Permalink
Optimize remove_crlf()
Browse files Browse the repository at this point in the history
Patch by: michaelortmann
  • Loading branch information
michaelortmann authored and vanosg committed Oct 28, 2018
1 parent fe6e2eb commit 489b840
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/misc.c
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/mod/server.mod/server.c
Expand Up @@ -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 */
Expand Down

0 comments on commit 489b840

Please sign in to comment.