| 1 | /* |
| 2 | Formatting library for C++ |
| 3 | |
| 4 | Copyright (c) 2012 - 2016, Victor Zverovich |
| 5 | All rights reserved. |
| 6 | |
| 7 | Redistribution and use in source and binary forms, with or without |
| 8 | modification, are permitted provided that the following conditions are met: |
| 9 | |
| 10 | 1. Redistributions of source code must retain the above copyright notice, this |
| 11 | list of conditions and the following disclaimer. |
| 12 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 | this list of conditions and the following disclaimer in the documentation |
| 14 | and/or other materials provided with the distribution. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "format.h"cxx . . $ `<file>/src/common/format.h`/ |
| 29 | |
| 30 | #include <string.h> |
| 31 | |
| 32 | #include <cctype> |
| 33 | #include <cerrno> |
| 34 | #include <climits> |
| 35 | #include <cmath> |
| 36 | #include <cstdarg> |
| 37 | #include <cstddef> // for std::ptrdiff_t |
| 38 | |
| 39 | #if defined(_WIN32) && defined(__MINGW32__) |
| 40 | # include <cstring> |
| 41 | #endif |
| 42 | |
| 43 | #if FMT_USE_WINDOWS_Hcxx . . $ `src/common/format.h:958:10`! |
| 44 | # if defined(NOMINMAX) || defined(FMT_WIN_MINMAX) |
| 45 | # include <windows.h> |
| 46 | # else |
| 47 | # define NOMINMAX |
| 48 | # include <windows.h> |
| 49 | # undef NOMINMAX |
| 50 | # endif |
| 51 | #endif |
| 52 | |
| 53 | using fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::Argcxx . . $ Arg#; |
| 54 | |
| 55 | #if FMT_EXCEPTIONScxx . . $ `src/common/format.h:167:10`! |
| 56 | # define FMT_TRYcxx . . $ `src/common/format.cc:56:10`! try |
| 57 | # define FMT_CATCHcxx . . $ `src/common/format.cc:57:10`!(x) catch (x) |
| 58 | #else |
| 59 | # define FMT_TRY if (true) |
| 60 | # define FMT_CATCH(x) if (false) |
| 61 | #endif |
| 62 | |
| 63 | #ifdef _MSC_VER |
| 64 | # pragma warning(push) |
| 65 | # pragma warning(disable: 4127) // conditional expression is constant |
| 66 | # pragma warning(disable: 4702) // unreachable code |
| 67 | // Disable deprecation warning for strerror. The latter is not called but |
| 68 | // MSVC fails to detect it. |
| 69 | # pragma warning(disable: 4996) |
| 70 | #endif |
| 71 | |
| 72 | // Dummy implementations of strerror_r and strerror_s called if corresponding |
| 73 | // system functions are not available. |
| 74 | static inline fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::Nullcxx . . $ fmt/internal/Null#<> strerror_rcxx . . $ strerror_r(d1a4c5a7425213e5).(int, char *, ...) { |
| 75 | return fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::Nullcxx . . $ fmt/internal/Null#<>(); |
| 76 | } |
| 77 | static inline fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::Nullcxx . . $ fmt/internal/Null#<> strerror_scxx . . $ strerror_s(77a34204105448c1).(char *, stdcxx . . $ std/::size_tcxx . . $ std/size_t#, ...) { |
| 78 | return fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::Nullcxx . . $ fmt/internal/Null#<>(); |
| 79 | } |
| 80 | |
| 81 | namespace fmtcxx . . $ fmt/ { |
| 82 | |
| 83 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! internalcxx . . $ fmt/internal/::RuntimeErrorcxx . . $ fmt/internal/RuntimeError#::~cxx . . $ fmt/internal/RuntimeError#`~RuntimeError`(ced63f7c635d850d).RuntimeErrorcxx . . $ fmt/internal/RuntimeError#() throw() {} |
| 84 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! FormatErrorcxx . . $ fmt/FormatError#::~cxx . . $ fmt/FormatError#`~FormatError`(ced63f7c635d850d).FormatErrorcxx . . $ fmt/FormatError#() throw() {} |
| 85 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! SystemErrorcxx . . $ fmt/SystemError#::~cxx . . $ fmt/SystemError#`~SystemError`(ced63f7c635d850d).SystemErrorcxx . . $ fmt/SystemError#() throw() {} |
| 86 | |
| 87 | namespacecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ { |
| 88 | |
| 89 | #ifndef _MSC_VER |
| 90 | # define FMT_SNPRINTFcxx . . $ `src/common/format.cc:90:10`! snprintf |
| 91 | #else // _MSC_VER |
| 92 | inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) { |
| 93 | va_list args; |
| 94 | va_start(args, format); |
| 95 | int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args); |
| 96 | va_end(args); |
| 97 | return result; |
| 98 | } |
| 99 | # define FMT_SNPRINTF fmt_snprintf |
| 100 | #endif // _MSC_VER |
| 101 | |
| 102 | #if defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT) |
| 103 | # define FMT_SWPRINTF snwprintf |
| 104 | #else |
| 105 | # define FMT_SWPRINTFcxx . . $ `src/common/format.cc:105:10`! swprintf |
| 106 | #endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT) |
| 107 | |
| 108 | // Checks if a value fits in int - used to avoid warnings about comparing |
| 109 | // signed and unsigned integers. |
| 110 | template <bool IsSigned> |
| 111 | struct IntCheckercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker# { |
| 112 | template <typename T> |
| 113 | static bool fits_in_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker#fits_in_int(809eade93cab327b).(T value) { |
| 114 | unsigned max = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; |
| 115 | return value <= max; |
| 116 | } |
| 117 | static bool fits_in_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker#fits_in_int(efaadfb7dc14930a).(bool) { return true; } |
| 118 | }; |
| 119 | |
| 120 | template <> |
| 121 | struct IntCheckercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker#<true> { |
| 122 | template <typename T> |
| 123 | static bool fits_in_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker#fits_in_int(ee44d93984fb03e9).(T value) { |
| 124 | return value >= INT_MINcxx . . $ `<external>/67164224788392828/limits.h:118:9`! && value <= INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; |
| 125 | } |
| 126 | static bool fits_in_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker#fits_in_int(83c267b20bac841a).(int) { return true; } |
| 127 | }; |
| 128 | |
| 129 | const char RESET_COLORcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/RESET_COLOR.[] = "\x1b[0m"; |
| 130 | |
| 131 | typedef void(*FormatFunccxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/FormatFunc#)(Writercxx . . $ fmt/Writer# &, int, StringRefcxx . . $ fmt/StringRef#); |
| 132 | |
| 133 | // Portable thread-safe version of strerror. |
| 134 | // Sets buffer to point to a string describing the error code. |
| 135 | // This can be either a pointer to a string stored in buffer, |
| 136 | // or a pointer to some static immutable string. |
| 137 | // Returns one of the following values: |
| 138 | // 0 - success |
| 139 | // ERANGE - buffer is not large enough to store the error message |
| 140 | // other - failure |
| 141 | // Buffer should be at least of size 1. |
| 142 | int safe_strerrorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).( |
| 143 | int error_code, char *&buffer, stdcxx . . $ std/::size_tcxx . . $ std/size_t# buffer_size) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { |
| 144 | FMT_ASSERTcxx . . $ `src/common/format.h:240:10`!(buffer != 0 && buffer_size != 0, "invalid buffer"); |
| 145 | |
| 146 | class StrErrorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError# { |
| 147 | private: |
| 148 | int error_code_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#error_code_.; |
| 149 | char *&buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_.; |
| 150 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# buffer_size_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_size_.; |
| 151 | |
| 152 | // A noop assignment operator to avoid bogus warnings. |
| 153 | void operatorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#`operator=`(8025fcbd1a542131).=(const StrErrorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError# &) {} |
| 154 | |
| 155 | // Handle the result of XSI-compliant version of strerror_r. |
| 156 | int handlecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#handle(7864480464b09eea).(int result) { |
| 157 | // glibc versions before 2.13 return result in errno. |
| 158 | return result == -1 ? errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! : result; |
| 159 | } |
| 160 | |
| 161 | // Handle the result of GNU-specific version of strerror_r. |
| 162 | int handlecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#handle(1ef8e6ec083aabb9).(char *message) { |
| 163 | // If the buffer is full then the message is probably truncated. |
| 164 | if (message == buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_. && strlen(buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_.) == buffer_size_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_size_. - 1) |
| 165 | return ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!; |
| 166 | buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_. = message; |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | // Handle the case when strerror_r is not available. |
| 171 | int handlecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#handle(66c9ffe06204f7c1).(internalcxx . . $ fmt/internal/::Nullcxx . . $ fmt/internal/Null#<>) { |
| 172 | return fallbackcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#fallback(66c9ffe06204f7c1).(strerror_scxx . . $ strerror_s(77a34204105448c1).(buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_., buffer_size_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_size_., error_code_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#error_code_.)); |
| 173 | } |
| 174 | |
| 175 | // Fallback to strerror_s when strerror_r is not available. |
| 176 | int fallbackcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#fallback(7864480464b09eea).(int result) { |
| 177 | // If the buffer is full then the message is probably truncated. |
| 178 | return result == 0 && strlen(buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_.) == buffer_size_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_size_. - 1 ? |
| 179 | ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`! : result; |
| 180 | } |
| 181 | |
| 182 | // Fallback to strerror if strerror_r and strerror_s are not available. |
| 183 | int fallbackcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#fallback(66c9ffe06204f7c1).(internalcxx . . $ fmt/internal/::Nullcxx . . $ fmt/internal/Null#<>) { |
| 184 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 185 | buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_. = strerror(error_code_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#error_code_.); |
| 186 | return errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; |
| 187 | } |
| 188 | |
| 189 | public: |
| 190 | StrErrorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#StrError(9d68690d07e5b3cf).(int err_code, char *&buf, stdcxx . . $ std/::size_tcxx . . $ std/size_t# buf_size) |
| 191 | : error_code_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#error_code_.(err_code), buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_.(buf), buffer_size_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_size_.(buf_size) {} |
| 192 | |
| 193 | int runcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#run(b126dc7c1de90089).() { |
| 194 | strerror_rcxx . . $ strerror_r(d1a4c5a7425213e5).(0, 0, ""); // Suppress a warning about unused strerror_r. |
| 195 | return handlecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#handle(1ef8e6ec083aabb9).(strerror_r(error_code_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#error_code_., buffer_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_., buffer_size_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#buffer_size_.)); |
| 196 | } |
| 197 | }; |
| 198 | return StrErrorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#StrError(9d68690d07e5b3cf).(error_code, buffer, buffer_size).runcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).StrError#run(b126dc7c1de90089).(); |
| 199 | } |
| 200 | |
| 201 | void format_error_codecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/format_error_code(a97816e40fb22830).(Writercxx . . $ fmt/Writer# &out, int error_code, |
| 202 | StringRefcxx . . $ fmt/StringRef# message) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { |
| 203 | // Report error code making sure that the output fits into |
| 204 | // INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential |
| 205 | // bad_alloc. |
| 206 | out.clearcxx . . $ fmt/BasicWriter#clear(ced63f7c635d850d).(); |
| 207 | static const char SEP[] = ": "; |
| 208 | static const char ERROR_STR[] = "error "; |
| 209 | // Subtract 2 to account for terminating null characters in SEP and ERROR_STR. |
| 210 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2; |
| 211 | typedef internalcxx . . $ fmt/internal/::IntTraitscxx . . $ fmt/internal/IntTraits#<int>::MainTypecxx . . $ fmt/internal/IntTraits#MainType# MainTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/format_error_code(a97816e40fb22830).MainType#; |
| 212 | MainTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/format_error_code(a97816e40fb22830).MainType# abs_value = static_cast<MainTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/format_error_code(a97816e40fb22830).MainType#>(error_code); |
| 213 | if (internalcxx . . $ fmt/internal/::is_negativecxx . . $ fmt/internal/is_negative(ee44d93984fb03e9).(error_code)) { |
| 214 | abs_value = 0 - abs_value; |
| 215 | ++error_code_size; |
| 216 | } |
| 217 | error_code_size += internalcxx . . $ fmt/internal/::count_digitscxx . . $ fmt/internal/count_digits(2141b656ce2cc063).(abs_value); |
| 218 | if (message.sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).() <= internalcxx . . $ fmt/internal/::INLINE_BUFFER_SIZEcxx . . $ fmt/internal/INLINE_BUFFER_SIZE. - error_code_size) |
| 219 | out <<cxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df). message <<cxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df). SEPcxx . . $ fmt/BasicStringRef#BasicStringRef(88376428bb603c08).; |
| 220 | out <<cxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df). ERROR_STRcxx . . $ fmt/BasicStringRef#BasicStringRef(88376428bb603c08). <<cxx . . $ fmt/BasicWriter#`operator<<`(650b44d5e358551d). error_code; |
| 221 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(out.size() <= internal::INLINE_BUFFER_SIZE); |
| 222 | } |
| 223 | |
| 224 | void report_errorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/report_error(888630e745b7c273).(FormatFunccxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/FormatFunc# func, int error_code, |
| 225 | StringRefcxx . . $ fmt/StringRef# message) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { |
| 226 | MemoryWritercxx . . $ fmt/MemoryWriter# full_messagecxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 227 | func(full_message, error_code, message); |
| 228 | // Use Writer::data instead of Writer::c_str to avoid potential memory |
| 229 | // allocation. |
| 230 | stdcxx . . $ std/::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(full_message.datacxx . . $ fmt/BasicWriter#data(8e614c7de0b1573e).(), full_message.sizecxx . . $ fmt/BasicWriter#size(fe4d2d262d4164a8).(), 1, stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 231 | stdcxx . . $ std/::fputccxx . . $ std/fputc(b1cd03d6c470d1bd).('\n', stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 232 | } |
| 233 | |
| 234 | // IsZeroInt::visit(arg) returns true iff arg is a zero integer. |
| 235 | class IsZeroIntcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IsZeroInt# : public ArgVisitorcxx . . $ fmt/ArgVisitor#<IsZeroIntcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IsZeroInt#, bool> { |
| 236 | public: |
| 237 | template <typename T> |
| 238 | bool visit_any_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IsZeroInt#visit_any_int(ee44d93984fb03e9).(T value) { return value == 0; } |
| 239 | }; |
| 240 | |
| 241 | // Checks if an argument is a valid printf width specifier and sets |
| 242 | // left alignment if it is negative. |
| 243 | class WidthHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler# : public ArgVisitorcxx . . $ fmt/ArgVisitor#<WidthHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#, unsigned> { |
| 244 | private: |
| 245 | FormatSpeccxx . . $ fmt/FormatSpec# &spec_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#spec_.; |
| 246 | |
| 247 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ `src/common/format.h:217:10`!(WidthHandler); |
| 248 | |
| 249 | public: |
| 250 | explicit WidthHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#WidthHandler(b24f332c44b36186).(FormatSpeccxx . . $ fmt/FormatSpec# &spec) : spec_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#spec_.(spec) {} |
| 251 | |
| 252 | void report_unhandled_argcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#report_unhandled_arg(49f6e7a06ebc5aa8).() { |
| 253 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("width is not integer")); |
| 254 | } |
| 255 | |
| 256 | template <typename T> |
| 257 | unsigned visit_any_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#visit_any_int(78ea24164916a3a1).(T value) { |
| 258 | typedef typename internalcxx . . $ fmt/internal/::IntTraitscxx . . $ fmt/internal/IntTraits#<T>::MainType UnsignedTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#visit_any_int(78ea24164916a3a1).UnsignedType#; |
| 259 | UnsignedTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#visit_any_int(78ea24164916a3a1).UnsignedType# width = static_cast<UnsignedTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#visit_any_int(78ea24164916a3a1).UnsignedType#>(value); |
| 260 | if (internalcxx . . $ fmt/internal/::is_negativecxx . . $ fmt/internal/is_negative(ee44d93984fb03e9).(value)) { |
| 261 | spec_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#spec_..align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.; |
| 262 | width = 0 - width; |
| 263 | } |
| 264 | if (width > INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!) |
| 265 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("number is too big")); |
| 266 | return static_cast<unsigned>(width); |
| 267 | } |
| 268 | }; |
| 269 | |
| 270 | class PrecisionHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/PrecisionHandler# : public ArgVisitorcxx . . $ fmt/ArgVisitor#<PrecisionHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/PrecisionHandler#, int> { |
| 271 | public: |
| 272 | void report_unhandled_argcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/PrecisionHandler#report_unhandled_arg(49f6e7a06ebc5aa8).() { |
| 273 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("precision is not integer")); |
| 274 | } |
| 275 | |
| 276 | template <typename T> |
| 277 | int visit_any_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/PrecisionHandler#visit_any_int(f4542d83968c5b4e).(T value) { |
| 278 | if (!IntCheckercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IntChecker#<std::numeric_limits<T>::is_signed>::fits_in_int(value)) |
| 279 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("number is too big")); |
| 280 | return static_cast<int>(value); |
| 281 | } |
| 282 | }; |
| 283 | |
| 284 | template <typename T, typename U> |
| 285 | struct is_samecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/is_same# { |
| 286 | enumcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/is_same#$anonymous_type_0# { valuecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/is_same#value. = 0 }; |
| 287 | }; |
| 288 | |
| 289 | template <typename T> |
| 290 | struct is_samecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/is_same#<T, T> { |
| 291 | enumcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/is_same#$anonymous_type_1# { valuecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/is_same#value. = 1 }; |
| 292 | }; |
| 293 | |
| 294 | // An argument visitor that converts an integer argument to T for printf, |
| 295 | // if T is an integral type. If T is void, the argument is converted to |
| 296 | // corresponding signed or unsigned type depending on the type specifier: |
| 297 | // 'd' and 'i' - signed, other - unsigned) |
| 298 | template <typename T = void> |
| 299 | class ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter# : public ArgVisitorcxx . . $ fmt/ArgVisitor#<ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<T>, void> { |
| 300 | private: |
| 301 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# &arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_.; |
| 302 | wchar_t type_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#type_.; |
| 303 | |
| 304 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ `src/common/format.h:217:10`!(ArgConverter); |
| 305 | |
| 306 | public: |
| 307 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#`ArgConverter<T>`(2e2c2f5c8243756d).(internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# &arg, wchar_t type) |
| 308 | : arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_.(arg), type_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#type_.(type) {} |
| 309 | |
| 310 | void visit_boolcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_bool(b45ddcbc8423892c).(bool value) { |
| 311 | if (type_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#type_. != 's') |
| 312 | visit_any_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).(value); |
| 313 | } |
| 314 | |
| 315 | template <typename U> |
| 316 | void visit_any_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).(U value) { |
| 317 | bool is_signed = type_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#type_. == 'd' || type_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#type_. == 'i'; |
| 318 | using internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).Arg#; |
| 319 | typedef typename internalcxx . . $ fmt/internal/::Conditionalcxx . . $ fmt/internal/Conditional#< |
| 320 | is_same<T, void>::value, U, T>::type TargetTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).TargetType#; |
| 321 | if (sizeof(TargetTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).TargetType#) <= sizeof(int)) { |
| 322 | // Extra casts are used to silence warnings. |
| 323 | if (is_signed) { |
| 324 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..typecxx . . $ fmt/internal/Arg#type. = Argcxx . . $ fmt/internal/Arg#::INTcxx . . $ fmt/internal/Value#INT.; |
| 325 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. = static_cast<int>(static_cast<TargetTypecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).TargetType#>(value)); |
| 326 | } |
| 327 | else { |
| 328 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..typecxx . . $ fmt/internal/Arg#type. = Argcxx . . $ fmt/internal/Arg#::UINTcxx . . $ fmt/internal/Value#UINT.; |
| 329 | typedef typename internalcxx . . $ fmt/internal/::MakeUnsignedcxx . . $ fmt/internal/MakeUnsigned#<TargetType>::Type Unsignedcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).Unsigned#; |
| 330 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..uint_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#uint_value. = static_cast<unsigned>(static_cast<Unsignedcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#visit_any_int(b07662a27bd562f9).Unsigned#>(value)); |
| 331 | } |
| 332 | } |
| 333 | else { |
| 334 | if (is_signed) { |
| 335 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..typecxx . . $ fmt/internal/Arg#type. = Argcxx . . $ fmt/internal/Arg#::LONG_LONGcxx . . $ fmt/internal/Value#LONG_LONG.; |
| 336 | // glibc's printf doesn't sign extend arguments of smaller types: |
| 337 | // std::printf("%lld", -42); // prints "4294967254" |
| 338 | // but we don't have to do the same because it's a UB. |
| 339 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value. = static_cast<LongLongcxx . . $ fmt/LongLong#>(value); |
| 340 | } |
| 341 | else { |
| 342 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..typecxx . . $ fmt/internal/Arg#type. = Argcxx . . $ fmt/internal/Arg#::ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG.; |
| 343 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#arg_..ulong_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#ulong_long_value. = |
| 344 | static_cast<typename internalcxx . . $ fmt/internal/::MakeUnsignedcxx . . $ fmt/internal/MakeUnsigned#<U>::Type>(value); |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | }; |
| 349 | |
| 350 | // Converts an integer argument to char for printf. |
| 351 | class CharConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter# : public ArgVisitorcxx . . $ fmt/ArgVisitor#<CharConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#, void> { |
| 352 | private: |
| 353 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# &arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#arg_.; |
| 354 | |
| 355 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ `src/common/format.h:217:10`!(CharConverter); |
| 356 | |
| 357 | public: |
| 358 | explicit CharConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#CharConverter(ca8b6ae1d45b27ad).(internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# &arg) : arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#arg_.(arg) {} |
| 359 | |
| 360 | template <typename T> |
| 361 | void visit_any_intcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#visit_any_int(9b289cee16747614).(T value) { |
| 362 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#arg_..typecxx . . $ fmt/internal/Arg#type. = internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::CHARcxx . . $ fmt/internal/Value#CHAR.; |
| 363 | arg_cxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#arg_..int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. = static_cast<char>(value); |
| 364 | } |
| 365 | }; |
| 366 | } // namespace |
| 367 | |
| 368 | namespace internalcxx . . $ fmt/internal/ { |
| 369 | |
| 370 | template <typename Char> |
| 371 | class PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter# : |
| 372 | public ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#<PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#<Char>, Char> { |
| 373 | |
| 374 | void write_null_pointercxx . . $ fmt/internal/PrintfArgFormatter#write_null_pointer(49f6e7a06ebc5aa8).() { |
| 375 | this->speccxx . . $ fmt/internal/ArgFormatterBase#spec(2dfd5853dabd6fc1).().type_ = 0; |
| 376 | this->writecxx . . $ fmt/internal/ArgFormatterBase#write(b45ddcbc8423892c).("(nil)"); |
| 377 | } |
| 378 | |
| 379 | typedef ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#<PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#<Char>, Char> Basecxx . . $ fmt/internal/PrintfArgFormatter#Base#; |
| 380 | |
| 381 | public: |
| 382 | PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#`PrintfArgFormatter<Char>`(8a980781144a0a4a).(BasicWritercxx . . $ fmt/BasicWriter#<Char> &w, FormatSpeccxx . . $ fmt/FormatSpec# &s) |
| 383 | : ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#<PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#<Char>, Char>(w, s) {} |
| 384 | |
| 385 | void visit_boolcxx . . $ fmt/internal/PrintfArgFormatter#visit_bool(b45ddcbc8423892c).(bool value) { |
| 386 | FormatSpeccxx . . $ fmt/FormatSpec# &fmt_spec = this->speccxx . . $ fmt/internal/ArgFormatterBase#spec(2dfd5853dabd6fc1).(); |
| 387 | if (fmt_spec.type_cxx . . $ fmt/FormatSpec#type_. != 's') |
| 388 | return this->visit_any_intcxx . . $ fmt/internal/ArgFormatterBase#visit_any_int(b07662a27bd562f9).(value); |
| 389 | fmt_spec.type_cxx . . $ fmt/FormatSpec#type_. = 0; |
| 390 | this->writecxx . . $ fmt/internal/ArgFormatterBase#write(b45ddcbc8423892c).(value); |
| 391 | } |
| 392 | |
| 393 | void visit_charcxx . . $ fmt/internal/PrintfArgFormatter#visit_char(d4f767463ce0a6b3).(int value) { |
| 394 | const FormatSpeccxx . . $ fmt/FormatSpec# &fmt_spec = this->speccxx . . $ fmt/internal/ArgFormatterBase#spec(2dfd5853dabd6fc1).(); |
| 395 | BasicWritercxx . . $ fmt/BasicWriter#<Char> &w = this->writercxx . . $ fmt/internal/ArgFormatterBase#writer(3a564b1b84870d38).(); |
| 396 | if (fmt_spec.type_cxx . . $ fmt/FormatSpec#type_. && fmt_spec.type_cxx . . $ fmt/FormatSpec#type_. != 'c') |
| 397 | w.write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(value, fmt_spec); |
| 398 | typedef typename BasicWritercxx . . $ fmt/BasicWriter#<Char>::CharPtr CharPtrcxx . . $ fmt/internal/PrintfArgFormatter#visit_char(d4f767463ce0a6b3).CharPtr#; |
| 399 | CharPtrcxx . . $ fmt/internal/PrintfArgFormatter#visit_char(d4f767463ce0a6b3).CharPtr# out = CharPtrcxx . . $ fmt/internal/PrintfArgFormatter#visit_char(d4f767463ce0a6b3).CharPtr#(); |
| 400 | if (fmt_spec.width_cxx . . $ fmt/WidthSpec#width_. > 1) { |
| 401 | Char fill = ' '; |
| 402 | out = w.grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(fmt_spec.width_cxx . . $ fmt/WidthSpec#width_.); |
| 403 | if (fmt_spec.align_cxx . . $ fmt/AlignSpec#align_. != ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.) { |
| 404 | stdcxx . . $ std/::fill_n(out, fmt_spec.width_cxx . . $ fmt/WidthSpec#width_. - 1, fill); |
| 405 | out += fmt_spec.width_cxx . . $ fmt/WidthSpec#width_. - 1; |
| 406 | } |
| 407 | else { |
| 408 | stdcxx . . $ std/::fill_n(out + 1, fmt_spec.width_cxx . . $ fmt/WidthSpec#width_. - 1, fill); |
| 409 | } |
| 410 | } |
| 411 | else { |
| 412 | out = w.grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(1); |
| 413 | } |
| 414 | *out = static_cast<Char>(value); |
| 415 | } |
| 416 | |
| 417 | void visit_cstringcxx . . $ fmt/internal/PrintfArgFormatter#visit_cstring(85c52e162fed56f9).(const char *value) { |
| 418 | if (value) |
| 419 | Basecxx . . $ fmt/internal/PrintfArgFormatter#Base#::visit_cstring(value); |
| 420 | else if (this->speccxx . . $ fmt/internal/ArgFormatterBase#spec(2dfd5853dabd6fc1).().type_ == 'p') |
| 421 | write_null_pointercxx . . $ fmt/internal/PrintfArgFormatter#write_null_pointer(49f6e7a06ebc5aa8).(); |
| 422 | else |
| 423 | this->writecxx . . $ fmt/internal/ArgFormatterBase#write(b45ddcbc8423892c).("(null)"); |
| 424 | } |
| 425 | |
| 426 | void visit_pointercxx . . $ fmt/internal/PrintfArgFormatter#visit_pointer(e4289f82fef2c2f9).(const void *value) { |
| 427 | if (value) |
| 428 | return Basecxx . . $ fmt/internal/PrintfArgFormatter#Base#::visit_pointer(value); |
| 429 | this->speccxx . . $ fmt/internal/ArgFormatterBase#spec(2dfd5853dabd6fc1).().type_ = 0; |
| 430 | write_null_pointercxx . . $ fmt/internal/PrintfArgFormatter#write_null_pointer(49f6e7a06ebc5aa8).(); |
| 431 | } |
| 432 | |
| 433 | void visit_customcxx . . $ fmt/internal/PrintfArgFormatter#visit_custom(796649238ada7a37).(Argcxx . . $ fmt/internal/Arg#::CustomValuecxx . . $ fmt/internal/Value#CustomValue# c) { |
| 434 | BasicFormattercxx . . $ fmt/BasicFormatter#<Char> formatter(ArgListcxx . . $ fmt/ArgList#ArgList(49f6e7a06ebc5aa8).(), this->writercxx . . $ fmt/internal/ArgFormatterBase#writer(3a564b1b84870d38).()); |
| 435 | const Char format_str[] = { '}', 0 }; |
| 436 | const Char *format = format_str; |
| 437 | c.formatcxx . . $ fmt/internal/Value#CustomValue#format.(&formatter, c.valuecxx . . $ fmt/internal/Value#CustomValue#value., &format); |
| 438 | } |
| 439 | }; |
| 440 | } // namespace internal |
| 441 | } // namespace fmt |
| 442 | |
| 443 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::SystemErrorcxx . . $ fmt/SystemError#::initcxx . . $ fmt/SystemError#init(60989cf3251a0945).( |
| 444 | int err_code, CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args) { |
| 445 | error_code_cxx . . $ fmt/SystemError#error_code_. = err_code; |
| 446 | MemoryWritercxx . . $ fmt/MemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 447 | internalcxx . . $ fmt/internal/::format_system_errorcxx . . $ fmt/internal/format_system_error(a97816e40fb22830).(w, err_code, formatcxx . . $ fmt/BasicStringRef#BasicStringRef(a6cf34ce58443556).(format_str, args)); |
| 448 | stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# &base = *this; |
| 449 | base =cxx . . $ std/runtime_error#`operator=`(922d48a9228d5f48). stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#(w.strcxx . . $ fmt/BasicWriter#str(25a55eb745a1b6bc).()); |
| 450 | } |
| 451 | |
| 452 | template <typename T> |
| 453 | int fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<char>::format_floatcxx . . $ fmt/internal/CharTraits#format_float(9e602bfe50fad09d).( |
| 454 | char *buffer, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size, const char *format, |
| 455 | unsigned width, int precision, T value) { |
| 456 | if (width == 0) { |
| 457 | return precision < 0 ? |
| 458 | FMT_SNPRINTFcxx . . $ `src/common/format.cc:90:10`!(buffer, size, format, value) : |
| 459 | FMT_SNPRINTFcxx . . $ `src/common/format.cc:90:10`!(buffer, size, format, precision, value); |
| 460 | } |
| 461 | return precision < 0 ? |
| 462 | FMT_SNPRINTFcxx . . $ `src/common/format.cc:90:10`!(buffer, size, format, width, value) : |
| 463 | FMT_SNPRINTFcxx . . $ `src/common/format.cc:90:10`!(buffer, size, format, width, precision, value); |
| 464 | } |
| 465 | |
| 466 | template <typename T> |
| 467 | int fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<wchar_t>::format_floatcxx . . $ fmt/internal/CharTraits#format_float(ab2f2ee480ef4af2).( |
| 468 | wchar_t *buffer, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size, const wchar_t *format, |
| 469 | unsigned width, int precision, T value) { |
| 470 | if (width == 0) { |
| 471 | return precision < 0 ? |
| 472 | FMT_SWPRINTFcxx . . $ `src/common/format.cc:105:10`!(buffer, size, format, value) : |
| 473 | FMT_SWPRINTFcxx . . $ `src/common/format.cc:105:10`!(buffer, size, format, precision, value); |
| 474 | } |
| 475 | return precision < 0 ? |
| 476 | FMT_SWPRINTFcxx . . $ `src/common/format.cc:105:10`!(buffer, size, format, width, value) : |
| 477 | FMT_SWPRINTFcxx . . $ `src/common/format.cc:105:10`!(buffer, size, format, width, precision, value); |
| 478 | } |
| 479 | |
| 480 | template <typename T> |
| 481 | const char fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::BasicDatacxx . . $ fmt/internal/BasicData#<T>::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[] = |
| 482 | "0001020304050607080910111213141516171819" |
| 483 | "2021222324252627282930313233343536373839" |
| 484 | "4041424344454647484950515253545556575859" |
| 485 | "6061626364656667686970717273747576777879" |
| 486 | "8081828384858687888990919293949596979899"; |
| 487 | |
| 488 | #define FMT_POWERS_OF_10cxx . . $ `src/common/format.cc:488:9`!(factor) \ |
| 489 | factor * 10, \ |
| 490 | factor * 100, \ |
| 491 | factor * 1000, \ |
| 492 | factor * 10000, \ |
| 493 | factor * 100000, \ |
| 494 | factor * 1000000, \ |
| 495 | factor * 10000000, \ |
| 496 | factor * 100000000, \ |
| 497 | factor * 1000000000 |
| 498 | |
| 499 | template <typename T> |
| 500 | const uint32_tcxx . . $ uint32_t# fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::BasicDatacxx . . $ fmt/internal/BasicData#<T>::POWERS_OF_10_32cxx . . $ fmt/internal/BasicData#POWERS_OF_10_32.[] = { |
| 501 | 0, FMT_POWERS_OF_10cxx . . $ `src/common/format.cc:488:9`!(1) |
| 502 | }; |
| 503 | |
| 504 | template <typename T> |
| 505 | const uint64_tcxx . . $ uint64_t# fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::BasicDatacxx . . $ fmt/internal/BasicData#<T>::POWERS_OF_10_64cxx . . $ fmt/internal/BasicData#POWERS_OF_10_64.[] = { |
| 506 | 0, |
| 507 | FMT_POWERS_OF_10cxx . . $ `src/common/format.cc:488:9`!(1), |
| 508 | FMT_POWERS_OF_10cxx . . $ `src/common/format.cc:488:9`!(fmt::ULongLong(1000000000)), |
| 509 | // Multiply several constants instead of using a single long long constant |
| 510 | // to avoid warnings about C++98 not supporting long long. |
| 511 | fmtcxx . . $ fmt/::ULongLongcxx . . $ fmt/ULongLong#(1000000000) * fmtcxx . . $ fmt/::ULongLongcxx . . $ fmt/ULongLong#(1000000000) * 10 |
| 512 | }; |
| 513 | |
| 514 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::report_unknown_typecxx . . $ fmt/internal/report_unknown_type(6d02e1a5f7bf8914).(char code, const char *type) { |
| 515 | (void)type; |
| 516 | if (stdcxx . . $ std/::isprintcxx . . $ std/isprint(a1851578aea3f541).(static_cast<unsigned char>(code))) { |
| 517 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(fmt::FormatError( |
| 518 | fmt::format("unknown format code '{}' for {}", code, type))); |
| 519 | } |
| 520 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(fmt::FormatError( |
| 521 | fmt::format("unknown format code '\\x{:02x}' for {}", |
| 522 | static_cast<unsigned>(code), type))); |
| 523 | } |
| 524 | |
| 525 | #if FMT_USE_WINDOWS_Hcxx . . $ `src/common/format.h:958:10`! |
| 526 | |
| 527 | FMT_FUNC fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) { |
| 528 | static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16"; |
| 529 | if (s.size() > INT_MAX) |
| 530 | FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG)); |
| 531 | int s_size = static_cast<int>(s.size()); |
| 532 | int length = MultiByteToWideChar( |
| 533 | CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, 0, 0); |
| 534 | if (length == 0) |
| 535 | FMT_THROW(WindowsError(GetLastError(), ERROR_MSG)); |
| 536 | buffer_.resize(length + 1); |
| 537 | length = MultiByteToWideChar( |
| 538 | CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, &buffer_[0], length); |
| 539 | if (length == 0) |
| 540 | FMT_THROW(WindowsError(GetLastError(), ERROR_MSG)); |
| 541 | buffer_[length] = 0; |
| 542 | } |
| 543 | |
| 544 | FMT_FUNC fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) { |
| 545 | if (int error_code = convert(s)) { |
| 546 | FMT_THROW(WindowsError(error_code, |
| 547 | "cannot convert string from UTF-16 to UTF-8")); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | FMT_FUNC int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) { |
| 552 | if (s.size() > INT_MAX) |
| 553 | return ERROR_INVALID_PARAMETER; |
| 554 | int s_size = static_cast<int>(s.size()); |
| 555 | int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, 0, 0, 0, 0); |
| 556 | if (length == 0) |
| 557 | return GetLastError(); |
| 558 | buffer_.resize(length + 1); |
| 559 | length = WideCharToMultiByte( |
| 560 | CP_UTF8, 0, s.data(), s_size, &buffer_[0], length, 0, 0); |
| 561 | if (length == 0) |
| 562 | return GetLastError(); |
| 563 | buffer_[length] = 0; |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | FMT_FUNC void fmt::WindowsError::init( |
| 568 | int err_code, CStringRef format_str, ArgList args) { |
| 569 | error_code_ = err_code; |
| 570 | MemoryWriter w; |
| 571 | internal::format_windows_error(w, err_code, format(format_str, args)); |
| 572 | std::runtime_error &base = *this; |
| 573 | base = std::runtime_error(w.str()); |
| 574 | } |
| 575 | |
| 576 | FMT_FUNC void fmt::internal::format_windows_error( |
| 577 | fmt::Writer &out, int error_code, |
| 578 | fmt::StringRef message) FMT_NOEXCEPT { |
| 579 | FMT_TRY{ |
| 580 | MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer; |
| 581 | buffer.resize(INLINE_BUFFER_SIZE); |
| 582 | for (;;) { |
| 583 | wchar_t *system_message = &buffer[0]; |
| 584 | int result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 585 | 0, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 586 | system_message, static_cast<uint32_t>(buffer.size()), 0); |
| 587 | if (result != 0) { |
| 588 | UTF16ToUTF8 utf8_message; |
| 589 | if (utf8_message.convert(system_message) == ERROR_SUCCESS) { |
| 590 | out << message << ": " << utf8_message; |
| 591 | return; |
| 592 | } |
| 593 | break; |
| 594 | } |
| 595 | if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) |
| 596 | break; // Can't get error message, report error code instead. |
| 597 | buffer.resize(buffer.size() * 2); |
| 598 | } |
| 599 | } FMT_CATCH(...) {} |
| 600 | fmt::format_error_code(out, error_code, message); // 'fmt::' is for bcc32. |
| 601 | } |
| 602 | |
| 603 | #endif // FMT_USE_WINDOWS_H |
| 604 | |
| 605 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::format_system_errorcxx . . $ fmt/internal/format_system_error(a97816e40fb22830).( |
| 606 | fmtcxx . . $ fmt/::Writercxx . . $ fmt/Writer# &out, int error_code, |
| 607 | fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# message) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { |
| 608 | FMT_TRYcxx . . $ `src/common/format.cc:56:10`!{ |
| 609 | MemoryBuffercxx . . $ fmt/internal/MemoryBuffer#<char, INLINE_BUFFER_SIZEcxx . . $ fmt/internal/INLINE_BUFFER_SIZE.> buffercxx . . $ fmt/internal/MemoryBuffer#MemoryBuffer(dac9925308f1454a).; |
| 610 | buffer.resizecxx . . $ fmt/Buffer#resize(2c44cd906ae4e829).(INLINE_BUFFER_SIZEcxx . . $ fmt/internal/INLINE_BUFFER_SIZE.); |
| 611 | for (;;) { |
| 612 | char *system_message = &buffer[cxx . . $ fmt/Buffer#`operator[]`(ec43b8547ac5c60).0]; |
| 613 | int result = safe_strerrorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/safe_strerror(1bfad49e456f5dc6).(error_code, system_message, buffer.sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).()); |
| 614 | if (result == 0) { |
| 615 | out <<cxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df). message <<cxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df). ": "cxx . . $ fmt/BasicStringRef#BasicStringRef(88376428bb603c08). <<cxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df). system_messagecxx . . $ fmt/BasicStringRef#BasicStringRef(88376428bb603c08).; |
| 616 | return; |
| 617 | } |
| 618 | if (result != ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!) |
| 619 | break; // Can't get error message, report error code instead. |
| 620 | buffer.resizecxx . . $ fmt/Buffer#resize(2c44cd906ae4e829).(buffer.sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).() * 2); |
| 621 | } |
| 622 | } FMT_CATCHcxx . . $ `src/common/format.cc:57:10`!(...) {} |
| 623 | fmtcxx . . $ fmt/::format_error_codecxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/format_error_code(a97816e40fb22830).(out, error_code, message); // 'fmt::' is for bcc32. |
| 624 | } |
| 625 | |
| 626 | template <typename Char> |
| 627 | void fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::ArgMapcxx . . $ fmt/internal/ArgMap#<Char>::initcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).(const ArgListcxx . . $ fmt/ArgList# &args) { |
| 628 | if (!map_cxx . . $ fmt/internal/ArgMap#map_..emptycxx . . $ std/vector#empty(3482b152b9333168).()) |
| 629 | return; |
| 630 | typedef internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<Char> NamedArgcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).NamedArg#; |
| 631 | const NamedArgcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).NamedArg# *named_arg = 0; |
| 632 | bool use_values = |
| 633 | args.typecxx . . $ fmt/ArgList#type(9e7eabfe59388a4d).(ArgListcxx . . $ fmt/ArgList#::MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS. - 1) == internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.; |
| 634 | if (use_values) { |
| 635 | for (unsigned i = 0;/*nothing*/; ++i) { |
| 636 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::Typecxx . . $ fmt/internal/Value#Type# arg_type = args.typecxx . . $ fmt/ArgList#type(9e7eabfe59388a4d).(i); |
| 637 | switch (arg_type) { |
| 638 | case internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.: |
| 639 | return; |
| 640 | case internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG.: |
| 641 | named_arg = static_cast<const NamedArgcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).NamedArg#*>(args.values_cxx . . $ fmt/ArgList#$anonymous_type_12#values_.[i].pointercxx . . $ fmt/internal/Value#$anonymous_type_1#pointer.); |
| 642 | map_cxx . . $ fmt/internal/ArgMap#map_..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(Paircxx . . $ fmt/internal/ArgMap#Pair#(named_arg->namecxx . . $ fmt/internal/NamedArg#name., *named_arg)); |
| 643 | break; |
| 644 | default: |
| 645 | /*nothing*/; |
| 646 | } |
| 647 | } |
| 648 | return; |
| 649 | } |
| 650 | for (unsigned i = 0; i != ArgListcxx . . $ fmt/ArgList#::MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS.; ++i) { |
| 651 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::Typecxx . . $ fmt/internal/Value#Type# arg_type = args.typecxx . . $ fmt/ArgList#type(9e7eabfe59388a4d).(i); |
| 652 | if (arg_type == internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG.) { |
| 653 | named_arg = static_cast<const NamedArgcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).NamedArg#*>(args.args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[i].pointercxx . . $ fmt/internal/Value#$anonymous_type_1#pointer.); |
| 654 | map_cxx . . $ fmt/internal/ArgMap#map_..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(Paircxx . . $ fmt/internal/ArgMap#Pair#(named_arg->namecxx . . $ fmt/internal/NamedArg#name., *named_arg)); |
| 655 | } |
| 656 | } |
| 657 | for (unsigned i = ArgListcxx . . $ fmt/ArgList#::MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS.;/*nothing*/; ++i) { |
| 658 | switch (args.args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[i].typecxx . . $ fmt/internal/Arg#type.) { |
| 659 | case internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.: |
| 660 | return; |
| 661 | case internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG.: |
| 662 | named_arg = static_cast<const NamedArgcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).NamedArg#*>(args.args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[i].pointercxx . . $ fmt/internal/Value#$anonymous_type_1#pointer.); |
| 663 | map_cxx . . $ fmt/internal/ArgMap#map_..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(Paircxx . . $ fmt/internal/ArgMap#Pair#(named_arg->namecxx . . $ fmt/internal/NamedArg#name., *named_arg)); |
| 664 | break; |
| 665 | default: |
| 666 | /*nothing*/; |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | template <typename Char> |
| 672 | void fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::FixedBuffercxx . . $ fmt/internal/FixedBuffer#<Char>::growcxx . . $ fmt/internal/FixedBuffer#grow(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t#) { |
| 673 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(std::runtime_error("buffer overflow")); |
| 674 | } |
| 675 | |
| 676 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! Argcxx . . $ Arg# fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::FormatterBasecxx . . $ fmt/internal/FormatterBase#::do_get_argcxx . . $ fmt/internal/FormatterBase#do_get_arg(e6750e432c057443).( |
| 677 | unsigned arg_index, const char *&error) { |
| 678 | Argcxx . . $ fmt/internal/Arg# arg = args_cxx . . $ fmt/internal/FormatterBase#args_.[cxx . . $ fmt/ArgList#`operator[]`(608608331423e214).arg_index]; |
| 679 | switch (arg.typecxx . . $ fmt/internal/Arg#type.) { |
| 680 | case Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.: |
| 681 | error = "argument index out of range"; |
| 682 | break; |
| 683 | case Argcxx . . $ fmt/internal/Arg#::NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG.: |
| 684 | arg =cxx . . $ fmt/internal/Arg#`operator=`(8236794834140450). *static_cast<const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#*>(arg.pointercxx . . $ fmt/internal/Value#$anonymous_type_1#pointer.); |
| 685 | break; |
| 686 | default: |
| 687 | /*nothing*/; |
| 688 | } |
| 689 | return arg; |
| 690 | } |
| 691 | |
| 692 | template <typename Char> |
| 693 | void fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::PrintfFormattercxx . . $ fmt/internal/PrintfFormatter#<Char>::parse_flagscxx . . $ fmt/internal/PrintfFormatter#parse_flags(34fdf22eefd20db8).( |
| 694 | FormatSpeccxx . . $ fmt/FormatSpec# &spec, const Char *&s) { |
| 695 | for (;;) { |
| 696 | switch (*s++) { |
| 697 | case '-': |
| 698 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.; |
| 699 | break; |
| 700 | case '+': |
| 701 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= SIGN_FLAGcxx . . $ fmt/SIGN_FLAG. | PLUS_FLAGcxx . . $ fmt/PLUS_FLAG.; |
| 702 | break; |
| 703 | case '0': |
| 704 | spec.fill_cxx . . $ fmt/WidthSpec#fill_. = '0'; |
| 705 | break; |
| 706 | case ' ': |
| 707 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= SIGN_FLAGcxx . . $ fmt/SIGN_FLAG.; |
| 708 | break; |
| 709 | case '#': |
| 710 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= HASH_FLAGcxx . . $ fmt/HASH_FLAG.; |
| 711 | break; |
| 712 | default: |
| 713 | --s; |
| 714 | return; |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | template <typename Char> |
| 720 | Argcxx . . $ Arg# fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::PrintfFormattercxx . . $ fmt/internal/PrintfFormatter#<Char>::get_argcxx . . $ fmt/internal/PrintfFormatter#get_arg(6639e3f2d4ffaf54).( |
| 721 | const Char *s, unsigned arg_index) { |
| 722 | (void)s; |
| 723 | const char *error = 0; |
| 724 | Argcxx . . $ fmt/internal/Arg# arg = arg_index == UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`! ? |
| 725 | next_argcxx . . $ fmt/internal/FormatterBase#next_arg(706a258656295a38).(error) : FormatterBasecxx . . $ fmt/internal/FormatterBase#::get_argcxx . . $ fmt/internal/FormatterBase#get_arg(e6750e432c057443).(arg_index - 1, error); |
| 726 | if (error) |
| 727 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError(!*s ? "invalid format string" : error)); |
| 728 | return arg; |
| 729 | } |
| 730 | |
| 731 | template <typename Char> |
| 732 | unsigned fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::PrintfFormattercxx . . $ fmt/internal/PrintfFormatter#<Char>::parse_headercxx . . $ fmt/internal/PrintfFormatter#parse_header(48902020be8b8fd8).( |
| 733 | const Char *&s, FormatSpeccxx . . $ fmt/FormatSpec# &spec) { |
| 734 | unsigned arg_index = UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!; |
| 735 | Char c = *s; |
| 736 | if (c >= '0' && c <= '9') { |
| 737 | // Parse an argument index (if followed by '$') or a width possibly |
| 738 | // preceded with '0' flag(s). |
| 739 | unsigned value = parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(s); |
| 740 | if (*s == '$') { // value is an argument index |
| 741 | ++s; |
| 742 | arg_index = value; |
| 743 | } |
| 744 | else { |
| 745 | if (c == '0') |
| 746 | spec.fill_cxx . . $ fmt/WidthSpec#fill_. = '0'; |
| 747 | if (value != 0) { |
| 748 | // Nonzero value means that we parsed width and don't need to |
| 749 | // parse it or flags again, so return now. |
| 750 | spec.width_cxx . . $ fmt/WidthSpec#width_. = value; |
| 751 | return arg_index; |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | parse_flagscxx . . $ fmt/internal/PrintfFormatter#parse_flags(34fdf22eefd20db8).(spec, s); |
| 756 | // Parse width. |
| 757 | if (*s >= '0' && *s <= '9') { |
| 758 | spec.width_cxx . . $ fmt/WidthSpec#width_. = parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(s); |
| 759 | } |
| 760 | else if (*s == '*') { |
| 761 | ++s; |
| 762 | spec.width_cxx . . $ fmt/WidthSpec#width_. = WidthHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/WidthHandler#(spec).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(get_argcxx . . $ fmt/internal/PrintfFormatter#get_arg(6639e3f2d4ffaf54).(s)); |
| 763 | } |
| 764 | return arg_index; |
| 765 | } |
| 766 | |
| 767 | template <typename Char> |
| 768 | void fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::PrintfFormattercxx . . $ fmt/internal/PrintfFormatter#<Char>::formatcxx . . $ fmt/internal/PrintfFormatter#format(aaacc8ac315733de).( |
| 769 | BasicWritercxx . . $ fmt/BasicWriter#<Char> &writer, BasicCStringRefcxx . . $ fmt/BasicCStringRef#<Char> format_str) { |
| 770 | const Char *start = format_str.c_strcxx . . $ fmt/BasicCStringRef#c_str(1016ee5406d91ab9).(); |
| 771 | const Char *s = start; |
| 772 | while (*s) { |
| 773 | Char c = *s++; |
| 774 | if (c != '%') continue; |
| 775 | if (*s == c) { |
| 776 | writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(writer, start, s); |
| 777 | start = ++s; |
| 778 | continue; |
| 779 | } |
| 780 | writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(writer, start, s - 1); |
| 781 | |
| 782 | FormatSpeccxx . . $ fmt/FormatSpec# speccxx . . $ fmt/FormatSpec#FormatSpec(38cf5fc7ed65b972).; |
| 783 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_RIGHTcxx . . $ fmt/ALIGN_RIGHT.; |
| 784 | |
| 785 | // Parse argument index, flags and width. |
| 786 | unsigned arg_index = parse_headercxx . . $ fmt/internal/PrintfFormatter#parse_header(48902020be8b8fd8).(s, spec); |
| 787 | |
| 788 | // Parse precision. |
| 789 | if (*s == '.') { |
| 790 | ++s; |
| 791 | if ('0' <= *s && *s <= '9') { |
| 792 | spec.precision_cxx . . $ fmt/FormatSpec#precision_. = static_cast<int>(parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(s)); |
| 793 | } |
| 794 | else if (*s == '*') { |
| 795 | ++s; |
| 796 | spec.precision_cxx . . $ fmt/FormatSpec#precision_. = PrecisionHandlercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/PrecisionHandler#().visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(get_argcxx . . $ fmt/internal/PrintfFormatter#get_arg(6639e3f2d4ffaf54).(s)); |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | Argcxx . . $ fmt/internal/Arg# arg = get_argcxx . . $ fmt/internal/PrintfFormatter#get_arg(6639e3f2d4ffaf54).(s, arg_index); |
| 801 | if (spec.flagcxx . . $ fmt/FormatSpec#flag(8de63fdb265b07c1).(HASH_FLAGcxx . . $ fmt/HASH_FLAG.) && IsZeroIntcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/IsZeroInt#().visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg)) |
| 802 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. &= ~to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).<int>(HASH_FLAGcxx . . $ fmt/HASH_FLAG.); |
| 803 | if (spec.fill_cxx . . $ fmt/WidthSpec#fill_. == '0') { |
| 804 | if (arg.typecxx . . $ fmt/internal/Arg#type. <= Argcxx . . $ fmt/internal/Arg#::LAST_NUMERIC_TYPEcxx . . $ fmt/internal/Value#LAST_NUMERIC_TYPE.) |
| 805 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC.; |
| 806 | else |
| 807 | spec.fill_cxx . . $ fmt/WidthSpec#fill_. = ' '; // Ignore '0' flag for non-numeric types. |
| 808 | } |
| 809 | |
| 810 | // Parse length and convert the argument to the required type. |
| 811 | switch (*s++) { |
| 812 | case 'h': |
| 813 | if (*s == 'h') |
| 814 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<signed char>(arg, *++s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 815 | else |
| 816 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<short>(arg, *s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 817 | break; |
| 818 | case 'l': |
| 819 | if (*s == 'l') |
| 820 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<fmtcxx . . $ fmt/::LongLongcxx . . $ fmt/LongLong#>(arg, *++s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 821 | else |
| 822 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<long>(arg, *s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 823 | break; |
| 824 | case 'j': |
| 825 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<intmax_tcxx . . $ intmax_t#>(arg, *s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 826 | break; |
| 827 | case 'z': |
| 828 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<stdcxx . . $ std/::size_tcxx . . $ std/size_t#>(arg, *s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 829 | break; |
| 830 | case 't': |
| 831 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<stdcxx . . $ std/::ptrdiff_tcxx . . $ std/ptrdiff_t#>(arg, *s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 832 | break; |
| 833 | case 'L': |
| 834 | // printf produces garbage when 'L' is omitted for long double, no |
| 835 | // need to do the same. |
| 836 | break; |
| 837 | default: |
| 838 | --s; |
| 839 | ArgConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/ArgConverter#<void>(arg, *s).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 840 | } |
| 841 | |
| 842 | // Parse type. |
| 843 | if (!*s) |
| 844 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("invalid format string")); |
| 845 | spec.type_cxx . . $ fmt/FormatSpec#type_. = static_cast<char>(*s++); |
| 846 | if (arg.typecxx . . $ fmt/internal/Arg#type. <= Argcxx . . $ fmt/internal/Arg#::LAST_INTEGER_TYPEcxx . . $ fmt/internal/Value#LAST_INTEGER_TYPE.) { |
| 847 | // Normalize type. |
| 848 | switch (spec.type_cxx . . $ fmt/FormatSpec#type_.) { |
| 849 | case 'i': case 'u': |
| 850 | spec.type_cxx . . $ fmt/FormatSpec#type_. = 'd'; |
| 851 | break; |
| 852 | case 'c': |
| 853 | // TODO: handle wchar_t |
| 854 | CharConvertercxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/CharConverter#(arg).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 855 | break; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | start = s; |
| 860 | |
| 861 | // Format argument. |
| 862 | internalcxx . . $ fmt/internal/::PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#<Char>(writer, spec).visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(arg); |
| 863 | } |
| 864 | writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(writer, start, s); |
| 865 | } |
| 866 | |
| 867 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::report_system_errorcxx . . $ fmt/report_system_error(5342d16ac7ed7db5).( |
| 868 | int error_code, fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# message) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { |
| 869 | // 'fmt::' is for bcc32. |
| 870 | fmtcxx . . $ fmt/::report_errorcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/report_error(888630e745b7c273).(internalcxx . . $ fmt/internal/::format_system_errorcxx . . $ fmt/internal/format_system_error(a97816e40fb22830)., error_code, message); |
| 871 | } |
| 872 | |
| 873 | #if FMT_USE_WINDOWS_Hcxx . . $ `src/common/format.h:958:10`! |
| 874 | FMT_FUNC void fmt::report_windows_error( |
| 875 | int error_code, fmt::StringRef message) FMT_NOEXCEPT { |
| 876 | // 'fmt::' is for bcc32. |
| 877 | fmt::report_error(internal::format_windows_error, error_code, message); |
| 878 | } |
| 879 | #endif |
| 880 | |
| 881 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::printcxx . . $ fmt/print(e8f536e71f29b79e).(stdcxx . . $ std/::FILEcxx . . $ std/FILE# *f, CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args) { |
| 882 | MemoryWritercxx . . $ fmt/MemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 883 | w.writecxx . . $ fmt/BasicWriter#write(b7238e95b93927f0).(format_str, args); |
| 884 | stdcxx . . $ std/::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(w.datacxx . . $ fmt/BasicWriter#data(8e614c7de0b1573e).(), 1, w.sizecxx . . $ fmt/BasicWriter#size(fe4d2d262d4164a8).(), f); |
| 885 | } |
| 886 | |
| 887 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::printcxx . . $ fmt/print(152d9752edd7c5e9).(CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args) { |
| 888 | printcxx . . $ fmt/print(e8f536e71f29b79e).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, format_str, args); |
| 889 | } |
| 890 | |
| 891 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! void fmtcxx . . $ fmt/::print_coloredcxx . . $ fmt/print_colored(eba6a579d5b12442).(Colorcxx . . $ fmt/Color# c, CStringRefcxx . . $ fmt/CStringRef# format, ArgListcxx . . $ fmt/ArgList# args) { |
| 892 | char escape[] = "\x1b[30m"; |
| 893 | escape[3] = static_cast<char>('0' + c); |
| 894 | stdcxx . . $ std/::fputscxx . . $ std/fputs(874fa6a5e59ab9bd).(escape, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 895 | printcxx . . $ fmt/print(152d9752edd7c5e9).(format, args); |
| 896 | stdcxx . . $ std/::fputscxx . . $ std/fputs(874fa6a5e59ab9bd).(RESET_COLORcxx . . $ fmt/`$anonymous_namespace_src/common/format.cc`/RESET_COLOR., stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 897 | } |
| 898 | |
| 899 | FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! int fmtcxx . . $ fmt/::fprintfcxx . . $ fmt/fprintf(796076e824467111).(stdcxx . . $ std/::FILEcxx . . $ std/FILE# *f, CStringRefcxx . . $ fmt/CStringRef# format, ArgListcxx . . $ fmt/ArgList# args) { |
| 900 | MemoryWritercxx . . $ fmt/MemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 901 | printfcxx . . $ fmt/printf(a24296c0c844b519).(w, format, args); |
| 902 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# size = w.sizecxx . . $ fmt/BasicWriter#size(fe4d2d262d4164a8).(); |
| 903 | return stdcxx . . $ std/::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(w.datacxx . . $ fmt/BasicWriter#data(8e614c7de0b1573e).(), 1, size, f) < size ? -1 : static_cast<int>(size); |
| 904 | } |
| 905 | |
| 906 | #ifndef FMT_HEADER_ONLY |
| 907 | |
| 908 | template struct fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::BasicDatacxx . . $ fmt/internal/BasicData#<void>; |
| 909 | |
| 910 | // Explicit instantiations for char. |
| 911 | |
| 912 | template void fmt::internal::FixedBuffer<char>::grow(std::size_t); |
| 913 | |
| 914 | template void fmt::internal::ArgMap<char>::init(const fmt::ArgList &args); |
| 915 | |
| 916 | template void fmt::internal::PrintfFormatter<char>::format( |
| 917 | BasicWriter<char> &writer, CStringRef format); |
| 918 | |
| 919 | template int fmt::internal::CharTraits<char>::format_float( |
| 920 | char *buffer, std::size_t size, const char *format, |
| 921 | unsigned width, int precision, double value); |
| 922 | |
| 923 | template int fmt::internal::CharTraits<char>::format_float( |
| 924 | char *buffer, std::size_t size, const char *format, |
| 925 | unsigned width, int precision, long double value); |
| 926 | |
| 927 | // Explicit instantiations for wchar_t. |
| 928 | |
| 929 | template void fmt::internal::FixedBuffer<wchar_t>::grow(std::size_t); |
| 930 | |
| 931 | template void fmt::internal::ArgMap<wchar_t>::init(const fmt::ArgList &args); |
| 932 | |
| 933 | template void fmt::internal::PrintfFormatter<wchar_t>::format( |
| 934 | BasicWriter<wchar_t> &writer, WCStringRef format); |
| 935 | |
| 936 | template int fmt::internal::CharTraits<wchar_t>::format_float( |
| 937 | wchar_t *buffer, std::size_t size, const wchar_t *format, |
| 938 | unsigned width, int precision, double value); |
| 939 | |
| 940 | template int fmt::internal::CharTraits<wchar_t>::format_float( |
| 941 | wchar_t *buffer, std::size_t size, const wchar_t *format, |
| 942 | unsigned width, int precision, long double value); |
| 943 | |
| 944 | #endif // FMT_HEADER_ONLY |
| 945 | |
| 946 | #ifdef _MSC_VER |
| 947 | # pragma warning(pop) |
| 948 | #endif |