Skip to content

Commit

Permalink
Revert "Revert a011d42"
Browse files Browse the repository at this point in the history
This reverts commit aafd64e602d793810bbcf623ff68fb725796bb31.
  • Loading branch information
krlmlr committed Jul 4, 2024
1 parent 65f5f0b commit 0e6812c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 3 additions & 2 deletions inst/include/cpp11/declarations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ T& unmove(T&& t) {
SEXP err = R_NilValue; \
char buf[CPP11_ERROR_BUFSIZE] = ""; \
try {
#define END_CPP11 \
#define END_CPP11_EX(RET) \
} \
catch (cpp11::unwind_exception & e) { \
err = e.token; \
Expand All @@ -62,4 +62,5 @@ T& unmove(T&& t) {
} else if (err != R_NilValue) { \
CPP11_UNWIND \
} \
return R_NilValue;
return RET;
#define END_CPP11 END_CPP11_EX(R_NilValue)
15 changes: 4 additions & 11 deletions inst/include/cpp11/protect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,10 @@ void stop [[noreturn]] (const std::string& fmt_arg, Args&&... args) {
safe.noreturn(Rf_errorcall)(R_NilValue, "%s", msg.c_str());
}

template <typename... Args>
void warning(const char* fmt_arg, Args&&... args) {
std::string msg = fmt::format(fmt_arg, std::forward<Args>(args)...);
safe[Rf_warningcall](R_NilValue, "%s", msg.c_str());
}
// Always making copy of string to avoid weird unwind behavior.

template <typename... Args>
void warning(const std::string& fmt_arg, Args&&... args) {
void warning(const std::string fmt_arg, Args&&... args) {
std::string msg = fmt::format(fmt_arg, std::forward<Args>(args)...);
safe[Rf_warningcall](R_NilValue, "%s", msg.c_str());
}
Expand All @@ -236,13 +232,10 @@ void stop [[noreturn]] (const std::string& fmt, Args... args) {
safe.noreturn(Rf_errorcall)(R_NilValue, fmt.c_str(), args...);
}

template <typename... Args>
void warning(const char* fmt, Args... args) {
safe[Rf_warningcall](R_NilValue, fmt, args...);
}
// Always making copy of string to avoid weird unwind behavior.

template <typename... Args>
void warning(const std::string& fmt, Args... args) {
void warning(const std::string fmt, Args... args) {
safe[Rf_warningcall](R_NilValue, fmt.c_str(), args...);
}
#endif
Expand Down

0 comments on commit 0e6812c

Please sign in to comment.