nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 4104376e7c94d1b4c54f7e401b3bd5e8ac2c8672
parent ffa0a9ef645fda4a7b3daa8d89ebdfb5202645c8
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  2 Jan 2019 17:52:11 +0100

tweaks: rename a variable, elide another, and adjust two comments

Also, adjust the type of a parameter to 'size_t', as it is a
character index.

Diffstat:
Msrc/text.c | 20+++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -3042,23 +3042,21 @@ void do_verbatim_input(void) #ifdef ENABLE_WORDCOMPLETION /* Return a copy of the found completion candidate. */ -char *copy_completion(char *check_line, int start) +char *copy_completion(char *check_line, size_t start) { char *word; - size_t position = start, len_of_word = 0, index = 0; + size_t afterit = start, index = 0; - /* Find the length of the word by travelling to its end. */ - while (is_word_mbchar(&check_line[position], FALSE)) - position = move_mbright(check_line, position); + /* Find the position where the candidate word ends. */ + while (is_word_mbchar(&check_line[afterit], FALSE)) + afterit = move_mbright(check_line, afterit); - len_of_word = position - start; - word = charalloc(len_of_word + 1); - - /* Simply copy the word. */ - while (index < len_of_word) + /* Now copy this candidate to a new string. */ + word = charalloc(afterit - start + 1); + while (start < afterit) word[index++] = check_line[start++]; - word[index] = '\0'; + return word; }