diff options
author | June McEnroe <june@causal.agency> | 2022-02-20 11:54:06 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2022-02-20 11:54:06 -0500 |
commit | 157be8a8d72f17b4c56fc64c1659ac7b1cac22df (patch) | |
tree | 088b0e245cadd53ddb5bd3a44aba34f9b2835e03 | |
parent | Remove unneeded includes in ui.c (diff) | |
download | catgirl-157be8a8d72f17b4c56fc64c1659ac7b1cac22df.tar.gz catgirl-157be8a8d72f17b4c56fc64c1659ac7b1cac22df.zip |
Remove unused mbs.len field from struct Edit
Diffstat (limited to '')
-rw-r--r-- | edit.c | 15 | ||||
-rw-r--r-- | edit.h | 1 |
2 files changed, 7 insertions, 9 deletions
diff --git a/edit.c b/edit.c index 5766b29..b0bdb23 100644 --- a/edit.c +++ b/edit.c @@ -44,7 +44,7 @@ void editFree(struct Edit *e) { free(e->mbs.buf); e->pos = e->len = e->cap = 0; e->cut.len = 0; - e->mbs.pos = e->mbs.len = 0; + e->mbs.pos = 0; } char *editString(struct Edit *e) { @@ -54,19 +54,18 @@ char *editString(struct Edit *e) { e->mbs.buf = buf; const wchar_t *ptr = e->buf; - e->mbs.len = wcsnrtombs(e->mbs.buf, &ptr, e->pos, cap-1, NULL); - if (e->mbs.len == (size_t)-1) return NULL; - e->mbs.pos = e->mbs.len; + size_t len = wcsnrtombs(e->mbs.buf, &ptr, e->pos, cap-1, NULL); + if (len == (size_t)-1) return NULL; + e->mbs.pos = len; ptr = &e->buf[e->pos]; size_t n = wcsnrtombs( - &e->mbs.buf[e->mbs.len], &ptr, e->len - e->pos, - cap-1 - e->mbs.len, NULL + &e->mbs.buf[len], &ptr, e->len - e->pos, cap-1 - len, 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; } diff --git a/edit.h b/edit.h index d15e5fb..49adb7f 100644 --- a/edit.h +++ b/edit.h @@ -45,7 +45,6 @@ struct Edit { struct { char *buf; size_t pos; - size_t len; } mbs; }; |