From 78bc63d92cc40049d55da9619f07ed43dbd37b78 Mon Sep 17 00:00:00 2001 From: janwas Date: Sat, 14 Nov 2009 18:32:27 +0000 Subject: [PATCH] VC fix: mustn't use filename/parent_path instead of leaf/branch_path because those aren't yet available in the version of boost we're currently using. remove needless restriction on wdbg_printf buffer size update description of wdbg_printf to match wvsprintfW's real behavior This was SVN commit r7199. --- source/lib/debug.cpp | 8 ++------ source/lib/file/file_system.cpp | 8 ++++---- source/lib/sysdep/os/win/wdbg.cpp | 4 ++-- source/lib/sysdep/os/win/wdbg.h | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 4ab51b5dbd..a1c6aac64c 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -165,18 +165,14 @@ bool debug_filter_allows(const wchar_t* text) return false; } -// max # characters (including \0) output by debug_printf in one call. -const size_t DEBUG_PRINTF_MAX_CHARS = 1024; // refer to wdbg.cpp!debug_vsprintf before changing this - #undef debug_printf // allowing #defining it out - void debug_printf(const wchar_t* fmt, ...) { - wchar_t buf[DEBUG_PRINTF_MAX_CHARS]; buf[ARRAY_SIZE(buf)-1] = '\0'; + wchar_t buf[4096]; va_list ap; va_start(ap, fmt); - const int numChars = vswprintf_s(buf, DEBUG_PRINTF_MAX_CHARS, fmt, ap); + const int numChars = vswprintf_s(buf, ARRAY_SIZE(buf), fmt, ap); debug_assert(numChars >= 0); va_end(ap); diff --git a/source/lib/file/file_system.cpp b/source/lib/file/file_system.cpp index 651b468a9a..5935861386 100644 --- a/source/lib/file/file_system.cpp +++ b/source/lib/file/file_system.cpp @@ -117,11 +117,11 @@ LibError CreateDirectories(const fs::wpath& path, mode_t mode) } // If we were passed a path ending with '/', strip the '/' now so that - // we can consistently use parent_path to find parent directory names - if (path.filename() == L".") - return CreateDirectories(path.parent_path(), mode); + // we can consistently use branch_path to find parent directory names + if (path.leaf() == L".") + return CreateDirectories(path.branch_path(), mode); - RETURN_ERR(CreateDirectories(path.parent_path(), mode)); + RETURN_ERR(CreateDirectories(path.branch_path(), mode)); const fs::path path_c = path_from_wpath(path); errno = 0; diff --git a/source/lib/sysdep/os/win/wdbg.cpp b/source/lib/sysdep/os/win/wdbg.cpp index 27ec106bfc..0c555402f4 100644 --- a/source/lib/sysdep/os/win/wdbg.cpp +++ b/source/lib/sysdep/os/win/wdbg.cpp @@ -95,10 +95,10 @@ void debug_puts(const wchar_t* text) void wdbg_printf(const wchar_t* fmt, ...) { - wchar_t buf[1024/sizeof(wchar_t)]; // as required by wvsprintf + wchar_t buf[1024+1]; // wvsprintfW will truncate to this size va_list ap; va_start(ap, fmt); - wvsprintfW(buf, fmt, ap); + wvsprintfW(buf, fmt, ap); // (return value doesn't indicate whether truncation occurred) va_end(ap); debug_puts(buf); diff --git a/source/lib/sysdep/os/win/wdbg.h b/source/lib/sysdep/os/win/wdbg.h index 6f46205fa8..da705cb3a7 100644 --- a/source/lib/sysdep/os/win/wdbg.h +++ b/source/lib/sysdep/os/win/wdbg.h @@ -24,7 +24,7 @@ /** * same as debug_printf except that some type conversions aren't supported - * (in particular, no floating point). + * (in particular, no floating point) and output is limited to 1024+1 characters. * * this function does not allocate memory from the CRT heap, which makes it * safe to use from an allocation hook.