Skip to content

Commit ca81e18

Browse files
committed
fix multiple bugs from last commit
1 parent 3f33290 commit ca81e18

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kirc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#define CHA_MAX 200 /* gauranteed max channel length */
1717

1818
static int conn; /* connection socket */
19-
size_t int verb = 0; /* verbose output (e.g. raw stream) */
20-
size_t int cmax = 80; /* max number of chars per line */
21-
size_t int gutl = 10; /* max char width of left column */
19+
static size_t verb = 0; /* verbose output (e.g. raw stream) */
20+
static size_t cmax = 80; /* max number of chars per line */
21+
static size_t gutl = 10; /* max char width of left column */
2222
static char * host = "irc.freenode.org"; /* irc host address */
2323
static char * chan = "kisslinux"; /* channel */
2424
static char * port = "6667"; /* server port */
@@ -61,7 +61,7 @@ raw(char *fmt, ...) {
6161

6262
if (verb) printf("<< %s", cmd_str);
6363
if (olog) printa(cmd_str);
64-
if (write(conn, cmd_str, strlen(cmd_str)) < 0) error(1);
64+
if (write(conn, cmd_str, strlen(cmd_str)) < 0) exit(1);
6565

6666
free(cmd_str);
6767
}
@@ -107,7 +107,7 @@ printw(const char *format, ...) {
107107
for(tok = strtok(&line[i], " "); tok != NULL; tok = strtok(NULL, " ")) {
108108
wordwidth = strlen(tok);
109109
if ((wordwidth + spacewidth) > spaceleft) {
110-
printf("\n%*.s%s", gutl + 2, "", tok);
110+
printf("\n%*.s%s", (int) gutl + 2, "", tok);
111111
spaceleft = cmax - (gutl + 2 + wordwidth);
112112
} else {
113113
printf(" %s", tok);
@@ -212,7 +212,7 @@ main(int argc, char **argv) {
212212
if (!kbhit()) dprintf(fd[1], "/\n");
213213
else {
214214
tcsetattr(STDIN_FILENO, TCSANOW, &tp);
215-
if (fgets(usrin, len, stdin) == NULL) return 1;
215+
if (fgets(usrin, MSG_MAX, stdin) == NULL) return 1;
216216
tcsetattr(STDIN_FILENO, TCSANOW, &save);
217217

218218
if (sscanf(usrin, "/%[m] %s %[^\n]\n", &c1, v2, v1) == 3 ||

0 commit comments

Comments
 (0)