Use MSVC mode marcos for creat in q3cpp on Windows

Using unix mode 0666 for creat was causing crashes when compiled with MSVC.
So use the marcos recommended by MSDN. MinGW also has the marcos, so apply
to Windows builds in general.
This commit is contained in:
Zack Middleton 2015-01-07 18:16:27 -06:00
parent aa1aad928e
commit bd2af6e4ea

View file

@ -2,6 +2,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "cpp.h"
extern int lcc_getopt(int, char *const *, const char *);
@ -66,7 +67,12 @@ setup(int argc, char **argv)
error(FATAL, "Can't open input file %s", fp);
}
if (optind+1<argc) {
int fdo = creat(argv[optind+1], 0666);
int fdo;
#ifdef WIN32
fdo = creat(argv[optind+1], _S_IREAD | _S_IWRITE);
#else
fdo = creat(argv[optind+1], 0666);
#endif
if (fdo<0)
error(FATAL, "Can't open output file %s", argv[optind+1]);
dup2(fdo, 1);