From a1667f92905da03c1c3e26e8311fa7bd2802ca78 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 10 Apr 2017 16:28:37 +0200 Subject: weechat: Fix double-slash --- weechat/tomsg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/weechat/tomsg.c b/weechat/tomsg.c index 41ade25..2954a47 100644 --- a/weechat/tomsg.c +++ b/weechat/tomsg.c @@ -88,18 +88,21 @@ static int room_input_cb(const void *room_vp,void *_d,struct t_gui_buffer *buffe struct conndata *conn=room->conn; const char *tosend; const char *p=strchr(input,'\n'); + bool skipfirst=input[0]=='/'&&input[1]=='/'; + bool free_tosend=false; if(p!=NULL){ fprintf(debugf,"room_input_cb: input contained newline <%s>\n",input); - tosend=strdup(input); + tosend=strdup(input+skipfirst); *strchr(tosend,'\n')='\0'; + free_tosend=true; } else { - tosend=input; + tosend=input+skipfirst; } net_sendf(conn->fd,message_net_callback,NULL,"send %s %s",room->name,tosend); weechat_printf(room->buffer,"%s\t%s",conn->username,tosend); - if(tosend!=input){ + if(free_tosend){ free((void*)tosend); } return WEECHAT_RC_OK; -- cgit v1.2.3-70-g09d2