Browse Source

Defer newlines going to curses logwin, to avoid a useless blank line at the bottom of the window

Luke Dashjr 12 years ago
parent
commit
6a07fd5d6b
1 changed files with 19 additions and 0 deletions
  1. 19 0
      miner.c

+ 19 - 0
miner.c

@@ -2824,6 +2824,25 @@ static void switch_logsize(void)
 /* For mandatory printing when mutex is already locked */
 void _wlog(const char *str)
 {
+	static bool newline;
+	size_t end = strlen(str) - 1;
+	
+	if (newline)
+		wprintw(logwin, "\n");
+	
+	if (str[end] == '\n')
+	{
+		char *s;
+		
+		newline = true;
+		s = alloca(end);
+		memcpy(s, str, end);
+		s[end] = '\0';
+		str = s;
+	}
+	else
+		newline = false;
+	
 	wprintw(logwin, "%s", str);
 }