nano

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

commit 19a6120dc827273f6aa7a45de97fe2322bb409da
parent f4a33b868abe5c99ca611b9e5f1ca815d74cbf00
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu,  9 Apr 2020 12:27:07 +0200

tweaks: rename a function, to be more general and clearer

Diffstat:
Msrc/cut.c | 4++--
Msrc/proto.h | 2+-
Msrc/text.c | 2+-
Msrc/utils.c | 10+++++-----
Msrc/winio.c | 2+-
5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/cut.c b/src/cut.c @@ -294,7 +294,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_ } /* Subtract the size of the excised text from the buffer size. */ - openfile->totsize -= get_totsize(taken, last); + openfile->totsize -= number_of_characters_in(taken, last); /* If the cutbuffer is currently empty, just move all the text directly * into it; otherwise, append the text to what is already there. */ @@ -357,7 +357,7 @@ void ingraft_buffer(linestruct *topline) botline = botline->next; /* Add the size of the text to be grafted to the buffer size. */ - openfile->totsize += get_totsize(topline, botline); + openfile->totsize += number_of_characters_in(topline, botline); if (topline != botline) length = xpos; diff --git a/src/proto.h b/src/proto.h @@ -574,7 +574,7 @@ bool mark_is_before_cursor(void); void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x); void get_range(linestruct **top, linestruct **bot); #endif -size_t get_totsize(const linestruct *begin, const linestruct *end); +size_t number_of_characters_in(const linestruct *begin, const linestruct *end); #ifndef NANO_TINY linestruct *line_from_number(ssize_t lineno); #endif diff --git a/src/text.c b/src/text.c @@ -2920,7 +2920,7 @@ void do_wordlinechar_count(void) get_region(&topline, &top_x, &botline, &bot_x); if (topline != botline) - chars = get_totsize(topline->next, botline); + chars = number_of_characters_in(topline->next, botline); chars += mbstrlen(topline->data + top_x) - mbstrlen(botline->data + bot_x); chars += (botline->next == NULL) ? 1 : 0; diff --git a/src/utils.c b/src/utils.c @@ -512,19 +512,19 @@ linestruct *line_from_number(ssize_t number) #endif /* !NANO_TINY */ /* Count the number of characters from begin to end, and return it. */ -size_t get_totsize(const linestruct *begin, const linestruct *end) +size_t number_of_characters_in(const linestruct *begin, const linestruct *end) { const linestruct *line; - size_t totsize = 0; + size_t count = 0; /* Sum the number of characters (plus a newline) in each line. */ for (line = begin; line != end->next; line = line->next) - totsize += mbstrlen(line->data) + 1; + count += mbstrlen(line->data) + 1; /* The last line of a file doesn't have a newline -- otherwise it * wouldn't be the last line -- so subtract 1 when at EOF. */ if (line == NULL) - totsize--; + count--; - return totsize; + return count; } diff --git a/src/winio.c b/src/winio.c @@ -3338,7 +3338,7 @@ void do_cursorpos(bool force) saved_byte = openfile->current->data[openfile->current_x]; openfile->current->data[openfile->current_x] = '\0'; - sum = get_totsize(openfile->filetop, openfile->current); + sum = number_of_characters_in(openfile->filetop, openfile->current); openfile->current->data[openfile->current_x] = saved_byte;