From 8a7634f07007c7681e77ff9c2c5def9e2a45e5db Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 21 Oct 2019 13:00:57 +0200 Subject: [PATCH] tweaks: rename two parameters plus a variable, to match others Also improve a comment and normalize an indentation. --- src/chars.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/chars.c b/src/chars.c index aec44db9..51ea080b 100644 --- a/src/chars.c +++ b/src/chars.c @@ -286,29 +286,28 @@ size_t mbstrlen(const char *pointer) return count; } -/* Parse a multibyte character from buf. Return the number of bytes - * used, and store the multibyte character in *chr. */ -int collect_char(const char *buf, char *chr) +/* Return the length (in bytes) of the character at the start of the + * given string, and return a copy of this character in *thechar. */ +int collect_char(const char *string, char *thechar) { - int length; + int charlen; #ifdef ENABLE_UTF8 /* If this is a UTF-8 starter byte, get the number of bytes of the character. */ - if ((signed char)*buf < 0) { - length = mblen(buf, MAXCHARLEN); + if ((signed char)*string < 0) { + charlen = mblen(string, MAXCHARLEN); /* When the multibyte sequence is invalid, only take the first byte. */ - if (length <= 0) - length = 1; + if (charlen <= 0) + charlen = 1; } else #endif - length = 1; + charlen = 1; - /* Store the multibyte character in chr. */ - for (int i = 0; i < length; i++) - chr[i] = buf[i]; + for (int i = 0; i < charlen; i++) + thechar[i] = string[i]; - return length; + return charlen; } /* Return the length (in bytes) of the character at the start of