in src/RStuff/RUtil.h [82:111]
inline std::string evalAndGetPrintedValueWithLimit(SEXP expr, int maxLength, bool &trimmed) {
SHIELD(expr);
std::string result;
trimmed = false;
bool wasAsyncInterrupt = false;
ScopedAssign<std::function<void()>> withInterruptHandler(asyncInterruptHandler, [&] {
R_interrupts_pending = true;
wasAsyncInterrupt = true;
}, asyncInterruptHandlerMutex);
try {
WithOutputHandler handler([&](const char *s, size_t c, OutputType type) {
if (type == STDOUT) {
if (result.size() + c > maxLength) {
trimmed = true;
result.insert(result.end(), s, s + (maxLength - result.size()));
R_interrupts_pending = true;
} else {
result.insert(result.end(), s, s + c);
}
}
});
WithOption option("width", DEFAULT_WIDTH);
safeEval(expr, R_GlobalEnv);
} catch (RInterruptedException const&) {
}
R_interrupts_pending = false;
if (wasAsyncInterrupt) throw RInterruptedException();
fixUTF8Tail(result);
return result;
}