Remove unused mbs.len field from struct Edit

weechat-hashes
June McEnroe 2022-02-20 11:54:06 -05:00
parent 3b4ad30d97
commit 157be8a8d7
2 changed files with 7 additions and 9 deletions

15
edit.c
View File

@ -44,7 +44,7 @@ void editFree(struct Edit *e) {
free(e->mbs.buf); free(e->mbs.buf);
e->pos = e->len = e->cap = 0; e->pos = e->len = e->cap = 0;
e->cut.len = 0; e->cut.len = 0;
e->mbs.pos = e->mbs.len = 0; e->mbs.pos = 0;
} }
char *editString(struct Edit *e) { char *editString(struct Edit *e) {
@ -54,19 +54,18 @@ char *editString(struct Edit *e) {
e->mbs.buf = buf; e->mbs.buf = buf;
const wchar_t *ptr = e->buf; const wchar_t *ptr = e->buf;
e->mbs.len = wcsnrtombs(e->mbs.buf, &ptr, e->pos, cap-1, NULL); size_t len = wcsnrtombs(e->mbs.buf, &ptr, e->pos, cap-1, NULL);
if (e->mbs.len == (size_t)-1) return NULL; if (len == (size_t)-1) return NULL;
e->mbs.pos = e->mbs.len; e->mbs.pos = len;
ptr = &e->buf[e->pos]; ptr = &e->buf[e->pos];
size_t n = wcsnrtombs( size_t n = wcsnrtombs(
&e->mbs.buf[e->mbs.len], &ptr, e->len - e->pos, &e->mbs.buf[len], &ptr, e->len - e->pos, cap-1 - len, NULL
cap-1 - e->mbs.len, NULL
); );
if (n == (size_t)-1) return NULL; if (n == (size_t)-1) return NULL;
e->mbs.len += n; len += n;
e->mbs.buf[e->mbs.len] = '\0'; e->mbs.buf[len] = '\0';
return e->mbs.buf; return e->mbs.buf;
} }

1
edit.h
View File

@ -45,7 +45,6 @@ struct Edit {
struct { struct {
char *buf; char *buf;
size_t pos; size_t pos;
size_t len;
} mbs; } mbs;
}; };