]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fix some issues
authorDale Weiler <killfieldengine@gmail.com>
Wed, 2 Jan 2013 16:34:55 +0000 (16:34 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 2 Jan 2013 16:34:55 +0000 (16:34 +0000)
conout.c
file.c
gmqcc.h
test.c

index 39d02fbf8116c179c4c30bab8ff1adbc6ab175af..2ccbd40901b0cd21a035d4f56893876875703400 100644 (file)
--- 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 <windows.h>
 
@@ -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 fd7b84e67a67911f171866e25de4418373677145..fe6167f3a979d33533bb757f9e4eff713f7f20da 100644 (file)
--- 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 02b9bfe147f0b06535c8f14b5115e10b45272587..bdda81b8b14ffd24dfbcbe60d0c2ac533bffa3d4 100644 (file)
--- 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 bf32885a19fb31a306f8c5b784eb99d4e0f1441b..f9696715a868cfb4546a7dbd9617c91eb79388fd 100644 (file)
--- a/test.c
+++ b/test.c
@@ -156,7 +156,7 @@ int task_pclose(FILE **handles) {
 #    define popen  _popen
 #    define pclose _pclose
 #    include <windows.h>
-#   include <io.h>
+#    include <io.h>
 #    include <fcntl.h>
     /*
      * 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 <dirent.h>
-#    elif defined (_MSC_VER)
+#    elif defined (_WIN32)
         /* 
          * visual studio lacks dirent.h it's a posix thing
          * so we emulate it with the WinAPI.