From 4f5d1717992ea726bc38edf88407d0512adfacf9 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Wed, 6 May 2015 22:20:02 +0200 Subject: degesch: add constant for word breaking characters --- degesch.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/degesch.c b/degesch.c index 0b7ee9c..98e4713 100644 --- a/degesch.c +++ b/degesch.c @@ -17,9 +17,6 @@ * */ -/// Some arbitrary limit for the history file -#define HISTORY_LIMIT 10000 - // A table of all attributes we use for output #define ATTR_TABLE(XX) \ XX( PROMPT, "prompt", "Terminal attributes for the prompt" ) \ @@ -78,6 +75,12 @@ enum #include #endif // HAVE_EDITLINE +/// Some arbitrary limit for the history file +#define HISTORY_LIMIT 10000 + +/// Characters that separate words +#define WORD_BREAKING_CHARS " \f\n\r\t\v" + // --- User interface ---------------------------------------------------------- // I'm not sure which one of these backends is worse: whether it's GNU Readline @@ -229,8 +232,7 @@ input_start (struct input *self, const char *program_name) rl_startup_hook = app_readline_init; rl_catch_sigwinch = false; - // TODO: global constant - rl_basic_word_break_characters = " \t"; + rl_basic_word_break_characters = WORD_BREAKING_CHARS; rl_completer_word_break_characters = NULL; rl_attempted_completion_function = app_readline_completion; @@ -3923,9 +3925,9 @@ static char * cut_word (char **s) { char *start = *s; - size_t word_len = strcspn (*s, " \t"); + size_t word_len = strcspn (*s, WORD_BREAKING_CHARS); char *end = start + word_len; - *s = end + strspn (end, " \t"); + *s = end + strspn (end, WORD_BREAKING_CHARS); *end = '\0'; return start; } -- cgit v1.2.3-70-g09d2