diff options
Diffstat (limited to 'src/irc.c')
| -rw-r--r-- | src/irc.c | 35 |
1 files changed, 20 insertions, 15 deletions
@@ -33,9 +33,8 @@ static void print_reason(void) { if(msg_text) { scr_print_active(": "); scr_print_active(msg_text); - } else { - scr_print_active("\n"); } + scr_eol_active(); } static void do_pong(void) { @@ -46,6 +45,7 @@ static void do_pong(void) { static void do_chan_nick(void) { scr_print_active("<"); + scr_print_active(msg_src); if(scr_active == SCR_SERVER) { /* if we don't have a window for it */ scr_print_active("/"); @@ -66,7 +66,8 @@ static void do_privmsg(void) { else do_priv_nick(); - scr_print_active(msg_text); /* text ends with an EOL, don't print another */ + scr_print_active(msg_text); + scr_eol_active(); } static void do_join(void) { @@ -79,7 +80,7 @@ static void do_join(void) { scr_print_active(msg_src); scr_print_active(" has joined "); scr_print_active(msg_dest); - scr_print_active("\n"); + scr_eol_active(); } } @@ -93,7 +94,7 @@ static void do_nick(void) { } scr_print_active(" now known as "); scr_print_active(msg_dest); - scr_print_active("\n"); + scr_eol_active(); } static void do_quit(void) { @@ -109,9 +110,8 @@ static void do_part(void) { if(msg_text) { scr_print_active(": "); scr_print_active(msg_text); - } else { - scr_print_active("\n"); } + scr_eol_active(); } static void do_topic(void) { @@ -120,6 +120,7 @@ static void do_topic(void) { scr_print_active(msg_dest); scr_print_active(" to: "); scr_print_active(msg_text); + scr_eol_active(); /* TODO: set topic in the screen! */ } @@ -140,7 +141,7 @@ static void do_mode(void) { scr_print_active(" "); scr_print_active(msg_args[i]); } - scr_print_active("\n"); + scr_eol_active(); } /* numerics call this with arg==1, since arg 0 is always our nick. @@ -163,6 +164,7 @@ static void do_catchall(int arg) { scr_print_active(" "); scr_print_active(msg_text); } + scr_eol_active(); } /* permutes last character (doesn't add one), so for "Bob" you get: @@ -256,6 +258,7 @@ static void do_numeric(void) { scr_print(s, msg_args[1]); scr_print(s, ": "); scr_print(s, msg_text); + scr_putc(s, '\n'); break; case RPL_TOPICWHOTIME: @@ -317,8 +320,8 @@ static void dispatch_msg(void) { } /* msgbuf contains a complete message from the server, whose - length is msgbuf_len. the last character *must* be CH_EOL, - and the last argument ends with CH_EOL. */ + length is msgbuf_len. The EOL that was at the end of the message + is *not* present here (been replaced with a null already). */ static void parse_msg(void) { char *p; @@ -326,7 +329,7 @@ static void parse_msg(void) { msg = msgbuf; /* ignore empty message */ - if(*msg == CH_EOL) return; + if(!*msg) return; /* if there's a final multiword arg... */ /* FIXME: channel names can have colons, which breaks this... */ @@ -378,7 +381,7 @@ static void parse_msg(void) { if((p = strstr(msg_src, "!"))) { msg_src++; *p = '\0'; - } else { + } else if(strstr(msg_src, ".")) { msg_src = 0; } } @@ -396,7 +399,9 @@ static void irc_split_Lines(void) { for(i = 0; i < rxbuflen; i++) { msgbuf[msgbuf_len] = *p; if(*p == CH_EOL) { - msgbuf[msgbuf_len + 1] = '\0'; + // msgbuf[msgbuf_len + 1] = '\0'; + /* do not include the EOL */ + msgbuf[msgbuf_len] = '\0'; parse_msg(); msgbuf_len = 0; } else { @@ -434,8 +439,8 @@ int irc_read(void) { // Get # of bytes waiting, no more than size of rx_buf rxbuflen = OS.dvstat[1] * 256 + OS.dvstat[0]; - if(rxbuflen > sizeof(rx_buf)) - rxbuflen = sizeof(rx_buf); + if(rxbuflen > MAX_MSG) + rxbuflen = MAX_MSG; if(rxbuflen > 0) { err = nread(url, rx_buf, rxbuflen); |
