From: Dale Weiler Date: Wed, 2 Jan 2013 16:34:55 +0000 (+0000) Subject: Fix some issues X-Git-Tag: before-library~388 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=467a4740dae1c0fa9d50c64e07b03ee82904e8e5 Fix some issues --- diff --git a/conout.c b/conout.c index 39d02fb..2ccbd40 100644 --- a/conout.c +++ b/conout.c @@ -54,7 +54,7 @@ typedef struct { * Doing colored output on windows is fucking stupid. The linux way is * the real way. So we emulate it on windows :) */ -#ifdef _MSC_VER +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -104,7 +104,7 @@ static const int ansi2win[] = { WWHITE }; -static int win_fputs(const char *str, FILE *h) { +static int win_fputs(FILE *h, const char *str) { /* state for translate */ int acolor; int wcolor; @@ -168,7 +168,7 @@ static int win_fputs(const char *str, FILE *h) { state = -1; } } else { - file_putc(*str, h); + file_putc(h, *str); length ++; } str++; @@ -212,7 +212,7 @@ static void con_enablecolor() { */ static int con_write(FILE *handle, const char *fmt, va_list va) { int ln; - #ifndef _MSC_VER + #ifndef _WIN32 ln = vfprintf(handle, fmt, va); #else { diff --git a/file.c b/file.c index fd7b84e..fe6167f 100644 --- a/file.c +++ b/file.c @@ -165,6 +165,11 @@ int file_seek(FILE *fp, long int off, int whence) { return fseek(fp, off, whence); } +int file_putc(FILE *fp, int ch) { + /* Invokes file_exception on windows if fp is null */ + return fputc(ch, fp); +} + /* * Implements libc getline for systems that don't have it, which is * assmed all. This works the same as getline(). diff --git a/gmqcc.h b/gmqcc.h index 02b9bfe..bdda81b 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -413,6 +413,7 @@ GMQCC_INLINE int file_error (FILE *); GMQCC_INLINE int file_getc (FILE *); GMQCC_INLINE int file_printf (FILE *, const char *, ...); GMQCC_INLINE int file_puts (FILE *, const char *); +GMQCC_INLINE int file_putc (FILE *, int); GMQCC_INLINE int file_seek (FILE *, long int, int); GMQCC_INLINE size_t file_read (void *, size_t, size_t, FILE *); diff --git a/test.c b/test.c index bf32885..f969671 100644 --- a/test.c +++ b/test.c @@ -156,7 +156,7 @@ int task_pclose(FILE **handles) { # define popen _popen # define pclose _pclose # include -# include +# include # include /* * Bidirectional piping implementation for windows using CreatePipe and DuplicateHandle + @@ -185,7 +185,7 @@ int task_pclose(FILE **handles) { # ifdef __MINGW32__ /* mingw32 has dirent.h */ # include -# elif defined (_MSC_VER) +# elif defined (_WIN32) /* * visual studio lacks dirent.h it's a posix thing * so we emulate it with the WinAPI.