Skip to content

Commit

Permalink
fmt: add upstream patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongRuoyu committed Feb 13, 2024
1 parent 5c6ee30 commit d81dd47
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Formula/f/fmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Fmt < Formula
url "https://github.com/fmtlib/fmt/archive/refs/tags/10.2.1.tar.gz"
sha256 "1250e4cc58bf06ee631567523f48848dc4596133e163f02615c97f78bab6c811"
license "MIT"
revision 1
head "https://github.com/fmtlib/fmt.git", branch: "master"

bottle do
Expand All @@ -18,6 +19,11 @@ class Fmt < Formula

depends_on "cmake" => :build

# Fix handling of static separator; cherry-picked from:
# https://github.com/fmtlib/fmt/commit/44c3fe1ebb466ab5c296e1a1a6991c7c7b51b72e
# Remove when included in a release.
patch :DATA

def install
system "cmake", "-S", ".", "-B", "build", "-DBUILD_SHARED_LIBS=TRUE", *std_cmake_args
system "cmake", "--build", "build"
Expand Down Expand Up @@ -48,3 +54,30 @@ def install
assert_equal "The answer is 42", shell_output("./test")
end
end

__END__
diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h
index 9fc87ecf2027df0346935e7666ea80ec70e65575..872aa9802df1ffa8572a2f0d29f58bdb2b171a1a 100644
--- a/include/fmt/format-inl.h
+++ b/include/fmt/format-inl.h
@@ -110,7 +110,11 @@ template <typename Char> FMT_FUNC Char decimal_point_impl(locale_ref) {

FMT_FUNC auto write_loc(appender out, loc_value value,
const format_specs<>& specs, locale_ref loc) -> bool {
-#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
+#ifdef FMT_STATIC_THOUSANDS_SEPARATOR
+ value.visit(loc_writer<>{
+ out, specs, std::string(1, FMT_STATIC_THOUSANDS_SEPARATOR), "\3", "."});
+ return true;
+#else
auto locale = loc.get<std::locale>();
// We cannot use the num_put<char> facet because it may produce output in
// a wrong encoding.
@@ -119,7 +123,6 @@ FMT_FUNC auto write_loc(appender out, loc_value value,
return std::use_facet<facet>(locale).put(out, value, specs);
return facet(locale).put(out, value, specs);
#endif
- return false;
}
} // namespace detail

0 comments on commit d81dd47

Please sign in to comment.