xglcomp
diff src/logger.c @ 2:876efea9424c
OpenGL
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 22 Jan 2016 06:31:03 +0200 |
parents | d9b3fba68705 |
children |
line diff
1.1 --- a/src/logger.c Thu Jan 21 22:50:10 2016 +0200 1.2 +++ b/src/logger.c Fri Jan 22 06:31:03 2016 +0200 1.3 @@ -3,6 +3,11 @@ 1.4 #include <string.h> 1.5 #include <errno.h> 1.6 #include <stdarg.h> 1.7 +#ifdef _MSC_VER 1.8 +#include <malloc.h> 1.9 +#else 1.10 +#include <alloca.h> 1.11 +#endif 1.12 #include "logger.h" 1.13 1.14 #if defined(unix) || defined(__unix__) || defined(__APPLE__) 1.15 @@ -214,7 +219,16 @@ 1.16 #if defined(unix) || defined(__unix__) || defined(__APPLE__) 1.17 if(isatty(fileno(targ->fp)) && type != LOG_INFO) { 1.18 int c = typecolor(type); 1.19 - fprintf(targ->fp, "\033[%dm%s\033[0m", c, str); 1.20 + 1.21 + int len = strlen(str); 1.22 + if(str[len - 1] == '\n') { 1.23 + char *s = alloca(len); 1.24 + memcpy(s, str, len); 1.25 + s[len - 1] = 0; 1.26 + fprintf(targ->fp, "\033[%dm%s\033[0m\n", c, s); 1.27 + } else { 1.28 + fprintf(targ->fp, "\033[%dm%s\033[0m", c, str); 1.29 + } 1.30 } else 1.31 #endif 1.32 {