From 959e88211e2b4280982d47eaa0818c97ca8eae02 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 7 Jan 2011 15:38:20 -0700 Subject: [PATCH] Fix a few bugs --- .gitignore | 8 +++----- cobalt-handler | 4 +++- dispatch.c | 4 +--- firebot | 2 ++ irc.c | 7 ++++++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index ae2fb91..49316e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -*.cmi -*.cmo *~ -bot -.omake* -.depend +*.o +dispatch +irc diff --git a/cobalt-handler b/cobalt-handler index 3375144..3f1089e 100755 --- a/cobalt-handler +++ b/cobalt-handler @@ -21,7 +21,9 @@ join () { case $command in 001) - join "#cobalt" + for chan in ${CHANNELS:-#cobalt}; do + join $chan + done ;; 433) raw "NICK bottimus" diff --git a/dispatch.c b/dispatch.c index f38140c..37e5a34 100644 --- a/dispatch.c +++ b/dispatch.c @@ -173,10 +173,8 @@ call_with_lines(char *buf, while ((p = memchr(b, '\n', l))) { size_t n = p - b + 1; - size_t buflen = n; - if ('\r' == *(p-1)) buflen -= 1; - func(b, buflen); + func(b, n); l -= n; b += n; } diff --git a/firebot b/firebot index 85cac26..36c9996 100755 --- a/firebot +++ b/firebot @@ -1,5 +1,7 @@ #! /bin/sh +exec 2>&1 + cmd=${1%% *} [ "$cmd" = "$1" ] || args=${1#* } case $cmd in diff --git a/irc.c b/irc.c index 6889050..6601253 100644 --- a/irc.c +++ b/irc.c @@ -65,6 +65,10 @@ main(int argc, char *argv[]) line += 1; } } + + /* Strip trailing carriage return */ + while (*line) line += 1; + if ('\r' == *(line-1)) *(line-1) = '\0'; } /* Set command, converting to upper case */ @@ -108,7 +112,8 @@ main(int argc, char *argv[]) sender = parts[1]; forum = sender; } else if (0 == strcmp(cmd, "PING")) { - dprintf(1, "PONG :%s\r\n", text); + printf("PONG :%s\r\n", text); + fflush(stdout); } {