Skip to content

Commit 2d4bbb5

Browse files
committed
implement r-lib#432
1 parent aeb1895 commit 2d4bbb5

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cpp11test/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ Suggests:
2020
xml2
2121
LazyData: true
2222
Roxygen: list(markdown = TRUE)
23-
RoxygenNote: 7.1.1
23+
RoxygenNote: 7.3.2

inst/include/cpp11/as.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,14 @@ template <typename T>
184184
enable_if_c_string<T, T> as_cpp(SEXP from) {
185185
if (Rf_isString(from)) {
186186
if (Rf_xlength(from) == 1) {
187-
// TODO: use vmaxget / vmaxset here?
188-
return {unwind_protect([&] { return Rf_translateCharUTF8(STRING_ELT(from, 0)); })};
187+
void* vmax = vmaxget();
188+
189+
const char* result =
190+
unwind_protect([&] { return Rf_translateCharUTF8(STRING_ELT(from, 0)); });
191+
192+
vmaxset(vmax);
193+
194+
return {result};
189195
}
190196
}
191197

0 commit comments

Comments
 (0)