Add whitespace helpers to complete.h/cpp

This commit is contained in:
Mahmoud Al-Qudsi 2018-03-06 12:35:07 -06:00
parent 93209ab053
commit 3c895c2839
2 changed files with 14 additions and 0 deletions

View file

@ -74,6 +74,13 @@ 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 char *whitespace_narrow = " \t\r\n\v";
bool is_whitespace(const wcstring &input) {
return input.find_first_not_of(whitespace);
}
bool has_working_tty_timestamps = true;
/// Convert a character to its integer equivalent if it is a valid character for the requested base.

View file

@ -203,6 +203,13 @@ extern const wchar_t *program_name;
/// the tty.
extern bool has_working_tty_timestamps;
/// A list of all whitespace characters
extern const wchar_t *whitespace;
extern const char *whitespace_narrow;
bool is_whitespace(const wcstring &input);
inline bool is_whitespace(const wchar_t *input) { return is_whitespace(wcstring(input)); }
/// This macro is used to check that an argument is true. It is a bit like a non-fatal form of
/// assert. Instead of exiting on failure, the current function is ended at once. The second
/// parameter is the return value of the current function on failure.