From 1861448e6cfbbb8967fc72dfb94be5f58caac12e Mon Sep 17 00:00:00 2001 From: janwas Date: Mon, 1 Mar 2010 14:52:58 +0000 Subject: [PATCH] needed to split lib into separate headers and source files, which requires lots of drudgery to specify paths for each include filename (no longer relying on same-directory lookups) also rename wchar -> utf8 to avoid conflict with (requires rebuild of workspace) (unfortunately copying history fails to "502 bad gateway"; had to delete old + add new independently) This was SVN commit r7340. --- source/lib/allocators/aligned_allocator.cpp | 2 +- source/lib/allocators/allocators.cpp | 4 +- source/lib/allocators/bucket.cpp | 4 +- source/lib/allocators/dynarray.cpp | 4 +- source/lib/allocators/headerless.cpp | 6 +- source/lib/allocators/mem_util.cpp | 2 +- source/lib/allocators/pool.cpp | 4 +- source/lib/allocators/pool.h | 2 +- source/lib/allocators/shared_ptr.cpp | 4 +- source/lib/allocators/string_pool.cpp | 2 +- source/lib/allocators/string_pool.h | 2 +- source/lib/app_hooks.cpp | 2 +- source/lib/bits.cpp | 2 +- source/lib/byte_order.cpp | 4 +- source/lib/debug.cpp | 8 +- source/lib/debug_stl.cpp | 4 +- source/lib/external_libraries/dbghelp.cpp | 6 +- source/lib/external_libraries/dbghelp.h | 2 +- source/lib/external_libraries/sdl.h | 2 +- source/lib/fat_time.cpp | 2 +- source/lib/file/archive/archive.cpp | 2 +- source/lib/file/archive/archive_zip.cpp | 10 +- source/lib/file/archive/archive_zip.h | 2 +- source/lib/file/archive/codec.cpp | 2 +- source/lib/file/archive/codec_zlib.cpp | 4 +- source/lib/file/archive/codec_zlib.h | 2 +- source/lib/file/archive/stream.cpp | 4 +- source/lib/file/archive/stream.h | 2 +- source/lib/file/common/file_loader.cpp | 2 +- source/lib/file/common/file_stats.cpp | 2 +- source/lib/file/common/real_directory.cpp | 2 +- source/lib/file/common/real_directory.h | 2 +- source/lib/file/common/trace.cpp | 2 +- source/lib/file/file.cpp | 2 +- source/lib/file/file_system.cpp | 4 +- source/lib/file/file_system_util.cpp | 2 +- source/lib/file/io/block_cache.cpp | 4 +- source/lib/file/io/io.cpp | 6 +- source/lib/file/io/io_align.cpp | 2 +- source/lib/file/io/write_buffer.cpp | 6 +- source/lib/file/vfs/file_cache.cpp | 2 +- source/lib/file/vfs/file_cache.h | 2 +- source/lib/file/vfs/vfs.cpp | 10 +- source/lib/file/vfs/vfs_lookup.cpp | 8 +- source/lib/file/vfs/vfs_lookup.h | 2 +- source/lib/file/vfs/vfs_path.cpp | 2 +- source/lib/file/vfs/vfs_populate.cpp | 8 +- source/lib/file/vfs/vfs_tree.cpp | 2 +- source/lib/frequency_filter.cpp | 2 +- source/lib/lib.cpp | 2 +- source/lib/lib.h | 2 +- source/lib/lib_errors.cpp | 2 +- source/lib/lockfree.cpp | 6 +- source/lib/module_init.cpp | 2 +- source/lib/ogl.cpp | 8 +- source/lib/ogl.h | 2 +- source/lib/path_util.cpp | 4 +- source/lib/posix/posix.cpp | 2 +- source/lib/posix/posix.h | 20 +- source/lib/posix/posix_aio.h | 2 +- source/lib/posix/posix_dlfcn.h | 2 +- source/lib/posix/posix_filesystem.h | 2 +- source/lib/posix/posix_mman.h | 2 +- source/lib/posix/posix_pthread.h | 2 +- source/lib/posix/posix_sock.h | 2 +- source/lib/posix/posix_terminal.h | 2 +- source/lib/posix/posix_time.h | 2 +- source/lib/posix/posix_utsname.h | 2 +- source/lib/rand.cpp | 2 +- source/lib/secure_crt.cpp | 4 +- source/lib/self_test.cpp | 4 +- source/lib/sysdep/acpi.cpp | 2 +- source/lib/sysdep/arch/amd64/amd64.cpp | 4 +- source/lib/sysdep/arch/ia32/ia32.cpp | 4 +- source/lib/sysdep/arch/x86_x64/topology.cpp | 4 +- source/lib/sysdep/arch/x86_x64/x86_x64.cpp | 6 +- source/lib/sysdep/cpu.cpp | 2 +- source/lib/sysdep/gfx.cpp | 2 +- source/lib/sysdep/os/win/mahaf.cpp | 6 +- source/lib/sysdep/os/win/wclipboard.cpp | 4 +- source/lib/sysdep/os/win/wcpu.cpp | 2 +- source/lib/sysdep/os/win/wcpu.h | 2 +- source/lib/sysdep/os/win/wcursor.cpp | 4 +- source/lib/sysdep/os/win/wdbg.cpp | 4 +- source/lib/sysdep/os/win/wdbg_heap.cpp | 10 +- source/lib/sysdep/os/win/wdbg_sym.cpp | 8 +- source/lib/sysdep/os/win/wdir_watch.cpp | 6 +- source/lib/sysdep/os/win/wdll_delay_load.cpp | 6 +- source/lib/sysdep/os/win/wdll_ver.cpp | 6 +- source/lib/sysdep/os/win/wgfx.cpp | 6 +- source/lib/sysdep/os/win/whrt/counter.cpp | 12 +- source/lib/sysdep/os/win/whrt/hpet.cpp | 4 +- source/lib/sysdep/os/win/whrt/pmt.cpp | 4 +- source/lib/sysdep/os/win/whrt/qpc.cpp | 8 +- source/lib/sysdep/os/win/whrt/tgt.cpp | 4 +- source/lib/sysdep/os/win/whrt/tsc.cpp | 4 +- source/lib/sysdep/os/win/whrt/whrt.cpp | 4 +- source/lib/sysdep/os/win/winit.cpp | 4 +- source/lib/sysdep/os/win/wmi.cpp | 2 +- source/lib/sysdep/os/win/wmi.h | 2 +- source/lib/sysdep/os/win/wnuma.cpp | 8 +- source/lib/sysdep/os/win/wposix/waio.cpp | 10 +- source/lib/sysdep/os/win/wposix/waio.h | 4 +- source/lib/sysdep/os/win/wposix/wdlfcn.cpp | 4 +- .../lib/sysdep/os/win/wposix/wfilesystem.cpp | 10 +- source/lib/sysdep/os/win/wposix/wmman.cpp | 6 +- source/lib/sysdep/os/win/wposix/wposix.cpp | 4 +- source/lib/sysdep/os/win/wposix/wpthread.cpp | 8 +- source/lib/sysdep/os/win/wposix/wsock.cpp | 6 +- source/lib/sysdep/os/win/wposix/wterminal.cpp | 6 +- source/lib/sysdep/os/win/wposix/wtime.cpp | 4 +- source/lib/sysdep/os/win/wposix/wutsname.cpp | 6 +- source/lib/sysdep/os/win/wsdl.cpp | 6 +- source/lib/sysdep/os/win/wseh.cpp | 10 +- source/lib/sysdep/os/win/wsnd.cpp | 8 +- source/lib/sysdep/os/win/wstartup.cpp | 4 +- source/lib/sysdep/os/win/wsysdep.cpp | 6 +- source/lib/sysdep/os/win/wutil.cpp | 6 +- source/lib/sysdep/os/win/wutil.h | 2 +- source/lib/sysdep/os_cpu.cpp | 2 +- source/lib/sysdep/snd.cpp | 2 +- source/lib/sysdep/tests/test_sysdep.h | 2 +- source/lib/tests/test_wchar.h | 4 +- source/lib/timer.cpp | 2 +- source/lib/types.h | 2 +- source/lib/{wchar.cpp => utf8.cpp} | 462 +++++++++--------- source/lib/{wchar.h => utf8.h} | 104 ++-- 127 files changed, 541 insertions(+), 541 deletions(-) rename source/lib/{wchar.cpp => utf8.cpp} (89%) rename source/lib/{wchar.h => utf8.h} (84%) diff --git a/source/lib/allocators/aligned_allocator.cpp b/source/lib/allocators/aligned_allocator.cpp index 97703c816e..bc3274e8f4 100644 --- a/source/lib/allocators/aligned_allocator.cpp +++ b/source/lib/allocators/aligned_allocator.cpp @@ -25,4 +25,4 @@ */ #include "precompiled.h" -#include "aligned_allocator.h" +#include "lib/allocators/aligned_allocator.h" diff --git a/source/lib/allocators/allocators.cpp b/source/lib/allocators/allocators.cpp index 5fc88c85b7..959ab89c18 100644 --- a/source/lib/allocators/allocators.cpp +++ b/source/lib/allocators/allocators.cpp @@ -25,12 +25,12 @@ */ #include "precompiled.h" -#include "allocators.h" +#include "lib/allocators/allocators.h" #include "lib/sysdep/cpu.h" // cpu_CAS #include "lib/bits.h" -#include "mem_util.h" +#include "lib/allocators/mem_util.h" //----------------------------------------------------------------------------- diff --git a/source/lib/allocators/bucket.cpp b/source/lib/allocators/bucket.cpp index ffa78841ee..e6fcd59140 100644 --- a/source/lib/allocators/bucket.cpp +++ b/source/lib/allocators/bucket.cpp @@ -25,10 +25,10 @@ */ #include "precompiled.h" -#include "bucket.h" +#include "lib/allocators/bucket.h" #include "lib/bits.h" -#include "mem_util.h" +#include "lib/allocators/mem_util.h" // power-of-2 isn't required; value is arbitrary. diff --git a/source/lib/allocators/dynarray.cpp b/source/lib/allocators/dynarray.cpp index 2bcbc4173b..0ad9e2bd7b 100644 --- a/source/lib/allocators/dynarray.cpp +++ b/source/lib/allocators/dynarray.cpp @@ -25,11 +25,11 @@ */ #include "precompiled.h" -#include "dynarray.h" +#include "lib/allocators/dynarray.h" #include "lib/posix/posix_mman.h" // PROT_* constants for da_set_prot #include "lib/sysdep/cpu.h" -#include "mem_util.h" +#include "lib/allocators/mem_util.h" // indicates that this DynArray must not be resized or freed diff --git a/source/lib/allocators/headerless.cpp b/source/lib/allocators/headerless.cpp index e06f7f6dc7..fdb0d3bc44 100644 --- a/source/lib/allocators/headerless.cpp +++ b/source/lib/allocators/headerless.cpp @@ -25,10 +25,10 @@ */ #include "precompiled.h" -#include "headerless.h" +#include "lib/allocators/headerless.h" -#include "mem_util.h" -#include "pool.h" +#include "lib/allocators/mem_util.h" +#include "lib/allocators/pool.h" #include "lib/bits.h" diff --git a/source/lib/allocators/mem_util.cpp b/source/lib/allocators/mem_util.cpp index d1388bba33..1892ce7dab 100644 --- a/source/lib/allocators/mem_util.cpp +++ b/source/lib/allocators/mem_util.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "mem_util.h" +#include "lib/allocators/mem_util.h" #include "lib/bits.h" // round_up #include "lib/posix/posix_mman.h" diff --git a/source/lib/allocators/pool.cpp b/source/lib/allocators/pool.cpp index edb71cfb4a..85d651c816 100644 --- a/source/lib/allocators/pool.cpp +++ b/source/lib/allocators/pool.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "pool.h" +#include "lib/allocators/pool.h" -#include "mem_util.h" +#include "lib/allocators/mem_util.h" LibError pool_create(Pool* p, size_t max_size, size_t el_size) diff --git a/source/lib/allocators/pool.h b/source/lib/allocators/pool.h index 3c63818989..5a3150a49b 100644 --- a/source/lib/allocators/pool.h +++ b/source/lib/allocators/pool.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_POOL #define INCLUDED_POOL -#include "dynarray.h" +#include "lib/allocators/dynarray.h" /** * allocator design parameters: diff --git a/source/lib/allocators/shared_ptr.cpp b/source/lib/allocators/shared_ptr.cpp index 616fe23fcb..4bc4a11411 100644 --- a/source/lib/allocators/shared_ptr.cpp +++ b/source/lib/allocators/shared_ptr.cpp @@ -21,9 +21,9 @@ */ #include "precompiled.h" -#include "shared_ptr.h" +#include "lib/allocators/shared_ptr.h" -#include "allocators.h" // AllocatorChecker +#include "lib/allocators/allocators.h" // AllocatorChecker #ifndef NDEBUG diff --git a/source/lib/allocators/string_pool.cpp b/source/lib/allocators/string_pool.cpp index 305acd0e30..1811c42536 100644 --- a/source/lib/allocators/string_pool.cpp +++ b/source/lib/allocators/string_pool.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "string_pool.h" +#include "lib/allocators/string_pool.h" #include "lib/rand.h" #include "lib/sysdep/cpu.h" // cpu_memcpy diff --git a/source/lib/allocators/string_pool.h b/source/lib/allocators/string_pool.h index 08894ff4cf..eb11260d27 100644 --- a/source/lib/allocators/string_pool.h +++ b/source/lib/allocators/string_pool.h @@ -28,7 +28,7 @@ #define INCLUDED_STRING_POOL #include "lib/adts.h" // DynHashTbl -#include "pool.h" +#include "lib/allocators/pool.h" class StringPool { diff --git a/source/lib/app_hooks.cpp b/source/lib/app_hooks.cpp index a9cc65b504..7a6f1d7e18 100644 --- a/source/lib/app_hooks.cpp +++ b/source/lib/app_hooks.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "app_hooks.h" +#include "lib/app_hooks.h" #include "lib/path_util.h" #include "lib/sysdep/sysdep.h" diff --git a/source/lib/bits.cpp b/source/lib/bits.cpp index 21e121deab..74f2986a9a 100644 --- a/source/lib/bits.cpp +++ b/source/lib/bits.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "bits.h" +#include "lib/bits.h" static inline u32 get_float_bits(const float x) { diff --git a/source/lib/byte_order.cpp b/source/lib/byte_order.cpp index 1100193ea2..8ab2073215 100644 --- a/source/lib/byte_order.cpp +++ b/source/lib/byte_order.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "byte_order.h" +#include "lib/byte_order.h" -#include "bits.h" +#include "lib/bits.h" #ifndef swap16 diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index c75ce1e9a1..150ac9be58 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -25,16 +25,16 @@ */ #include "precompiled.h" -#include "debug.h" +#include "lib/debug.h" #include #include #include -#include "app_hooks.h" -#include "path_util.h" +#include "lib/app_hooks.h" +#include "lib/path_util.h" #include "lib/allocators/allocators.h" // page_aligned_alloc -#include "fnv_hash.h" +#include "lib/fnv_hash.h" #include "lib/sysdep/cpu.h" // cpu_CAS #include "lib/sysdep/sysdep.h" diff --git a/source/lib/debug_stl.cpp b/source/lib/debug_stl.cpp index 50c115fa34..290304264e 100644 --- a/source/lib/debug_stl.cpp +++ b/source/lib/debug_stl.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "debug_stl.h" +#include "lib/debug_stl.h" #include #include @@ -33,7 +33,7 @@ #include #include -#include "regex.h" +#include "lib/regex.h" ERROR_ASSOCIATE(ERR::STL_CNT_UNKNOWN, L"Unknown STL container type_name", -1); diff --git a/source/lib/external_libraries/dbghelp.cpp b/source/lib/external_libraries/dbghelp.cpp index b3c7091a32..b6d54899ce 100644 --- a/source/lib/external_libraries/dbghelp.cpp +++ b/source/lib/external_libraries/dbghelp.cpp @@ -24,13 +24,13 @@ #if OS_WIN -#include "dbghelp.h" +#include "lib/external_libraries/dbghelp.h" // define extension function pointers extern "C" { #define FUNC(ret, name, params) ret (__stdcall *p##name) params; -#include "dbghelp_funcs.h" +#include "lib/external_libraries/dbghelp_funcs.h" #undef FUNC } @@ -39,7 +39,7 @@ void dbghelp_ImportFunctions() HMODULE hDbghelp = LoadLibraryW(L"dbghelp.dll"); debug_assert(hDbghelp); #define FUNC(ret, name, params) p##name = (ret (__stdcall*) params)GetProcAddress(hDbghelp, #name); -#include "dbghelp_funcs.h" +#include "lib/external_libraries/dbghelp_funcs.h" #undef FUNC } diff --git a/source/lib/external_libraries/dbghelp.h b/source/lib/external_libraries/dbghelp.h index 4189da498e..3d05e8e431 100644 --- a/source/lib/external_libraries/dbghelp.h +++ b/source/lib/external_libraries/dbghelp.h @@ -125,7 +125,7 @@ enum DataKind // declare function pointers #define FUNC(ret, name, params) EXTERN_C ret (__stdcall *p##name) params; -#include "dbghelp_funcs.h" +#include "lib/external_libraries/dbghelp_funcs.h" #undef FUNC extern void dbghelp_ImportFunctions(); diff --git a/source/lib/external_libraries/sdl.h b/source/lib/external_libraries/sdl.h index 3f57ea991d..a5777317eb 100644 --- a/source/lib/external_libraries/sdl.h +++ b/source/lib/external_libraries/sdl.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_SDL #define INCLUDED_SDL -#include "sdl_fwd.h" +#include "lib/external_libraries/sdl_fwd.h" #include "lib/config2.h" // CONFIG2_WSDL #if OS_WIN && CONFIG2_WSDL diff --git a/source/lib/fat_time.cpp b/source/lib/fat_time.cpp index a57a0ba2d9..d832e4e3c1 100644 --- a/source/lib/fat_time.cpp +++ b/source/lib/fat_time.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "fat_time.h" +#include "lib/fat_time.h" #include diff --git a/source/lib/file/archive/archive.cpp b/source/lib/file/archive/archive.cpp index 0ad93cdfb3..8695f129be 100644 --- a/source/lib/file/archive/archive.cpp +++ b/source/lib/file/archive/archive.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "archive.h" +#include "lib/file/archive/archive.h" ERROR_ASSOCIATE(ERR::ARCHIVE_UNKNOWN_FORMAT, L"Unknown archive format", -1); ERROR_ASSOCIATE(ERR::ARCHIVE_UNKNOWN_METHOD, L"Unknown compression method", -1); diff --git a/source/lib/file/archive/archive_zip.cpp b/source/lib/file/archive/archive_zip.cpp index 6bb718ff69..d90a1bf53f 100644 --- a/source/lib/file/archive/archive_zip.cpp +++ b/source/lib/file/archive/archive_zip.cpp @@ -25,21 +25,21 @@ */ #include "precompiled.h" -#include "archive_zip.h" +#include "lib/file/archive/archive_zip.h" #include #include #include "lib/bits.h" #include "lib/byte_order.h" -#include "lib/wchar.h" // wstring_from_utf8 +#include "lib/utf8.h" // wstring_from_utf8 #include "lib/fat_time.h" #include "lib/path_util.h" #include "lib/allocators/pool.h" #include "lib/sysdep/cpu.h" // cpu_memcpy -#include "archive.h" -#include "codec_zlib.h" -#include "stream.h" +#include "lib/file/archive/archive.h" +#include "lib/file/archive/codec_zlib.h" +#include "lib/file/archive/stream.h" #include "lib/file/file.h" #include "lib/file/io/io.h" #include "lib/file/io/io_align.h" // BLOCK_SIZE diff --git a/source/lib/file/archive/archive_zip.h b/source/lib/file/archive/archive_zip.h index 8abcf84269..0a8457fe09 100644 --- a/source/lib/file/archive/archive_zip.h +++ b/source/lib/file/archive/archive_zip.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_ARCHIVE_ZIP #define INCLUDED_ARCHIVE_ZIP -#include "archive.h" +#include "lib/file/archive/archive.h" LIB_API PIArchiveReader CreateArchiveReader_Zip(const fs::wpath& archivePathname); LIB_API PIArchiveWriter CreateArchiveWriter_Zip(const fs::wpath& archivePathname); diff --git a/source/lib/file/archive/codec.cpp b/source/lib/file/archive/codec.cpp index 8742410fad..2b6e7b6283 100644 --- a/source/lib/file/archive/codec.cpp +++ b/source/lib/file/archive/codec.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "codec.h" +#include "lib/file/archive/codec.h" ICodec::~ICodec() { diff --git a/source/lib/file/archive/codec_zlib.cpp b/source/lib/file/archive/codec_zlib.cpp index 97eb593c0c..8fb64be428 100644 --- a/source/lib/file/archive/codec_zlib.cpp +++ b/source/lib/file/archive/codec_zlib.cpp @@ -21,9 +21,9 @@ */ #include "precompiled.h" -#include "codec_zlib.h" +#include "lib/file/archive/codec_zlib.h" -#include "codec.h" +#include "lib/file/archive/codec.h" #include "lib/external_libraries/zlib.h" #include "lib/sysdep/cpu.h" diff --git a/source/lib/file/archive/codec_zlib.h b/source/lib/file/archive/codec_zlib.h index 9c0d8159e7..88d82ec2a4 100644 --- a/source/lib/file/archive/codec_zlib.h +++ b/source/lib/file/archive/codec_zlib.h @@ -23,7 +23,7 @@ #ifndef INCLUDED_CODEC_ZLIB #define INCLUDED_CODEC_ZLIB -#include "codec.h" +#include "lib/file/archive/codec.h" extern PICodec CreateCodec_ZLibNone(); extern PICodec CreateCompressor_ZLibDeflate(); diff --git a/source/lib/file/archive/stream.cpp b/source/lib/file/archive/stream.cpp index 645f10908f..28a4d4ea89 100644 --- a/source/lib/file/archive/stream.cpp +++ b/source/lib/file/archive/stream.cpp @@ -21,11 +21,11 @@ */ #include "precompiled.h" -#include "stream.h" +#include "lib/file/archive/stream.h" #include "lib/allocators/allocators.h" // page_aligned_alloc #include "lib/allocators/shared_ptr.h" -#include "codec.h" +#include "lib/file/archive/codec.h" //#include "lib/timer.h" //TIMER_ADD_CLIENT(tc_stream); diff --git a/source/lib/file/archive/stream.h b/source/lib/file/archive/stream.h index 89eb7172f6..ab1e80cdb0 100644 --- a/source/lib/file/archive/stream.h +++ b/source/lib/file/archive/stream.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_STREAM #define INCLUDED_STREAM -#include "codec.h" +#include "lib/file/archive/codec.h" // note: this is similar in function to std::vector, but we don't need // iterators etc. and would prefer to avoid initializing each byte. diff --git a/source/lib/file/common/file_loader.cpp b/source/lib/file/common/file_loader.cpp index e30a2522b6..05abe53575 100644 --- a/source/lib/file/common/file_loader.cpp +++ b/source/lib/file/common/file_loader.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "file_loader.h" +#include "lib/file/common/file_loader.h" /*virtual*/ IFileLoader::~IFileLoader() { diff --git a/source/lib/file/common/file_stats.cpp b/source/lib/file/common/file_stats.cpp index 598c539db6..907a9fb461 100644 --- a/source/lib/file/common/file_stats.cpp +++ b/source/lib/file/common/file_stats.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "file_stats.h" +#include "lib/file/common/file_stats.h" #include diff --git a/source/lib/file/common/real_directory.cpp b/source/lib/file/common/real_directory.cpp index af8afbc3d9..60ac8e29f9 100644 --- a/source/lib/file/common/real_directory.cpp +++ b/source/lib/file/common/real_directory.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "real_directory.h" +#include "lib/file/common/real_directory.h" #include "lib/path_util.h" #include "lib/file/file.h" diff --git a/source/lib/file/common/real_directory.h b/source/lib/file/common/real_directory.h index 8dd0981231..bed3d3dca9 100644 --- a/source/lib/file/common/real_directory.h +++ b/source/lib/file/common/real_directory.h @@ -23,7 +23,7 @@ #ifndef INCLUDED_REAL_DIRECTORY #define INCLUDED_REAL_DIRECTORY -#include "file_loader.h" +#include "lib/file/common/file_loader.h" #include "lib/sysdep/dir_watch.h" class RealDirectory : public IFileLoader diff --git a/source/lib/file/common/trace.cpp b/source/lib/file/common/trace.cpp index 62be587d35..4c90a4b8a2 100644 --- a/source/lib/file/common/trace.cpp +++ b/source/lib/file/common/trace.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "trace.h" +#include "lib/file/common/trace.h" #include diff --git a/source/lib/file/file.cpp b/source/lib/file/file.cpp index e637981552..4945072c85 100644 --- a/source/lib/file/file.cpp +++ b/source/lib/file/file.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "file.h" +#include "lib/file/file.h" #include "lib/file/common/file_stats.h" #include "lib/sysdep/sysdep.h" // sys_wopen diff --git a/source/lib/file/file_system.cpp b/source/lib/file/file_system.cpp index ea66726451..0567303f45 100644 --- a/source/lib/file/file_system.cpp +++ b/source/lib/file/file_system.cpp @@ -21,14 +21,14 @@ */ #include "precompiled.h" -#include "file_system.h" +#include "lib/file/file_system.h" #include #include #include #include "lib/path_util.h" -#include "lib/wchar.h" // wstring_from_utf8 +#include "lib/utf8.h" // wstring_from_utf8 #include "lib/posix/posix_filesystem.h" diff --git a/source/lib/file/file_system_util.cpp b/source/lib/file/file_system_util.cpp index a0c3d64a09..a3744c3a62 100644 --- a/source/lib/file/file_system_util.cpp +++ b/source/lib/file/file_system_util.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "file_system_util.h" +#include "lib/file/file_system_util.h" #include #include diff --git a/source/lib/file/io/block_cache.cpp b/source/lib/file/io/block_cache.cpp index 40d1c5d09c..851493905f 100644 --- a/source/lib/file/io/block_cache.cpp +++ b/source/lib/file/io/block_cache.cpp @@ -25,14 +25,14 @@ */ #include "precompiled.h" -#include "block_cache.h" +#include "lib/file/io/block_cache.h" #include "lib/config2.h" // CONFIG2_CACHE_READ_ONLY #include "lib/file/common/file_stats.h" #include "lib/lockfree.h" #include "lib/allocators/pool.h" #include "lib/fnv_hash.h" -#include "io_align.h" +#include "lib/file/io/io_align.h" //----------------------------------------------------------------------------- diff --git a/source/lib/file/io/io.cpp b/source/lib/file/io/io.cpp index 435a301151..7bc7b51d3f 100644 --- a/source/lib/file/io/io.cpp +++ b/source/lib/file/io/io.cpp @@ -21,14 +21,14 @@ */ #include "precompiled.h" -#include "io.h" +#include "lib/file/io/io.h" #include "lib/allocators/allocators.h" // AllocatorChecker #include "lib/sysdep/cpu.h" // cpu_memcpy #include "lib/file/file.h" #include "lib/file/common/file_stats.h" -#include "block_cache.h" -#include "io_align.h" +#include "lib/file/io/block_cache.h" +#include "lib/file/io/io_align.h" static const size_t ioDepth = 16; diff --git a/source/lib/file/io/io_align.cpp b/source/lib/file/io/io_align.cpp index b4f370526f..ecf418bd3b 100644 --- a/source/lib/file/io/io_align.cpp +++ b/source/lib/file/io/io_align.cpp @@ -21,4 +21,4 @@ */ #include "precompiled.h" -#include "io_align.h" +#include "lib/file/io/io_align.h" diff --git a/source/lib/file/io/write_buffer.cpp b/source/lib/file/io/write_buffer.cpp index f8c2f251a4..0003f61ca2 100644 --- a/source/lib/file/io/write_buffer.cpp +++ b/source/lib/file/io/write_buffer.cpp @@ -21,12 +21,12 @@ */ #include "precompiled.h" -#include "write_buffer.h" +#include "lib/file/io/write_buffer.h" #include "lib/bits.h" // IsAligned #include "lib/sysdep/cpu.h" -#include "io.h" -#include "io_align.h" +#include "lib/file/io/io.h" +#include "lib/file/io/io_align.h" WriteBuffer::WriteBuffer() diff --git a/source/lib/file/vfs/file_cache.cpp b/source/lib/file/vfs/file_cache.cpp index 6b194bb64c..3b9fbaa44d 100644 --- a/source/lib/file/vfs/file_cache.cpp +++ b/source/lib/file/vfs/file_cache.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "file_cache.h" +#include "lib/file/vfs/file_cache.h" #include "lib/file/common/file_stats.h" #include "lib/file/io/io_align.h" // BLOCK_SIZE diff --git a/source/lib/file/vfs/file_cache.h b/source/lib/file/vfs/file_cache.h index e50cf275ab..5cb06b6205 100644 --- a/source/lib/file/vfs/file_cache.h +++ b/source/lib/file/vfs/file_cache.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_FILE_CACHE #define INCLUDED_FILE_CACHE -#include "vfs_path.h" +#include "lib/file/vfs/vfs_path.h" /** * cache of file contents with support for zero-copy IO. diff --git a/source/lib/file/vfs/vfs.cpp b/source/lib/file/vfs/vfs.cpp index f41db2df5b..772b6f584c 100644 --- a/source/lib/file/vfs/vfs.cpp +++ b/source/lib/file/vfs/vfs.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "vfs.h" +#include "lib/file/vfs/vfs.h" #include "lib/allocators/shared_ptr.h" #include "lib/path_util.h" @@ -29,10 +29,10 @@ #include "lib/file/common/trace.h" #include "lib/file/archive/archive.h" #include "lib/file/io/io.h" -#include "vfs_tree.h" -#include "vfs_lookup.h" -#include "vfs_populate.h" -#include "file_cache.h" +#include "lib/file/vfs/vfs_tree.h" +#include "lib/file/vfs/vfs_lookup.h" +#include "lib/file/vfs/vfs_populate.h" +#include "lib/file/vfs/file_cache.h" ERROR_ASSOCIATE(ERR::VFS_DIR_NOT_FOUND, L"VFS directory not found", -1); ERROR_ASSOCIATE(ERR::VFS_FILE_NOT_FOUND, L"VFS file not found", -1); diff --git a/source/lib/file/vfs/vfs_lookup.cpp b/source/lib/file/vfs/vfs_lookup.cpp index 7592c1149b..e6608f4120 100644 --- a/source/lib/file/vfs/vfs_lookup.cpp +++ b/source/lib/file/vfs/vfs_lookup.cpp @@ -25,12 +25,12 @@ */ #include "precompiled.h" -#include "vfs_lookup.h" +#include "lib/file/vfs/vfs_lookup.h" #include "lib/path_util.h" // path_foreach_component -#include "vfs.h" // error codes -#include "vfs_tree.h" -#include "vfs_populate.h" +#include "lib/file/vfs/vfs.h" // error codes +#include "lib/file/vfs/vfs_tree.h" +#include "lib/file/vfs/vfs_populate.h" #include "lib/timer.h" diff --git a/source/lib/file/vfs/vfs_lookup.h b/source/lib/file/vfs/vfs_lookup.h index b9ef7f5e76..ffe9fdf292 100644 --- a/source/lib/file/vfs/vfs_lookup.h +++ b/source/lib/file/vfs/vfs_lookup.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_VFS_LOOKUP #define INCLUDED_VFS_LOOKUP -#include "vfs_path.h" +#include "lib/file/vfs/vfs_path.h" class VfsFile; class VfsDirectory; diff --git a/source/lib/file/vfs/vfs_path.cpp b/source/lib/file/vfs/vfs_path.cpp index 3c2dc2b646..6f02d93afb 100644 --- a/source/lib/file/vfs/vfs_path.cpp +++ b/source/lib/file/vfs/vfs_path.cpp @@ -21,4 +21,4 @@ */ #include "precompiled.h" -#include "vfs_path.h" +#include "lib/file/vfs/vfs_path.h" diff --git a/source/lib/file/vfs/vfs_populate.cpp b/source/lib/file/vfs/vfs_populate.cpp index a7a1fc4ab0..4ac6331890 100644 --- a/source/lib/file/vfs/vfs_populate.cpp +++ b/source/lib/file/vfs/vfs_populate.cpp @@ -25,13 +25,13 @@ */ #include "precompiled.h" -#include "vfs_populate.h" +#include "lib/file/vfs/vfs_populate.h" #include "lib/path_util.h" #include "lib/file/archive/archive_zip.h" -#include "vfs_tree.h" -#include "vfs_lookup.h" -#include "vfs.h" // error codes +#include "lib/file/vfs/vfs_tree.h" +#include "lib/file/vfs/vfs_lookup.h" +#include "lib/file/vfs/vfs.h" // error codes static std::vector s_looseFiles; diff --git a/source/lib/file/vfs/vfs_tree.cpp b/source/lib/file/vfs/vfs_tree.cpp index 2ece214d5d..b2416997e4 100644 --- a/source/lib/file/vfs/vfs_tree.cpp +++ b/source/lib/file/vfs/vfs_tree.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "vfs_tree.h" +#include "lib/file/vfs/vfs_tree.h" #include diff --git a/source/lib/frequency_filter.cpp b/source/lib/frequency_filter.cpp index d81b782997..089820b3b5 100644 --- a/source/lib/frequency_filter.cpp +++ b/source/lib/frequency_filter.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "frequency_filter.h" +#include "lib/frequency_filter.h" static const double errorTolerance = 0.05f; static const double sensitivity = 0.10; diff --git a/source/lib/lib.cpp b/source/lib/lib.cpp index 6460c52979..ae680b77c4 100644 --- a/source/lib/lib.cpp +++ b/source/lib/lib.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "lib.h" +#include "lib/lib.h" #include #include diff --git a/source/lib/lib.h b/source/lib/lib.h index 6e6d6bffa8..ff8a3ef25d 100644 --- a/source/lib/lib.h +++ b/source/lib/lib.h @@ -65,7 +65,7 @@ scope #include // numeric_limits #include // out_of_range -#include "config.h" +#include "lib/config.h" const size_t KiB = size_t(1) << 10; diff --git a/source/lib/lib_errors.cpp b/source/lib/lib_errors.cpp index bb44bac3a5..6b2a378978 100644 --- a/source/lib/lib_errors.cpp +++ b/source/lib/lib_errors.cpp @@ -30,7 +30,7 @@ // object files of the same name but in different paths. #include "precompiled.h" -#include "lib_errors.h" +#include "lib/lib_errors.h" #include #include // abs diff --git a/source/lib/lockfree.cpp b/source/lib/lockfree.cpp index ea0529b30a..98681e6c86 100644 --- a/source/lib/lockfree.cpp +++ b/source/lib/lockfree.cpp @@ -26,7 +26,7 @@ #include "precompiled.h" #if 0 // JW: disabled, not used -#include "lockfree.h" +#include "lib/lockfree.h" #include #include @@ -35,8 +35,8 @@ #include "lib/bits.h" #include "lib/sysdep/cpu.h" #include "lib/sysdep/sysdep.h" -#include "timer.h" -#include "module_init.h" +#include "lib/timer.h" +#include "lib/module_init.h" /* diff --git a/source/lib/module_init.cpp b/source/lib/module_init.cpp index 90b2d97073..377e232756 100644 --- a/source/lib/module_init.cpp +++ b/source/lib/module_init.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "module_init.h" +#include "lib/module_init.h" #include "lib/sysdep/cpu.h" // cpu_CAS, cpu_AtomicAdd diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp index a81ea8fd32..7e77a8b977 100644 --- a/source/lib/ogl.cpp +++ b/source/lib/ogl.cpp @@ -25,14 +25,14 @@ */ #include "precompiled.h" -#include "ogl.h" +#include "lib/ogl.h" #include #include #include #include "lib/external_libraries/sdl.h" -#include "debug.h" +#include "lib/debug.h" #include "lib/sysdep/gfx.h" #include "lib/res/h_mgr.h" @@ -54,7 +54,7 @@ extern "C" #define FUNC(ret, name, params) ret (GL_CALL_CONV *p##name) params; #define FUNC2(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameARB) params; #define FUNC3(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameCore) params; -#include "glext_funcs.h" +#include "lib/glext_funcs.h" #undef FUNC3 #undef FUNC2 #undef FUNC @@ -255,7 +255,7 @@ static void importExtensionFunctions() pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameARB); #define FUNC2(ret, nameARB, nameCore, version, params) FUNC23(p##nameARB, ret, nameARB, nameCore, version, params) #define FUNC3(ret, nameARB, nameCore, version, params) FUNC23(p##nameCore, ret, nameARB, nameCore, version, params) -#include "glext_funcs.h" +#include "lib/glext_funcs.h" #undef FUNC3 #undef FUNC2 #undef FUNC23 diff --git a/source/lib/ogl.h b/source/lib/ogl.h index 9cb2255496..a30c9c520e 100644 --- a/source/lib/ogl.h +++ b/source/lib/ogl.h @@ -133,7 +133,7 @@ extern const char* ogl_ExtensionString(); #define FUNC(ret, name, params) EXTERN_C ret (GL_CALL_CONV *p##name) params; #define FUNC2(ret, nameARB, nameCore, version, params) EXTERN_C ret (GL_CALL_CONV *p##nameARB) params; #define FUNC3(ret, nameARB, nameCore, version, params) EXTERN_C ret (GL_CALL_CONV *p##nameCore) params; -#include "glext_funcs.h" +#include "lib/glext_funcs.h" #undef FUNC3 #undef FUNC2 #undef FUNC diff --git a/source/lib/path_util.cpp b/source/lib/path_util.cpp index 957652f849..656058ad82 100644 --- a/source/lib/path_util.cpp +++ b/source/lib/path_util.cpp @@ -25,12 +25,12 @@ */ #include "precompiled.h" -#include "path_util.h" +#include "lib/path_util.h" #include #include -#include "lib/wchar.h" +#include "lib/utf8.h" ERROR_ASSOCIATE(ERR::PATH_EMPTY, L"path is an empty string", -1); diff --git a/source/lib/posix/posix.cpp b/source/lib/posix/posix.cpp index 4d3eb649db..1f66e70c42 100644 --- a/source/lib/posix/posix.cpp +++ b/source/lib/posix/posix.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "posix.h" +#include "lib/posix/posix.h" #if ARCH_IA32 # include "lib/sysdep/arch/ia32/ia32_asm.h" diff --git a/source/lib/posix/posix.h b/source/lib/posix/posix.h index 7e77ee4bbc..88ce95b686 100644 --- a/source/lib/posix/posix.h +++ b/source/lib/posix/posix.h @@ -66,16 +66,16 @@ need only be renamed (e.g. _open, _stat). # include "lib/sysdep/os/win/wposix/wposix.h" #endif -#include "posix_types.h" -#include "posix_aio.h" -#include "posix_dlfcn.h" -#include "posix_filesystem.h" -#include "posix_mman.h" -#include "posix_pthread.h" -//#include "posix_sock.h" -//#include "posix_terminal.h" -//#include "posix_time.h" -#include "posix_utsname.h" +#include "lib/posix/posix_types.h" +#include "lib/posix/posix_aio.h" +#include "lib/posix/posix_dlfcn.h" +#include "lib/posix/posix_filesystem.h" +#include "lib/posix/posix_mman.h" +#include "lib/posix/posix_pthread.h" +//#include "lib/posix/posix_sock.h" +//#include "lib/posix/posix_terminal.h" +//#include "lib/posix/posix_time.h" +#include "lib/posix/posix_utsname.h" // note: the following need only be #defined (instead of defining a diff --git a/source/lib/posix/posix_aio.h b/source/lib/posix/posix_aio.h index 8c2840e1fe..6de8998208 100644 --- a/source/lib/posix/posix_aio.h +++ b/source/lib/posix/posix_aio.h @@ -31,4 +31,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_dlfcn.h b/source/lib/posix/posix_dlfcn.h index 67d2675f5e..5443e0bcf3 100644 --- a/source/lib/posix/posix_dlfcn.h +++ b/source/lib/posix/posix_dlfcn.h @@ -26,4 +26,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_filesystem.h b/source/lib/posix/posix_filesystem.h index ca798c17f4..5f0fb9b877 100644 --- a/source/lib/posix/posix_filesystem.h +++ b/source/lib/posix/posix_filesystem.h @@ -28,6 +28,6 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience #include "lib/sysdep/filesystem.h" diff --git a/source/lib/posix/posix_mman.h b/source/lib/posix/posix_mman.h index 8deb8d4527..3d2ca35e78 100644 --- a/source/lib/posix/posix_mman.h +++ b/source/lib/posix/posix_mman.h @@ -26,4 +26,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_pthread.h b/source/lib/posix/posix_pthread.h index a008c1beb2..bb2b083cb4 100644 --- a/source/lib/posix/posix_pthread.h +++ b/source/lib/posix/posix_pthread.h @@ -27,4 +27,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_sock.h b/source/lib/posix/posix_sock.h index c895efc26d..f1662c66ab 100644 --- a/source/lib/posix/posix_sock.h +++ b/source/lib/posix/posix_sock.h @@ -30,4 +30,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_terminal.h b/source/lib/posix/posix_terminal.h index 11d7f703f2..d16afec6cd 100644 --- a/source/lib/posix/posix_terminal.h +++ b/source/lib/posix/posix_terminal.h @@ -26,4 +26,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_time.h b/source/lib/posix/posix_time.h index b22b86fe99..d0f5651b67 100644 --- a/source/lib/posix/posix_time.h +++ b/source/lib/posix/posix_time.h @@ -26,4 +26,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/posix/posix_utsname.h b/source/lib/posix/posix_utsname.h index 268b217aa3..554b61fa0f 100644 --- a/source/lib/posix/posix_utsname.h +++ b/source/lib/posix/posix_utsname.h @@ -26,4 +26,4 @@ # include #endif -#include "posix_errno.h" // for user convenience +#include "lib/posix/posix_errno.h" // for user convenience diff --git a/source/lib/rand.cpp b/source/lib/rand.cpp index 549c5eb3b4..23c9cf0cb0 100644 --- a/source/lib/rand.cpp +++ b/source/lib/rand.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "rand.h" +#include "lib/rand.h" // avoids several common pitfalls; see discussion at // http://www.azillionmonkeys.com/qed/random.html diff --git a/source/lib/secure_crt.cpp b/source/lib/secure_crt.cpp index e317512f21..c1fb2ae1e7 100644 --- a/source/lib/secure_crt.cpp +++ b/source/lib/secure_crt.cpp @@ -30,10 +30,10 @@ #include #include -#include "secure_crt.h" +#include "lib/secure_crt.h" #ifdef WSECURE_CRT -#include "lib/wchar.h" +#include "lib/utf8.h" #endif diff --git a/source/lib/self_test.cpp b/source/lib/self_test.cpp index eb36f9509f..0a15f0db62 100644 --- a/source/lib/self_test.cpp +++ b/source/lib/self_test.cpp @@ -28,8 +28,8 @@ #if 0 -#include "self_test.h" -#include "timer.h" +#include "lib/self_test.h" +#include "lib/timer.h" // checked by debug_OnAssertionFailure; disables asserts if true (see above). // set/cleared by self_test_run. diff --git a/source/lib/sysdep/acpi.cpp b/source/lib/sysdep/acpi.cpp index 751f3540ed..4fd93d190d 100644 --- a/source/lib/sysdep/acpi.cpp +++ b/source/lib/sysdep/acpi.cpp @@ -21,7 +21,7 @@ */ #include "precompiled.h" -#include "acpi.h" +#include "lib/sysdep/acpi.h" #include "lib/sysdep/os/win/mahaf.h" #include "lib/sysdep/cpu.h" diff --git a/source/lib/sysdep/arch/amd64/amd64.cpp b/source/lib/sysdep/arch/amd64/amd64.cpp index 6dfee1adc3..4d9d490889 100644 --- a/source/lib/sysdep/arch/amd64/amd64.cpp +++ b/source/lib/sysdep/arch/amd64/amd64.cpp @@ -24,8 +24,8 @@ #if ARCH_AMD64 -#include "amd64.h" -#include "amd64_asm.h" +#include "lib/sysdep/arch/amd64/amd64.h" +#include "lib/sysdep/arch/amd64/amd64_asm.h" #include "lib/sysdep/cpu.h" #if MSC_VERSION diff --git a/source/lib/sysdep/arch/ia32/ia32.cpp b/source/lib/sysdep/arch/ia32/ia32.cpp index 1db689920b..0c5bdb1130 100644 --- a/source/lib/sysdep/arch/ia32/ia32.cpp +++ b/source/lib/sysdep/arch/ia32/ia32.cpp @@ -26,10 +26,10 @@ #include "precompiled.h" -#include "ia32.h" +#include "lib/sysdep/arch/ia32/ia32.h" #include "lib/sysdep/cpu.h" -#include "ia32_asm.h" +#include "lib/sysdep/arch/ia32/ia32_asm.h" static const size_t maxInstructionLength = 15; // IA-32 limitation diff --git a/source/lib/sysdep/arch/x86_x64/topology.cpp b/source/lib/sysdep/arch/x86_x64/topology.cpp index b0c6c45f34..f515063720 100644 --- a/source/lib/sysdep/arch/x86_x64/topology.cpp +++ b/source/lib/sysdep/arch/x86_x64/topology.cpp @@ -25,14 +25,14 @@ */ #include "precompiled.h" -#include "topology.h" +#include "lib/sysdep/arch/x86_x64/topology.h" #include #include "lib/bits.h" #include "lib/sysdep/cpu.h" // ERR::CPU_FEATURE_MISSING #include "lib/sysdep/os_cpu.h" -#include "x86_x64.h" +#include "lib/sysdep/arch/x86_x64/x86_x64.h" //----------------------------------------------------------------------------- diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp index 358031e4f6..0035ac4e72 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "x86_x64.h" +#include "lib/sysdep/arch/x86_x64/x86_x64.h" #include #include @@ -40,9 +40,9 @@ #include "lib/sysdep/os_cpu.h" #if ARCH_AMD64 -# include "../amd64/amd64_asm.h" +# include "lib/sysdep/arch/amd64/amd64_asm.h" #else -# include "../ia32/ia32_asm.h" +# include "lib/sysdep/arch/ia32/ia32_asm.h" #endif #if MSC_VERSION diff --git a/source/lib/sysdep/cpu.cpp b/source/lib/sysdep/cpu.cpp index 19bfdcd005..e253cf171a 100644 --- a/source/lib/sysdep/cpu.cpp +++ b/source/lib/sysdep/cpu.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "cpu.h" +#include "lib/sysdep/cpu.h" ERROR_ASSOCIATE(ERR::CPU_FEATURE_MISSING, L"This CPU doesn't support a required feature", -1); ERROR_ASSOCIATE(ERR::CPU_UNKNOWN_OPCODE, L"Disassembly failed", -1); diff --git a/source/lib/sysdep/gfx.cpp b/source/lib/sysdep/gfx.cpp index 92bea9513b..05921a2731 100644 --- a/source/lib/sysdep/gfx.cpp +++ b/source/lib/sysdep/gfx.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "gfx.h" +#include "lib/sysdep/gfx.h" #include "lib/external_libraries/sdl.h" #include "lib/ogl.h" diff --git a/source/lib/sysdep/os/win/mahaf.cpp b/source/lib/sysdep/os/win/mahaf.cpp index 134dd05e96..2a66c84a59 100644 --- a/source/lib/sysdep/os/win/mahaf.cpp +++ b/source/lib/sysdep/os/win/mahaf.cpp @@ -26,10 +26,10 @@ #include "precompiled.h" -#include "win.h" +#include "lib/sysdep/os/win/win.h" #include -#include "aken/aken.h" -#include "wutil.h" +#include "lib/sysdep/os/win/aken/aken.h" +#include "lib/sysdep/os/win/wutil.h" #include "lib/module_init.h" diff --git a/source/lib/sysdep/os/win/wclipboard.cpp b/source/lib/sysdep/os/win/wclipboard.cpp index 49e49721df..8a3eced7c1 100644 --- a/source/lib/sysdep/os/win/wclipboard.cpp +++ b/source/lib/sysdep/os/win/wclipboard.cpp @@ -23,8 +23,8 @@ #include "precompiled.h" #include "lib/sysdep/clipboard.h" -#include "win.h" -#include "wutil.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" // caller is responsible for freeing *hMem. static LibError SetClipboardText(const wchar_t* text, HGLOBAL* hMem) diff --git a/source/lib/sysdep/os/win/wcpu.cpp b/source/lib/sysdep/os/win/wcpu.cpp index d4d6bab438..f58a00e853 100644 --- a/source/lib/sysdep/os/win/wcpu.cpp +++ b/source/lib/sysdep/os/win/wcpu.cpp @@ -27,7 +27,7 @@ #include "precompiled.h" #include "lib/sysdep/os_cpu.h" -#include "win.h" +#include "lib/sysdep/os/win/win.h" #include "lib/bits.h" #include "lib/module_init.h" diff --git a/source/lib/sysdep/os/win/wcpu.h b/source/lib/sysdep/os/win/wcpu.h index 1ca39aaab6..7f8fba6a67 100644 --- a/source/lib/sysdep/os/win/wcpu.h +++ b/source/lib/sysdep/os/win/wcpu.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_WCPU #define INCLUDED_WCPU -#include "win.h" +#include "lib/sysdep/os/win/win.h" // "affinity" and "processorNumber" are what Windows sees. // "processorMask" and "processor" are the idealized representation we expose diff --git a/source/lib/sysdep/os/win/wcursor.cpp b/source/lib/sysdep/os/win/wcursor.cpp index bcfbeaf7af..6afc5758f3 100644 --- a/source/lib/sysdep/os/win/wcursor.cpp +++ b/source/lib/sysdep/os/win/wcursor.cpp @@ -23,8 +23,8 @@ #include "precompiled.h" #include "lib/sysdep/cursor.h" -#include "win.h" -#include "wutil.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" static sys_cursor cursor_from_HICON(HICON hIcon) diff --git a/source/lib/sysdep/os/win/wdbg.cpp b/source/lib/sysdep/os/win/wdbg.cpp index ed8521d3da..52d4be7ef8 100644 --- a/source/lib/sysdep/os/win/wdbg.cpp +++ b/source/lib/sysdep/os/win/wdbg.cpp @@ -28,8 +28,8 @@ #include "lib/debug.h" #include "lib/bits.h" -#include "win.h" -#include "wutil.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" // return 1 if the pointer appears to be totally bogus, otherwise 0. diff --git a/source/lib/sysdep/os/win/wdbg_heap.cpp b/source/lib/sysdep/os/win/wdbg_heap.cpp index 6420bb09fc..cb9d9a0082 100644 --- a/source/lib/sysdep/os/win/wdbg_heap.cpp +++ b/source/lib/sysdep/os/win/wdbg_heap.cpp @@ -21,17 +21,17 @@ */ #include "precompiled.h" -#include "wdbg_heap.h" +#include "lib/sysdep/os/win/wdbg_heap.h" -#include "win.h" +#include "lib/sysdep/os/win/win.h" #include #include #include "lib/external_libraries/dbghelp.h" #include "lib/sysdep/cpu.h" // cpu_AtomicAdd -#include "winit.h" -#include "wdbg.h" // wdbg_printf -#include "wdbg_sym.h" // wdbg_sym_WalkStack +#include "lib/sysdep/os/win/winit.h" +#include "lib/sysdep/os/win/wdbg.h" // wdbg_printf +#include "lib/sysdep/os/win/wdbg_sym.h" // wdbg_sym_WalkStack WINIT_REGISTER_EARLY_INIT2(wdbg_heap_Init); // wutil -> wdbg_heap diff --git a/source/lib/sysdep/os/win/wdbg_sym.cpp b/source/lib/sysdep/os/win/wdbg_sym.cpp index d42c30cee4..8712c7c933 100644 --- a/source/lib/sysdep/os/win/wdbg_sym.cpp +++ b/source/lib/sysdep/os/win/wdbg_sym.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "wdbg_sym.h" +#include "lib/sysdep/os/win/wdbg_sym.h" #include #include @@ -42,9 +42,9 @@ # include "lib/sysdep/arch/ia32/ia32_asm.h" #endif #include "lib/external_libraries/dbghelp.h" -#include "winit.h" -#include "wdbg.h" -#include "wutil.h" +#include "lib/sysdep/os/win/winit.h" +#include "lib/sysdep/os/win/wdbg.h" +#include "lib/sysdep/os/win/wutil.h" WINIT_REGISTER_CRITICAL_INIT(wdbg_sym_Init); diff --git a/source/lib/sysdep/os/win/wdir_watch.cpp b/source/lib/sysdep/os/win/wdir_watch.cpp index d2879a69b2..bf510b9ce3 100644 --- a/source/lib/sysdep/os/win/wdir_watch.cpp +++ b/source/lib/sysdep/os/win/wdir_watch.cpp @@ -29,9 +29,9 @@ #include "lib/allocators/shared_ptr.h" #include "lib/path_util.h" // path_is_subpath -#include "win.h" -#include "winit.h" -#include "wutil.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/winit.h" +#include "lib/sysdep/os/win/wutil.h" WINIT_REGISTER_MAIN_INIT(wdir_watch_Init); diff --git a/source/lib/sysdep/os/win/wdll_delay_load.cpp b/source/lib/sysdep/os/win/wdll_delay_load.cpp index f92d49d021..4928cc93a7 100644 --- a/source/lib/sysdep/os/win/wdll_delay_load.cpp +++ b/source/lib/sysdep/os/win/wdll_delay_load.cpp @@ -25,11 +25,11 @@ */ #include "precompiled.h" -#include "wdll_delay_load.h" +#include "lib/sysdep/os/win/wdll_delay_load.h" #include "lib/sysdep/cpu.h" -#include "win.h" -#include "winit.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/winit.h" WINIT_REGISTER_LATE_SHUTDOWN2(wdll_Shutdown); // last - DLLs are unloaded here diff --git a/source/lib/sysdep/os/win/wdll_ver.cpp b/source/lib/sysdep/os/win/wdll_ver.cpp index 2eb9409e4e..4a9a4debf7 100644 --- a/source/lib/sysdep/os/win/wdll_ver.cpp +++ b/source/lib/sysdep/os/win/wdll_ver.cpp @@ -25,13 +25,13 @@ */ #include "precompiled.h" -#include "wdll_ver.h" +#include "lib/sysdep/os/win/wdll_ver.h" #include #include -#include "win.h" -#include "wutil.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" #include "lib/allocators/shared_ptr.h" diff --git a/source/lib/sysdep/os/win/wgfx.cpp b/source/lib/sysdep/os/win/wgfx.cpp index be41e7edf3..ca05cbc7a3 100644 --- a/source/lib/sysdep/os/win/wgfx.cpp +++ b/source/lib/sysdep/os/win/wgfx.cpp @@ -27,9 +27,9 @@ #include "precompiled.h" #include "lib/sysdep/gfx.h" -#include "wdll_ver.h" -#include "win.h" -#include "wmi.h" +#include "lib/sysdep/os/win/wdll_ver.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wmi.h" #if MSC_VERSION #pragma comment(lib, "advapi32.lib") // registry diff --git a/source/lib/sysdep/os/win/whrt/counter.cpp b/source/lib/sysdep/os/win/whrt/counter.cpp index 1ae7d83afb..76ae215c8b 100644 --- a/source/lib/sysdep/os/win/whrt/counter.cpp +++ b/source/lib/sysdep/os/win/whrt/counter.cpp @@ -25,16 +25,16 @@ */ #include "precompiled.h" -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" #include "lib/bits.h" #include "lib/sysdep/cpu.h" // cpu_CAS -#include "tsc.h" -#include "hpet.h" -#include "pmt.h" -#include "qpc.h" -#include "tgt.h" +#include "lib/sysdep/os/win/whrt/tsc.h" +#include "lib/sysdep/os/win/whrt/hpet.h" +#include "lib/sysdep/os/win/whrt/pmt.h" +#include "lib/sysdep/os/win/whrt/qpc.h" +#include "lib/sysdep/os/win/whrt/tgt.h" // to add a new counter type, simply include its header here and // insert a case in ConstructCounterAt's switch statement. diff --git a/source/lib/sysdep/os/win/whrt/hpet.cpp b/source/lib/sysdep/os/win/whrt/hpet.cpp index 7fc3d0d058..982b873a34 100644 --- a/source/lib/sysdep/os/win/whrt/hpet.cpp +++ b/source/lib/sysdep/os/win/whrt/hpet.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "hpet.h" +#include "lib/sysdep/os/win/whrt/hpet.h" // for atomic 64-bit read/write: #define HAVE_X64_MOVD ARCH_AMD64 && (ICC_VERSION || MSC_VERSION >= 1500) @@ -35,7 +35,7 @@ # include #endif -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" #include "lib/sysdep/os/win/win.h" #include "lib/sysdep/os/win/mahaf.h" diff --git a/source/lib/sysdep/os/win/whrt/pmt.cpp b/source/lib/sysdep/os/win/whrt/pmt.cpp index 01f6e3399f..6fcfc52463 100644 --- a/source/lib/sysdep/os/win/whrt/pmt.cpp +++ b/source/lib/sysdep/os/win/whrt/pmt.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "pmt.h" +#include "lib/sysdep/os/win/whrt/pmt.h" -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" #include "lib/sysdep/os/win/win.h" #include "lib/sysdep/acpi.h" diff --git a/source/lib/sysdep/os/win/whrt/qpc.cpp b/source/lib/sysdep/os/win/whrt/qpc.cpp index 0c62705a38..28a0cd11da 100644 --- a/source/lib/sysdep/os/win/whrt/qpc.cpp +++ b/source/lib/sysdep/os/win/whrt/qpc.cpp @@ -25,15 +25,15 @@ */ #include "precompiled.h" -#include "qpc.h" +#include "lib/sysdep/os/win/whrt/qpc.h" -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" #include "lib/sysdep/os_cpu.h" #include "lib/sysdep/os/win/win.h" #include "lib/sysdep/os/win/wutil.h" // wutil_argv -#include "pit.h" // PIT_FREQ -#include "pmt.h" // PMT_FREQ +#include "lib/sysdep/os/win/whrt/pit.h" // PIT_FREQ +#include "lib/sysdep/os/win/whrt/pmt.h" // PMT_FREQ class CounterQPC : public ICounter diff --git a/source/lib/sysdep/os/win/whrt/tgt.cpp b/source/lib/sysdep/os/win/whrt/tgt.cpp index f7f40dac55..c31e08fb0b 100644 --- a/source/lib/sysdep/os/win/whrt/tgt.cpp +++ b/source/lib/sysdep/os/win/whrt/tgt.cpp @@ -29,9 +29,9 @@ // fairly slow) #include "precompiled.h" -#include "tgt.h" +#include "lib/sysdep/os/win/whrt/tgt.h" -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" #include "lib/sysdep/os/win/win.h" #include diff --git a/source/lib/sysdep/os/win/whrt/tsc.cpp b/source/lib/sysdep/os/win/whrt/tsc.cpp index aa96e60e5c..eafee54505 100644 --- a/source/lib/sysdep/os/win/whrt/tsc.cpp +++ b/source/lib/sysdep/os/win/whrt/tsc.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "tsc.h" +#include "lib/sysdep/os/win/whrt/tsc.h" -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" #include "lib/bits.h" #include "lib/sysdep/os_cpu.h" diff --git a/source/lib/sysdep/os/win/whrt/whrt.cpp b/source/lib/sysdep/os/win/whrt/whrt.cpp index bfba04dba5..91edd4f362 100644 --- a/source/lib/sysdep/os/win/whrt/whrt.cpp +++ b/source/lib/sysdep/os/win/whrt/whrt.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "whrt.h" +#include "lib/sysdep/os/win/whrt/whrt.h" #include // _beginthreadex @@ -36,7 +36,7 @@ #include "lib/adts.h" #include "lib/bits.h" -#include "counter.h" +#include "lib/sysdep/os/win/whrt/counter.h" WINIT_REGISTER_EARLY_INIT2(whrt_Init); // wutil -> whrt -> wtime WINIT_REGISTER_LATE_SHUTDOWN(whrt_Shutdown); diff --git a/source/lib/sysdep/os/win/winit.cpp b/source/lib/sysdep/os/win/winit.cpp index 651ae84746..557e73e8e6 100644 --- a/source/lib/sysdep/os/win/winit.cpp +++ b/source/lib/sysdep/os/win/winit.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "winit.h" +#include "lib/sysdep/os/win/winit.h" -#include "win.h" // GetTickCount for quick'n dirty timing +#include "lib/sysdep/os/win/win.h" // GetTickCount for quick'n dirty timing // see http://blogs.msdn.com/larryosterman/archive/2004/09/27/234840.aspx // for discussion of a similar mechanism. diff --git a/source/lib/sysdep/os/win/wmi.cpp b/source/lib/sysdep/os/win/wmi.cpp index f2fcb66ea1..e9cddd3ad2 100644 --- a/source/lib/sysdep/os/win/wmi.cpp +++ b/source/lib/sysdep/os/win/wmi.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "wmi.h" +#include "lib/sysdep/os/win/wmi.h" #include diff --git a/source/lib/sysdep/os/win/wmi.h b/source/lib/sysdep/os/win/wmi.h index 984864c1f0..bbbabfaca4 100644 --- a/source/lib/sysdep/os/win/wmi.h +++ b/source/lib/sysdep/os/win/wmi.h @@ -32,7 +32,7 @@ // everything to be converted to/parsed from strings. it does drag in // OLE headers, but this module is entirely Windows-specific anyway. #define _WIN32_DCOM -#include "win.h" +#include "lib/sysdep/os/win/win.h" #include // VARIANT typedef std::map WmiMap; diff --git a/source/lib/sysdep/os/win/wnuma.cpp b/source/lib/sysdep/os/win/wnuma.cpp index f39a5a9b92..bc4284e0e3 100644 --- a/source/lib/sysdep/os/win/wnuma.cpp +++ b/source/lib/sysdep/os/win/wnuma.cpp @@ -27,10 +27,10 @@ #include "lib/timer.h" #include "lib/sysdep/os_cpu.h" #include "lib/sysdep/acpi.h" -#include "win.h" -#include "wutil.h" -#include "wcpu.h" -#include "winit.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" +#include "lib/sysdep/os/win/wcpu.h" +#include "lib/sysdep/os/win/winit.h" #include diff --git a/source/lib/sysdep/os/win/wposix/waio.cpp b/source/lib/sysdep/os/win/wposix/waio.cpp index e5920b6cc5..587fc8ce59 100644 --- a/source/lib/sysdep/os/win/wposix/waio.cpp +++ b/source/lib/sysdep/os/win/wposix/waio.cpp @@ -25,13 +25,13 @@ */ #include "precompiled.h" -#include "waio.h" +#include "lib/sysdep/os/win/wposix/waio.h" -#include "crt_posix.h" // correct definitions of _open() etc. +#include "lib/sysdep/os/win/wposix/crt_posix.h" // correct definitions of _open() etc. -#include "wposix_internal.h" -#include "wfilesystem.h" // mode_t -#include "wtime.h" // timespec +#include "lib/sysdep/os/win/wposix/wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wfilesystem.h" // mode_t +#include "lib/sysdep/os/win/wposix/wtime.h" // timespec #include "lib/sysdep/cpu.h" #include "lib/bits.h" diff --git a/source/lib/sysdep/os/win/wposix/waio.h b/source/lib/sysdep/os/win/wposix/waio.h index 98d5a30a8d..a60b387561 100644 --- a/source/lib/sysdep/os/win/wposix/waio.h +++ b/source/lib/sysdep/os/win/wposix/waio.h @@ -27,9 +27,9 @@ #ifndef INCLUDED_WAIO #define INCLUDED_WAIO -#include "wposix_types.h" +#include "lib/sysdep/os/win/wposix/wposix_types.h" -#include "no_crt_posix.h" +#include "lib/sysdep/os/win/wposix/no_crt_posix.h" #include "lib/lib_errors.h" diff --git a/source/lib/sysdep/os/win/wposix/wdlfcn.cpp b/source/lib/sysdep/os/win/wposix/wdlfcn.cpp index 2fab54cea7..6f33aec7e7 100644 --- a/source/lib/sysdep/os/win/wposix/wdlfcn.cpp +++ b/source/lib/sysdep/os/win/wposix/wdlfcn.cpp @@ -21,9 +21,9 @@ */ #include "precompiled.h" -#include "wdlfcn.h" +#include "lib/sysdep/os/win/wposix/wdlfcn.h" -#include "wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wposix_internal.h" static HMODULE HMODULE_from_void(void* handle) diff --git a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp index 49a6a9dd8c..292011cc99 100644 --- a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -21,13 +21,13 @@ */ #include "precompiled.h" -#include "wfilesystem.h" +#include "lib/sysdep/os/win/wposix/wfilesystem.h" #include "lib/allocators/allocators.h" // single_calloc -#include "wposix_internal.h" -#include "waio.h" -#include "wtime_internal.h" // wtime_utc_filetime_to_time_t -#include "crt_posix.h" // _rmdir, _access +#include "lib/sysdep/os/win/wposix/wposix_internal.h" +#include "lib/sysdep/os/win/wposix/waio.h" +#include "lib/sysdep/os/win/wposix/wtime_internal.h" // wtime_utc_filetime_to_time_t +#include "lib/sysdep/os/win/wposix/crt_posix.h" // _rmdir, _access // // determine file system type on the current drive - diff --git a/source/lib/sysdep/os/win/wposix/wmman.cpp b/source/lib/sysdep/os/win/wposix/wmman.cpp index 68db8019e2..3a120dba11 100644 --- a/source/lib/sysdep/os/win/wposix/wmman.cpp +++ b/source/lib/sysdep/os/win/wposix/wmman.cpp @@ -21,10 +21,10 @@ */ #include "precompiled.h" -#include "wmman.h" +#include "lib/sysdep/os/win/wposix/wmman.h" -#include "wposix_internal.h" -#include "crt_posix.h" // _get_osfhandle +#include "lib/sysdep/os/win/wposix/wposix_internal.h" +#include "lib/sysdep/os/win/wposix/crt_posix.h" // _get_osfhandle //----------------------------------------------------------------------------- diff --git a/source/lib/sysdep/os/win/wposix/wposix.cpp b/source/lib/sysdep/os/win/wposix/wposix.cpp index b6af88c087..9d877888ad 100644 --- a/source/lib/sysdep/os/win/wposix/wposix.cpp +++ b/source/lib/sysdep/os/win/wposix/wposix.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "wposix.h" +#include "lib/sysdep/os/win/wposix/wposix.h" -#include "wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wposix_internal.h" #include "lib/bits.h" WINIT_REGISTER_CRITICAL_INIT(wposix_Init); // wposix -> error handling diff --git a/source/lib/sysdep/os/win/wposix/wpthread.cpp b/source/lib/sysdep/os/win/wposix/wpthread.cpp index dc8a9d7316..bc7af0618b 100644 --- a/source/lib/sysdep/os/win/wposix/wpthread.cpp +++ b/source/lib/sysdep/os/win/wposix/wpthread.cpp @@ -25,16 +25,16 @@ */ #include "precompiled.h" -#include "wpthread.h" +#include "lib/sysdep/os/win/wposix/wpthread.h" #include #include #include "lib/sysdep/cpu.h" // cpu_CAS -#include "wposix_internal.h" -#include "wtime.h" // timespec -#include "../wseh.h" // wseh_ExceptionFilter +#include "lib/sysdep/os/win/wposix/wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wtime.h" // timespec +#include "lib/sysdep/os/win/wseh.h" // wseh_ExceptionFilter static HANDLE HANDLE_from_pthread(pthread_t p) diff --git a/source/lib/sysdep/os/win/wposix/wsock.cpp b/source/lib/sysdep/os/win/wposix/wsock.cpp index 5fc2ec1f4f..4e691e489a 100644 --- a/source/lib/sysdep/os/win/wposix/wsock.cpp +++ b/source/lib/sysdep/os/win/wposix/wsock.cpp @@ -25,11 +25,11 @@ */ #include "precompiled.h" -#include "wsock.h" +#include "lib/sysdep/os/win/wposix/wsock.h" #include "lib/sysdep/os/win/wdll_delay_load.h" -#include "wposix_internal.h" -#include "wsock_internal.h" +#include "lib/sysdep/os/win/wposix/wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wsock_internal.h" #include "lib/module_init.h" #if MSC_VERSION diff --git a/source/lib/sysdep/os/win/wposix/wterminal.cpp b/source/lib/sysdep/os/win/wposix/wterminal.cpp index 7d2d00beea..b0e81de200 100644 --- a/source/lib/sysdep/os/win/wposix/wterminal.cpp +++ b/source/lib/sysdep/os/win/wposix/wterminal.cpp @@ -21,10 +21,10 @@ */ #include "precompiled.h" -#include "wterminal.h" +#include "lib/sysdep/os/win/wposix/wterminal.h" -#include "wposix_internal.h" -#include "crt_posix.h" // _get_osfhandle +#include "lib/sysdep/os/win/wposix/wposix_internal.h" +#include "lib/sysdep/os/win/wposix/crt_posix.h" // _get_osfhandle int ioctl(int fd, int op, int* data) diff --git a/source/lib/sysdep/os/win/wposix/wtime.cpp b/source/lib/sysdep/os/win/wposix/wtime.cpp index 2186d8bcd8..4e19102a94 100644 --- a/source/lib/sysdep/os/win/wposix/wtime.cpp +++ b/source/lib/sysdep/os/win/wposix/wtime.cpp @@ -29,9 +29,9 @@ // which costs time and accuracy. #include "precompiled.h" -#include "wtime.h" +#include "lib/sysdep/os/win/wposix/wtime.h" -#include "wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wposix_internal.h" #include "lib/sysdep/cpu.h" // cpu_i64FromDouble #include "lib/sysdep/os/win/whrt/whrt.h" diff --git a/source/lib/sysdep/os/win/wposix/wutsname.cpp b/source/lib/sysdep/os/win/wposix/wutsname.cpp index 0dc91b2bf5..77fbc31080 100644 --- a/source/lib/sysdep/os/win/wposix/wutsname.cpp +++ b/source/lib/sysdep/os/win/wposix/wutsname.cpp @@ -21,11 +21,11 @@ */ #include "precompiled.h" -#include "wutsname.h" +#include "lib/sysdep/os/win/wposix/wutsname.h" -#include "../wutil.h" +#include "lib/sysdep/os/win/wutil.h" -#include "wposix_internal.h" +#include "lib/sysdep/os/win/wposix/wposix_internal.h" int uname(struct utsname* un) diff --git a/source/lib/sysdep/os/win/wsdl.cpp b/source/lib/sysdep/os/win/wsdl.cpp index 04c6b8ed46..dbc2896638 100644 --- a/source/lib/sysdep/os/win/wsdl.cpp +++ b/source/lib/sysdep/os/win/wsdl.cpp @@ -34,14 +34,14 @@ #include #include -#include "win.h" +#include "lib/sysdep/os/win/win.h" #include // _beginthreadex #include // message crackers #include "lib/posix/posix_pthread.h" #include "lib/module_init.h" -#include "wutil.h" -#include "winit.h" +#include "lib/sysdep/os/win/wutil.h" +#include "lib/sysdep/os/win/winit.h" #include "lib/sysdep/os/win/wmi.h" // for SDL_GetVideoInfo #if MSC_VERSION diff --git a/source/lib/sysdep/os/win/wseh.cpp b/source/lib/sysdep/os/win/wseh.cpp index f10fd26875..ce43ee6ab1 100644 --- a/source/lib/sysdep/os/win/wseh.cpp +++ b/source/lib/sysdep/os/win/wseh.cpp @@ -25,14 +25,14 @@ */ #include "precompiled.h" -#include "wseh.h" +#include "lib/sysdep/os/win/wseh.h" #include "lib/byte_order.h" // FOURCC -#include "lib/wchar.h" +#include "lib/utf8.h" #include "lib/sysdep/cpu.h" -#include "win.h" -#include "wutil.h" -#include "wdbg_sym.h" // wdbg_sym_WriteMinidump +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" +#include "lib/sysdep/os/win/wdbg_sym.h" // wdbg_sym_WriteMinidump #if MSC_VERSION >= 1400 # include // __security_init_cookie diff --git a/source/lib/sysdep/os/win/wsnd.cpp b/source/lib/sysdep/os/win/wsnd.cpp index b5e63bf2fe..d35f14e758 100644 --- a/source/lib/sysdep/os/win/wsnd.cpp +++ b/source/lib/sysdep/os/win/wsnd.cpp @@ -33,10 +33,10 @@ #include #include "lib/path_util.h" -#include "wdll_ver.h" -#include "win.h" -#include "wutil.h" -#include "wmi.h" +#include "lib/sysdep/os/win/wdll_ver.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/wutil.h" +#include "lib/sysdep/os/win/wmi.h" static bool IsOpenAlDllName(const std::wstring& name) diff --git a/source/lib/sysdep/os/win/wstartup.cpp b/source/lib/sysdep/os/win/wstartup.cpp index 33482cdbf3..40d7b355b8 100644 --- a/source/lib/sysdep/os/win/wstartup.cpp +++ b/source/lib/sysdep/os/win/wstartup.cpp @@ -25,9 +25,9 @@ */ #include "precompiled.h" -#include "wstartup.h" +#include "lib/sysdep/os/win/wstartup.h" -#include "winit.h" +#include "lib/sysdep/os/win/winit.h" /* diff --git a/source/lib/sysdep/os/win/wsysdep.cpp b/source/lib/sysdep/os/win/wsysdep.cpp index a418d76d13..24bba1ae89 100644 --- a/source/lib/sysdep/os/win/wsysdep.cpp +++ b/source/lib/sysdep/os/win/wsysdep.cpp @@ -27,12 +27,12 @@ #include "precompiled.h" #include "lib/sysdep/sysdep.h" -#include "win.h" // includes windows.h; must come before shlobj +#include "lib/sysdep/os/win/win.h" // includes windows.h; must come before shlobj #include // pick_dir #include "lib/sysdep/clipboard.h" -#include "error_dialog.h" -#include "wutil.h" +#include "lib/sysdep/os/win/error_dialog.h" +#include "lib/sysdep/os/win/wutil.h" diff --git a/source/lib/sysdep/os/win/wutil.cpp b/source/lib/sysdep/os/win/wutil.cpp index 31c01e9a80..9168fa59ff 100644 --- a/source/lib/sysdep/os/win/wutil.cpp +++ b/source/lib/sysdep/os/win/wutil.cpp @@ -25,15 +25,15 @@ */ #include "precompiled.h" -#include "wutil.h" +#include "lib/sysdep/os/win/wutil.h" #include #include // __argc #include "lib/path_util.h" #include "lib/posix/posix.h" -#include "win.h" -#include "winit.h" +#include "lib/sysdep/os/win/win.h" +#include "lib/sysdep/os/win/winit.h" #include // SHGetFolderPath diff --git a/source/lib/sysdep/os/win/wutil.h b/source/lib/sysdep/os/win/wutil.h index 83c1f70d89..7f8c550784 100644 --- a/source/lib/sysdep/os/win/wutil.h +++ b/source/lib/sysdep/os/win/wutil.h @@ -31,7 +31,7 @@ #error "wutil.h: do not include if not compiling for Windows" #endif -#include "win.h" +#include "lib/sysdep/os/win/win.h" template bool wutil_IsValidHandle(H h) diff --git a/source/lib/sysdep/os_cpu.cpp b/source/lib/sysdep/os_cpu.cpp index c35533b6d0..99816da26d 100644 --- a/source/lib/sysdep/os_cpu.cpp +++ b/source/lib/sysdep/os_cpu.cpp @@ -25,6 +25,6 @@ */ #include "precompiled.h" -#include "os_cpu.h" +#include "lib/sysdep/os_cpu.h" ERROR_ASSOCIATE(ERR::OS_CPU_RESTRICTED_AFFINITY, L"Cannot set desired CPU affinity", -1); diff --git a/source/lib/sysdep/snd.cpp b/source/lib/sysdep/snd.cpp index 2b081f2fb3..95e085ead4 100644 --- a/source/lib/sysdep/snd.cpp +++ b/source/lib/sysdep/snd.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "snd.h" +#include "lib/sysdep/snd.h" #if OS_WIN # include "lib/sysdep/os/win/wsnd.h" diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index eca58dd8c8..a3b1547ef0 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -25,7 +25,7 @@ #include "lib/lib.h" #include "lib/path_util.h" #include "lib/secure_crt.h" -#include "lib/wchar.h" +#include "lib/utf8.h" #include "lib/sysdep/cpu.h" #include "lib/sysdep/sysdep.h" #include "lib/posix/posix.h" // fminf etc. diff --git a/source/lib/tests/test_wchar.h b/source/lib/tests/test_wchar.h index e2592ff422..92ca11d341 100644 --- a/source/lib/tests/test_wchar.h +++ b/source/lib/tests/test_wchar.h @@ -21,7 +21,7 @@ */ #include "lib/self_test.h" -#include "lib/wchar.h" +#include "lib/utf8.h" // (copied from CStr test) @@ -77,7 +77,7 @@ public: LibError err; const std::wstring str_utf8to16 = wstring_from_utf8(str_utf8, &err); - TS_ASSERT_EQUALS(err, ERR::WCHAR_INVALID_UTF8); + TS_ASSERT_EQUALS(err, ERR::UTF8_INVALID_UTF8); TS_ASSERT_EQUALS(str_utf16.length(), str_utf8to16.length()); TS_ASSERT_SAME_DATA(str_utf8to16.data(), str_utf16.data(), str_utf16.length()*sizeof(wchar_t)); } diff --git a/source/lib/timer.cpp b/source/lib/timer.cpp index a277bbcce2..fc3a76b5a1 100644 --- a/source/lib/timer.cpp +++ b/source/lib/timer.cpp @@ -25,7 +25,7 @@ */ #include "precompiled.h" -#include "timer.h" +#include "lib/timer.h" #include #include diff --git a/source/lib/types.h b/source/lib/types.h index b3f7a2aeef..f41ccd2bef 100644 --- a/source/lib/types.h +++ b/source/lib/types.h @@ -27,7 +27,7 @@ #ifndef INCLUDED_TYPES #define INCLUDED_TYPES -#include "posix/posix_types.h" +#include "lib/posix/posix_types.h" // defines instead of typedefs so we can #undef conflicting decls diff --git a/source/lib/wchar.cpp b/source/lib/utf8.cpp similarity index 89% rename from source/lib/wchar.cpp rename to source/lib/utf8.cpp index 2669b55181..376039fcab 100644 --- a/source/lib/wchar.cpp +++ b/source/lib/utf8.cpp @@ -1,231 +1,231 @@ -/* Copyright (c) 2010 Wildfire Games - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "precompiled.h" -#include "wchar.h" - -ERROR_ASSOCIATE(ERR::WCHAR_SURROGATE, L"UTF-16 surrogate pairs aren't supported", -1); -ERROR_ASSOCIATE(ERR::WCHAR_OUTSIDE_BMP, L"Code point outside BMP (> 0x10000)", -1); -ERROR_ASSOCIATE(ERR::WCHAR_NONCHARACTER, L"Noncharacter (e.g. WEOF)", -1); -ERROR_ASSOCIATE(ERR::WCHAR_INVALID_UTF8, L"Invalid UTF-8 sequence", -1); - - -// adapted from http://unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c -// which bears the following notice: -/* -* Copyright 2001-2004 Unicode, Inc. -* -* Disclaimer -* -* This source code is provided as is by Unicode, Inc. No claims are -* made as to fitness for any particular purpose. No warranties of any -* kind are expressed or implied. The recipient agrees to determine -* applicability of information provided. If this file has been -* purchased on magnetic or optical media from Unicode, Inc., the -* sole remedy for any claim will be exchange of defective media -* within 90 days of receipt. -* -* Limitations on Rights to Redistribute This Code -* -* Unicode, Inc. hereby grants the right to freely use the information -* supplied in this file in the creation of products supporting the -* Unicode Standard, and to make copies of this file in any form -* for internal or external distribution as long as this notice -* remains attached. -*/ - -// design rationale: -// - to cope with wchar_t differences between VC (UTF-16) and -// GCC (UCS-4), we only allow codepoints in the BMP. -// encoded UTF-8 sequences are therefore no longer than 3 bytes. -// - surrogates are disabled because variable-length strings -// violate the purpose of using wchar_t instead of UTF-8. -// - replacing disallowed characters instead of aborting outright -// avoids overly inconveniencing users and eases debugging. - -// this implementation survives http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt - -// (must be unsigned to avoid sign extension) -typedef u8 UTF8; -typedef u32 UTF32; - - -// called from ReplaceIfInvalid and UTF8Codec::Decode -static UTF32 RaiseError(LibError err, LibError* perr) -{ - if(perr) // caller wants return code, not warning dialog - { - if(*perr == INFO::OK) // only return the first error (see header) - *perr = err; - } - else - DEBUG_WARN_ERR(err); - - return 0xFFFDul; // replacement character -} - - -static UTF32 ReplaceIfInvalid(UTF32 u, LibError* err) -{ - // disallow surrogates - if(0xD800ul <= u && u <= 0xDFFFul) - return RaiseError(ERR::WCHAR_SURROGATE, err); - // outside BMP (UTF-16 representation would require surrogates) - if(u > 0xFFFFul) - return RaiseError(ERR::WCHAR_OUTSIDE_BMP, err); - // noncharacter (note: WEOF (0xFFFF) causes VC's swprintf to fail) - if(u == 0xFFFEul || u == 0xFFFFul || (0xFDD0ul <= u && u <= 0xFDEFul)) - return RaiseError(ERR::WCHAR_NONCHARACTER, err); - return u; -} - - -class UTF8Codec -{ -public: - static void Encode(UTF32 u, UTF8*& dstPos) - { - const size_t size = Size(u); - static const UTF8 firstByteMarks[1+3] = { 0, 0x00, 0xC0, 0xE0 }; - for(size_t i = 1; i < size; i++) - { - dstPos[size-i] = UTF8((u|0x80u) & 0xBFu); - u >>= 6; - } - dstPos[0] = UTF8(u | firstByteMarks[size]); - dstPos += size; - } - - // @return decoded scalar, or replacementCharacter on error - static UTF32 Decode(const UTF8*& srcPos, const UTF8* const srcEnd, LibError* err) - { - const size_t size = SizeFromFirstByte(*srcPos); - if(!IsValid(srcPos, size, srcEnd)) - { - srcPos += 1; // only skip the offending byte (increases chances of resynchronization) - return RaiseError(ERR::WCHAR_INVALID_UTF8, err); - } - - UTF32 u = 0; - for(size_t i = 0; i < size-1; i++) - { - u += UTF32(*srcPos++); - u <<= 6; - } - u += UTF32(*srcPos++); - - static const UTF32 offsets[1+4] = { 0, 0x00000000ul, 0x00003080ul, 0x000E2080ul, 0x03C82080UL }; - u -= offsets[size]; - return u; - } - -private: - static inline size_t Size(UTF32 u) - { - if(u < 0x80) - return 1; - if(u < 0x800) - return 2; - // ReplaceIfInvalid ensures > 3 byte encodings are never used. - return 3; - } - - static inline size_t SizeFromFirstByte(UTF8 firstByte) - { - if(firstByte < 0xC0) - return 1; - if(firstByte < 0xE0) - return 2; - if(firstByte < 0xF0) - return 3; - // IsValid rejects firstByte values that would cause > 4 byte encodings. - return 4; - } - - // c.f. Unicode 3.1 Table 3-7 - // @param size obtained via SizeFromFirstByte (our caller also uses it) - static bool IsValid(const UTF8* const src, size_t size, const UTF8* const srcEnd) - { - if(src+size > srcEnd) // not enough data - return false; - - if(src[0] < 0x80) - return true; - if(!(0xC2 <= src[0] && src[0] <= 0xF4)) - return false; - - // special cases (stricter than the loop) - if(src[0] == 0xE0 && src[1] < 0xA0) - return false; - if(src[0] == 0xED && src[1] > 0x9F) - return false; - if(src[0] == 0xF0 && src[1] < 0x90) - return false; - if(src[0] == 0xF4 && src[1] > 0x8F) - return false; - - for(size_t i = 1; i < size; i++) - { - if(!(0x80 <= src[i] && src[i] <= 0xBF)) - return false; - } - - return true; - } -}; - - -//----------------------------------------------------------------------------- - -std::string utf8_from_wstring(const std::wstring& src, LibError* err) -{ - if(err) - *err = INFO::OK; - - std::string dst(src.size()*3+1, ' '); // see UTF8Codec::Size; +1 ensures &dst[0] is valid - UTF8* dstPos = (UTF8*)&dst[0]; - for(size_t i = 0; i < src.size(); i++) - { - const UTF32 u = ReplaceIfInvalid(UTF32(src[i]), err); - UTF8Codec::Encode(u, dstPos); - } - dst.resize(dstPos - (UTF8*)&dst[0]); - return dst; -} - - -std::wstring wstring_from_utf8(const std::string& src, LibError* err) -{ - if(err) - *err = INFO::OK; - - std::wstring dst; - dst.reserve(src.size()); - const UTF8* srcPos = (const UTF8*)src.data(); - const UTF8* const srcEnd = srcPos + src.size(); - while(srcPos < srcEnd) - { - const UTF32 u = UTF8Codec::Decode(srcPos, srcEnd, err); - dst.push_back((wchar_t)ReplaceIfInvalid(u, err)); - } - return dst; -} +/* Copyright (c) 2010 Wildfire Games + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "precompiled.h" +#include "lib/utf8.h" + +ERROR_ASSOCIATE(ERR::UTF8_SURROGATE, L"UTF-16 surrogate pairs aren't supported", -1); +ERROR_ASSOCIATE(ERR::UTF8_OUTSIDE_BMP, L"Code point outside BMP (> 0x10000)", -1); +ERROR_ASSOCIATE(ERR::UTF8_NONCHARACTER, L"Noncharacter (e.g. WEOF)", -1); +ERROR_ASSOCIATE(ERR::UTF8_INVALID_UTF8, L"Invalid UTF-8 sequence", -1); + + +// adapted from http://unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c +// which bears the following notice: +/* +* Copyright 2001-2004 Unicode, Inc. +* +* Disclaimer +* +* This source code is provided as is by Unicode, Inc. No claims are +* made as to fitness for any particular purpose. No warranties of any +* kind are expressed or implied. The recipient agrees to determine +* applicability of information provided. If this file has been +* purchased on magnetic or optical media from Unicode, Inc., the +* sole remedy for any claim will be exchange of defective media +* within 90 days of receipt. +* +* Limitations on Rights to Redistribute This Code +* +* Unicode, Inc. hereby grants the right to freely use the information +* supplied in this file in the creation of products supporting the +* Unicode Standard, and to make copies of this file in any form +* for internal or external distribution as long as this notice +* remains attached. +*/ + +// design rationale: +// - to cope with wchar_t differences between VC (UTF-16) and +// GCC (UCS-4), we only allow codepoints in the BMP. +// encoded UTF-8 sequences are therefore no longer than 3 bytes. +// - surrogates are disabled because variable-length strings +// violate the purpose of using wchar_t instead of UTF-8. +// - replacing disallowed characters instead of aborting outright +// avoids overly inconveniencing users and eases debugging. + +// this implementation survives http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt + +// (must be unsigned to avoid sign extension) +typedef u8 UTF8; +typedef u32 UTF32; + + +// called from ReplaceIfInvalid and UTF8Codec::Decode +static UTF32 RaiseError(LibError err, LibError* perr) +{ + if(perr) // caller wants return code, not warning dialog + { + if(*perr == INFO::OK) // only return the first error (see header) + *perr = err; + } + else + DEBUG_WARN_ERR(err); + + return 0xFFFDul; // replacement character +} + + +static UTF32 ReplaceIfInvalid(UTF32 u, LibError* err) +{ + // disallow surrogates + if(0xD800ul <= u && u <= 0xDFFFul) + return RaiseError(ERR::UTF8_SURROGATE, err); + // outside BMP (UTF-16 representation would require surrogates) + if(u > 0xFFFFul) + return RaiseError(ERR::UTF8_OUTSIDE_BMP, err); + // noncharacter (note: WEOF (0xFFFF) causes VC's swprintf to fail) + if(u == 0xFFFEul || u == 0xFFFFul || (0xFDD0ul <= u && u <= 0xFDEFul)) + return RaiseError(ERR::UTF8_NONCHARACTER, err); + return u; +} + + +class UTF8Codec +{ +public: + static void Encode(UTF32 u, UTF8*& dstPos) + { + const size_t size = Size(u); + static const UTF8 firstByteMarks[1+3] = { 0, 0x00, 0xC0, 0xE0 }; + for(size_t i = 1; i < size; i++) + { + dstPos[size-i] = UTF8((u|0x80u) & 0xBFu); + u >>= 6; + } + dstPos[0] = UTF8(u | firstByteMarks[size]); + dstPos += size; + } + + // @return decoded scalar, or replacementCharacter on error + static UTF32 Decode(const UTF8*& srcPos, const UTF8* const srcEnd, LibError* err) + { + const size_t size = SizeFromFirstByte(*srcPos); + if(!IsValid(srcPos, size, srcEnd)) + { + srcPos += 1; // only skip the offending byte (increases chances of resynchronization) + return RaiseError(ERR::UTF8_INVALID_UTF8, err); + } + + UTF32 u = 0; + for(size_t i = 0; i < size-1; i++) + { + u += UTF32(*srcPos++); + u <<= 6; + } + u += UTF32(*srcPos++); + + static const UTF32 offsets[1+4] = { 0, 0x00000000ul, 0x00003080ul, 0x000E2080ul, 0x03C82080UL }; + u -= offsets[size]; + return u; + } + +private: + static inline size_t Size(UTF32 u) + { + if(u < 0x80) + return 1; + if(u < 0x800) + return 2; + // ReplaceIfInvalid ensures > 3 byte encodings are never used. + return 3; + } + + static inline size_t SizeFromFirstByte(UTF8 firstByte) + { + if(firstByte < 0xC0) + return 1; + if(firstByte < 0xE0) + return 2; + if(firstByte < 0xF0) + return 3; + // IsValid rejects firstByte values that would cause > 4 byte encodings. + return 4; + } + + // c.f. Unicode 3.1 Table 3-7 + // @param size obtained via SizeFromFirstByte (our caller also uses it) + static bool IsValid(const UTF8* const src, size_t size, const UTF8* const srcEnd) + { + if(src+size > srcEnd) // not enough data + return false; + + if(src[0] < 0x80) + return true; + if(!(0xC2 <= src[0] && src[0] <= 0xF4)) + return false; + + // special cases (stricter than the loop) + if(src[0] == 0xE0 && src[1] < 0xA0) + return false; + if(src[0] == 0xED && src[1] > 0x9F) + return false; + if(src[0] == 0xF0 && src[1] < 0x90) + return false; + if(src[0] == 0xF4 && src[1] > 0x8F) + return false; + + for(size_t i = 1; i < size; i++) + { + if(!(0x80 <= src[i] && src[i] <= 0xBF)) + return false; + } + + return true; + } +}; + + +//----------------------------------------------------------------------------- + +std::string utf8_from_wstring(const std::wstring& src, LibError* err) +{ + if(err) + *err = INFO::OK; + + std::string dst(src.size()*3+1, ' '); // see UTF8Codec::Size; +1 ensures &dst[0] is valid + UTF8* dstPos = (UTF8*)&dst[0]; + for(size_t i = 0; i < src.size(); i++) + { + const UTF32 u = ReplaceIfInvalid(UTF32(src[i]), err); + UTF8Codec::Encode(u, dstPos); + } + dst.resize(dstPos - (UTF8*)&dst[0]); + return dst; +} + + +std::wstring wstring_from_utf8(const std::string& src, LibError* err) +{ + if(err) + *err = INFO::OK; + + std::wstring dst; + dst.reserve(src.size()); + const UTF8* srcPos = (const UTF8*)src.data(); + const UTF8* const srcEnd = srcPos + src.size(); + while(srcPos < srcEnd) + { + const UTF32 u = UTF8Codec::Decode(srcPos, srcEnd, err); + dst.push_back((wchar_t)ReplaceIfInvalid(u, err)); + } + return dst; +} diff --git a/source/lib/wchar.h b/source/lib/utf8.h similarity index 84% rename from source/lib/wchar.h rename to source/lib/utf8.h index 0fdae290ce..e85336fdf0 100644 --- a/source/lib/wchar.h +++ b/source/lib/utf8.h @@ -1,52 +1,52 @@ -/* Copyright (c) 2010 Wildfire Games - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef INCLUDED_WCHAR -#define INCLUDED_WCHAR - -// note: error codes are returned via optional output parameter. -namespace ERR -{ - const LibError WCHAR_SURROGATE = -100700; - const LibError WCHAR_OUTSIDE_BMP = -100701; - const LibError WCHAR_NONCHARACTER = -100702; - const LibError WCHAR_INVALID_UTF8 = -100703; -} - -/** - * convert UTF-8 to a wide string (UTF-16 or UCS-4, depending on the - * platform's wchar_t). - * - * @param s input string (UTF-8) - * @param err if nonzero, this receives the first error encountered - * (the rest may be subsequent faults) or INFO::OK if all went well. - * otherwise, the function raises a warning dialog for every - * error/warning. - **/ -LIB_API std::wstring wstring_from_utf8(const std::string& s, LibError* err = 0); - -/** - * opposite of wstring_from_utf8 - **/ -LIB_API std::string utf8_from_wstring(const std::wstring& s, LibError* err = 0); - -#endif // #ifndef INCLUDED_WCHAR +/* Copyright (c) 2010 Wildfire Games + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef INCLUDED_UTF8 +#define INCLUDED_UTF8 + +// note: error codes are returned via optional output parameter. +namespace ERR +{ + const LibError UTF8_SURROGATE = -100700; + const LibError UTF8_OUTSIDE_BMP = -100701; + const LibError UTF8_NONCHARACTER = -100702; + const LibError UTF8_INVALID_UTF8 = -100703; +} + +/** + * convert UTF-8 to a wide string (UTF-16 or UCS-4, depending on the + * platform's wchar_t). + * + * @param s input string (UTF-8) + * @param err if nonzero, this receives the first error encountered + * (the rest may be subsequent faults) or INFO::OK if all went well. + * otherwise, the function raises a warning dialog for every + * error/warning. + **/ +LIB_API std::wstring wstring_from_utf8(const std::string& s, LibError* err = 0); + +/** + * opposite of wstring_from_utf8 + **/ +LIB_API std::string utf8_from_wstring(const std::wstring& s, LibError* err = 0); + +#endif // #ifndef INCLUDED_UTF8