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.master
parent
ffa0a9ef64
commit
4104376e7c
20
src/text.c
20
src/text.c
|
@ -3042,23 +3042,21 @@ void do_verbatim_input(void)
|
||||||
|
|
||||||
#ifdef ENABLE_WORDCOMPLETION
|
#ifdef ENABLE_WORDCOMPLETION
|
||||||
/* Return a copy of the found completion candidate. */
|
/* 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;
|
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. */
|
/* Find the position where the candidate word ends. */
|
||||||
while (is_word_mbchar(&check_line[position], FALSE))
|
while (is_word_mbchar(&check_line[afterit], FALSE))
|
||||||
position = move_mbright(check_line, position);
|
afterit = move_mbright(check_line, afterit);
|
||||||
|
|
||||||
len_of_word = position - start;
|
/* Now copy this candidate to a new string. */
|
||||||
word = charalloc(len_of_word + 1);
|
word = charalloc(afterit - start + 1);
|
||||||
|
while (start < afterit)
|
||||||
/* Simply copy the word. */
|
|
||||||
while (index < len_of_word)
|
|
||||||
word[index++] = check_line[start++];
|
word[index++] = check_line[start++];
|
||||||
|
|
||||||
word[index] = '\0';
|
word[index] = '\0';
|
||||||
|
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue