tweaks: rename two parameters plus a variable, to match others
Also improve a comment and normalize an indentation.master
parent
fa88fcc8f2
commit
8a7634f070
25
src/chars.c
25
src/chars.c
|
@ -286,29 +286,28 @@ size_t mbstrlen(const char *pointer)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a multibyte character from buf. Return the number of bytes
|
/* Return the length (in bytes) of the character at the start of the
|
||||||
* used, and store the multibyte character in *chr. */
|
* given string, and return a copy of this character in *thechar. */
|
||||||
int collect_char(const char *buf, char *chr)
|
int collect_char(const char *string, char *thechar)
|
||||||
{
|
{
|
||||||
int length;
|
int charlen;
|
||||||
|
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
||||||
if ((signed char)*buf < 0) {
|
if ((signed char)*string < 0) {
|
||||||
length = mblen(buf, MAXCHARLEN);
|
charlen = mblen(string, MAXCHARLEN);
|
||||||
|
|
||||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||||
if (length <= 0)
|
if (charlen <= 0)
|
||||||
length = 1;
|
charlen = 1;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
length = 1;
|
charlen = 1;
|
||||||
|
|
||||||
/* Store the multibyte character in chr. */
|
for (int i = 0; i < charlen; i++)
|
||||||
for (int i = 0; i < length; i++)
|
thechar[i] = string[i];
|
||||||
chr[i] = buf[i];
|
|
||||||
|
|
||||||
return length;
|
return charlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the length (in bytes) of the character at the start of
|
/* Return the length (in bytes) of the character at the start of
|
||||||
|
|
Loading…
Reference in New Issue