st

st fork
git clone git://git.rr3.xyz/st
Log | Files | Refs | README | LICENSE

commit 24f867e3af082fc307e903fe132f6b1695a9d2cd
parent cc288256286c75918ec882ab741d83072fa84897
Author: robert <robertrussell.72001@gmail.com>
Date:   Fri, 11 Jun 2021 07:54:11 -0700

Rename utf{decode,encode} to utf{dec,enc}

Diffstat:
Mst.c | 10+++++-----
Mutil.c | 20++++++++++----------
Mutil.h | 5++---
Mx.c | 2+-
4 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/st.c b/st.c @@ -436,7 +436,7 @@ getsel(void) if (gp->mode & ATTR_WDUMMY) continue; - ptr += utf8encode(gp->u, ptr); + ptr += utf8enc(gp->u, ptr); } /* @@ -1008,7 +1008,7 @@ tsetchar(Rune u, const Glyph *attr, int x, int y) */ if (term.trantbl[term.charset] == CS_GRAPHIC0 && BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41]) - utf8decode(vt100_0[u - 0x41], &u, UTF_SIZ); + utf8dec(vt100_0[u - 0x41], &u, UTF_SIZ); if (term.line[y][x].mode & ATTR_WIDE) { if (x+1 < term.col) { @@ -1818,7 +1818,7 @@ tdumpline(int n) end = &bp[MIN(tlinelen(n), term.col) - 1]; if (bp != end || bp->u != ' ') { for ( ; bp <= end; ++bp) - tprinter(buf, utf8encode(bp->u, buf)); + tprinter(buf, utf8enc(bp->u, buf)); } tprinter("\n", 1); } @@ -2104,7 +2104,7 @@ tputc(Rune u) c[0] = u; width = len = 1; } else { - len = utf8encode(u, c); + len = utf8enc(u, c); if (!control && (width = wcwidth(u)) == -1) width = 1; } @@ -2239,7 +2239,7 @@ twrite(const char *buf, int buflen, int show_ctrl) for (n = 0; n < buflen; n += charsize) { if (IS_SET(MODE_UTF8)) { /* process a complete utf8 char */ - charsize = utf8decode(buf + n, &u, buflen - n); + charsize = utf8dec(buf + n, &u, buflen - n); if (charsize == 0) break; } else { diff --git a/util.c b/util.c @@ -12,8 +12,8 @@ #include "util.h" #include "config.h" -static Rune utf8decodebyte(char, size_t *); -static char utf8encodebyte(Rune, size_t); +static Rune utf8decbyte(char, size_t *); +static char utf8encbyte(Rune, size_t); static size_t utf8validate(Rune *, size_t); static char base64dec_getc(const char **); static uint termkeymod(uint xmod); @@ -102,7 +102,7 @@ xwrite(int fd, const char *s, size_t len) } size_t -utf8decode(const char *c, Rune *u, size_t clen) +utf8dec(const char *c, Rune *u, size_t clen) { size_t i, j, len, type; Rune udecoded; @@ -110,11 +110,11 @@ utf8decode(const char *c, Rune *u, size_t clen) *u = UTF_INVALID; if (!clen) return 0; - udecoded = utf8decodebyte(c[0], &len); + udecoded = utf8decbyte(c[0], &len); if (!BETWEEN(len, 1, UTF_SIZ)) return 1; for (i = 1, j = 1; i < clen && j < len; ++i, ++j) { - udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type); + udecoded = (udecoded << 6) | utf8decbyte(c[i], &type); if (type != 0) return j; } @@ -127,7 +127,7 @@ utf8decode(const char *c, Rune *u, size_t clen) } Rune -utf8decodebyte(char c, size_t *i) +utf8decbyte(char c, size_t *i) { for (*i = 0; *i < LEN(utfmask); ++(*i)) if (((uchar)c & utfmask[*i]) == utfbyte[*i]) @@ -137,7 +137,7 @@ utf8decodebyte(char c, size_t *i) } size_t -utf8encode(Rune u, char *c) +utf8enc(Rune u, char *c) { size_t len, i; @@ -146,16 +146,16 @@ utf8encode(Rune u, char *c) return 0; for (i = len - 1; i != 0; --i) { - c[i] = utf8encodebyte(u, 0); + c[i] = utf8encbyte(u, 0); u >>= 6; } - c[0] = utf8encodebyte(u, len); + c[0] = utf8encbyte(u, len); return len; } char -utf8encodebyte(Rune u, size_t i) +utf8encbyte(Rune u, size_t i) { return utfbyte[i] | (u & ~utfmask[i]); } diff --git a/util.h b/util.h @@ -28,8 +28,7 @@ void *xmalloc(size_t); void *xrealloc(void *, size_t); char *xstrdup(const char *); ssize_t xwrite(int, const char *, size_t); -/* TODO: utf8 spells out decode, but base64 doesn't... */ -size_t utf8decode(const char *, Rune *, size_t); -size_t utf8encode(Rune, char *); +size_t utf8dec(const char *, Rune *, size_t); +size_t utf8enc(Rune, char *); char *base64dec(const char *); size_t csienc(char *, size_t, uint, uint, uint, char); diff --git a/x.c b/x.c @@ -1753,7 +1753,7 @@ kaction(XKeyEvent *e, int release) if (len == 0) return; - if ((state&KMOD) > 0 && utf8decode(buf, &c, len) == len + if ((state&KMOD) > 0 && utf8dec(buf, &c, len) == len && c != UTF_INVALID) /* Modified UTF8-encoded unicode? */ len = csienc(buf, sizeof buf, state, c, SHFT, 'u'); /* Default to directly sending composed string from the input method. */