]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Get it compiling in visual studio again.
authorDale Weiler <killfieldengine@gmail.com>
Wed, 24 Apr 2013 01:43:53 +0000 (01:43 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 24 Apr 2013 01:43:53 +0000 (01:43 +0000)
34 files changed:
.gitignore
ast.c [changed mode: 0644->0755]
ast.h [changed mode: 0644->0755]
code.c [changed mode: 0644->0755]
conout.c [changed mode: 0644->0755]
correct.c [changed mode: 0644->0755]
exec.c [changed mode: 0644->0755]
fs.c [changed mode: 0644->0755]
ftepp.c [changed mode: 0644->0755]
gmqcc.h [changed mode: 0644->0755]
intrin.h [changed mode: 0644->0755]
ir.c [changed mode: 0644->0755]
ir.h [changed mode: 0644->0755]
lexer.c [changed mode: 0644->0755]
lexer.h [changed mode: 0644->0755]
main.c [changed mode: 0644->0755]
msvc/gmqcc.sln [changed mode: 0644->0755]
msvc/gmqcc.vcxproj [deleted file]
msvc/gmqcc/gmqcc.vcxproj [new file with mode: 0755]
msvc/gmqcc/gmqcc.vcxproj.filters [new file with mode: 0755]
msvc/pak/pak.vcxproj [new file with mode: 0755]
msvc/pak/pak.vcxproj.filters [new file with mode: 0755]
msvc/qcvm.vcxproj [deleted file]
msvc/qcvm/qcvm.vcxproj [new file with mode: 0755]
msvc/qcvm/qcvm.vcxproj.filters [new file with mode: 0755]
msvc/testsuite.vcxproj [deleted file]
msvc/testsuite/testsuite.vcxproj [new file with mode: 0755]
msvc/testsuite/testsuite.vcxproj.filters [new file with mode: 0755]
opts.c [changed mode: 0644->0755]
pak.c [changed mode: 0644->0755]
parser.c [changed mode: 0644->0755]
test.c [changed mode: 0644->0755]
utf8.c [changed mode: 0644->0755]
util.c [changed mode: 0644->0755]

index 342039cb75acefa4cecf1becd535a07c01f49b30..416e445e16c72e2818595e75a99fbf375fc67bed 100644 (file)
@@ -3,11 +3,7 @@
 *.rej
 *.patch
 *.diff
-
-testsuite
-qcvm
-gmqcc
-pak
+*.exe
 
 distro/archlinux/*
 distro/archbsd/*
diff --git a/ast.c b/ast.c
old mode 100644 (file)
new mode 100755 (executable)
index ae710d6..aa70509
--- a/ast.c
+++ b/ast.c
@@ -220,7 +220,7 @@ static size_t ast_type_to_string_impl(ast_expression *e, char *buf, size_t bufsi
     if (!e) {
         if (pos + 6 >= bufsize)
             goto full;
-        strncpy(buf + pos, "(null)", 6);
+        util_strncpy(buf + pos, "(null)", 6);
         return pos + 6;
     }
 
@@ -229,7 +229,7 @@ static size_t ast_type_to_string_impl(ast_expression *e, char *buf, size_t bufsi
 
     switch (e->expression.vtype) {
         case TYPE_VARIANT:
-            strncpy(buf + pos, "(variant)", 9);
+            util_strncpy(buf + pos, "(variant)", 9);
             return pos + 9;
 
         case TYPE_FIELD:
@@ -275,7 +275,7 @@ static size_t ast_type_to_string_impl(ast_expression *e, char *buf, size_t bufsi
             if (pos + 1 >= bufsize)
                 goto full;
             buf[pos++] = '[';
-            pos += snprintf(buf + pos, bufsize - pos - 1, "%i", (int)e->expression.count);
+            pos += util_snprintf(buf + pos, bufsize - pos - 1, "%i", (int)e->expression.count);
             if (pos + 1 >= bufsize)
                 goto full;
             buf[pos++] = ']';
@@ -286,7 +286,7 @@ static size_t ast_type_to_string_impl(ast_expression *e, char *buf, size_t bufsi
             typelen = strlen(typestr);
             if (pos + typelen >= bufsize)
                 goto full;
-            strncpy(buf + pos, typestr, typelen);
+            util_strncpy(buf + pos, typestr, typelen);
             return pos + typelen;
     }
 
@@ -1219,12 +1219,12 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
 
             namelen = strlen(self->name);
             name    = (char*)mem_a(namelen + 16);
-            strncpy(name, self->name, namelen);
+            util_strncpy(name, self->name, namelen);
 
             array->ir_values = (ir_value**)mem_a(sizeof(array->ir_values[0]) * array->expression.count);
             array->ir_values[0] = v;
             for (ai = 1; ai < array->expression.count; ++ai) {
-                snprintf(name + namelen, 16, "[%u]", (unsigned int)ai);
+                util_snprintf(name + namelen, 16, "[%u]", (unsigned int)ai);
                 array->ir_values[ai] = ir_builder_create_field(ir, name, vtype);
                 if (!array->ir_values[ai]) {
                     mem_d(name);
@@ -1277,12 +1277,12 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
 
         namelen = strlen(self->name);
         name    = (char*)mem_a(namelen + 16);
-        strncpy(name, self->name, namelen);
+        util_strncpy(name, self->name, namelen);
 
         self->ir_values = (ir_value**)mem_a(sizeof(self->ir_values[0]) * self->expression.count);
         self->ir_values[0] = v;
         for (ai = 1; ai < self->expression.count; ++ai) {
-            snprintf(name + namelen, 16, "[%u]", (unsigned int)ai);
+            util_snprintf(name + namelen, 16, "[%u]", (unsigned int)ai);
             self->ir_values[ai] = ir_builder_create_global(ir, name, vtype);
             if (!self->ir_values[ai]) {
                 mem_d(name);
@@ -1419,11 +1419,11 @@ bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
 
         namelen = strlen(self->name);
         name    = (char*)mem_a(namelen + 16);
-        strncpy(name, self->name, namelen);
+        util_strncpy(name, self->name, namelen);
 
         self->ir_values[0] = v;
         for (ai = 1; ai < self->expression.count; ++ai) {
-            snprintf(name + namelen, 16, "[%u]", (unsigned int)ai);
+            util_snprintf(name + namelen, 16, "[%u]", (unsigned int)ai);
             self->ir_values[ai] = ir_function_create_local(func, name, vtype, param);
             if (!self->ir_values[ai]) {
                 compile_error(ast_ctx(self), "internal_error: ir_builder_create_global failed on `%s`", name);
diff --git a/ast.h b/ast.h
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/code.c b/code.c
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 7e8cd9a..dd4dca3
--- a/conout.c
+++ b/conout.c
@@ -110,7 +110,7 @@ static int win_fputs(FILE *h, const char *str) {
     int wcolor;
     int icolor;
 
-    int state;
+    int state = 0;
 
     /* attributes */
     int intense  =  -1;
@@ -218,7 +218,11 @@ static int con_write(FILE *handle, const char *fmt, va_list va) {
     {
         char data[4096];
         memset(data, 0, sizeof(data));
+#ifdef _MSC_VER
+        vsnprintf_s(data, sizeof(data), sizeof(data), fmt, va);
+#else
         vsnprintf(data, sizeof(data), fmt, va);
+#endif
         ln = (GMQCC_IS_DEFINE(handle)) ? win_fputs(handle, data) : fs_file_puts(handle, data);
     }
     #endif
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/exec.c b/exec.c
old mode 100644 (file)
new mode 100755 (executable)
index 8b0ee5e..dff388b
--- a/exec.c
+++ b/exec.c
@@ -36,7 +36,7 @@ static void loaderror(const char *fmt, ...)
     va_start(ap, fmt);
     vprintf(fmt, ap);
     va_end(ap);
-    printf(": %s\n", strerror(err));
+    printf(": %s\n", util_strerror(err));
 }
 
 static void qcvmerror(qc_program *prog, const char *fmt, ...)
@@ -672,7 +672,7 @@ static int qc_ftos(qc_program *prog)
     qcany str;
     CheckArgs(1);
     num = GetArg(0);
-    snprintf(buffer, sizeof(buffer), "%g", num->_float);
+    util_snprintf(buffer, sizeof(buffer), "%g", num->_float);
     str.string = prog_tempstring(prog, buffer);
     Return(str);
     return 0;
@@ -684,7 +684,7 @@ static int qc_stof(qc_program *prog)
     qcany num;
     CheckArgs(1);
     str = GetArg(0);
-    num._float = strtof(prog_getstring(prog, str->string), NULL);
+    num._float = (float)strtod(prog_getstring(prog, str->string), NULL);
     Return(num);
     return 0;
 }
