diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | kirc.c | 38 | ||||
-rw-r--r-- | kirc.h | 1 |
3 files changed, 20 insertions, 23 deletions
@@ -1,8 +1,10 @@ .POSIX: -ALL_WARNING = -Wall -Wextra -pedantic -std=c99 +ALL_WARNING = -Wall -Werror -Wextra -Wno-unused-result -pedantic -std=c99 PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/share/man +CFLAGS = -O0 -g3 +CFLAGS += -fsanitize=address kirc: kirc.c kirc.h $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 $(LDFLAGS) ${ALL_WARNING} kirc.c -o kirc @@ -1062,25 +1062,23 @@ static void param_print_private(param p) struct tm *timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); - char timestamp[13]; - if (!small_screen) { - if (strnlen(p->nickname, p->nicklen) > (size_t)p->nicklen - 8) { - *(p->nickname + p->nicklen - 8) = '\0'; - } - strcpy(timestamp, "\x1b[90m"); - char buf[8]; - if (timeinfo->tm_hour < 10) { - strcat(timestamp, "0"); - } - snprintf(buf, sizeof(buf), "%d:", timeinfo->tm_hour); - strcat(timestamp, buf); - if (timeinfo->tm_min < 10) { - strcat(timestamp, "0"); - } - snprintf(buf, sizeof(buf), "%d\x1b[0m ", timeinfo->tm_min); - strcat(timestamp, buf); - printf("%s", timestamp); - } + char timestamp[16]; + if (strnlen(p->nickname, p->nicklen) > (size_t)p->nicklen - 8) { + *(p->nickname + p->nicklen - 8) = '\0'; + } + strcpy(timestamp, "\x1b[90m"); + char buf[16]; + if (timeinfo->tm_hour < 10) { + strcat(timestamp, "0"); + } + snprintf(buf, sizeof(buf), "%d:", timeinfo->tm_hour); + strcat(timestamp, buf); + if (timeinfo->tm_min < 10) { + strcat(timestamp, "0"); + } + snprintf(buf, sizeof(buf), "%d\x1b[0m ", timeinfo->tm_min); + strcat(timestamp, buf); + printf("%s", timestamp); int s = 0; if (strnlen(p->nickname, MSG_MAX) <= (size_t)p->nicklen + strnlen(timestamp, sizeof(timestamp))) { s = p->nicklen - strnlen(p->nickname, MSG_MAX) - strnlen(timestamp, sizeof(timestamp)); @@ -1146,11 +1144,9 @@ static void raw_parser(char *string) }; if (WRAP_LEN > p.maxcols / 3) { - small_screen = 1; p.nicklen = p.maxcols / 3; } else { - small_screen = 0; p.nicklen = WRAP_LEN; } if (*chan != '\0' && !memcmp(p.command, "001", sizeof("001") - 1)) { @@ -90,7 +90,6 @@ static struct termios orig; static int history_len = 0; static char history_wrap = 0; static char history[HIS_MAX][MSG_MAX]; -static char small_screen; typedef struct PARAMETERS { char *prefix; |