| 64 | } |
| 65 | |
| 66 | inline 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 |