@@ -696,7 +696,7 @@ static int qc_vtos(qc_program *prog)
     qcany str;
     CheckArgs(1);
     num = GetArg(0);
-    snprintf(buffer, sizeof(buffer), "'%g %g %g'", num->vector[0], num->vector[1], num->vector[2]);
+    util_snprintf(buffer, sizeof(buffer), "'%g %g %g'", num->vector[0], num->vector[1], num->vector[2]);
     str.string = prog_tempstring(prog, buffer);
     Return(str);
     return 0;
@@ -709,7 +709,7 @@ static int qc_etos(qc_program *prog)
     qcany str;
     CheckArgs(1);
     num = GetArg(0);
-    snprintf(buffer, sizeof(buffer), "%i", num->_int);
+    util_snprintf(buffer, sizeof(buffer), "%i", num->_int);
     str.string = prog_tempstring(prog, buffer);
     Return(str);
     return 0;
diff --git a/fs.c b/fs.c
old mode 100644 (file)
new mode 100755 (executable)
index 3a482a1..501041f
--- a/fs.c
+++ b/fs.c
@@ -36,6 +36,7 @@
  * at least I think so).
  */
 #ifdef _MSC_VER
+#include <crtdbg.h> /* _CrtSetReportMode, _CRT_ASSERT */
 /* {{{ */
     /*
      * Visual Studio has security CRT features which I actually want to support
@@ -228,7 +229,7 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
         if (!dir)
             return NULL;
 
-        strncpy(dir->dd_name, name, strlen(name));
+        util_strncpy(dir->dd_name, name, strlen(name));
         return dir;
     }
 
@@ -248,8 +249,8 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
             if (*dir->dd_name) {
                 size_t n = strlen(dir->dd_name);
                 if ((dirname  = (char*)mem_a(n + 5) /* 4 + 1 */)) {
-                    strncpy(dirname, dir->dd_name, n);
-                    strncpy(dirname + n, "\\*.*", 4);   /* 4 + 1 */
+                    util_strncpy(dirname, dir->dd_name, n);
+                    util_strncpy(dirname + n, "\\*.*", 4);   /* 4 + 1 */
                 }
             } else {
                 if (!(dirname = util_strdup("\\*.*")))
@@ -269,7 +270,7 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
             return NULL;
 
         if ((data = (struct dirent*)mem_a(sizeof(struct dirent)))) {
-            strncpy(data->d_name, info.cFileName, FILENAME_MAX - 1);
+            util_strncpy(data->d_name, info.cFileName, FILENAME_MAX - 1);
             data->d_name[FILENAME_MAX - 1] = '\0'; /* terminate */
             data->d_namlen                 = strlen(data->d_name);
         }
@@ -283,13 +284,6 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
     int fs_dir_make(const char *path) {
         return !CreateDirectory(path, NULL);
     }
-
-    /*
-     * Visual studio also lacks S_ISDIR for sys/stat.h, so we emulate this as well
-     * which is not hard at all.
-     */
-#   undef  S_ISDIR
-#   define S_ISDIR(X) ((X)&_S_IFDIR)
 #else
 #   if !defined(__MINGW32__)
 #       include <sys/stat.h> /* mkdir */
diff --git a/ftepp.c b/ftepp.c
old mode 100644 (file)
new mode 100755 (executable)
index 233dee5..b07899a
--- a/ftepp.c
+++ b/ftepp.c
@@ -82,7 +82,7 @@ static uint32_t ftepp_predef_randval  = 0;
 
 /* __DATE__ */
 char *ftepp_predef_date(lex_file *context) {
-    struct tm *itime;
+    struct tm *itime = NULL;
     time_t     rtime;
     char      *value = (char*)mem_a(82);
     /* 82 is enough for strftime but we also have " " in our string */
@@ -91,7 +91,12 @@ char *ftepp_predef_date(lex_file *context) {
 
     /* get time */
     time (&rtime);
+
+#ifdef _MSC_VER
+    localtime_s(itime, &rtime);
+#else
     itime = localtime(&rtime);
+#endif
 
     strftime(value, 82, "\"%b %d %Y\"", itime);
 
@@ -100,7 +105,7 @@ char *ftepp_predef_date(lex_file *context) {
 
 /* __TIME__ */
 char *ftepp_predef_time(lex_file *context) {
-    struct tm *itime;
+    struct tm *itime = NULL;
     time_t     rtime;
     char      *value = (char*)mem_a(82);
     /* 82 is enough for strftime but we also have " " in our string */
@@ -109,7 +114,12 @@ char *ftepp_predef_time(lex_file *context) {
 
     /* get time */
     time (&rtime);
+
+#ifdef _MSC_VER
+    localtime_s(itime, &rtime);
+#else
     itime = localtime(&rtime);
+#endif
 
     strftime(value, 82, "\"%X\"", itime);
 
@@ -126,7 +136,7 @@ char *ftepp_predef_line(lex_file *context) {
 char *ftepp_predef_file(lex_file *context) {
     size_t  length = strlen(context->name) + 3; /* two quotes and a terminator */
     char   *value  = (char*)mem_a(length);
-    snprintf(value, length, "\"%s\"", context->name);
+    util_snprintf(value, length, "\"%s\"", context->name);
 
     return value;
 }
@@ -832,7 +842,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param
 
     if (resetline && !ftepp->in_macro) {
         char lineno[128];
-        snprintf(lineno, 128, "\n#pragma line(%lu)\n", (unsigned long)(old_lexer->sline));
+        util_snprintf(lineno, 128, "\n#pragma line(%lu)\n", (unsigned long)(old_lexer->sline));
         ftepp_out(ftepp, lineno, false);
     }
 
@@ -1432,7 +1442,7 @@ static bool ftepp_include(ftepp_t *ftepp)
 
     ftepp_out(ftepp, "\n#pragma file(", false);
     ftepp_out(ftepp, ctx.file, false);
-    snprintf(lineno, sizeof(lineno), ")\n#pragma line(%lu)\n", (unsigned long)(ctx.line+1));
+    util_snprintf(lineno, sizeof(lineno), ")\n#pragma line(%lu)\n", (unsigned long)(ctx.line+1));
     ftepp_out(ftepp, lineno, false);
 
     /* skip the line */
@@ -1797,12 +1807,12 @@ ftepp_t *ftepp_create()
         minor[2] = '"';
     } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
         ftepp_add_define(ftepp, NULL, "__STD_GMQCC__");
-        snprintf(major, 32, "\"%d\"", GMQCC_VERSION_MAJOR);
-        snprintf(minor, 32, "\"%d\"", GMQCC_VERSION_MINOR);
+        util_snprintf(major, 32, "\"%d\"", GMQCC_VERSION_MAJOR);
+        util_snprintf(minor, 32, "\"%d\"", GMQCC_VERSION_MINOR);
     } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCCX) {
         ftepp_add_define(ftepp, NULL, "__STD_QCCX__");
-        snprintf(major, 32, "\"%d\"", GMQCC_VERSION_MAJOR);
-        snprintf(minor, 32, "\"%d\"", GMQCC_VERSION_MINOR);
+        util_snprintf(major, 32, "\"%d\"", GMQCC_VERSION_MAJOR);
+        util_snprintf(minor, 32, "\"%d\"", GMQCC_VERSION_MINOR);
     } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
         ftepp_add_define(ftepp, NULL, "__STD_QCC__");
         /* 1.0 */
diff --git a/gmqcc.h b/gmqcc.h
old mode 100644 (file)
new mode 100755 (executable)
index ad185a0..6ae52e9
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -36,7 +36,6 @@
  */
 #ifdef _MSC_VER
 #   pragma warning(disable : 4244 ) /* conversion from 'int' to 'float', possible loss of data */
-#   pragma warning(disable : 4018 ) /* signed/unsigned mismatch                                */
 #endif /*! _MSC_VER */
 
 #define GMQCC_VERSION_MAJOR 0
@@ -168,17 +167,6 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
     typedef __int64          int64_t;
 #endif /*! _MSC_VER */
 
-/*
- *windows makes these prefixed because they're C99
- * TODO: utility versions that are type-safe and not
- * just plain textual subsitution.
- */
-#ifdef _MSC_VER
-#    define snprintf(X, Y, Z, ...) _snprintf(X, Y, Z, __VA_ARGS__)
-    /* strtof doesn't exist -> strtod does though :) */
-#    define strtof(X, Y)          (float)(strtod(X, Y))
-#endif /*! _MSC_VER */
-
 /*
  * Very roboust way at determining endianess at compile time: this handles
  * almost every possible situation.  Otherwise a runtime check has to be
@@ -275,7 +263,7 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
         unsigned short     d_reclen;
         unsigned short     d_namlen;
         char               d_name[FILENAME_MAX];
-    }
+    };
 
     typedef struct {
         struct _finddata_t dd_dta;
@@ -284,6 +272,14 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
         int                dd_stat;
         char               dd_name[1];
     } DIR;
+    /*
+     * Visual studio also lacks S_ISDIR for sys/stat.h, so we emulate this as well
+     * which is not hard at all.
+     */
+#    ifdef S_ISDIR
+#        undef  S_ISDIR
+#    endif /*! S_ISDIR */
+#   define S_ISDIR(X) ((X)&_S_IFDIR)
 #else
 #   include <dirent.h>
 #endif /*! _WIN32 && !defined(__MINGW32__) */
@@ -313,8 +309,18 @@ uint16_t util_crc16(uint16_t crc, const char *data, size_t len);
 void     util_seed(uint32_t);
 uint32_t util_rand();
 
-int util_vasprintf(char **ret, const char *fmt, va_list);
-int util_asprintf (char **ret, const char *fmt, ...);
+/*
+ * String functions (formatting, copying, concatenating, errors). These are wrapped
+ * to use the MSVC _safe_ versions when using MSVC, plus some implementations of
+ * these are non-conformant or don't exist such as asprintf and snprintf, which are
+ * not supported in C90, but do exist in C99.
+ */
+int         util_vasprintf(char **ret, const char *fmt, va_list);
+int         util_asprintf (char **ret, const char *fmt, ...);
+int         util_snprintf (char *src,  size_t bytes, const char *format, ...);
+char       *util_strcat   (char *dest, const char *src);
+char       *util_strncpy  (char *dest, const char *src, size_t num);
+const char *util_strerror (int num);
 
 
 #ifdef NOTRACK
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/ir.c b/ir.c
old mode 100644 (file)
new mode 100755 (executable)
index cabddf4..2552510
--- a/ir.c
+++ b/ir.c
@@ -3059,7 +3059,7 @@ static ir_value* ir_gen_extparam_proto(ir_builder *ir)
     ir_value *global;
     char      name[128];
 
-    snprintf(name, sizeof(name), "EXTPARM#%i", (int)(vec_size(ir->extparam_protos)));
+    util_snprintf(name, sizeof(name), "EXTPARM#%i", (int)(vec_size(ir->extparam_protos)));
     global = ir_value_var(name, store_global, TYPE_VECTOR);
 
     vec_push(ir->extparam_protos, global);
diff --git a/ir.h b/ir.h
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/lexer.c b/lexer.c
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/lexer.h b/lexer.h
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/main.c b/main.c
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index b87c6f4..39daed8
@@ -1,25 +1,38 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qcvm", "qcvm.vcxproj", "{8DC505A6-6047-4683-BA81-BC4B7A839352}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmqcc", "gmqcc.vcxproj", "{0F0B0779-1A2F-43E9-B833-18C443F7229E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite.vcxproj", "{3F8F0021-66B8-43ED-906C-1CFE204E5673}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Release|Win32 = Release|Win32
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {8DC505A6-6047-4683-BA81-BC4B7A839352}.Release|Win32.ActiveCfg = Release|Win32
-               {8DC505A6-6047-4683-BA81-BC4B7A839352}.Release|Win32.Build.0 = Release|Win32
-               {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Release|Win32.ActiveCfg = Release|Win32
-               {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Release|Win32.Build.0 = Release|Win32
-               {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.ActiveCfg = Release|Win32
-               {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.Build.0 = Release|Win32
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmqcc", "gmqcc\gmqcc.vcxproj", "{A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qcvm", "qcvm\qcvm.vcxproj", "{DC980E20-C7A8-4112-A517-631DBDA788E7}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pak", "pak\pak.vcxproj", "{A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite\testsuite.vcxproj", "{7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}.Debug|Win32.Build.0 = Debug|Win32\r
+               {A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}.Release|Win32.ActiveCfg = Release|Win32\r
+               {A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}.Release|Win32.Build.0 = Release|Win32\r
+               {DC980E20-C7A8-4112-A517-631DBDA788E7}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {DC980E20-C7A8-4112-A517-631DBDA788E7}.Debug|Win32.Build.0 = Debug|Win32\r
+               {DC980E20-C7A8-4112-A517-631DBDA788E7}.Release|Win32.ActiveCfg = Release|Win32\r
+               {DC980E20-C7A8-4112-A517-631DBDA788E7}.Release|Win32.Build.0 = Release|Win32\r
+               {A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}.Debug|Win32.Build.0 = Debug|Win32\r
+               {A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}.Release|Win32.ActiveCfg = Release|Win32\r
+               {A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}.Release|Win32.Build.0 = Release|Win32\r
+               {7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}.Debug|Win32.Build.0 = Debug|Win32\r
+               {7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}.Release|Win32.ActiveCfg = Release|Win32\r
+               {7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/msvc/gmqcc.vcxproj b/msvc/gmqcc.vcxproj
deleted file mode 100644 (file)
index d8f46a8..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{0F0B0779-1A2F-43E9-B833-18C443F7229E}</ProjectGuid>
-    <RootNamespace>gmqcc</RootNamespace>
-    <TrackFileAccess>false</TrackFileAccess>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <EmbedManifest>false</EmbedManifest>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>false</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <ProgramDatabaseFile>
-      </ProgramDatabaseFile>
-    </Link>
-    <PostBuildEvent>
-      <Command>Del /Q "$(IntDir)\*.tlog"</Command>
-    </PostBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\ast.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
-    </ClCompile>
-    <ClCompile Include="..\code.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
-    </ClCompile>
-    <ClCompile Include="..\conout.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_gmqcc.o</ObjectFileName>
-    </ClCompile>
-    <ClCompile Include="..\ftepp.c" />
-    <ClCompile Include="..\ir.c" />
-    <ClCompile Include="..\lexer.c" />
-    <ClCompile Include="..\main.c" />
-    <ClCompile Include="..\opts.c" />
-    <ClCompile Include="..\parser.c" />
-    <ClCompile Include="..\util.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_gmqcc.o</ObjectFileName>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\ast.h" />
-    <ClInclude Include="..\gmqcc.h" />
-    <ClInclude Include="..\ir.h" />
-    <ClInclude Include="..\lexer.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/msvc/gmqcc/gmqcc.vcxproj b/msvc/gmqcc/gmqcc.vcxproj
new file mode 100755 (executable)
index 0000000..f184b3b
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{A6BD74E1-31BB-4D00-A9E0-09FF1BC76ED6}</ProjectGuid>\r
+    <RootNamespace>gmqcc</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup />\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\ast.c" />\r
+    <ClCompile Include="..\..\code.c" />\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\correct.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\ftepp.c" />\r
+    <ClCompile Include="..\..\ir.c" />\r
+    <ClCompile Include="..\..\lexer.c" />\r
+    <ClCompile Include="..\..\main.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\parser.c" />\r
+    <ClCompile Include="..\..\utf8.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\ast.h" />\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+    <ClInclude Include="..\..\intrin.h" />\r
+    <ClInclude Include="..\..\ir.h" />\r
+    <ClInclude Include="..\..\lexer.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/gmqcc/gmqcc.vcxproj.filters b/msvc/gmqcc/gmqcc.vcxproj.filters
new file mode 100755 (executable)
index 0000000..9272e9f
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\ast.c" />\r
+    <ClCompile Include="..\..\code.c" />\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\correct.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\ftepp.c" />\r
+    <ClCompile Include="..\..\ir.c" />\r
+    <ClCompile Include="..\..\lexer.c" />\r
+    <ClCompile Include="..\..\main.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\parser.c" />\r
+    <ClCompile Include="..\..\utf8.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\ast.h" />\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+    <ClInclude Include="..\..\intrin.h" />\r
+    <ClInclude Include="..\..\ir.h" />\r
+    <ClInclude Include="..\..\lexer.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/pak/pak.vcxproj b/msvc/pak/pak.vcxproj
new file mode 100755 (executable)
index 0000000..ab075a9
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{A6F66BE9-57EF-4E93-AA9D-6E0C8B0990AD}</ProjectGuid>\r
+    <RootNamespace>pak</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup />\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\pak.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/pak/pak.vcxproj.filters b/msvc/pak/pak.vcxproj.filters
new file mode 100755 (executable)
index 0000000..745f4ce
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\opts.c" />\r
+    <ClCompile Include="..\..\pak.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="..\..\opts.def" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/qcvm.vcxproj b/msvc/qcvm.vcxproj
deleted file mode 100644 (file)
index 5382279..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{8DC505A6-6047-4683-BA81-BC4B7A839352}</ProjectGuid>
-    <RootNamespace>qcvm</RootNamespace>
-    <TrackFileAccess>false</TrackFileAccess>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Full</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
-      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
-      <OmitFramePointers>true</OmitFramePointers>
-      <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
-      <PreprocessorDefinitions>QCVM_EXECUTOR=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-    </Link>
-    <PostBuildEvent>
-      <Command>Del /Q "$(IntDir)\*.tlog"</Command>
-    </PostBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\conout.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_qcvm.o</ObjectFileName>
-    </ClCompile>
-    <ClCompile Include="..\exec.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
-    </ClCompile>
-    <ClCompile Include="..\util.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_qcvm.o</ObjectFileName>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\gmqcc.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/msvc/qcvm/qcvm.vcxproj b/msvc/qcvm/qcvm.vcxproj
new file mode 100755 (executable)
index 0000000..8892daa
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{DC980E20-C7A8-4112-A517-631DBDA788E7}</ProjectGuid>\r
+    <RootNamespace>qcvm</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup />\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>QCVM_EXECUTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>QCVM_EXECUTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\exec.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/qcvm/qcvm.vcxproj.filters b/msvc/qcvm/qcvm.vcxproj.filters
new file mode 100755 (executable)
index 0000000..526cd89
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\exec.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/testsuite.vcxproj b/msvc/testsuite.vcxproj
deleted file mode 100644 (file)
index 3e77231..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{3F8F0021-66B8-43ED-906C-1CFE204E5673}</ProjectGuid>
-    <RootNamespace>testsuite</RootNamespace>
-    <TrackFileAccess>false</TrackFileAccess>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-    </Link>
-    <PostBuildEvent>
-      <Command>Del /Q "$(IntDir)\*.tlog"</Command>
-    </PostBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\conout.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_testsuite.o</ObjectFileName>
-    </ClCompile>
-    <ClCompile Include="..\test.c" />
-    <ClCompile Include="..\util.c">
-      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_testsuite.o</ObjectFileName>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\gmqcc.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/msvc/testsuite/testsuite.vcxproj b/msvc/testsuite/testsuite.vcxproj
new file mode 100755 (executable)
index 0000000..f0207f9
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{7E2839D9-9C1A-4489-9FF9-FDC854EBED3D}</ProjectGuid>\r
+    <RootNamespace>testsuite</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup />\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\test.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/msvc/testsuite/testsuite.vcxproj.filters b/msvc/testsuite/testsuite.vcxproj.filters
new file mode 100755 (executable)
index 0000000..5cd16e3
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\conout.c" />\r
+    <ClCompile Include="..\..\fs.c" />\r
+    <ClCompile Include="..\..\test.c" />\r
+    <ClCompile Include="..\..\util.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\gmqcc.h" />\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/opts.c b/opts.c
old mode 100644 (file)
new mode 100755 (executable)
index c2e019e..77aa9c0
--- a/opts.c
+++ b/opts.c
@@ -216,7 +216,7 @@ static size_t opts_ini_parse (
             /* section found */
             if (*(parse_end = opts_ini_next(parse_beg + 1, ']')) == ']') {
                 * parse_end = '\0'; /* terminate bro */
-                strncpy(section_data, parse_beg + 1, sizeof(section_data));
+                util_strncpy(section_data, parse_beg + 1, sizeof(section_data));
                 section_data[sizeof(section_data) - 1] = '\0';
                 *oldname_data                          = '\0';
             } else if (!error) {
@@ -237,7 +237,7 @@ static size_t opts_ini_parse (
                 opts_ini_rstrip(read_value);
 
                 /* valid name value pair, lets call down to handler */
-                strncpy(oldname_data, read_name, sizeof(oldname_data));
+                util_strncpy(oldname_data, read_name, sizeof(oldname_data));
                 oldname_data[sizeof(oldname_data) - 1] ='\0';
 
                 if ((*errorhandle = loadhandle(section_data, read_name, read_value)) && !error)
diff --git a/pak.c b/pak.c
old mode 100644 (file)
new mode 100755 (executable)
index 2ab417d..653a463
--- a/pak.c
+++ b/pak.c
@@ -95,14 +95,14 @@ static void pak_tree_build(const char *entry) {
 
     memset(pathsplit, 0, 56);
 
-    strncpy(directory, entry, 56);
+    util_strncpy(directory, entry, 56);
     for (itr = 0; (token = pak_tree_sep(&directory, "/")) != NULL; itr++) {
         elements[itr] = token;
     }
 
     for (jtr = 0; jtr < itr - 1; jtr++) {
-        strcat(pathsplit, elements[jtr]);
-        strcat(pathsplit, "/");
+        util_strcat(pathsplit, elements[jtr]);
+        util_strcat(pathsplit, "/");
 
         if (fs_dir_make(pathsplit)) {
             mem_d(pathsplit);
@@ -364,7 +364,7 @@ bool pak_insert_one(pak_file_t *pak, const char *file) {
         return false;
     }
 
-    strncpy(dir.name, file, strlen(file));
+    util_strncpy(dir.name, file, strlen(file));
 
     /*
      * Allocate some memory for loading in the data that will be
old mode 100644 (file)
new mode 100755 (executable)
index 86c336a..c50eb17
--- a/parser.c
+++ b/parser.c
@@ -260,7 +260,7 @@ static ast_value* parser_const_string(parser_t *parser, const char *str, bool do
     if ( (out = (ast_value*)util_htgeth(parser->ht_imm_string, str, hash)) ) {
         if (dotranslate && out->name[0] == '#') {
             char name[32];
-            snprintf(name, sizeof(name), "dotranslate_%lu", (unsigned long)(parser->translated++));
+            util_snprintf(name, sizeof(name), "dotranslate_%lu", (unsigned long)(parser->translated++));
             ast_value_set_name(out, name);
         }
         return out;
@@ -273,7 +273,7 @@ static ast_value* parser_const_string(parser_t *parser, const char *str, bool do
     */
     if (dotranslate) {
         char name[32];
-        snprintf(name, sizeof(name), "dotranslate_%lu", (unsigned long)(parser->translated++));
+        util_snprintf(name, sizeof(name), "dotranslate_%lu", (unsigned long)(parser->translated++));
         out = ast_value_new(parser_ctx(parser), name, TYPE_STRING);
     } else
         out = ast_value_new(parser_ctx(parser), "#IMMEDIATE", TYPE_STRING);
@@ -4227,13 +4227,13 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
         varargs->expression.flags |= AST_FLAG_IS_VARARG;
         varargs->expression.next = (ast_expression*)ast_value_new(ast_ctx(var), NULL, TYPE_VECTOR);
         varargs->expression.count = 0;
-        snprintf(name, sizeof(name), "%s##va##SET", var->name);
+        util_snprintf(name, sizeof(name), "%s##va##SET", var->name);
         if (!parser_create_array_setter_proto(parser, varargs, name)) {
             ast_delete(varargs);
             ast_block_delete(block);
             goto enderrfn;
         }
-        snprintf(name, sizeof(name), "%s##va##GET", var->name);
+        util_snprintf(name, sizeof(name), "%s##va##GET", var->name);
         if (!parser_create_array_getter_proto(parser, varargs, varargs->expression.next, name)) {
             ast_delete(varargs);
             ast_block_delete(block);
@@ -5533,10 +5533,10 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
          */
         if (var->expression.vtype == TYPE_ARRAY) {
             char name[1024];
-            snprintf(name, sizeof(name), "%s##SET", var->name);
+            util_snprintf(name, sizeof(name), "%s##SET", var->name);
             if (!parser_create_array_setter(parser, var, name))
                 goto cleanup;
-            snprintf(name, sizeof(name), "%s##GET", var->name);
+            util_snprintf(name, sizeof(name), "%s##GET", var->name);
             if (!parser_create_array_getter(parser, var, var->expression.next, name))
                 goto cleanup;
         }
@@ -5554,14 +5554,14 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
                 goto cleanup;
             }
 
-            snprintf(name, sizeof(name), "%s##SETF", var->name);
+            util_snprintf(name, sizeof(name), "%s##SETF", var->name);
             if (!parser_create_array_field_setter(parser, array, name))
                 goto cleanup;
 
             telem = ast_type_copy(ast_ctx(var), array->expression.next);
             tfield = ast_value_new(ast_ctx(var), "<.type>", TYPE_FIELD);
             tfield->expression.next = telem;
-            snprintf(name, sizeof(name), "%s##GETFP", var->name);
+            util_snprintf(name, sizeof(name), "%s##GETFP", var->name);
             if (!parser_create_array_getter(parser, array, (ast_expression*)tfield, name)) {
                 ast_delete(tfield);
                 goto cleanup;
diff --git a/test.c b/test.c
old mode 100644 (file)
new mode 100755 (executable)
index 2ede2ae..6987bb3
--- a/test.c
+++ b/test.c
@@ -488,7 +488,7 @@ task_template_t *task_template_compile(const char *file, const char *dir, size_t
     FILE            *tempfile = NULL;
     task_template_t *tmpl     = NULL;
 
-    snprintf(fullfile,    sizeof(fullfile), "%s/%s", dir, file);
+    util_snprintf(fullfile,    sizeof(fullfile), "%s/%s", dir, file);
 
     tempfile = fs_file_open(fullfile, "r");
     tmpl     = (task_template_t*)mem_a(sizeof(task_template_t));
@@ -657,7 +657,7 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
     dir = fs_dir_open(curdir);
 
     while ((files = fs_dir_read(dir))) {
-        snprintf(buffer, sizeof(buffer), "%s/%s", curdir, files->d_name);
+        util_snprintf(buffer, sizeof(buffer), "%s/%s", curdir, files->d_name);
 
         if (stat(buffer, &directory) == -1) {
             con_err("internal error: stat failed, aborting\n");
@@ -697,7 +697,16 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
              * to test compile flags for all tests.  This needs to be
              * BEFORE other flags (so that the .tmpl can override them)
              */
+            #ifdef _MSC_VER
+            {
+                char   buffer[4096];
+                size_t size;
+                getenv_s(&size, buffer, sizeof(buffer), "QCFLAGS");
+                qcflags = buffer;
+            }
+            #else
             qcflags = getenv("QCFLAGS");
+            #endif
 
             /*
              * Generate the command required to open a pipe to a process
@@ -707,7 +716,7 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
             if (strcmp(tmpl->proceduretype, "-pp")) {
                 if (qcflags) {
                     if (tmpl->testflags && !strcmp(tmpl->testflags, "-no-defs")) {
-                        snprintf(buf, sizeof(buf), "%s %s/%s %s %s -o %s",
+                        util_snprintf(buf, sizeof(buf), "%s %s/%s %s %s -o %s",
                             task_bins[TASK_COMPILE],
                             curdir,
                             tmpl->sourcefile,
@@ -716,7 +725,7 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
                             tmpl->tempfilename
                         );
                     } else {
-                        snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s %s -o %s",
+                        util_snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s %s -o %s",
                             task_bins[TASK_COMPILE],
                             curdir,
                             defs,
@@ -729,7 +738,7 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
                     }
                 } else {
                     if (tmpl->testflags && !strcmp(tmpl->testflags, "-no-defs")) {
-                        snprintf(buf, sizeof(buf), "%s %s/%s %s -o %s",
+                        util_snprintf(buf, sizeof(buf), "%s %s/%s %s -o %s",
                             task_bins[TASK_COMPILE],
                             curdir,
                             tmpl->sourcefile,
@@ -737,7 +746,7 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
                             tmpl->tempfilename
                         );
                     } else {
-                        snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s -o %s",
+                        util_snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s -o %s",
                             task_bins[TASK_COMPILE],
                             curdir,
                             defs,
@@ -751,14 +760,14 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
             } else {
                 /* Preprocessing (qcflags mean shit all here we don't allow them) */
                 if (tmpl->testflags && !strcmp(tmpl->testflags, "-no-defs")) {
-                    snprintf(buf, sizeof(buf), "%s -E %s/%s -o %s",
+                    util_snprintf(buf, sizeof(buf), "%s -E %s/%s -o %s",
                         task_bins[TASK_COMPILE],
                         curdir,
                         tmpl->sourcefile,
                         tmpl->tempfilename
                     );
                 } else {
-                    snprintf(buf, sizeof(buf), "%s -E %s/%s %s/%s -o %s",
+                    util_snprintf(buf, sizeof(buf), "%s -E %s/%s %s/%s -o %s",
                         task_bins[TASK_COMPILE],
                         curdir,
                         defs,
@@ -786,14 +795,14 @@ bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
              * Open up some file desciptors for logging the stdout/stderr
              * to our own.
              */
-            snprintf(buf,  sizeof(buf), "%s.stdout", tmpl->tempfilename);
+            util_snprintf(buf,  sizeof(buf), "%s.stdout", tmpl->tempfilename);
             task.stdoutlogfile = util_strdup(buf);
             if (!(task.stdoutlog     = fs_file_open(buf, "w"))) {
                 con_err("error opening %s for stdout\n", buf);
                 continue;
             }
 
-            snprintf(buf,  sizeof(buf), "%s.stderr", tmpl->tempfilename);
+            util_snprintf(buf,  sizeof(buf), "%s.stderr", tmpl->tempfilename);
             task.stderrlogfile = util_strdup(buf);
             if (!(task.stderrlog = fs_file_open(buf, "w"))) {
                 con_err("error opening %s for stderr\n", buf);
@@ -829,7 +838,7 @@ void task_precleanup(const char *curdir) {
             strstr(files->d_name, ".stdout") ||
             strstr(files->d_name, ".stderr"))
         {
-            snprintf(buffer, sizeof(buffer), "%s/%s", curdir, files->d_name);
+            util_snprintf(buffer, sizeof(buffer), "%s/%s", curdir, files->d_name);
             if (remove(buffer))
                 con_err("error removing temporary file: %s\n", buffer);
             else
@@ -891,6 +900,7 @@ void task_destroy(void) {
  */
 bool task_trymatch(task_template_t *tmpl, char ***line) {
     bool     success = true;
+    bool     preprocessing = false;
     FILE    *execute;
     char     buffer[4096];
     memset  (buffer,0,sizeof(buffer));
@@ -901,12 +911,12 @@ bool task_trymatch(task_template_t *tmpl, char ***line) {
          * actually specified.
          */
         if (!strcmp(tmpl->executeflags, "$null")) {
-            snprintf(buffer,  sizeof(buffer), "%s %s",
+            util_snprintf(buffer,  sizeof(buffer), "%s %s",
                 task_bins[TASK_EXECUTE],
                 tmpl->tempfilename
             );
         } else {
-            snprintf(buffer,  sizeof(buffer), "%s %s %s",
+            util_snprintf(buffer,  sizeof(buffer), "%s %s %s",
                 task_bins[TASK_EXECUTE],
                 tmpl->executeflags,
                 tmpl->tempfilename
@@ -928,6 +938,8 @@ bool task_trymatch(task_template_t *tmpl, char ***line) {
          */
         if (!(execute = fs_file_open(tmpl->tempfilename, "r")))
             return false;
+
+        preprocessing = true;
     }
 
     /*
@@ -944,7 +956,10 @@ bool task_trymatch(task_template_t *tmpl, char ***line) {
                     tmpl->description,
                     tmpl->rulesfile
                 );
-                pclose(execute);
+                if (preprocessing)
+                    fs_file_close(execute);
+                else
+                    pclose(execute);
                 return false;
             }
 
@@ -983,7 +998,7 @@ bool task_trymatch(task_template_t *tmpl, char ***line) {
         data = NULL;
     }
 
-    if (strcmp(tmpl->proceduretype, "-pp"))
+    if (!preprocessing)
         pclose(execute);
     else
         fs_file_close(execute);
@@ -1017,11 +1032,11 @@ void task_schedualize(size_t *pad) {
     size_t i        = 0;
     size_t j        = 0;
 
-    snprintf(space[0], sizeof(space[0]), "%d", (int)vec_size(task_tasks));
+    util_snprintf(space[0], sizeof(space[0]), "%d", (int)vec_size(task_tasks));
 
     for (; i < vec_size(task_tasks); i++) {
         memset(space[1], 0, sizeof(space[1]));
-        snprintf(space[1], sizeof(space[1]), "%d", (int)(i + 1));
+        util_snprintf(space[1], sizeof(space[1]), "%d", (int)(i + 1));
 
         con_out("test #%u %*s", i + 1, strlen(space[0]) - strlen(space[1]), "");
 
diff --git a/utf8.c b/utf8.c
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/util.c b/util.c
old mode 100644 (file)
new mode 100755 (executable)
index b7e3c7c..abc102f
--- a/util.c
+++ b/util.c
@@ -688,14 +688,13 @@ int util_vasprintf(char **dat, const char *fmt, va_list args) {
      * will return the required amount to allocate.
      */
     #ifdef _MSC_VER
-        char *str;
         if ((len = _vscprintf(fmt, args)) < 0) {
             *dat = NULL;
             return -1;
         }
 
-        tmp = mem_a(len + 1);
-        if ((ret = _vsnprintf(tmp, len+1, fmt, args)) != len) {
+        tmp = (char*)mem_a(len + 1);
+        if ((ret = _vsnprintf_s(tmp, len+1, len+1, fmt, args)) != len) {
             mem_d(tmp);
             *dat = NULL;
             return -1;
@@ -742,6 +741,92 @@ int util_asprintf(char **ret, const char *fmt, ...) {
     return read;
 }
 
+/*
+ * These are various re-implementations (wrapping the real ones) of
+ * string functions that MSVC consideres unsafe. We wrap these up and
+ * use the safe varations on MSVC.
+ */
+#ifdef _MSC_VER
+    static char **util_strerror_allocated() {
+        static char **data = NULL;
+        return data;
+    }
+
+    static void util_strerror_cleanup(void) {
+        size_t i;
+        char  **data = util_strerror_allocated();
+        for (i = 0; i < vec_size(data); i++)
+            mem_d(data[i]);
+        vec_free(data);
+    }
+
+    const char *util_strerror(int num) {
+        char         *allocated = NULL;
+        static bool   install   = false;
+        static size_t tries     = 0;
+        char        **vector    = util_strerror_allocated();
+
+        /* try installing cleanup handler */
+        while (!install) {
+            if (tries == 32)
+                return "(unknown)";
+
+            install = !atexit(&util_strerror_cleanup);
+            tries ++;
+        }
+
+        allocated = (char*)mem_a(4096); /* A page must be enough */
+        strerror_s(allocated, 4096, num);
+    
+        vec_push(vector, allocated);
+        return (const char *)allocated;
+    }
+
+    int util_snprintf(char *src, size_t bytes, const char *format, ...) {
+        int      rt;
+        va_list  va;
+        va_start(va, format);
+
+        rt = vsprintf_s(src, bytes, format, va);
+        va_end  (va);
+
+        return rt;
+    }
+
+    char *util_strcat(char *dest, const char *src) {
+        strcat_s(dest, strlen(src), src);
+        return dest;
+    }
+
+    char *util_strncpy(char *dest, const char *src, size_t num) {
+        strncpy_s(dest, num, src, num);
+        return dest;
+    }
+#else
+    const char *util_strerror(int num) {
+        return strerror(num);
+    }
+
+    int util_snprintf(char *src, size_t bytes, const char *format, ...) {
+        int      rt;
+        va_list  va;
+        va_start(va, format);
+        rt = vsnprintf(src, bytes, format, va);
+        va_end  (va);
+
+        return rt;
+    }
+
+    char *util_strcat(char *dest, const char *src) {
+        return strcat(dest, src);
+    }
+
+    char *util_strncpy(char *dest, const char *src, size_t num) {
+        return strncpy(dest, src, num);
+    }
+
+#endif /*! _MSC_VER */
+
 /*
  * Implementation of the Mersenne twister PRNG (pseudo random numer
  * generator).  Implementation of MT19937.  Has a period of 2^19937-1