Browse code

First commit

Qurban Ullah authored on 27/02/2018 17:45:36
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,38 @@
1
+# $Id$
2
+# Maintainer: Qurban Ullah <qurbanullah@avouch.org>
3
+# Contributor: Qurban Ullah <qurbanullah@avouch.org>
4
+
5
+pkgname=cryfs
6
+pkgver=0.9.8
7
+pkgrel=1
8
+pkgdesc="Cryptographic filesystem for the cloud"
9
+arch=(x86_64)
10
+depends=(crypto++ fuse2 curl)
11
+makedepends=(cmake python boost)
12
+url="https://www.cryfs.org"
13
+license=(LGPL3)
14
+source=($pkgname-$pkgver.tar.gz::"https://codeload.github.com/cryfs/$pkgname/tar.gz/$pkgver")
15
+sha256sums=('98f977536ccb3094691ef43682e02c434cc7e606f1926c6c588b70c0c298f86f')
16
+
17
+prepare() {
18
+  mkdir -p build
19
+}
20
+
21
+build() {
22
+  cd build
23
+
24
+  cmake ../ \
25
+    -DCMAKE_INSTALL_PREFIX=/usr \
26
+    -DCMAKE_BUILD_TYPE=Release \
27
+    -DBUILD_TESTING=OFF \
28
+    -DCRYFS_UPDATE_CHECKS=OFF
29
+  make ${MAKEFLAGS}
30
+}
31
+
32
+package() {
33
+  cd build
34
+  make DESTDIR="$pkgdir" install
35
+
36
+  install -Dm 644 "$srcdir"/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
37
+  install -Dm 644 "$srcdir"/README.md -t "$pkgdir"/usr/share/doc/$pkgname
38
+}
0 39
new file mode 100644
... ...
@@ -0,0 +1,4835 @@
1
+diff --git a/vendor/README b/vendor/README
2
+index c3056600..7ca85751 100644
3
+--- a/vendor/README
4
+@@ -1,4 +1,4 @@
5
+ This directory contains external projects, taken from the following locations:
6
+ scrypt: http://www.tarsnap.com/scrypt.html
7
+ googletest: https://github.com/google/googletest/tree/release-1.8.0
8
+-spdlog: https://github.com/gabime/spdlog/tree/v0.11.0/include/spdlog
9
++spdlog: https://github.com/gabime/spdlog/tree/v0.12.0/include/spdlog
10
+diff --git a/vendor/spdlog/spdlog/common.h b/vendor/spdlog/spdlog/common.h
11
+index 490deec7..a0a227ef 100644
12
+--- a/vendor/spdlog/spdlog/common.h
13
+@@ -30,11 +30,11 @@
14
+ #endif
15
+ 
16
+ #if defined(__GNUC__)  || defined(__clang__)
17
+-#define DEPRECATED __attribute__((deprecated))
18
++#define SPDLOG_DEPRECATED __attribute__((deprecated))
19
+ #elif defined(_MSC_VER)
20
+-#define DEPRECATED __declspec(deprecated)
21
++#define SPDLOG_DEPRECATED __declspec(deprecated)
22
+ #else
23
+-#define DEPRECATED
24
++#define SPDLOG_DEPRECATED
25
+ #endif
26
+ 
27
+ 
28
+@@ -57,7 +57,7 @@ using formatter_ptr = std::shared_ptr<spdlog::formatter>;
29
+ #if defined(SPDLOG_NO_ATOMIC_LEVELS)
30
+ using level_t = details::null_atomic_int;
31
+ #else
32
+-using level_t = std::atomic_int;
33
++using level_t = std::atomic<int>;
34
+ #endif
35
+ 
36
+ using log_err_handler = std::function<void(const std::string &err_msg)>;
37
+diff --git a/vendor/spdlog/spdlog/details/async_log_helper.h b/vendor/spdlog/spdlog/details/async_log_helper.h
38
+index 7e9b3eb1..deb8dcc6 100644
39
+--- a/vendor/spdlog/spdlog/details/async_log_helper.h
40
+@@ -67,7 +67,7 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
41
+         {}
42
+ 
43
+         async_msg(async_msg_type m_type) :msg_type(m_type)
44
+-        {};
45
++        {}
46
+ 
47
+         async_msg& operator=(async_msg&& other) SPDLOG_NOEXCEPT
48
+         {
49
+@@ -82,7 +82,7 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
50
+ 
51
+         // never copy or assign. should only be moved..
52
+         async_msg(const async_msg&) = delete;
53
+-        async_msg& operator=(async_msg& other) = delete;
54
++        async_msg& operator=(const async_msg& other) = delete;
55
+ 
56
+         // construct from log_msg
57
+         async_msg(const details::log_msg& m) :
58
+@@ -229,8 +229,6 @@ inline spdlog::details::async_log_helper::~async_log_helper()
59
+ inline void spdlog::details::async_log_helper::log(const details::log_msg& msg)
60
+ {
61
+     push_msg(async_msg(msg));
62
+-
63
+-
64
+ }
65
+ 
66
+ inline void spdlog::details::async_log_helper::push_msg(details::async_log_helper::async_msg&& new_msg)
67
+@@ -246,7 +244,6 @@ inline void spdlog::details::async_log_helper::push_msg(details::async_log_helpe
68
+         }
69
+         while (!_q.enqueue(std::move(new_msg)));
70
+     }
71
+-
72
+ }
73
+ 
74
+ // optionally wait for the queue be empty and request flush from the sinks
75
+@@ -281,10 +278,8 @@ inline void spdlog::details::async_log_helper::worker_loop()
76
+ // return true if this thread should still be active (while no terminate msg was received)
77
+ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush)
78
+ {
79
+-
80
+     async_msg incoming_async_msg;
81
+ 
82
+-
83
+     if (_q.dequeue(incoming_async_msg))
84
+     {
85
+         last_pop = details::os::now();
86
+@@ -359,8 +354,7 @@ inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_
87
+ 
88
+     // yield upto 150 micros
89
+     if (time_since_op <= microseconds(100))
90
+-        return yield();
91
+-
92
++        return std::this_thread::yield();
93
+ 
94
+     // sleep for 20 ms upto 200 ms
95
+     if (time_since_op <= milliseconds(200))
96
+@@ -378,13 +372,7 @@ inline void spdlog::details::async_log_helper::wait_empty_q()
97
+     {
98
+         sleep_or_yield(details::os::now(), last_op);
99
+     }
100
+-
101
+ }
102
+ 
103
+ 
104
+ 
105
+-
106
+-
107
+-
108
+-
109
+-
110
+diff --git a/vendor/spdlog/spdlog/details/async_logger_impl.h b/vendor/spdlog/spdlog/details/async_logger_impl.h
111
+index 736d2e31..2092f06c 100644
112
+--- a/vendor/spdlog/spdlog/details/async_logger_impl.h
113
+@@ -31,13 +31,13 @@ inline spdlog::async_logger::async_logger(const std::string& logger_name,
114
+ }
115
+ 
116
+ inline spdlog::async_logger::async_logger(const std::string& logger_name,
117
+-        sinks_init_list sinks,
118
++        sinks_init_list sinks_list,
119
+         size_t queue_size,
120
+         const  async_overflow_policy overflow_policy,
121
+         const std::function<void()>& worker_warmup_cb,
122
+         const std::chrono::milliseconds& flush_interval_ms,
123
+         const std::function<void()>& worker_teardown_cb) :
124
+-    async_logger(logger_name, sinks.begin(), sinks.end(), queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
125
++    async_logger(logger_name, sinks_list.begin(), sinks_list.end(), queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
126
+ 
127
+ inline spdlog::async_logger::async_logger(const std::string& logger_name,
128
+         sink_ptr single_sink,
129
+diff --git a/vendor/spdlog/spdlog/details/file_helper.h b/vendor/spdlog/spdlog/details/file_helper.h
130
+index 2e6ce9d2..074d9b83 100644
131
+--- a/vendor/spdlog/spdlog/details/file_helper.h
132
+@@ -32,7 +32,7 @@ class file_helper
133
+     const int open_interval = 10;
134
+ 
135
+     explicit file_helper() :
136
+-        _fd(nullptr)        
137
++        _fd(nullptr)
138
+     {}
139
+ 
140
+     file_helper(const file_helper&) = delete;
141
+@@ -89,7 +89,7 @@ class file_helper
142
+         size_t msg_size = msg.formatted.size();
143
+         auto data = msg.formatted.data();
144
+         if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
145
+-            throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);        
146
++            throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
147
+     }
148
+ 
149
+     size_t size()
150
+@@ -112,7 +112,7 @@ class file_helper
151
+ 
152
+ private:
153
+     FILE* _fd;
154
+-    filename_t _filename;    
155
++    filename_t _filename;
156
+ };
157
+ }
158
+ }
159
+diff --git a/vendor/spdlog/spdlog/details/logger_impl.h b/vendor/spdlog/spdlog/details/logger_impl.h
160
+index a337b359..2b27f105 100644
161
+--- a/vendor/spdlog/spdlog/details/logger_impl.h
162
+@@ -291,3 +291,8 @@ inline bool spdlog::logger::_should_flush_on(const details::log_msg &msg)
163
+     const auto flush_level = _flush_level.load(std::memory_order_relaxed);
164
+     return (msg.level >= flush_level) && (msg.level != level::off);
165
+ }
166
++
167
++inline const std::vector<spdlog::sink_ptr>& spdlog::logger::sinks() const
168
++{
169
++    return _sinks;
170
++}
171
+diff --git a/vendor/spdlog/spdlog/details/os.h b/vendor/spdlog/spdlog/details/os.h
172
+index ed4f45cd..b63ce667 100644
173
+--- a/vendor/spdlog/spdlog/details/os.h
174
+@@ -10,10 +10,12 @@
175
+ #include <ctime>
176
+ #include <functional>
177
+ #include <string>
178
++#include <chrono>
179
++#include <thread>
180
+ #include <stdio.h>
181
+ #include <string.h>
182
+ #include <sys/stat.h>
183
+-
184
++#include <sys/types.h>
185
+ 
186
+ #ifdef _WIN32
187
+ 
188
+@@ -25,27 +27,32 @@
189
+ #define WIN32_LEAN_AND_MEAN
190
+ #endif
191
+ #include <windows.h>
192
++#include <process.h> //  _get_pid support
193
++#include <io.h> // _get_osfhandle support
194
+ 
195
+ #ifdef __MINGW32__
196
+ #include <share.h>
197
+ #endif
198
+ 
199
+-#include <sys/types.h>
200
++#else // unix
201
+ 
202
+-#elif __linux__
203
++#include <unistd.h>
204
++#include <fcntl.h>
205
+ 
206
++#ifdef __linux__
207
+ #include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
208
+-#include <unistd.h>
209
+-#include <chrono>
210
+ 
211
+ #elif __FreeBSD__
212
+ #include <sys/thr.h> //Use thr_self() syscall under FreeBSD to get thread id
213
++#endif
214
+ 
215
+-#else
216
+-#include <thread>
217
++#endif //unix
218
+ 
219
++#ifndef __has_feature       // Clang - feature checking macros.
220
++#define __has_feature(x) 0  // Compatibility with non-clang compilers.
221
+ #endif
222
+ 
223
++
224
+ namespace spdlog
225
+ {
226
+ namespace details
227
+@@ -135,6 +142,18 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
228
+ SPDLOG_CONSTEXPR static const char* eol = SPDLOG_EOL;
229
+ SPDLOG_CONSTEXPR static int eol_size = sizeof(SPDLOG_EOL) - 1;
230
+ 
231
++inline void prevent_child_fd(FILE *f)
232
++{
233
++#ifdef _WIN32
234
++    auto file_handle = (HANDLE)_get_osfhandle(_fileno(f));
235
++    if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0))
236
++        throw spdlog_ex("SetHandleInformation failed", errno);
237
++#else
238
++    auto fd = fileno(f);
239
++    if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
240
++        throw spdlog_ex("fcntl with FD_CLOEXEC failed", errno);
241
++#endif
242
++}
243
+ 
244
+ 
245
+ //fopen_s on non windows for writing
246
+@@ -146,13 +165,18 @@ inline int fopen_s(FILE** fp, const filename_t& filename, const filename_t& mode
247
+ #else
248
+     *fp = _fsopen((filename.c_str()), mode.c_str(), _SH_DENYWR);
249
+ #endif
250
+-    return *fp == nullptr;
251
+-#else
252
++#else //unix
253
+     *fp = fopen((filename.c_str()), mode.c_str());
254
+-    return *fp == nullptr;
255
+ #endif
256
++
257
++#ifdef SPDLOG_PREVENT_CHILD_FD
258
++    if(*fp != nullptr)
259
++        prevent_child_fd(*fp);
260
++#endif
261
++    return *fp == nullptr;
262
+ }
263
+ 
264
++
265
+ inline int remove(const filename_t &filename)
266
+ {
267
+ #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
268
+@@ -204,9 +228,9 @@ inline size_t filesize(FILE *f)
269
+         return st.st_size;
270
+ 
271
+ #else //windows 32 bits
272
+-    struct _stat st;
273
+-    if (_fstat(fd, &st) == 0)
274
+-        return st.st_size;
275
++    long ret = _filelength(fd);
276
++    if (ret >= 0)
277
++        return static_cast<size_t>(ret);
278
+ #endif
279
+ 
280
+ #else // unix
281
+@@ -215,11 +239,11 @@ inline size_t filesize(FILE *f)
282
+ #if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__))
283
+     struct stat64 st;
284
+     if (fstat64(fd, &st) == 0)
285
+-        return st.st_size;
286
++        return static_cast<size_t>(st.st_size);
287
+ #else // unix 32 bits or osx
288
+     struct stat st;
289
+     if (fstat(fd, &st) == 0)
290
+-        return st.st_size;
291
++        return static_cast<size_t>(st.st_size);
292
+ #endif
293
+ #endif
294
+     throw spdlog_ex("Failed getting file size from fd", errno);
295
+@@ -292,7 +316,7 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
296
+ 
297
+ //Return current thread id as size_t
298
+ //It exists because the std::this_thread::get_id() is much slower(espcially under VS 2013)
299
+-inline size_t thread_id()
300
++inline size_t _thread_id()
301
+ {
302
+ #ifdef _WIN32
303
+     return  static_cast<size_t>(::GetCurrentThreadId());
304
+@@ -308,11 +332,22 @@ inline size_t thread_id()
305
+ #else //Default to standard C++11 (OSX and other Unix)
306
+     return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
307
+ #endif
308
++}
309
+ 
310
+-
311
++//Return current thread id as size_t (from thread local storage)
312
++inline size_t thread_id()
313
++{
314
++#if defined(_MSC_VER) && (_MSC_VER < 1900) || defined(__clang__) && !__has_feature(cxx_thread_local)
315
++    return _thread_id();
316
++#else
317
++    static thread_local const size_t tid = _thread_id();
318
++    return tid;
319
++#endif
320
+ }
321
+ 
322
+ 
323
++
324
++
325
+ // wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
326
+ #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
327
+ #define SPDLOG_FILENAME_T(s) L ## s
328
+@@ -342,8 +377,8 @@ inline std::string errno_str(int err_num)
329
+     else
330
+         return "Unkown error";
331
+ 
332
+-#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(ANDROID) || \
333
+-      ((_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE) // posix version
334
++#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(ANDROID) || defined(__SUNPRO_CC) || \
335
++      ((_POSIX_C_SOURCE >= 200112L) && ! defined(_GNU_SOURCE)) // posix version
336
+ 
337
+     if (strerror_r(err_num, buf, buf_size) == 0)
338
+         return std::string(buf);
339
+@@ -355,6 +390,17 @@ inline std::string errno_str(int err_num)
340
+ #endif
341
+ }
342
+ 
343
++inline int pid()
344
++{
345
++
346
++#ifdef _WIN32
347
++    return ::_getpid();
348
++#else
349
++    return static_cast<int>(::getpid());
350
++#endif
351
++
352
++}
353
++
354
+ } //os
355
+ } //details
356
+ } //spdlog
357
+diff --git a/vendor/spdlog/spdlog/details/pattern_formatter_impl.h b/vendor/spdlog/spdlog/details/pattern_formatter_impl.h
358
+index 73c0db3b..2fefaa3c 100644
359
+--- a/vendor/spdlog/spdlog/details/pattern_formatter_impl.h
360
+@@ -18,6 +18,7 @@
361
+ #include <thread>
362
+ #include <utility>
363
+ #include <vector>
364
++#include <array>
365
+ 
366
+ namespace spdlog
367
+ {
368
+@@ -78,42 +79,60 @@ static int to12h(const tm& t)
369
+ }
370
+ 
371
+ //Abbreviated weekday name
372
+-static const std::string days[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
373
++using days_array = std::array<std::string, 7>;
374
++static const days_array& days()
375
++{
376
++    static const days_array arr{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
377
++    return arr;
378
++}
379
+ class a_formatter:public flag_formatter
380
+ {
381
+     void format(details::log_msg& msg, const std::tm& tm_time) override
382
+     {
383
+-        msg.formatted << days[tm_time.tm_wday];
384
++        msg.formatted << days()[tm_time.tm_wday];
385
+     }
386
+ };
387
+ 
388
+ //Full weekday name
389
+-static const std::string full_days[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
390
++static const days_array& full_days()
391
++{
392
++    static const days_array arr{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
393
++    return arr;
394
++}
395
+ class A_formatter:public flag_formatter
396
+ {
397
+     void format(details::log_msg& msg, const std::tm& tm_time) override
398
+     {
399
+-        msg.formatted << full_days[tm_time.tm_wday];
400
++        msg.formatted << full_days()[tm_time.tm_wday];
401
+     }
402
+ };
403
+ 
404
+ //Abbreviated month
405
+-static const std::string  months[] { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" };
406
++using months_array = std::array<std::string, 12>;
407
++static const months_array& months()
408
++{
409
++    static const months_array arr{ "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" };
410
++    return arr;
411
++}
412
+ class b_formatter:public flag_formatter
413
+ {
414
+     void format(details::log_msg& msg, const std::tm& tm_time) override
415
+     {
416
+-        msg.formatted << months[tm_time.tm_mon];
417
++        msg.formatted << months()[tm_time.tm_mon];
418
+     }
419
+ };
420
+ 
421
+ //Full month name
422
+-static const std::string full_months[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
423
++static const months_array& full_months()
424
++{
425
++    static const months_array arr{ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
426
++    return arr;
427
++}
428
+ class B_formatter:public flag_formatter
429
+ {
430
+     void format(details::log_msg& msg, const std::tm& tm_time) override
431
+     {
432
+-        msg.formatted << full_months[tm_time.tm_mon];
433
++        msg.formatted << full_months()[tm_time.tm_mon];
434
+     }
435
+ };
436
+ 
437
+@@ -138,7 +157,7 @@ class c_formatter:public flag_formatter
438
+ {
439
+     void format(details::log_msg& msg, const std::tm& tm_time) override
440
+     {
441
+-        msg.formatted << days[tm_time.tm_wday] << ' ' << months[tm_time.tm_mon] << ' ' << tm_time.tm_mday << ' ';
442
++        msg.formatted << days()[tm_time.tm_wday] << ' ' << months()[tm_time.tm_mon] << ' ' << tm_time.tm_mday << ' ';
443
+         pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << tm_time.tm_year + 1900;
444
+     }
445
+ };
446
+@@ -356,7 +375,7 @@ class z_formatter:public flag_formatter
447
+ 
448
+ 
449
+ 
450
+-//Thread id
451
++// Thread id
452
+ class t_formatter:public flag_formatter
453
+ {
454
+     void format(details::log_msg& msg, const std::tm&) override
455
+@@ -365,6 +384,15 @@ class t_formatter:public flag_formatter
456
+     }
457
+ };
458
+ 
459
++// Current pid
460
++class pid_formatter:public flag_formatter
461
++{
462
++    void format(details::log_msg& msg, const std::tm&) override
463
++    {
464
++        msg.formatted << details::os::pid();
465
++    }
466
++};
467
++
468
+ 
469
+ class v_formatter:public flag_formatter
470
+ {
471
+@@ -453,6 +481,8 @@ class full_formatter:public flag_formatter
472
+     }
473
+ };
474
+ 
475
++
476
++
477
+ }
478
+ }
479
+ ///////////////////////////////////////////////////////////////////////////////
480
+@@ -611,6 +641,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
481
+         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::full_formatter()));
482
+         break;
483
+ 
484
++    case ('P'):
485
++        _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::pid_formatter()));
486
++        break;
487
++
488
+     default: //Unkown flag appears as is
489
+         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter('%')));
490
+         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter(flag)));
491
+diff --git a/vendor/spdlog/spdlog/details/spdlog_impl.h b/vendor/spdlog/spdlog/details/spdlog_impl.h
492
+index bc283c83..a8011db4 100644
493
+--- a/vendor/spdlog/spdlog/details/spdlog_impl.h
494
+@@ -12,9 +12,20 @@
495
+ #include <spdlog/details/registry.h>
496
+ #include <spdlog/sinks/file_sinks.h>
497
+ #include <spdlog/sinks/stdout_sinks.h>
498
++#ifdef SPDLOG_ENABLE_SYSLOG
499
+ #include <spdlog/sinks/syslog_sink.h>
500
++#endif
501
++
502
++#ifdef _WIN32
503
++#include <spdlog/sinks/wincolor_sink.h>
504
++#else
505
+ #include <spdlog/sinks/ansicolor_sink.h>
506
++#endif
507
++
508
++
509
++#ifdef __ANDROID__
510
+ #include <spdlog/sinks/android_sink.h>
511
++#endif
512
+ 
513
+ #include <chrono>
514
+ #include <functional>
515
+@@ -69,34 +80,86 @@ inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string
516
+     return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, SPDLOG_FILENAME_T("txt"), hour, minute);
517
+ }
518
+ 
519
+-// Create stdout/stderr loggers (with optinal color support)
520
+-inline std::shared_ptr<spdlog::logger> create_console_logger(const std::string& logger_name, spdlog::sink_ptr sink, bool color)
521
++
522
++//
523
++// stdout/stderr loggers
524
++//
525
++inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt(const std::string& logger_name)
526
++{
527
++    return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_mt::instance());
528
++}
529
++
530
++inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st(const std::string& logger_name)
531
++{
532
++    return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_st::instance());
533
++}
534
++
535
++inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt(const std::string& logger_name)
536
+ {
537
+-    if (color) //use color wrapper sink
538
+-        sink = std::make_shared<spdlog::sinks::ansicolor_sink>(sink);
539
++    return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_mt::instance());
540
++}
541
++
542
++inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::string& logger_name)
543
++{
544
++    return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_st::instance());
545
++}
546
++
547
++//
548
++// stdout/stderr color loggers
549
++//
550
++#ifdef _WIN32
551
++inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt(const std::string& logger_name)
552
++{
553
++    auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>();
554
+     return spdlog::details::registry::instance().create(logger_name, sink);
555
+ }
556
+ 
557
+-inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt(const std::string& logger_name, bool color)
558
++inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string& logger_name)
559
+ {
560
+-    return create_console_logger(logger_name, sinks::stdout_sink_mt::instance(), color);
561
++    auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_st>();
562
++    return spdlog::details::registry::instance().create(logger_name, sink);
563
+ }
564
+ 
565
+-inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st(const std::string& logger_name, bool color)
566
++inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
567
+ {
568
+-    return create_console_logger(logger_name, sinks::stdout_sink_st::instance(), color);
569
++    auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_mt>();
570
++    return spdlog::details::registry::instance().create(logger_name, sink);
571
+ }
572
+ 
573
+-inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt(const std::string& logger_name, bool color)
574
++
575
++inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
576
+ {
577
+-    return create_console_logger(logger_name, sinks::stderr_sink_mt::instance(), color);
578
++    auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_st>();
579
++    return spdlog::details::registry::instance().create(logger_name, sink);
580
+ }
581
+ 
582
+-inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::string& logger_name, bool color)
583
++#else //ansi terminal colors
584
++
585
++inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt(const std::string& logger_name)
586
+ {
587
+-    return create_console_logger(logger_name, sinks::stderr_sink_st::instance(), color);
588
++    auto sink = std::make_shared<spdlog::sinks::ansicolor_sink>(spdlog::sinks::stdout_sink_mt::instance());
589
++    return spdlog::details::registry::instance().create(logger_name, sink);
590
+ }
591
+ 
592
++inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string& logger_name)
593
++{
594
++    auto sink = std::make_shared<spdlog::sinks::ansicolor_sink>(spdlog::sinks::stdout_sink_st::instance());
595
++    return spdlog::details::registry::instance().create(logger_name, sink);
596
++}
597
++
598
++inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
599
++{
600
++    auto sink = std::make_shared<spdlog::sinks::ansicolor_sink>(spdlog::sinks::stderr_sink_mt::instance());
601
++    return spdlog::details::registry::instance().create(logger_name, sink);
602
++}
603
++
604
++inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
605
++{
606
++    auto sink = std::make_shared<spdlog::sinks::ansicolor_sink>(spdlog::sinks::stderr_sink_st::instance());
607
++    return spdlog::details::registry::instance().create(logger_name, sink);
608
++}
609
++#endif
610
++
611
+ #ifdef SPDLOG_ENABLE_SYSLOG
612
+ // Create syslog logger
613
+ inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option)
614
+@@ -105,7 +168,7 @@ inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string&
615
+ }
616
+ #endif
617
+ 
618
+-#if defined(__ANDROID__)
619
++#ifdef __ANDROID__
620
+ inline std::shared_ptr<spdlog::logger> spdlog::android_logger(const std::string& logger_name, const std::string& tag)
621
+ {
622
+     return create<spdlog::sinks::android_sink>(logger_name, tag);
623
+diff --git a/vendor/spdlog/spdlog/fmt/bundled/format.cc b/vendor/spdlog/spdlog/fmt/bundled/format.cc
624
+index 0f7e0aa2..fd8855be 100644
625
+--- a/vendor/spdlog/spdlog/fmt/bundled/format.cc
626
+@@ -1,33 +1,31 @@
627
+ /*
628
+- Formatting library for C++
629
+-
630
+- Copyright (c) 2012 - 2016, Victor Zverovich
631
+- All rights reserved.
632
+-
633
+- Redistribution and use in source and binary forms, with or without
634
+- modification, are permitted provided that the following conditions are met:
635
+-
636
+- 1. Redistributions of source code must retain the above copyright notice, this
637
+-    list of conditions and the following disclaimer.
638
+- 2. Redistributions in binary form must reproduce the above copyright notice,
639
+-    this list of conditions and the following disclaimer in the documentation
640
+-    and/or other materials provided with the distribution.
641
+-
642
+- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
643
+- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
644
+- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
645
+- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
646
+- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
647
+- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
648
+- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
649
+- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
650
+- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
651
+- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
652
+- */
653
+-
654
+-// Commented out by spdlog to use header only
655
+-// #include "fmt/format.h"
656
+-// #include "fmt/printf.h"
657
++Formatting library for C++
658
++
659
++Copyright (c) 2012 - 2016, Victor Zverovich
660
++All rights reserved.
661
++
662
++Redistribution and use in source and binary forms, with or without
663
++modification, are permitted provided that the following conditions are met:
664
++
665
++1. Redistributions of source code must retain the above copyright notice, this
666
++list of conditions and the following disclaimer.
667
++2. Redistributions in binary form must reproduce the above copyright notice,
668
++this list of conditions and the following disclaimer in the documentation
669
++and/or other materials provided with the distribution.
670
++
671
++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
672
++ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
673
++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
674
++DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
675
++ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
676
++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
677
++LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
678
++ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
679
++(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
680
++SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
681
++*/
682
++
683
++#include "format.h"
684
+ 
685
+ #include <string.h>
686
+ 
687
+@@ -73,31 +71,37 @@ using fmt::internal::Arg;
688
+ 
689
+ // Dummy implementations of strerror_r and strerror_s called if corresponding
690
+ // system functions are not available.
691
+-static inline fmt::internal::Null<> strerror_r(int, char *, ...) {
692
+-  return fmt::internal::Null<>();
693
++static inline fmt::internal::Null<> strerror_r(int, char *, ...)
694
++{
695
++	return fmt::internal::Null<>();
696
+ }
697
+-static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
698
+-  return fmt::internal::Null<>();
699
++static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...)
700
++{
701
++	return fmt::internal::Null<>();
702
+ }
703
+ 
704
+ namespace fmt {
705
+ 
706
+-FMT_FUNC internal::RuntimeError::~RuntimeError() throw() {}
707
+-FMT_FUNC FormatError::~FormatError() throw() {}
708
+-FMT_FUNC SystemError::~SystemError() throw() {}
709
++	FMT_FUNC internal::RuntimeError::~RuntimeError() FMT_DTOR_NOEXCEPT
710
++	{}
711
++	FMT_FUNC FormatError::~FormatError() FMT_DTOR_NOEXCEPT
712
++	{}
713
++	FMT_FUNC SystemError::~SystemError() FMT_DTOR_NOEXCEPT
714
++	{}
715
+ 
716
+-namespace {
717
++	namespace {
718
+ 
719
+ #ifndef _MSC_VER
720
+ # define FMT_SNPRINTF snprintf
721
+ #else  // _MSC_VER
722
+-inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
723
+-  va_list args;
724
+-  va_start(args, format);
725
+-  int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args);
726
+-  va_end(args);
727
+-  return result;
728
+-}
729
++		inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...)
730
++		{
731
++			va_list args;
732
++			va_start(args, format);
733
++			int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args);
734
++			va_end(args);
735
++			return result;
736
++		}
737
+ # define FMT_SNPRINTF fmt_snprintf
738
+ #endif  // _MSC_VER
739
+ 
740
+@@ -107,166 +111,183 @@ inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
741
+ # define FMT_SWPRINTF swprintf
742
+ #endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT)
743
+ 
744
+-const char RESET_COLOR[] = "\x1b[0m";
745
+-
746
+-typedef void (*FormatFunc)(Writer &, int, StringRef);
747
+-
748
+-// Portable thread-safe version of strerror.
749
+-// Sets buffer to point to a string describing the error code.
750
+-// This can be either a pointer to a string stored in buffer,
751
+-// or a pointer to some static immutable string.
752
+-// Returns one of the following values:
753
+-//   0      - success
754
+-//   ERANGE - buffer is not large enough to store the error message
755
+-//   other  - failure
756
+-// Buffer should be at least of size 1.
757
+-int safe_strerror(
758
+-    int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT {
759
+-  FMT_ASSERT(buffer != 0 && buffer_size != 0, "invalid buffer");
760
+-
761
+-  class StrError {
762
+-   private:
763
+-    int error_code_;
764
+-    char *&buffer_;
765
+-    std::size_t buffer_size_;
766
+-
767
+-    // A noop assignment operator to avoid bogus warnings.
768
+-    void operator=(const StrError &) {}
769
+-
770
+-    // Handle the result of XSI-compliant version of strerror_r.
771
+-    int handle(int result) {
772
+-      // glibc versions before 2.13 return result in errno.
773
+-      return result == -1 ? errno : result;
774
+-    }
775
+-
776
+-    // Handle the result of GNU-specific version of strerror_r.
777
+-    int handle(char *message) {
778
+-      // If the buffer is full then the message is probably truncated.
779
+-      if (message == buffer_ && strlen(buffer_) == buffer_size_ - 1)
780
+-        return ERANGE;
781
+-      buffer_ = message;
782
+-      return 0;
783
+-    }
784
+-
785
+-    // Handle the case when strerror_r is not available.
786
+-    int handle(internal::Null<>) {
787
+-      return fallback(strerror_s(buffer_, buffer_size_, error_code_));
788
+-    }
789
+-
790
+-    // Fallback to strerror_s when strerror_r is not available.
791
+-    int fallback(int result) {
792
+-      // If the buffer is full then the message is probably truncated.
793
+-      return result == 0 && strlen(buffer_) == buffer_size_ - 1 ?
794
+-            ERANGE : result;
795
+-    }
796
+-
797
+-    // Fallback to strerror if strerror_r and strerror_s are not available.
798
+-    int fallback(internal::Null<>) {
799
+-      errno = 0;
800
+-      buffer_ = strerror(error_code_);
801
+-      return errno;
802
+-    }
803
+-
804
+-   public:
805
+-    StrError(int err_code, char *&buf, std::size_t buf_size)
806
+-      : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {}
807
+-
808
+-    int run() {
809
+-      strerror_r(0, 0, "");  // Suppress a warning about unused strerror_r.
810
+-      return handle(strerror_r(error_code_, buffer_, buffer_size_));
811
+-    }
812
+-  };
813
+-  return StrError(error_code, buffer, buffer_size).run();
814
+-}
815
+-
816
+-void format_error_code(Writer &out, int error_code,
817
+-                       StringRef message) FMT_NOEXCEPT {
818
+-  // Report error code making sure that the output fits into
819
+-  // INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
820
+-  // bad_alloc.
821
+-  out.clear();
822
+-  static const char SEP[] = ": ";
823
+-  static const char ERROR_STR[] = "error ";
824
+-  // Subtract 2 to account for terminating null characters in SEP and ERROR_STR.
825
+-  std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2;
826
+-  typedef internal::IntTraits<int>::MainType MainType;
827
+-  MainType abs_value = static_cast<MainType>(error_code);
828
+-  if (internal::is_negative(error_code)) {
829
+-    abs_value = 0 - abs_value;
830
+-    ++error_code_size;
831
+-  }
832
+-  error_code_size += internal::count_digits(abs_value);
833
+-  if (message.size() <= internal::INLINE_BUFFER_SIZE - error_code_size)
834
+-    out << message << SEP;
835
+-  out << ERROR_STR << error_code;
836
+-  assert(out.size() <= internal::INLINE_BUFFER_SIZE);
837
+-}
838
+-
839
+-void report_error(FormatFunc func, int error_code,
840
+-                  StringRef message) FMT_NOEXCEPT {
841
+-  MemoryWriter full_message;
842
+-  func(full_message, error_code, message);
843
+-  // Use Writer::data instead of Writer::c_str to avoid potential memory
844
+-  // allocation.
845
+-  std::fwrite(full_message.data(), full_message.size(), 1, stderr);
846
+-  std::fputc('\n', stderr);
847
+-}
848
+-}  // namespace
849
+-
850
+-namespace internal {
851
+-
852
+-// This method is used to preserve binary compatibility with fmt 3.0.
853
+-// It can be removed in 4.0.
854
+-FMT_FUNC void format_system_error(
855
+-  Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
856
+-  fmt::format_system_error(out, error_code, message);
857
+-}
858
+-}  // namespace internal
859
+-
860
+-FMT_FUNC void SystemError::init(
861
+-    int err_code, CStringRef format_str, ArgList args) {
862
+-  error_code_ = err_code;
863
+-  MemoryWriter w;
864
+-  format_system_error(w, err_code, format(format_str, args));
865
+-  std::runtime_error &base = *this;
866
+-  base = std::runtime_error(w.str());
867
+-}
868
+-
869
+-template <typename T>
870
+-int internal::CharTraits<char>::format_float(
871
+-    char *buffer, std::size_t size, const char *format,
872
+-    unsigned width, int precision, T value) {
873
+-  if (width == 0) {
874
+-    return precision < 0 ?
875
+-        FMT_SNPRINTF(buffer, size, format, value) :
876
+-        FMT_SNPRINTF(buffer, size, format, precision, value);
877
+-  }
878
+-  return precision < 0 ?
879
+-      FMT_SNPRINTF(buffer, size, format, width, value) :
880
+-      FMT_SNPRINTF(buffer, size, format, width, precision, value);
881
+-}
882
+-
883
+-template <typename T>
884
+-int internal::CharTraits<wchar_t>::format_float(
885
+-    wchar_t *buffer, std::size_t size, const wchar_t *format,
886
+-    unsigned width, int precision, T value) {
887
+-  if (width == 0) {
888
+-    return precision < 0 ?
889
+-        FMT_SWPRINTF(buffer, size, format, value) :
890
+-        FMT_SWPRINTF(buffer, size, format, precision, value);
891
+-  }
892
+-  return precision < 0 ?
893
+-      FMT_SWPRINTF(buffer, size, format, width, value) :
894
+-      FMT_SWPRINTF(buffer, size, format, width, precision, value);
895
+-}
896
+-
897
+-template <typename T>
898
+-const char internal::BasicData<T>::DIGITS[] =
899
+-    "0001020304050607080910111213141516171819"
900
+-    "2021222324252627282930313233343536373839"
901
+-    "4041424344454647484950515253545556575859"
902
+-    "6061626364656667686970717273747576777879"
903
+-    "8081828384858687888990919293949596979899";
904
++		const char RESET_COLOR[] = "\x1b[0m";
905
++
906
++		typedef void(*FormatFunc)(Writer &, int, StringRef);
907
++
908
++		// Portable thread-safe version of strerror.
909
++		// Sets buffer to point to a string describing the error code.
910
++		// This can be either a pointer to a string stored in buffer,
911
++		// or a pointer to some static immutable string.
912
++		// Returns one of the following values:
913
++		//   0      - success
914
++		//   ERANGE - buffer is not large enough to store the error message
915
++		//   other  - failure
916
++		// Buffer should be at least of size 1.
917
++		int safe_strerror(
918
++			int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT
919
++		{
920
++			FMT_ASSERT(buffer != 0 && buffer_size != 0, "invalid buffer");
921
++
922
++			class StrError
923
++			{
924
++			private:
925
++				int error_code_;
926
++				char *&buffer_;
927
++				std::size_t buffer_size_;
928
++
929
++				// A noop assignment operator to avoid bogus warnings.
930
++				void operator=(const StrError &)
931
++				{}
932
++
933
++				// Handle the result of XSI-compliant version of strerror_r.
934
++				int handle(int result)
935
++				{
936
++					// glibc versions before 2.13 return result in errno.
937
++					return result == -1 ? errno : result;
938
++				}
939
++
940
++				// Handle the result of GNU-specific version of strerror_r.
941
++				int handle(char *message)
942
++				{
943
++					// If the buffer is full then the message is probably truncated.
944
++					if (message == buffer_ && strlen(buffer_) == buffer_size_ - 1)
945
++						return ERANGE;
946
++					buffer_ = message;
947
++					return 0;
948
++				}
949
++
950
++				// Handle the case when strerror_r is not available.
951
++				int handle(internal::Null<>)
952
++				{
953
++					return fallback(strerror_s(buffer_, buffer_size_, error_code_));
954
++				}
955
++
956
++				// Fallback to strerror_s when strerror_r is not available.
957
++				int fallback(int result)
958
++				{
959
++					// If the buffer is full then the message is probably truncated.
960
++					return result == 0 && strlen(buffer_) == buffer_size_ - 1 ?
961
++						ERANGE : result;
962
++				}
963
++
964
++				// Fallback to strerror if strerror_r and strerror_s are not available.
965
++				int fallback(internal::Null<>)
966
++				{
967
++					errno = 0;
968
++					buffer_ = strerror(error_code_);
969
++					return errno;
970
++				}
971
++
972
++			public:
973
++				StrError(int err_code, char *&buf, std::size_t buf_size)
974
++					: error_code_(err_code), buffer_(buf), buffer_size_(buf_size)
975
++				{}
976
++
977
++				int run()
978
++				{
979
++					// Suppress a warning about unused strerror_r.
980
++					strerror_r(0, FMT_NULL, "");
981
++					return handle(strerror_r(error_code_, buffer_, buffer_size_));
982
++				}
983
++			};
984
++			return StrError(error_code, buffer, buffer_size).run();
985
++		}
986
++
987
++		void format_error_code(Writer &out, int error_code,
988
++			StringRef message) FMT_NOEXCEPT
989
++		{
990
++			// Report error code making sure that the output fits into
991
++			// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
992
++			// bad_alloc.
993
++			out.clear();
994
++			static const char SEP[] = ": ";
995
++			static const char ERROR_STR[] = "error ";
996
++			// Subtract 2 to account for terminating null characters in SEP and ERROR_STR.
997
++			std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2;
998
++			typedef internal::IntTraits<int>::MainType MainType;
999
++			MainType abs_value = static_cast<MainType>(error_code);
1000
++			if (internal::is_negative(error_code)) {
1001
++				abs_value = 0 - abs_value;
1002
++				++error_code_size;
1003
++			}
1004
++			error_code_size += internal::count_digits(abs_value);
1005
++			if (message.size() <= internal::INLINE_BUFFER_SIZE - error_code_size)
1006
++				out << message << SEP;
1007
++			out << ERROR_STR << error_code;
1008
++			assert(out.size() <= internal::INLINE_BUFFER_SIZE);
1009
++		}
1010
++
1011
++		void report_error(FormatFunc func, int error_code,
1012
++			StringRef message) FMT_NOEXCEPT
1013
++		{
1014
++			MemoryWriter full_message;
1015
++			func(full_message, error_code, message);
1016
++			// Use Writer::data instead of Writer::c_str to avoid potential memory
1017
++			// allocation.
1018
++			std::fwrite(full_message.data(), full_message.size(), 1, stderr);
1019
++			std::fputc('\n', stderr);
1020
++		}
1021
++	}  // namespace
1022
++
1023
++	namespace internal {
1024
++
1025
++		// This method is used to preserve binary compatibility with fmt 3.0.
1026
++		// It can be removed in 4.0.
1027
++		FMT_FUNC void format_system_error(
1028
++			Writer &out, int error_code, StringRef message) FMT_NOEXCEPT
1029
++		{
1030
++			fmt::format_system_error(out, error_code, message);
1031
++		}
1032
++	}  // namespace internal
1033
++
1034
++	FMT_FUNC void SystemError::init(
1035
++		int err_code, CStringRef format_str, ArgList args)
1036
++	{
1037
++		error_code_ = err_code;
1038
++		MemoryWriter w;
1039
++		format_system_error(w, err_code, format(format_str, args));
1040
++		std::runtime_error &base = *this;
1041
++		base = std::runtime_error(w.str());
1042
++	}
1043
++
1044
++	template <typename T>
1045
++	int internal::CharTraits<char>::format_float(
1046
++		char *buffer, std::size_t size, const char *format,
1047
++		unsigned width, int precision, T value)
1048
++	{
1049
++		if (width == 0) {
1050
++			return precision < 0 ?
1051
++				FMT_SNPRINTF(buffer, size, format, value) :
1052
++				FMT_SNPRINTF(buffer, size, format, precision, value);
1053
++		}
1054
++		return precision < 0 ?
1055
++			FMT_SNPRINTF(buffer, size, format, width, value) :
1056
++			FMT_SNPRINTF(buffer, size, format, width, precision, value);
1057
++	}
1058
++
1059
++	template <typename T>
1060
++	int internal::CharTraits<wchar_t>::format_float(
1061
++		wchar_t *buffer, std::size_t size, const wchar_t *format,
1062
++		unsigned width, int precision, T value)
1063
++	{
1064
++		if (width == 0) {
1065
++			return precision < 0 ?
1066
++				FMT_SWPRINTF(buffer, size, format, value) :
1067
++				FMT_SWPRINTF(buffer, size, format, precision, value);
1068
++		}
1069
++		return precision < 0 ?
1070
++			FMT_SWPRINTF(buffer, size, format, width, value) :
1071
++			FMT_SWPRINTF(buffer, size, format, width, precision, value);
1072
++	}
1073
++
1074
++	template <typename T>
1075
++	const char internal::BasicData<T>::DIGITS[] =
1076
++		"0001020304050607080910111213141516171819"
1077
++		"2021222324252627282930313233343536373839"
1078
++		"4041424344454647484950515253545556575859"
1079
++		"6061626364656667686970717273747576777879"
1080
++		"8081828384858687888990919293949596979899";
1081
+ 
1082
+ #define FMT_POWERS_OF_10(factor) \
1083
+   factor * 10, \
1084
+@@ -279,274 +300,279 @@ const char internal::BasicData<T>::DIGITS[] =
1085
+   factor * 100000000, \
1086
+   factor * 1000000000
1087
+ 
1088
+-template <typename T>
1089
+-const uint32_t internal::BasicData<T>::POWERS_OF_10_32[] = {
1090
+-  0, FMT_POWERS_OF_10(1)
1091
+-};
1092
+-
1093
+-template <typename T>
1094
+-const uint64_t internal::BasicData<T>::POWERS_OF_10_64[] = {
1095
+-  0,
1096
+-  FMT_POWERS_OF_10(1),
1097
+-  FMT_POWERS_OF_10(ULongLong(1000000000)),
1098
+-  // Multiply several constants instead of using a single long long constant
1099
+-  // to avoid warnings about C++98 not supporting long long.
1100
+-  ULongLong(1000000000) * ULongLong(1000000000) * 10
1101
+-};
1102
+-
1103
+-FMT_FUNC void internal::report_unknown_type(char code, const char *type) {
1104
+-  (void)type;
1105
+-  if (std::isprint(static_cast<unsigned char>(code))) {
1106
+-    FMT_THROW(FormatError(
1107
+-        format("unknown format code '{}' for {}", code, type)));
1108
+-  }
1109
+-  FMT_THROW(FormatError(
1110
+-      format("unknown format code '\\x{:02x}' for {}",
1111
+-        static_cast<unsigned>(code), type)));
1112
+-}
1113
++	template <typename T>
1114
++	const uint32_t internal::BasicData<T>::POWERS_OF_10_32[] = {
1115
++		0, FMT_POWERS_OF_10(1)
1116
++	};
1117
++
1118
++	template <typename T>
1119
++	const uint64_t internal::BasicData<T>::POWERS_OF_10_64[] = {
1120
++		0,
1121
++		FMT_POWERS_OF_10(1),
1122
++		FMT_POWERS_OF_10(ULongLong(1000000000)),
1123
++		// Multiply several constants instead of using a single long long constant
1124
++		// to avoid warnings about C++98 not supporting long long.
1125
++		ULongLong(1000000000) * ULongLong(1000000000) * 10
1126
++	};
1127
++
1128
++	FMT_FUNC void internal::report_unknown_type(char code, const char *type)
1129
++	{
1130
++		(void)type;
1131
++		if (std::isprint(static_cast<unsigned char>(code))) {
1132
++			FMT_THROW(FormatError(
1133
++				format("unknown format code '{}' for {}", code, type)));
1134
++		}
1135
++		FMT_THROW(FormatError(
1136
++			format("unknown format code '\\x{:02x}' for {}",
1137
++				static_cast<unsigned>(code), type)));
1138
++	}
1139
+ 
1140
+ #if FMT_USE_WINDOWS_H
1141
+ 
1142
+-FMT_FUNC internal::UTF8ToUTF16::UTF8ToUTF16(StringRef s) {
1143
+-  static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16";
1144
+-  if (s.size() > INT_MAX)
1145
+-    FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG));
1146
+-  int s_size = static_cast<int>(s.size());
1147
+-  int length = MultiByteToWideChar(
1148
+-      CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, 0, 0);
1149
+-  if (length == 0)
1150
+-    FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
1151
+-  buffer_.resize(length + 1);
1152
+-  length = MultiByteToWideChar(
1153
+-    CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, &buffer_[0], length);
1154
+-  if (length == 0)
1155
+-    FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
1156
+-  buffer_[length] = 0;
1157
+-}
1158
+-
1159
+-FMT_FUNC internal::UTF16ToUTF8::UTF16ToUTF8(WStringRef s) {
1160
+-  if (int error_code = convert(s)) {
1161
+-    FMT_THROW(WindowsError(error_code,
1162
+-        "cannot convert string from UTF-16 to UTF-8"));
1163
+-  }
1164
+-}
1165
+-
1166
+-FMT_FUNC int internal::UTF16ToUTF8::convert(WStringRef s) {
1167
+-  if (s.size() > INT_MAX)
1168
+-    return ERROR_INVALID_PARAMETER;
1169
+-  int s_size = static_cast<int>(s.size());
1170
+-  int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, 0, 0, 0, 0);
1171
+-  if (length == 0)
1172
+-    return GetLastError();
1173
+-  buffer_.resize(length + 1);
1174
+-  length = WideCharToMultiByte(
1175
+-    CP_UTF8, 0, s.data(), s_size, &buffer_[0], length, 0, 0);
1176
+-  if (length == 0)
1177
+-    return GetLastError();
1178
+-  buffer_[length] = 0;
1179
+-  return 0;
1180
+-}
1181
+-
1182
+-FMT_FUNC void WindowsError::init(
1183
+-    int err_code, CStringRef format_str, ArgList args) {
1184
+-  error_code_ = err_code;
1185
+-  MemoryWriter w;
1186
+-  internal::format_windows_error(w, err_code, format(format_str, args));
1187
+-  std::runtime_error &base = *this;
1188
+-  base = std::runtime_error(w.str());
1189
+-}
1190
+-
1191
+-FMT_FUNC void internal::format_windows_error(
1192
+-    Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
1193
+-  FMT_TRY {
1194
+-    MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer;
1195
+-    buffer.resize(INLINE_BUFFER_SIZE);
1196
+-    for (;;) {
1197
+-      wchar_t *system_message = &buffer[0];
1198
+-      int result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
1199
+-                                  0, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1200
+-                                  system_message, static_cast<uint32_t>(buffer.size()), 0);
1201
+-      if (result != 0) {
1202
+-        UTF16ToUTF8 utf8_message;
1203
+-        if (utf8_message.convert(system_message) == ERROR_SUCCESS) {
1204
+-          out << message << ": " << utf8_message;
1205
+-          return;
1206
+-        }
1207
+-        break;
1208
+-      }
1209
+-      if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
1210
+-        break;  // Can't get error message, report error code instead.
1211
+-      buffer.resize(buffer.size() * 2);
1212
+-    }
1213
+-  } FMT_CATCH(...) {}
1214
+-  fmt::format_error_code(out, error_code, message);  // 'fmt::' is for bcc32.
1215
+-}
1216
++	FMT_FUNC internal::UTF8ToUTF16::UTF8ToUTF16(StringRef s)
1217
++	{
1218
++		static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16";
1219
++		if (s.size() > INT_MAX)
1220
++			FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG));
1221
++		int s_size = static_cast<int>(s.size());
1222
++		int length = MultiByteToWideChar(
1223
++			CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, FMT_NULL, 0);
1224
++		if (length == 0)
1225
++			FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
1226
++		buffer_.resize(length + 1);
1227
++		length = MultiByteToWideChar(
1228
++			CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, &buffer_[0], length);
1229
++		if (length == 0)
1230
++			FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
1231
++		buffer_[length] = 0;
1232
++	}
1233
++
1234
++	FMT_FUNC internal::UTF16ToUTF8::UTF16ToUTF8(WStringRef s)
1235
++	{
1236
++		if (int error_code = convert(s)) {
1237
++			FMT_THROW(WindowsError(error_code,
1238
++				"cannot convert string from UTF-16 to UTF-8"));
1239
++		}
1240
++	}
1241
++
1242
++	FMT_FUNC int internal::UTF16ToUTF8::convert(WStringRef s)
1243
++	{
1244
++		if (s.size() > INT_MAX)
1245
++			return ERROR_INVALID_PARAMETER;
1246
++		int s_size = static_cast<int>(s.size());
1247
++		int length = WideCharToMultiByte(
1248
++			CP_UTF8, 0, s.data(), s_size, FMT_NULL, 0, FMT_NULL, FMT_NULL);
1249
++		if (length == 0)
1250
++			return GetLastError();
1251
++		buffer_.resize(length + 1);
1252
++		length = WideCharToMultiByte(
1253
++			CP_UTF8, 0, s.data(), s_size, &buffer_[0], length, FMT_NULL, FMT_NULL);
1254
++		if (length == 0)
1255
++			return GetLastError();
1256
++		buffer_[length] = 0;
1257
++		return 0;
1258
++	}
1259
++
1260
++	FMT_FUNC void WindowsError::init(
1261
++		int err_code, CStringRef format_str, ArgList args)
1262
++	{
1263
++		error_code_ = err_code;
1264
++		MemoryWriter w;
1265
++		internal::format_windows_error(w, err_code, format(format_str, args));
1266
++		std::runtime_error &base = *this;
1267
++		base = std::runtime_error(w.str());
1268
++	}
1269
++
1270
++	FMT_FUNC void internal::format_windows_error(
1271
++		Writer &out, int error_code, StringRef message) FMT_NOEXCEPT
1272
++	{
1273
++		FMT_TRY{
1274
++			MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer;
1275
++		buffer.resize(INLINE_BUFFER_SIZE);
1276
++		for (;;) {
1277
++			wchar_t *system_message = &buffer[0];
1278
++			int result = FormatMessageW(
1279
++				FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
1280
++				FMT_NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1281
++				system_message, static_cast<uint32_t>(buffer.size()), FMT_NULL);
1282
++			if (result != 0) {
1283
++				UTF16ToUTF8 utf8_message;
1284
++				if (utf8_message.convert(system_message) == ERROR_SUCCESS) {
1285
++					out << message << ": " << utf8_message;
1286
++					return;
1287
++				}
1288
++				break;
1289
++			}
1290
++			if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
1291
++				break;  // Can't get error message, report error code instead.
1292
++			buffer.resize(buffer.size() * 2);
1293
++		}
1294
++		} FMT_CATCH(...)
1295
++		{}
1296
++		fmt::format_error_code(out, error_code, message);  // 'fmt::' is for bcc32.
1297
++	}
1298
+ 
1299
+ #endif  // FMT_USE_WINDOWS_H
1300
+ 
1301
+-FMT_FUNC void format_system_error(
1302
+-    Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
1303
+-  FMT_TRY {
1304
+-    internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> buffer;
1305
+-    buffer.resize(internal::INLINE_BUFFER_SIZE);
1306
+-    for (;;) {
1307
+-      char *system_message = &buffer[0];
1308
+-      int result = safe_strerror(error_code, system_message, buffer.size());
1309
+-      if (result == 0) {
1310
+-        out << message << ": " << system_message;
1311
+-        return;
1312
+-      }
1313
+-      if (result != ERANGE)
1314
+-        break;  // Can't get error message, report error code instead.
1315
+-      buffer.resize(buffer.size() * 2);
1316
+-    }
1317
+-  } FMT_CATCH(...) {}
1318
+-  fmt::format_error_code(out, error_code, message);  // 'fmt::' is for bcc32.
1319
+-}
1320
+-
1321
+-template <typename Char>
1322
+-void internal::ArgMap<Char>::init(const ArgList &args) {
1323
+-  if (!map_.empty())
1324
+-    return;
1325
+-  typedef internal::NamedArg<Char> NamedArg;
1326
+-  const NamedArg *named_arg = 0;
1327
+-  bool use_values =
1328
+-      args.type(ArgList::MAX_PACKED_ARGS - 1) == internal::Arg::NONE;
1329
+-  if (use_values) {
1330
+-    for (unsigned i = 0;/*nothing*/; ++i) {
1331
+-      internal::Arg::Type arg_type = args.type(i);
1332
+-      switch (arg_type) {
1333
+-      case internal::Arg::NONE:
1334
+-        return;
1335
+-      case internal::Arg::NAMED_ARG:
1336
+-        named_arg = static_cast<const NamedArg*>(args.values_[i].pointer);
1337
+-        map_.push_back(Pair(named_arg->name, *named_arg));
1338
+-        break;
1339
+-      default:
1340
+-        /*nothing*/;
1341
+-      }
1342
+-    }
1343
+-    return;
1344
+-  }
1345
+-  for (unsigned i = 0; i != ArgList::MAX_PACKED_ARGS; ++i) {
1346
+-    internal::Arg::Type arg_type = args.type(i);
1347
+-    if (arg_type == internal::Arg::NAMED_ARG) {
1348
+-      named_arg = static_cast<const NamedArg*>(args.args_[i].pointer);
1349
+-      map_.push_back(Pair(named_arg->name, *named_arg));
1350
+-    }
1351
+-  }
1352
+-  for (unsigned i = ArgList::MAX_PACKED_ARGS;/*nothing*/; ++i) {
1353
+-    switch (args.args_[i].type) {
1354
+-    case internal::Arg::NONE:
1355
+-      return;
1356
+-    case internal::Arg::NAMED_ARG: