From 1074d336ce915830a5bd2efcdbdb670fd82eef3a Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 30 Oct 2024 10:36:57 -0400 Subject: [PATCH] Add printf for all facets --- libcxx/src/locale.cpp | 59 +++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 63177cd64c3716..fe4affb10df916 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -237,53 +237,56 @@ locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), if (facets_[i]) facets_[i]->__add_shared(); - { - std::fprintf(stderr, "Creating collate_byname\n"); - auto* byname = new collate_byname(name_); - - std::fprintf(stderr, "Installing collate_byname\n"); - install(byname); - } +#define _DOIT(...) \ + do { \ + std::fprintf(stderr, "Creating " #__VA_ARGS__ "\n"); \ + auto* the_facet = new __VA_ARGS__(name_); \ + \ + std::fprintf(stderr, "Installing " #__VA_ARGS__ "\n"); \ + install(the_facet); \ + } while (false) + + _DOIT(collate_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new collate_byname(name_)); + _DOIT(collate_byname); #endif - install(new ctype_byname(name_)); + _DOIT(ctype_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new ctype_byname(name_)); + _DOIT(ctype_byname); #endif - install(new codecvt_byname(name_)); + _DOIT(codecvt_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new codecvt_byname(name_)); + _DOIT(codecvt_byname); #endif _LIBCPP_SUPPRESS_DEPRECATED_PUSH - install(new codecvt_byname(name_)); - install(new codecvt_byname(name_)); + _DOIT(codecvt_byname); + _DOIT(codecvt_byname); _LIBCPP_SUPPRESS_DEPRECATED_POP #if _LIBCPP_HAS_CHAR8_T - install(new codecvt_byname(name_)); - install(new codecvt_byname(name_)); + _DOIT(codecvt_byname); + _DOIT(codecvt_byname); #endif - install(new numpunct_byname(name_)); + _DOIT(numpunct_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new numpunct_byname(name_)); + _DOIT(numpunct_byname); #endif - install(new moneypunct_byname(name_)); - install(new moneypunct_byname(name_)); + _DOIT(moneypunct_byname); + _DOIT(moneypunct_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new moneypunct_byname(name_)); - install(new moneypunct_byname(name_)); + _DOIT(moneypunct_byname); + _DOIT(moneypunct_byname); #endif - install(new time_get_byname(name_)); + _DOIT(time_get_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new time_get_byname(name_)); + _DOIT(time_get_byname); #endif - install(new time_put_byname(name_)); + _DOIT(time_put_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new time_put_byname(name_)); + _DOIT(time_put_byname); #endif - install(new messages_byname(name_)); + _DOIT(messages_byname); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - install(new messages_byname(name_)); + _DOIT(messages_byname); #endif #if _LIBCPP_HAS_EXCEPTIONS } catch (...) {