Avoiding a compiler warning, and straightening out the logic.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4772 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
cd634e074c
Коммит
ff8454a6f5
@ -8,6 +8,8 @@
|
||||
* src/text.c (break_line): Initialize a variable to avoid a compiler
|
||||
warning, rename it to be more apt, add a comment, tweak some others,
|
||||
and remove an unneeded 'if'.
|
||||
* src/char.c (move_mbleft): Avoid a compiler warning (int → size_t),
|
||||
rename the variable, and another, and straighten out the logic.
|
||||
|
||||
2014-04-13 Benno Schulenberg <bensberg@justemail.net>
|
||||
* proto.h, global.c, rcfile.c: Remove the unused parameter 'menu'
|
||||
|
14
src/chars.c
14
src/chars.c
@ -472,22 +472,18 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
* before the one at pos. */
|
||||
size_t move_mbleft(const char *buf, size_t pos)
|
||||
{
|
||||
size_t pos_prev = pos;
|
||||
size_t before = 0, char_len = 0;
|
||||
|
||||
assert(buf != NULL && pos <= strlen(buf));
|
||||
|
||||
/* There is no library function to move backward one multibyte
|
||||
* character. Here is the naive, O(pos) way to do it. */
|
||||
while (TRUE) {
|
||||
int buf_mb_len = parse_mbchar(buf + pos - pos_prev, NULL, NULL);
|
||||
|
||||
if (pos_prev <= buf_mb_len)
|
||||
break;
|
||||
|
||||
pos_prev -= buf_mb_len;
|
||||
while (before < pos) {
|
||||
char_len = parse_mbchar(buf + before, NULL, NULL);
|
||||
before += char_len;
|
||||
}
|
||||
|
||||
return pos - pos_prev;
|
||||
return before - char_len;
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user