From 4a59329784741bb210d332e3e4a0b7d5da625390 Mon Sep 17 00:00:00 2001
From: Rodrigo Braz Monteiro <zeratul@cellosoft.com>
Date: Wed, 23 Jan 2008 06:17:18 +0000
Subject: [PATCH] Made universalchardet work on Win64 (it's a one-line patch
 [prcpucfg.h:146] to make it work on other OS, but I don't know what the
 proper define is)

Originally committed to SVN as r1817.
---
 aegisub/font_file_lister.cpp               |  2 +-
 aegisub/font_file_lister.h                 |  2 +-
 aegisub/stdwx.h                            |  2 +
 build/aegisub_vs2005/aegisub_vs2005.vcproj | 40 ++++++++++++-----
 universalchardet/prcpucfg.h                | 52 ++++++++++++++++++++++
 universalchardet/universalcharset.vcproj   | 36 +++++++--------
 6 files changed, 104 insertions(+), 30 deletions(-)

diff --git a/aegisub/font_file_lister.cpp b/aegisub/font_file_lister.cpp
index 460347886..fb9f0243e 100644
--- a/aegisub/font_file_lister.cpp
+++ b/aegisub/font_file_lister.cpp
@@ -42,7 +42,7 @@
 #include "text_file_writer.h"
 #include "text_file_reader.h"
 #include "standard_paths.h"
-#if defined(WIN32) || defined(__APPLE__)
+#if defined(__WINDOWS__) || defined(__APPLE__)
 #ifdef WITH_FREETYPE2
 #include "font_file_lister_freetype.h"
 #define FontListerClass FreetypeFontFileLister
diff --git a/aegisub/font_file_lister.h b/aegisub/font_file_lister.h
index 5c5cd5acb..90e1e2cce 100644
--- a/aegisub/font_file_lister.h
+++ b/aegisub/font_file_lister.h
@@ -47,7 +47,7 @@
 
 ////////////
 // Typedefs
-#if defined(WIN32) || defined(__APPLE__)
+#if defined(__WINDOWS__) || defined(__APPLE__)
 typedef struct FT_LibraryRec_ *FT_Library;
 #endif
 typedef std::map<wxString,wxArrayString> FontMap;
diff --git a/aegisub/stdwx.h b/aegisub/stdwx.h
index dfc83cb9c..8f837d35a 100644
--- a/aegisub/stdwx.h
+++ b/aegisub/stdwx.h
@@ -99,5 +99,7 @@
 #include <list>
 #include <map>
 
+#pragma warning(default: 6011)
+
 
 #endif // C++
diff --git a/build/aegisub_vs2005/aegisub_vs2005.vcproj b/build/aegisub_vs2005/aegisub_vs2005.vcproj
index f840a1d18..5356e1521 100644
--- a/build/aegisub_vs2005/aegisub_vs2005.vcproj
+++ b/build/aegisub_vs2005/aegisub_vs2005.vcproj
@@ -132,7 +132,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="../../aegisub/win64;../../hunspell/src"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+				PreprocessorDefinitions="WIN32;WIN64;_DEBUG;_WINDOWS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -305,7 +305,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="../../aegisub/win64;../../hunspell/src"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+				PreprocessorDefinitions="WIN32;WIN64;NDEBUG;_WINDOWS"
 				RuntimeLibrary="2"
 				OpenMP="true"
 				UsePrecompiledHeader="2"
@@ -1387,14 +1387,6 @@
 		<Filter
 			Name="Core"
 			>
-			<File
-				RelativePath="..\..\aegisub\win32\config.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\aegisub\win32\config0.h"
-				>
-			</File>
 			<File
 				RelativePath="..\..\aegisub\frame_main.cpp"
 				>
@@ -1820,6 +1812,34 @@
 				>
 			</File>
 		</Filter>
+		<Filter
+			Name="Config"
+			>
+			<Filter
+				Name="win32"
+				>
+				<File
+					RelativePath="..\..\aegisub\win32\config.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\aegisub\win32\config0.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="win64"
+				>
+				<File
+					RelativePath="..\..\aegisub\win64\config.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\aegisub\win64\config0.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
 		<File
 			RelativePath="..\..\aegisub\changelog.txt"
 			>
diff --git a/universalchardet/prcpucfg.h b/universalchardet/prcpucfg.h
index ff316f8f1..7b1c816e4 100644
--- a/universalchardet/prcpucfg.h
+++ b/universalchardet/prcpucfg.h
@@ -143,8 +143,60 @@
 
 #else /* defined(_M_IX86) || defined(_X86_) */
 
+#ifdef WIN64
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_WORD	4
+#define PR_BYTES_PER_DWORD	8
+#define PR_BYTES_PER_DOUBLE 8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_WORD	32
+#define PR_BITS_PER_DWORD	64
+#define PR_BITS_PER_DOUBLE  64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_WORD_LOG2	5
+#define PR_BITS_PER_DWORD_LOG2	6
+#define PR_BITS_PER_DOUBLE_LOG2 6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_WORD	4
+#define PR_ALIGN_OF_DWORD	8
+#define PR_ALIGN_OF_DOUBLE  4
+#define PR_ALIGN_OF_POINTER 4
+
+#define PR_BYTES_PER_WORD_LOG2	2
+#define PR_BYTES_PER_DWORD_LOG2	2
+
+#else
+
 #error unknown processor architecture
 
+#endif
+
 #endif /* defined(_M_IX86) || defined(_X86_) */
 
 #define HAVE_LONG_LONG
diff --git a/universalchardet/universalcharset.vcproj b/universalchardet/universalcharset.vcproj
index 75d3f2f35..671a424d6 100644
--- a/universalchardet/universalcharset.vcproj
+++ b/universalchardet/universalcharset.vcproj
@@ -82,12 +82,11 @@
 			/>
 		</Configuration>
 		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			Name="Debug|x64"
+			OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
-			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -103,11 +102,15 @@
 			/>
 			<Tool
 				Name="VCMIDLTool"
+				TargetEnvironment="3"
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
-				RuntimeLibrary="2"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;WIN64;_DEBUG;_LIB"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
@@ -124,7 +127,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="../lib/univcset.lib"
+				OutputFile="../lib/univcset_d.lib"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -143,11 +146,12 @@
 			/>
 		</Configuration>
 		<Configuration
-			Name="Debug|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
-			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
+			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -163,15 +167,11 @@
 			/>
 			<Tool
 				Name="VCMIDLTool"
-				TargetEnvironment="3"
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				Optimization="0"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
@@ -188,7 +188,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="../lib/univcset_d.lib"
+				OutputFile="../lib/univcset.lib"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -232,7 +232,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				PreprocessorDefinitions="WIN32;WIN64;NDEBUG;_LIB"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
-- 
GitLab