diff options
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/app_main.h | 2 | ||||
-rw-r--r-- | wx+/button.cpp | 2 | ||||
-rw-r--r-- | wx+/button.h | 2 | ||||
-rw-r--r-- | wx+/choice_enum.h | 8 | ||||
-rw-r--r-- | wx+/context_menu.h | 2 | ||||
-rw-r--r-- | wx+/create_pch.cpp | 2 | ||||
-rw-r--r-- | wx+/dir_picker.h | 35 | ||||
-rw-r--r-- | wx+/file_drop.h | 2 | ||||
-rw-r--r-- | wx+/format_unit.cpp | 24 | ||||
-rw-r--r-- | wx+/format_unit.h | 4 | ||||
-rw-r--r-- | wx+/graph.cpp | 2 | ||||
-rw-r--r-- | wx+/graph.h | 2 | ||||
-rw-r--r-- | wx+/grid.cpp | 7 | ||||
-rw-r--r-- | wx+/grid.h | 2 | ||||
-rw-r--r-- | wx+/image_tools.h | 2 | ||||
-rw-r--r-- | wx+/mouse_move_dlg.cpp | 2 | ||||
-rw-r--r-- | wx+/mouse_move_dlg.h | 2 | ||||
-rw-r--r-- | wx+/no_flicker.h | 2 | ||||
-rw-r--r-- | wx+/pch.h | 2 | ||||
-rw-r--r-- | wx+/rtl.h | 2 | ||||
-rw-r--r-- | wx+/shell_execute.h | 2 | ||||
-rw-r--r-- | wx+/string_conv.h | 2 | ||||
-rw-r--r-- | wx+/timespan.h | 2 | ||||
-rw-r--r-- | wx+/toggle_button.h | 2 | ||||
-rw-r--r-- | wx+/tooltip.cpp | 2 | ||||
-rw-r--r-- | wx+/tooltip.h | 2 | ||||
-rw-r--r-- | wx+/zlib_wrap.cpp | 2 | ||||
-rw-r--r-- | wx+/zlib_wrap.h | 95 |
28 files changed, 97 insertions, 120 deletions
diff --git a/wx+/app_main.h b/wx+/app_main.h index 0177fbf3..47331982 100644 --- a/wx+/app_main.h +++ b/wx+/app_main.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef APPMAIN_H_INCLUDED diff --git a/wx+/button.cpp b/wx+/button.cpp index 0b193cfb..c710c158 100644 --- a/wx+/button.cpp +++ b/wx+/button.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "button.h" diff --git a/wx+/button.h b/wx+/button.h index bf741945..89e376a2 100644 --- a/wx+/button.h +++ b/wx+/button.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef CUSTOMBUTTON_H_INCLUDED diff --git a/wx+/choice_enum.h b/wx+/choice_enum.h index e12c7a9b..e591a67f 100644 --- a/wx+/choice_enum.h +++ b/wx+/choice_enum.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WX_CHOICE_ENUM_H_INCLUDED @@ -19,9 +19,9 @@ Member variable: Constructor code: enumDescrMap. - add(ON_ERROR_POPUP , _("Show pop-up") , _("Show pop-up on errors or warnings")). - add(ON_ERROR_IGNORE, _("Ignore errors") , _("Hide all error and warning messages")). - add(ON_ERROR_EXIT , _("Exit instantly"), _("Abort synchronization immediately")); + add(ON_ERROR_POPUP , "Show pop-up" , "Show pop-up on errors or warnings"). <- add localization + add(ON_ERROR_IGNORE, "Ignore errors" , "Hide all error and warning messages"). + add(ON_ERROR_EXIT , "Exit instantly", "Abort synchronization immediately"); Set enum value: setEnumVal(enumDescrMap, *m_choiceHandleError, value); diff --git a/wx+/context_menu.h b/wx+/context_menu.h index 9f2f844b..a2534291 100644 --- a/wx+/context_menu.h +++ b/wx+/context_menu.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef CONTEXT_HEADER_18047302153418174632141234 diff --git a/wx+/create_pch.cpp b/wx+/create_pch.cpp index a9b2ea37..406ce5b4 100644 --- a/wx+/create_pch.cpp +++ b/wx+/create_pch.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** //dummy file for Visual Studio to compile precompiled header: diff --git a/wx+/dir_picker.h b/wx+/dir_picker.h deleted file mode 100644 index 51bd9757..00000000 --- a/wx+/dir_picker.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef DIR_PICKER_I18N_H_INCLUDED -#define DIR_PICKER_I18N_H_INCLUDED - -#include <wx/filepicker.h> -#include <zen/i18n.h> - -namespace zen -{ -class DirPickerCtrl : public wxDirPickerCtrl -{ -public: - DirPickerCtrl(wxWindow* parent, wxWindowID id, - const wxString& path = wxEmptyString, - const wxString& message = wxDirSelectorPromptStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDIRP_DEFAULT_STYLE, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDirPickerCtrlNameStr) : - wxDirPickerCtrl(parent, id, path, message, pos, size, style, validator, name) - { -#ifdef FFS_WIN - //fix wxWidgets localization gap: - wxButton* button = dynamic_cast<wxButton*>(m_pickerIface); - if (button) - { - button->SetLabel(_("Browse")); //button width needs to be adapted for very long translations - SetMinSize(button->GetBestSize()); //SetSize and wxButton::SetSize just do nothing!!?? - } -#endif - } -}; -} - -#endif // DIR_PICKER_I18N_H_INCLUDED diff --git a/wx+/file_drop.h b/wx+/file_drop.h index cdb19f4b..1d905c7a 100644 --- a/wx+/file_drop.h +++ b/wx+/file_drop.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILE_DROP_H_INCLUDED diff --git a/wx+/format_unit.cpp b/wx+/format_unit.cpp index 9d805f41..a2190397 100644 --- a/wx+/format_unit.cpp +++ b/wx+/format_unit.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "format_unit.h" @@ -133,7 +133,7 @@ std::wstring zen::remainingTimeToShortString(double timeInSec) std::wstring zen::fractionToShortString(double fraction) { //return replaceCpy(_("%x%"), L"%x", printNumber<std::wstring>(L"%3.2f", fraction * 100.0), false); - return printNumber<std::wstring>(L"%3.2f", fraction * 100.0) + L'%'; //no need to internationalize faction!? + return printNumber<std::wstring>(L"%3.2f", fraction * 100.0) + L'%'; //no need to internationalize fraction!? } @@ -182,9 +182,10 @@ private: IntegerFormat() : fmt(), valid_(false) { - //all we want is default NUMBERFMT, but set NumDigits to 0. what a disgrace: + //all we want is default NUMBERFMT, but set NumDigits to 0 fmt.NumDigits = 0; + //what a disgrace: std::wstring grouping; if (getUserSetting(LOCALE_ILZERO, fmt.LeadingZero) && getUserSetting(LOCALE_SGROUPING, grouping) && @@ -241,8 +242,8 @@ std::wstring zen::ffs_Impl::includeNumberSeparator(const std::wstring& number) //::setlocale (LC_ALL, ""); -> implicitly called by wxLocale const lconv* localInfo = ::localeconv(); //always bound according to doc const std::wstring& thousandSep = utfCvrtTo<std::wstring>(localInfo->thousands_sep); - // why not working? - // THOUSANDS_SEPARATOR = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).thousands_sep(); + + // THOUSANDS_SEPARATOR = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).thousands_sep(); - why not working? // DECIMAL_POINT = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).decimal_point(); std::wstring output(number); @@ -293,6 +294,8 @@ const bool useNewLocalTimeCalculation = zen::vistaOrLater(); std::wstring zen::utcToLocalTimeString(Int64 utcTime) { + auto errorMsg = [&] { return _("Error") + L" (time_t: " + numberTo<std::wstring>(utcTime) + L")"; }; + #ifdef FFS_WIN FILETIME lastWriteTimeUtc = tofiletime(utcTime); //convert ansi C time to FILETIME @@ -303,23 +306,23 @@ std::wstring zen::utcToLocalTimeString(Int64 utcTime) SYSTEMTIME systemTimeUtc = {}; if (!::FileTimeToSystemTime(&lastWriteTimeUtc, //__in const FILETIME *lpFileTime, &systemTimeUtc)) //__out LPSYSTEMTIME lpSystemTime - return _("Error"); + return errorMsg(); if (!::SystemTimeToTzSpecificLocalTime(nullptr, //__in_opt LPTIME_ZONE_INFORMATION lpTimeZone, &systemTimeUtc, //__in LPSYSTEMTIME lpUniversalTime, &systemTimeLocal)) //__out LPSYSTEMTIME lpLocalTime - return _("Error"); + return errorMsg(); } else //use DST setting (like in Windows 2000 and XP) { FILETIME fileTimeLocal = {}; if (!::FileTimeToLocalFileTime(&lastWriteTimeUtc, //pointer to UTC file time to convert &fileTimeLocal)) //pointer to converted file time - return _("Error"); + return errorMsg(); if (!::FileTimeToSystemTime(&fileTimeLocal, //pointer to file time to convert &systemTimeLocal)) //pointer to structure to receive system time - return _("Error"); + return errorMsg(); } zen::TimeComp loc; @@ -334,5 +337,6 @@ std::wstring zen::utcToLocalTimeString(Int64 utcTime) zen::TimeComp loc = zen::localTime(to<time_t>(utcTime)); #endif - return formatTime<std::wstring>(L"%x %X", loc); + std::wstring dateString = formatTime<std::wstring>(L"%x %X", loc); + return !dateString.empty() ? dateString : errorMsg(); } diff --git a/wx+/format_unit.h b/wx+/format_unit.h index 361e7d86..6d29d9a8 100644 --- a/wx+/format_unit.h +++ b/wx+/format_unit.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef UTIL_H_INCLUDED @@ -20,7 +20,7 @@ std::wstring fractionToShortString(double fraction); //within [0, 1] template <class NumberType> std::wstring toGuiString(NumberType number); //format integer number including thousands separator -std::wstring utcToLocalTimeString(Int64 utcTime); //throw std::runtime_error +std::wstring utcToLocalTimeString(Int64 utcTime); diff --git a/wx+/graph.cpp b/wx+/graph.cpp index 6ba794b0..b69173bb 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "graph.h" diff --git a/wx+/graph.h b/wx+/graph.h index 70da5dc3..d500dcc0 100644 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WX_PLOT_HEADER_2344252459 diff --git a/wx+/grid.cpp b/wx+/grid.cpp index 33419c8e..5f49b9fa 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "grid.h" @@ -2126,11 +2126,12 @@ void Grid::setColWidthAndNotify(ptrdiff_t width, size_t col, size_t compPos, boo const ptrdiff_t offset = width - getColStretchedWidth(vcRs.stretch_, stretchTotal, mainWinWidth); //width := stretchedWidth + (normalized) offset vcRs.offset_ = offset; + //CAVEAT: //I. width may be < COLUMN_MIN_WIDTH: for non-stretched columns this doesn't matter, since it's normalized in getColWidths() anyway, // for stretched columns on the other hand negative width would be evaluated *before* normalization! => need to normalize here! //II. worse: resizing any column should normalize *all* other stretched columns' offsets considering current mainWinWidth! - // Testcase: 1. make main window so small in width that horizontal scrollbars are shown despite existing streched column. - // 2. resize a fixed size column so that scrollbars vanish. 3. verify that the stretched column is resizing immediately while main dialog is enlarged + // Testcase: 1. make main window so small in width that horizontal scrollbars are shown despite existing streched column. + // 2. resize a fixed size column so that scrollbars vanish. 3. verify that the stretched column is resizing immediately while main dialog is enlarged std::for_each(comp.begin(), comp.end(), [&](Component& c) { std::for_each(c.visibleCols.begin(), c.visibleCols.end(), [&](VisibleColumn& vc) @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef GENERIC_GRID_HEADER_83470213483173 diff --git a/wx+/image_tools.h b/wx+/image_tools.h index 772189a6..c5011634 100644 --- a/wx+/image_tools.h +++ b/wx+/image_tools.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef IMAGE_TOOLS_HEADER_45782456427634254 diff --git a/wx+/mouse_move_dlg.cpp b/wx+/mouse_move_dlg.cpp index 697a5d47..72e464d6 100644 --- a/wx+/mouse_move_dlg.cpp +++ b/wx+/mouse_move_dlg.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "mouse_move_dlg.h" diff --git a/wx+/mouse_move_dlg.h b/wx+/mouse_move_dlg.h index 142dac49..29e62cd9 100644 --- a/wx+/mouse_move_dlg.h +++ b/wx+/mouse_move_dlg.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef MOUSEMOVEWINDOW_H_INCLUDED diff --git a/wx+/no_flicker.h b/wx+/no_flicker.h index 22952977..d96e0134 100644 --- a/wx+/no_flicker.h +++ b/wx+/no_flicker.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef NO_FLICKER_HEADER_893421590321532 @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FFS_PRECOMPILED_HEADER @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef RTL_H_0183487180058718273432148 diff --git a/wx+/shell_execute.h b/wx+/shell_execute.h index 953efc43..62b6ab41 100644 --- a/wx+/shell_execute.h +++ b/wx+/shell_execute.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef EXECUTE_HEADER_23482134578134134 diff --git a/wx+/string_conv.h b/wx+/string_conv.h index ba6f8d48..815cf881 100644 --- a/wx+/string_conv.h +++ b/wx+/string_conv.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef STRINGCONV_H_INCLUDED diff --git a/wx+/timespan.h b/wx+/timespan.h index 58d5df4e..56f0a2db 100644 --- a/wx+/timespan.h +++ b/wx+/timespan.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WX_TIMESPAN_CTRL_HEADER_INCLUDED diff --git a/wx+/toggle_button.h b/wx+/toggle_button.h index 74f90974..d213e024 100644 --- a/wx+/toggle_button.h +++ b/wx+/toggle_button.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef TOGGLEBUTTON_H_INCLUDED diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp index 6d81cdae..fdb62618 100644 --- a/wx+/tooltip.cpp +++ b/wx+/tooltip.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "tooltip.h" diff --git a/wx+/tooltip.h b/wx+/tooltip.h index 195ceaf7..127ad86c 100644 --- a/wx+/tooltip.h +++ b/wx+/tooltip.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef CUSTOMTOOLTIP_H_INCLUDED diff --git a/wx+/zlib_wrap.cpp b/wx+/zlib_wrap.cpp index a27a4fa4..fa0c54f0 100644 --- a/wx+/zlib_wrap.cpp +++ b/wx+/zlib_wrap.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "zlib_wrap.h" diff --git a/wx+/zlib_wrap.h b/wx+/zlib_wrap.h index c229a589..9fa50240 100644 --- a/wx+/zlib_wrap.h +++ b/wx+/zlib_wrap.h @@ -1,7 +1,7 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * // * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef SIMPLE_H_INCLUDED_18134135134135345489 @@ -55,27 +55,28 @@ template <class BinContainer> BinContainer compress(const BinContainer& stream, int level) //throw ZlibInternalError { BinContainer contOut; - - //save uncompressed stream size for decompression - const std::uint64_t uncompressedSize = stream.size(); //use portable number type! - contOut.resize(sizeof(uncompressedSize)); - std::copy(reinterpret_cast<const char*>(&uncompressedSize), - reinterpret_cast<const char*>(&uncompressedSize) + sizeof(uncompressedSize), - &*contOut.begin()); - - const size_t bufferEstimate = impl::zlib_compressBound(stream.size()); //upper limit for buffer size, larger than input size!!! - - contOut.resize(contOut.size() + bufferEstimate); - - const size_t bytesWritten = impl::zlib_compress(&*stream.begin(), - stream.size(), - &*contOut.begin() + contOut.size() - bufferEstimate, - bufferEstimate, - level); //throw ZlibInternalError - if (bytesWritten < bufferEstimate) - contOut.resize(contOut.size() - (bufferEstimate - bytesWritten)); //caveat: unsigned arithmetics - //caveat: physical memory consumption still *unchanged*! - + if (!stream.empty()) //don't dereference iterator into empty container! + { + //save uncompressed stream size for decompression + const std::uint64_t uncompressedSize = stream.size(); //use portable number type! + contOut.resize(sizeof(uncompressedSize)); + std::copy(reinterpret_cast<const char*>(&uncompressedSize), + reinterpret_cast<const char*>(&uncompressedSize) + sizeof(uncompressedSize), + &*contOut.begin()); + + const size_t bufferEstimate = impl::zlib_compressBound(stream.size()); //upper limit for buffer size, larger than input size!!! + + contOut.resize(contOut.size() + bufferEstimate); + + const size_t bytesWritten = impl::zlib_compress(&*stream.begin(), + stream.size(), + &*contOut.begin() + contOut.size() - bufferEstimate, + bufferEstimate, + level); //throw ZlibInternalError + if (bytesWritten < bufferEstimate) + contOut.resize(contOut.size() - (bufferEstimate - bytesWritten)); //caveat: unsigned arithmetics + //caveat: physical memory consumption still *unchanged*! + } return contOut; } @@ -83,31 +84,37 @@ BinContainer compress(const BinContainer& stream, int level) //throw ZlibInterna template <class BinContainer> BinContainer decompress(const BinContainer& stream) //throw ZlibInternalError { - //retrieve size of uncompressed data - std::uint64_t uncompressedSize = 0; //use portable number type! - if (stream.size() < sizeof(uncompressedSize)) - throw ZlibInternalError(); - std::copy(&*stream.begin(), - &*stream.begin() + sizeof(uncompressedSize), - reinterpret_cast<char*>(&uncompressedSize)); - BinContainer contOut; - try - { - contOut.resize(uncompressedSize); //throw std::bad_alloc - } - catch (std::bad_alloc&) //most likely due to data corruption! + if (!stream.empty()) //don't dereference iterator into empty container! { - throw ZlibInternalError(); + //retrieve size of uncompressed data + std::uint64_t uncompressedSize = 0; //use portable number type! + if (stream.size() < sizeof(uncompressedSize)) + throw ZlibInternalError(); + std::copy(&*stream.begin(), + &*stream.begin() + sizeof(uncompressedSize), + reinterpret_cast<char*>(&uncompressedSize)); + try + { + //attention: contOut MUST NOT be empty! Else it will pass a nullptr to zlib_decompress() => Z_STREAM_ERROR although "uncompressedSize == 0"!!! + //secondary bug: don't dereference iterator into empty container! + if (uncompressedSize == 0) //cannot be 0: compress() directly maps empty -> empty container skipping zlib! + throw ZlibInternalError(); + + contOut.resize(uncompressedSize); //throw std::bad_alloc + } + catch (std::bad_alloc&) //most likely due to data corruption! + { + throw ZlibInternalError(); + } + + const size_t bytesWritten = impl::zlib_decompress(&*stream.begin() + sizeof(uncompressedSize), + stream.size() - sizeof(uncompressedSize), + &*contOut.begin(), + uncompressedSize); //throw ZlibInternalError + if (bytesWritten != uncompressedSize) + throw ZlibInternalError(); } - - const size_t bytesWritten = impl::zlib_decompress(&*stream.begin() + sizeof(uncompressedSize), - stream.size() - sizeof(uncompressedSize), - &*contOut.begin(), - uncompressedSize); //throw ZlibInternalError - if (bytesWritten != uncompressedSize) - throw ZlibInternalError(); - return contOut; } } |