MAGENTA,
CYAN,
GRAY,
- WHITE
+ WHITE = GRAY
};
enum {
WMAGENTA = WBLUE | WRED,
WYELLOW = WGREEN | WRED,
WWHITE = WBLUE | WGREEN | WRED
-}
+};
-static const ansi2win[] = {
+static const int ansi2win[] = {
WBLACK,
WRED,
WGREEN,
WWHITE
};
-static void win_fputs(char *str, FILE *h) {
+static int win_fputs(const char *str, FILE *h) {
/* state for translate */
int acolor;
int wcolor;
int intense = -1;
int colors[] = {-1, -1 };
int colorpos = 1;
-
+ int length = 0;
CONSOLE_SCREEN_BUFFER_INFO cinfo;
GetConsoleScreenBufferInfo (
(GMQCC_IS_STDOUT(h)) ?
icolor = cinfo.wAttributes;
while (*str) {
- if (*str == '\e')
- state = '\e';
- else if (state == '\e' && *str == '[')
+ if (*str == '\x1B')
+ state = '\x1B';
+ else if (state == '\x1B' && *str == '[')
state = '[';
else if (state == '[') {
if (*str != 'm') {
intense = WBLACK;
wcolor = icolor;
}
- else if (BLACK < acolor && acolor <= WHITE)
+ else if (BLACK <= acolor && acolor <= WHITE)
wcolor = ansi2win[acolor - 30];
else if (acolor == 90) {
/* special gray really white man */
}
SetConsoleTextAttribute (
- (h == stdout) ?
+ (GMQCC_IS_STDOUT(h)) ?
GetStdHandle(STD_OUTPUT_HANDLE) :
GetStdHandle(STD_ERROR_HANDLE),
}
} else {
fputc(*str, h);
+ length ++;
}
+ str++;
}
/* restore */
SetConsoleTextAttribute(
GetStdHandle(STD_ERROR_HANDLE),
icolor
);
+ return length;
}
#endif
ln = vfprintf(handle, fmt, va);
#else
{
- char *data = NULL;
- ln = _vscprintf(fmt, va);
- data = malloc(ln + 1);
- data[ln] = 0;
- vsprintf(data, fmt, va);
- if (GMQCC_IS_DEFINE(handle))
- win_fputs(data, handle);
- else
- ln = fputs(data, handle);
- free(data);
+ char data[4096];
+ memset(data, 0, sizeof(data));
+ vsnprintf(data, sizeof(data), fmt, va);
+ ln = (GMQCC_IS_DEFINE(handle)) ? win_fputs(data, handle) : fputs(data, handle);
}
#endif
return ln;
# endif /* !__STDC_VERSION__ */
#endif /* !__cplusplus */
+
+
/*
* Of some functions which are generated we want to make sure
* that the result isn't ignored. To find such function calls,
uint16_t util_crc16(uint16_t crc, const char *data, size_t len);
uint32_t util_crc32(uint32_t crc, const char *data, size_t len);
+/*
+ * If we're compiling as C++ code we need to fix some subtle issues regarding casts between mem_a/mem_d
+ * since C++ doesn't allow implicit conversions between void*
+ */
+#ifdef __cplusplus
+ /*
+ * void * will be implicitally converted to gmqcc_voidptr using gmqcc_voidptr(void*). This is what
+ * essentially allows us to allow implicit conversion to whatever pointer type we're trying to assign
+ * to because it acks as a default assignment constructor.
+ */
+ class gmqcc_voidptr {
+ void *m_pointer;
+ public:
+ gmqcc_voidptr(void *pointer) :
+ m_pointer(pointer)
+ { };
+
+ template <typename T>
+ GMQCC_INLINE operator T *() {
+ return m_pointer;
+ }
+ };
+
+# define GMQCC_IMPLICIT_POINTER(X) (gmqcc_voidptr(X))
+#else
+# define GMQCC_IMPLICIT_POINTER(X) (X)
+#endif
+
#ifdef NOTRACK
-# define mem_a(x) malloc (x)
-# define mem_d(x) free (x)
-# define mem_r(x, n) realloc(x, n)
+# define mem_a(x) GMQCC_IMPLICIT_POINTER(malloc (x))
+# define mem_d(x) free ((void*)x)
+# define mem_r(x, n) realloc((void*)x, n)
#else
-# define mem_a(x) util_memory_a((x), __LINE__, __FILE__)
-# define mem_d(x) util_memory_d((x), __LINE__, __FILE__)
-# define mem_r(x, n) util_memory_r((x), (n), __LINE__, __FILE__)
+# define mem_a(x) GMQCC_IMPLICIT_POINTER(util_memory_a((x), __LINE__, __FILE__))
+# define mem_d(x) util_memory_d((void*)(x), __LINE__, __FILE__)
+# define mem_r(x, n) util_memory_r((void*)(x), (n), __LINE__, __FILE__)
#endif
/*
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8DC505A6-6047-4683-BA81-BC4B7A839352}.Debug|Win32.ActiveCfg = Debug|Win32
- {8DC505A6-6047-4683-BA81-BC4B7A839352}.Debug|Win32.Build.0 = Debug|Win32
{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}.Debug|Win32.ActiveCfg = Debug|Win32
- {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Debug|Win32.Build.0 = Debug|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}.Debug|Win32.ActiveCfg = Debug|Win32
- {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Debug|Win32.Build.0 = Debug|Win32
{3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.ActiveCfg = Release|Win32
{3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
<?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="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
<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)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </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 />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <EmbedManifest>false</EmbedManifest>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
+ <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" />
- <ClCompile Include="..\code.c" />
- <ClCompile Include="..\conout.c" />
+ <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" />
+ <ClCompile Include="..\util.c">
+ <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_gmqcc.o</ObjectFileName>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ast.h" />
<?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="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
<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)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <UseOfMfc>false</UseOfMfc>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </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 />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Full</Optimization>
- <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>
- </Link>
- </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
+ <PostBuildEvent>
+ <Command>Del /Q "$(IntDir)\*.tlog"</Command>
+ </PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\conout.c" />
- <ClCompile Include="..\exec.c" />
- <ClCompile Include="..\util.c" />
+ <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" />
<?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="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
<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)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </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 />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
+ <PostBuildEvent>
+ <Command>Del /Q "$(IntDir)\*.tlog"</Command>
+ </PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\conout.c" />
+ <ClCompile Include="..\conout.c">
+ <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_testsuite.o</ObjectFileName>
+ </ClCompile>
<ClCompile Include="..\test.c" />
- <ClCompile Include="..\util.c" />
+ <ClCompile Include="..\util.c">
+ <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_testsuite.o</ObjectFileName>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\gmqcc.h" />