Skip to content

Commit 8cd62ba

Browse files
committed
Reapply "Revert a011d42"
This reverts commit fe615c4.
1 parent 0070941 commit 8cd62ba

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

inst/include/cpp11/declarations.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ T& unmove(T&& t) {
4646
SEXP err = R_NilValue; \
4747
char buf[CPP11_ERROR_BUFSIZE] = ""; \
4848
try {
49-
#define END_CPP11_EX(RET) \
49+
#define END_CPP11 \
5050
} \
5151
catch (cpp11::unwind_exception & e) { \
5252
err = e.token; \
@@ -62,5 +62,4 @@ T& unmove(T&& t) {
6262
} else if (err != R_NilValue) { \
6363
CPP11_UNWIND \
6464
} \
65-
return RET;
66-
#define END_CPP11 END_CPP11_EX(R_NilValue)
65+
return R_NilValue;

inst/include/cpp11/protect.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,14 @@ void stop [[noreturn]] (const std::string& fmt_arg, Args&&... args) {
214214
safe.noreturn(Rf_errorcall)(R_NilValue, "%s", msg.c_str());
215215
}
216216

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

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

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

237244
template <typename... Args>
238-
void warning(const std::string fmt, Args... args) {
245+
void warning(const std::string& fmt, Args... args) {
239246
safe[Rf_warningcall](R_NilValue, fmt.c_str(), args...);
240247
}
241248
#endif

0 commit comments

Comments
 (0)