degesch: add constant for word breaking characters

This commit is contained in:
Přemysl Eric Janouch 2015-05-06 22:20:02 +02:00
parent 894c45bef4
commit 4f5d171799
1 changed files with 9 additions and 7 deletions

View File

@ -17,9 +17,6 @@
* *
*/ */
/// Some arbitrary limit for the history file
#define HISTORY_LIMIT 10000
// A table of all attributes we use for output // A table of all attributes we use for output
#define ATTR_TABLE(XX) \ #define ATTR_TABLE(XX) \
XX( PROMPT, "prompt", "Terminal attributes for the prompt" ) \ XX( PROMPT, "prompt", "Terminal attributes for the prompt" ) \
@ -78,6 +75,12 @@ enum
#include <histedit.h> #include <histedit.h>
#endif // HAVE_EDITLINE #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 ---------------------------------------------------------- // --- User interface ----------------------------------------------------------
// I'm not sure which one of these backends is worse: whether it's GNU Readline // 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_startup_hook = app_readline_init;
rl_catch_sigwinch = false; rl_catch_sigwinch = false;
// TODO: global constant rl_basic_word_break_characters = WORD_BREAKING_CHARS;
rl_basic_word_break_characters = " \t";
rl_completer_word_break_characters = NULL; rl_completer_word_break_characters = NULL;
rl_attempted_completion_function = app_readline_completion; rl_attempted_completion_function = app_readline_completion;
@ -3923,9 +3925,9 @@ static char *
cut_word (char **s) cut_word (char **s)
{ {
char *start = *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; char *end = start + word_len;
*s = end + strspn (end, " \t"); *s = end + strspn (end, WORD_BREAKING_CHARS);
*end = '\0'; *end = '\0';
return start; return start;
} }