summarylogtreecommitdiffstats
path: root/fmt-update.patch
blob: dd0aeca8adf367a1615147e6feb01b791e65f360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
From 9efe4231660b564090c0c56c1dc9ed77fa9192bf Mon Sep 17 00:00:00 2001
From: Henri Gasc <gasc@eurecom.fr>
Date: Fri, 9 May 2025 18:37:06 +0200
Subject: [PATCH 1/2] Update libfmt to 11.2.0

---
 lib/libimhex/source/helpers/logger.cpp                     | 4 ++--
 main/gui/source/init/splash_window.cpp                     | 2 +-
 plugins/builtin/source/content/data_inspector.cpp          | 6 +++---
 plugins/builtin/source/content/providers/file_provider.cpp | 6 +++---
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp
index 46caa5b681069..d6c53c1a7be31 100644
--- a/lib/libimhex/source/helpers/logger.cpp
+++ b/lib/libimhex/source/helpers/logger.cpp
@@ -83,7 +83,7 @@ namespace hex::log {

             for (const auto &path : paths::Logs.all()) {
                 wolv::io::fs::createDirectories(path);
-                s_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", fmt::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()))), wolv::io::File::Mode::Create);
+                s_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", std::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()))), wolv::io::File::Mode::Create);
                 s_loggerFile.disableBuffering();

                 if (s_loggerFile.isValid()) {
@@ -120,7 +120,7 @@ namespace hex::log {


         void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level, const char *projectName) {
-            const auto now = fmt::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
+            const auto now = std::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));

             fmt::print(dest, "[{0:%H:%M:%S}] ", now);

diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp
index ffec4b44aea66..5ba6bee045c17 100644
--- a/main/gui/source/init/splash_window.cpp
+++ b/main/gui/source/init/splash_window.cpp
@@ -111,7 +111,7 @@ namespace hex::init {
                 const auto now = std::chrono::system_clock::now();
                 const auto time = std::chrono::system_clock::to_time_t(now);

-                return fmt::localtime(time);
+                return std::localtime(time);
             }();

             for (const auto &colorConfig : highlightConfig) {
diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp
index f4b2b5af598e8..43e959aad5cb0 100644
--- a/plugins/builtin/source/content/data_inspector.cpp
+++ b/plugins/builtin/source/content/data_inspector.cpp
@@ -625,7 +625,7 @@ namespace hex::plugin::builtin {

             std::string value;
             try {
-                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", fmt::localtime(endianAdjustedTime));
+                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", std::localtime(endianAdjustedTime));
             } catch (fmt::format_error &) {
                 value = "Invalid";
             }
@@ -640,7 +640,7 @@ namespace hex::plugin::builtin {

             std::string value;
             try {
-                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", fmt::localtime(endianAdjustedTime));
+                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", std::localtime(endianAdjustedTime));
             } catch (fmt::format_error &) {
                 value = "Invalid";
             }
@@ -657,7 +657,7 @@ namespace hex::plugin::builtin {

             std::string value;
             try {
-                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", fmt::localtime(endianAdjustedTime));
+                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", std::localtime(endianAdjustedTime));
             } catch (fmt::format_error &e) {
                 value = "Invalid";
             }
diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp
index c53a9a2632a5e..14461a6b34dc9 100644
--- a/plugins/builtin/source/content/providers/file_provider.cpp
+++ b/plugins/builtin/source/content/providers/file_provider.cpp
@@ -135,13 +135,13 @@ namespace hex::plugin::builtin {
         if (m_fileStats.has_value()) {
             std::string creationTime, accessTime, modificationTime;

-            try { creationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(m_fileStats->st_ctime)); }
+            try { creationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", std::localtime(m_fileStats->st_ctime)); }
             catch (const std::exception&) { creationTime = "???"; }

-            try { accessTime = hex::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(m_fileStats->st_atime)); }
+            try { accessTime = hex::format("{:%Y-%m-%d %H:%M:%S}", std::localtime(m_fileStats->st_atime)); }
             catch (const std::exception&) { accessTime = "???"; }

-            try { modificationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(m_fileStats->st_mtime)); }
+            try { modificationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", std::localtime(m_fileStats->st_mtime)); }
             catch (const std::exception&) { modificationTime = "???"; }

             result.emplace_back("hex.builtin.provider.file.creation"_lang,      creationTime);

From a683fa96f399a2eda782ea2c23582ed609ed3ee2 Mon Sep 17 00:00:00 2001
From: Nik <werwolv98@gmail.com>
Date: Fri, 9 May 2025 18:52:56 +0200
Subject: [PATCH 2/2] Fixed function interface, catch correct exception

---
 lib/libimhex/source/helpers/logger.cpp               |  6 ++++--
 main/gui/source/init/splash_window.cpp               |  2 +-
 plugins/builtin/source/content/data_inspector.cpp    | 12 ++++++------
 .../source/content/providers/file_provider.cpp       | 12 ++++++------
 4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp
index d6c53c1a7be31..797fc41810401 100644
--- a/lib/libimhex/source/helpers/logger.cpp
+++ b/lib/libimhex/source/helpers/logger.cpp
@@ -83,7 +83,8 @@ namespace hex::log {

             for (const auto &path : paths::Logs.all()) {
                 wolv::io::fs::createDirectories(path);
-                s_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", std::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()))), wolv::io::File::Mode::Create);
+                time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
+                s_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", *std::localtime(&time)), wolv::io::File::Mode::Create);
                 s_loggerFile.disableBuffering();

                 if (s_loggerFile.isValid()) {
@@ -120,7 +121,8 @@ namespace hex::log {


         void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level, const char *projectName) {
-            const auto now = std::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
+            const auto time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
+            const auto now = *std::localtime(&time);

             fmt::print(dest, "[{0:%H:%M:%S}] ", now);

diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp
index 5ba6bee045c17..eb69fc945082b 100644
--- a/main/gui/source/init/splash_window.cpp
+++ b/main/gui/source/init/splash_window.cpp
@@ -111,7 +111,7 @@ namespace hex::init {
                 const auto now = std::chrono::system_clock::now();
                 const auto time = std::chrono::system_clock::to_time_t(now);

-                return std::localtime(time);
+                return *std::localtime(&time);
             }();

             for (const auto &colorConfig : highlightConfig) {
diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp
index 43e959aad5cb0..470f738d7c72f 100644
--- a/plugins/builtin/source/content/data_inspector.cpp
+++ b/plugins/builtin/source/content/data_inspector.cpp
@@ -621,11 +621,11 @@ namespace hex::plugin::builtin {
         ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(u32), [](auto buffer, auto endian, auto style) {
             std::ignore = style;

-            auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<u32 *>(buffer.data()), endian);
+            time_t endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<u32 *>(buffer.data()), endian);

             std::string value;
             try {
-                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", std::localtime(endianAdjustedTime));
+                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *std::localtime(&endianAdjustedTime));
             } catch (fmt::format_error &) {
                 value = "Invalid";
             }
@@ -636,11 +636,11 @@ namespace hex::plugin::builtin {
         ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(u64), [](auto buffer, auto endian, auto style) {
             std::ignore = style;

-            auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<u64 *>(buffer.data()), endian);
+            time_t endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<u64 *>(buffer.data()), endian);

             std::string value;
             try {
-                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", std::localtime(endianAdjustedTime));
+                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *std::localtime(&endianAdjustedTime));
             } catch (fmt::format_error &) {
                 value = "Invalid";
             }
@@ -653,11 +653,11 @@ namespace hex::plugin::builtin {
         ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
             std::ignore = style;

-            auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<time_t *>(buffer.data()), endian);
+            time_t endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<time_t *>(buffer.data()), endian);

             std::string value;
             try {
-                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", std::localtime(endianAdjustedTime));
+                value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *std::localtime(&endianAdjustedTime));
             } catch (fmt::format_error &e) {
                 value = "Invalid";
             }
diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp
index 14461a6b34dc9..e2dde4fa40a95 100644
--- a/plugins/builtin/source/content/providers/file_provider.cpp
+++ b/plugins/builtin/source/content/providers/file_provider.cpp
@@ -135,14 +135,14 @@ namespace hex::plugin::builtin {
         if (m_fileStats.has_value()) {
             std::string creationTime, accessTime, modificationTime;

-            try { creationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", std::localtime(m_fileStats->st_ctime)); }
-            catch (const std::exception&) { creationTime = "???"; }
+            try { creationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_ctime)); }
+            catch (const fmt::format_error&) { creationTime = "???"; }

-            try { accessTime = hex::format("{:%Y-%m-%d %H:%M:%S}", std::localtime(m_fileStats->st_atime)); }
-            catch (const std::exception&) { accessTime = "???"; }
+            try { accessTime = hex::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_atime)); }
+            catch (const fmt::format_error&) { accessTime = "???"; }

-            try { modificationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", std::localtime(m_fileStats->st_mtime)); }
-            catch (const std::exception&) { modificationTime = "???"; }
+            try { modificationTime = hex::format("{:%Y-%m-%d %H:%M:%S}", *std::localtime(&m_fileStats->st_mtime)); }
+            catch (const fmt::format_error&) { modificationTime = "???"; }

             result.emplace_back("hex.builtin.provider.file.creation"_lang,      creationTime);
             result.emplace_back("hex.builtin.provider.file.access"_lang,        accessTime);