tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

comment-format-system-error.patch (6641B)


      1 diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h
      2 --- a/include/fmt/format-inl.h
      3 +++ b/include/fmt/format-inl.h
      4 @@ -69,19 +69,20 @@ FMT_FUNC void do_report_error(format_fun
      5   func(full_message, error_code, message);
      6   // Don't use fwrite_all because the latter may throw.
      7   if (std::fwrite(full_message.data(), full_message.size(), 1, stderr) > 0)
      8     std::fputc('\n', stderr);
      9 }
     10 
     11 // A wrapper around fwrite that throws on error.
     12 inline void fwrite_all(const void* ptr, size_t count, FILE* stream) {
     13 -  size_t written = std::fwrite(ptr, 1, count, stream);
     14 -  if (written < count)
     15 -    FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
     16 +  std::fwrite(ptr, 1, count, stream);
     17 +  // size_t written = std::fwrite(ptr, 1, count, stream);
     18 +  // if (written < count)
     19 +  //   FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
     20 }
     21 
     22 #if FMT_USE_LOCALE
     23 using std::locale;
     24 using std::numpunct;
     25 using std::use_facet;
     26 
     27 template <typename Locale, enable_if_t<(sizeof(Locale::collate) != 0), int>>
     28 @@ -153,21 +154,21 @@ template <typename Locale> format_facet<
     29 template <>
     30 FMT_API FMT_FUNC auto format_facet<std::locale>::do_put(
     31     appender out, loc_value val, const format_specs& specs) const -> bool {
     32   return val.visit(
     33       detail::loc_writer<>{out, specs, separator_, grouping_, decimal_point_});
     34 }
     35 #endif
     36 
     37 -FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)
     38 -    -> std::system_error {
     39 -  auto ec = std::error_code(error_code, std::generic_category());
     40 -  return std::system_error(ec, vformat(fmt, args));
     41 -}
     42 +// FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)
     43 +//     -> std::system_error {
     44 +//   auto ec = std::error_code(error_code, std::generic_category());
     45 +//   return std::system_error(ec, vformat(fmt, args));
     46 +// }
     47 
     48 namespace detail {
     49 
     50 template <typename F>
     51 inline auto operator==(basic_fp<F> x, basic_fp<F> y) -> bool {
     52   return x.f == y.f && x.e == y.e;
     53 }
     54 
     55 @@ -1418,22 +1419,22 @@ FMT_FUNC detail::utf8_to_utf16::utf8_to_
     56     }
     57     return true;
     58   });
     59   buffer_.push_back(0);
     60 }
     61 
     62 FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
     63                                   const char* message) noexcept {
     64 -  FMT_TRY {
     65 -    auto ec = std::error_code(error_code, std::generic_category());
     66 -    detail::write(appender(out), std::system_error(ec, message).what());
     67 -    return;
     68 -  }
     69 -  FMT_CATCH(...) {}
     70 +  // FMT_TRY {
     71 +  //   auto ec = std::error_code(error_code, std::generic_category());
     72 +  //   detail::write(appender(out), std::system_error(ec, message).what());
     73 +  //   return;
     74 +  // }
     75 +  // FMT_CATCH(...) {}
     76   format_error_code(out, error_code, message);
     77 }
     78 
     79 FMT_FUNC void report_system_error(int error_code,
     80                                   const char* message) noexcept {
     81   do_report_error(format_system_error, error_code, message);
     82 }
     83 
     84 diff --git a/include/fmt/format.h b/include/fmt/format.h
     85 --- a/include/fmt/format.h
     86 +++ b/include/fmt/format.h
     87 @@ -4189,55 +4189,55 @@ class format_int {
     88  *
     89  * **Example**:
     90  *
     91  *     // A compile-time error because 'd' is an invalid specifier for strings.
     92  *     std::string s = fmt::format(FMT_STRING("{:d}"), "foo");
     93  */
     94 #define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string)
     95 
     96 -FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
     97 -    -> std::system_error;
     98 +// FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
     99 +//     -> std::system_error;
    100 
    101 /**
    102  * Constructs `std::system_error` with a message formatted with
    103  * `fmt::format(fmt, args...)`.
    104  * `error_code` is a system error code as given by `errno`.
    105  *
    106  * **Example**:
    107  *
    108  *     // This throws std::system_error with the description
    109  *     //   cannot open file 'madeup': No such file or directory
    110  *     // or similar (system message may vary).
    111  *     const char* filename = "madeup";
    112  *     FILE* file = fopen(filename, "r");
    113  *     if (!file)
    114  *       throw fmt::system_error(errno, "cannot open file '{}'", filename);
    115  */
    116 -template <typename... T>
    117 -auto system_error(int error_code, format_string<T...> fmt, T&&... args)
    118 -    -> std::system_error {
    119 -  return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});
    120 -}
    121 +// template <typename... T>
    122 +// auto system_error(int error_code, format_string<T...> fmt, T&&... args)
    123 +//     -> std::system_error {
    124 +//   return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});
    125 +// }
    126 
    127 /**
    128  * Formats an error message for an error returned by an operating system or a
    129  * language runtime, for example a file opening error, and writes it to `out`.
    130  * The format is the same as the one used by `std::system_error(ec, message)`
    131  * where `ec` is `std::error_code(error_code, std::generic_category())`.
    132  * It is implementation-defined but normally looks like:
    133  *
    134  *     <message>: <system-message>
    135  *
    136  * where `<message>` is the passed message and `<system-message>` is the system
    137  * message corresponding to the error code.
    138  * `error_code` is a system error code as given by `errno`.
    139  */
    140 -FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
    141 -                                 const char* message) noexcept;
    142 +// FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
    143 +//                                  const char* message) noexcept;
    144 
    145 // Reports a system error without throwing an exception.
    146 // Can be used to report errors from destructors.
    147 FMT_API void report_system_error(int error_code, const char* message) noexcept;
    148 
    149 inline auto vformat(detail::locale_ref loc, string_view fmt, format_args args)
    150     -> std::string {
    151   auto buf = memory_buffer();
    152 diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h
    153 --- a/include/fmt/xchar.h
    154 +++ b/include/fmt/xchar.h
    155 @@ -286,18 +286,19 @@ inline auto formatted_size(const S& fmt,
    156                      fmt::make_format_args<buffered_context<Char>>(args...));
    157   return buf.count();
    158 }
    159 
    160 inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
    161   auto buf = wmemory_buffer();
    162   detail::vformat_to(buf, fmt, args);
    163   buf.push_back(L'\0');
    164 -  if (std::fputws(buf.data(), f) == -1)
    165 -    FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
    166 +  std::fputws(buf.data(), f);
    167 +  // if (std::fputws(buf.data(), f) == -1)
    168 +  //   FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
    169 }
    170 
    171 inline void vprint(wstring_view fmt, wformat_args args) {
    172   vprint(stdout, fmt, args);
    173 }
    174 
    175 template <typename... T>
    176 void print(std::FILE* f, wformat_string<T...> fmt, T&&... args) {