From fc71e66e5186fb75206290deca2b9a6cfbefa9ac Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sat, 12 Jun 2021 09:59:08 -0400 Subject: add upstream 11.11 --- zen/file_access.cpp | 2 +- zen/i18n.h | 2 +- zen/legacy_compiler.h | 6 ------ zen/string_base.h | 4 ++-- zen/string_tools.h | 3 +-- zen/time.h | 14 ++++++++++++++ 6 files changed, 19 insertions(+), 12 deletions(-) (limited to 'zen') diff --git a/zen/file_access.cpp b/zen/file_access.cpp index fb770f19..db4f2505 100644 --- a/zen/file_access.cpp +++ b/zen/file_access.cpp @@ -668,7 +668,7 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target /* we cannot set the target file times (::futimes) while the file descriptor is still open after a write operation: this triggers bugs on Samba shares where the modification time is set to current time instead. Linux: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=340236 - http://comments.gmane.org/gmane.linux.file-systems.cifs/2854 + http://comments.gmane.org/gmane.linux.file-systems.cifs/2854 macOS: https://freefilesync.org/forum/viewtopic.php?t=356 */ setWriteTimeNative(targetFile, sourceInfo.st_mtim, ProcSymlink::follow); //throw FileError } diff --git a/zen/i18n.h b/zen/i18n.h index 160b9625..31bb3df8 100644 --- a/zen/i18n.h +++ b/zen/i18n.h @@ -58,7 +58,7 @@ std::shared_ptr getTranslator(); namespace impl { //getTranslator() may be called even after static objects of this translation unit are destroyed! -inline constinit2 Global globalTranslationHandler; +inline constinit Global globalTranslationHandler; } inline diff --git a/zen/legacy_compiler.h b/zen/legacy_compiler.h index 66b750c9..50d340ca 100644 --- a/zen/legacy_compiler.h +++ b/zen/legacy_compiler.h @@ -24,15 +24,9 @@ namespace std { - - } //--------------------------------------------------------------------------------- -//constinit - #define constinit2 constinit //GCC, clang have it - - namespace zen { double fromChars(const char* first, const char* last); diff --git a/zen/string_base.h b/zen/string_base.h index f0899433..5c17fb47 100644 --- a/zen/string_base.h +++ b/zen/string_base.h @@ -10,7 +10,7 @@ #include #include #include "string_tools.h" -#include "legacy_compiler.h" //constinit2 +#include "legacy_compiler.h" //constinit //Zbase - a policy based string class optimizing performance and flexibility @@ -209,7 +209,7 @@ private: static_assert(offsetof(GlobalEmptyString, nullTerm) - offsetof(GlobalEmptyString, descr) == sizeof(Descriptor), "no gap!"); static_assert(std::is_trivially_destructible_v, "this memory needs to live forever"); - inline static constinit2 GlobalEmptyString globalEmptyString; //constinit: dodge static initialization order fiasco! + inline static constinit GlobalEmptyString globalEmptyString; //constinit: dodge static initialization order fiasco! }; diff --git a/zen/string_tools.h b/zen/string_tools.h index 8150df05..5f9273c9 100644 --- a/zen/string_tools.h +++ b/zen/string_tools.h @@ -568,9 +568,8 @@ template inline S printNumber(const T& format, const Num& number) //format a single number using ::sprintf { #ifdef __cpp_lib_format -#error refactor +#error refactor? #endif - static_assert(std::is_same_v, GetCharTypeT>); const int BUFFER_SIZE = 128; diff --git a/zen/time.h b/zen/time.h index b3b903b6..9b5f670e 100644 --- a/zen/time.h +++ b/zen/time.h @@ -159,11 +159,23 @@ TimeComp getUtcTime2(time_t utc) { //1. convert: seconds since year 1: //... + //assert(time_t is signed) //TODO: what if < 0? long long remDays = utc / (24 * 3600); long long remSecs = utc % (24 * 3600); + //days per year + const int dpYearStd = 365; + const int dpYearLeap = dpYearStd + 1; + const int dp4Years = 3 * dpYearStd + dpYearLeap; + const int dp100YearsStd = 25 * dp4Years - 1; //no leap days for centuries... + const int dp100YearsExc = 25 * dp4Years; //...except if divisible by 400 + const int dp400Years = 3 * dp100YearsStd + dp100YearsExc; + + + + const int daysPer4Years = 4 * 365 /*usual days per year*/ + 1 /*including leap day*/; const int daysPerYear = 365; //non-leap const int daysPer100Years = 25 * daysPer4Years - 1; @@ -197,6 +209,8 @@ TimeComp getUtcTime2(time_t utc) + const char daysPerMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + //first four years of century: -- cgit