about summary refs log tree commit diff
path: root/ui-ssdiff.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ui-ssdiff.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index 7f261ed..68c2044 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -114,11 +114,10 @@ static char *replace_tabs(char *line)
 {
 	char *prev_buf = line;
 	char *cur_buf;
-	int linelen = strlen(line);
+	size_t linelen = strlen(line);
 	int n_tabs = 0;
 	int i;
 	char *result;
-	char *spaces = "        ";
 
 	if (linelen == 0) {
 		result = xmalloc(1);
@@ -126,20 +125,23 @@ static char *replace_tabs(char *line)
 		return result;
 	}
 
-	for (i = 0; i < linelen; i++)
+	for (i = 0; i < linelen; i++) {
 		if (line[i] == '\t')
 			n_tabs += 1;
+	}
 	result = xmalloc(linelen + n_tabs * 8 + 1);
 	result[0] = '\0';
 
-	while (1) {
+	for (;;) {
 		cur_buf = strchr(prev_buf, '\t');
 		if (!cur_buf) {
 			strcat(result, prev_buf);
 			break;
 		} else {
 			strncat(result, prev_buf, cur_buf - prev_buf);
-			strncat(result, spaces, 8 - (strlen(result) % 8));
+			linelen = strlen(result);
+			memset(&result[linelen], ' ', 8 - (linelen % 8));
+			result[linelen + 8 - (linelen % 8)] = '\0';
 		}
 		prev_buf = cur_buf + 1;
 	}
Use time_t for save signatureJune McEnroe 2020-02-11Set self.nick to * initiallyJune McEnroe 2020-02-11Define ColorCap instead of hardcoding 100June McEnroe 2020-02-11Move hash to top of chat.hJune McEnroe 2020-02-11Move base64 out of chat.hJune McEnroe 2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe 2020-02-11Fix whois idle unit calculationJune McEnroe 2020-02-11Cast towupper to wchar_tJune McEnroe 2020-02-11Cast set but unused variables to voidJune McEnroe 2020-02-11Declare strlcatJune McEnroe 2020-02-11Check if VDSUSP existsJune McEnroe 2020-02-11Fix completeReplace iterationJune McEnroe 2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe 2020-02-11Remove legacy codeJune McEnroe 2020-02-11Add INSTALLING section to READMEJune McEnroe