Fix some issues

This commit is contained in:
Dale Weiler 2013-01-02 16:34:55 +00:00
parent 0d839bd138
commit 467a4740da
4 changed files with 12 additions and 6 deletions

View file

@ -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
{

5
file.c
View file

@ -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().

View file

@ -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 *);

4
test.c
View file

@ -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.