MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / trim_both

Function trim_both

inst/include/Rcpp/sugar/functions/strings/trimws.h:66–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66inline const char* trim_both(const char* str, R_len_t sz, std::string* buff) {
67 if (!str) {
68 return "";
69 }
70
71 buff->clear();
72
73 while (isws(*str)) {
74 ++str; --sz;
75 }
76
77 const char* ptr = str + sz - 1;
78
79 for (; ptr > str && isws(*ptr); --sz, --ptr);
80
81 buff->append(str, sz);
82 return buff->c_str();
83}
84
85
86} // detail

Callers 1

trimwsFunction · 0.85

Calls 2

iswsFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected