mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
Improve and expand is_whitespace helper functions
This commit is contained in:
parent
2951fadc6b
commit
0b96b516d5
2 changed files with 13 additions and 3 deletions
|
@ -75,11 +75,20 @@ static volatile bool termsize_valid = false;
|
|||
static char *wcs2str_internal(const wchar_t *in, char *out);
|
||||
static void debug_shared(const wchar_t msg_level, const wcstring &msg);
|
||||
|
||||
const wchar_t *whitespace = L" \t\r\n\v";
|
||||
const wcstring whitespace = L" \t\r\n\v";
|
||||
const char *whitespace_narrow = " \t\r\n\v";
|
||||
|
||||
bool is_whitespace(const wchar_t input) {
|
||||
for (auto c : whitespace) {
|
||||
if (c == input) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_whitespace(const wcstring &input) {
|
||||
return input.find_first_not_of(whitespace);
|
||||
return input.find_first_not_of(whitespace) == wcstring::npos;
|
||||
}
|
||||
|
||||
bool has_working_tty_timestamps = true;
|
||||
|
|
|
@ -206,9 +206,10 @@ extern const wchar_t *program_name;
|
|||
extern bool has_working_tty_timestamps;
|
||||
|
||||
/// A list of all whitespace characters
|
||||
extern const wchar_t *whitespace;
|
||||
extern const wcstring whitespace;
|
||||
extern const char *whitespace_narrow;
|
||||
|
||||
bool is_whitespace(const wchar_t input);
|
||||
bool is_whitespace(const wcstring &input);
|
||||
inline bool is_whitespace(const wchar_t *input) { return is_whitespace(wcstring(input)); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue