From 2aefa348baf4b702fdce98eb105bcba175d8283f Mon Sep 17 00:00:00 2001 From: Zacchary Dempsey-Plante Date: Sun, 13 Mar 2022 10:44:08 +0100 Subject: [PATCH 1/4] make underlines and strikethroughs respect `chscale` --- x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x.c b/x.c index cd96575..2a3bd38 100644 --- a/x.c +++ b/x.c @@ -1493,12 +1493,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i /* Render underline and strikethrough. */ if (base.mode & ATTR_UNDERLINE) { - XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1, + XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1, width, 1); } if (base.mode & ATTR_STRUCK) { - XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, + XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3, width, 1); } From af3bb68add1c40d19d0dee382009e21b0870a38f Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 18 Mar 2022 16:20:54 +0600 Subject: [PATCH 2/4] avoid potential UB when using isprint() all the ctype.h functions' argument must be representable as an unsigned char or as EOF, otherwise the behavior is undefined. --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index c71fa06..1307fdf 100644 --- a/st.c +++ b/st.c @@ -367,7 +367,7 @@ static const char base64_digits[] = { char base64dec_getc(const char **src) { - while (**src && !isprint(**src)) + while (**src && !isprint((unsigned char)**src)) (*src)++; return **src ? *((*src)++) : '='; /* emulate padding if string ends */ } From ef0551932fb162f907b40185d2f48c3b497708ee Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 18 Mar 2022 17:03:34 +0600 Subject: [PATCH 3/4] base64_digits: reduce scope, implicit zero, +1 size the array is not accessed outside of base64dec() so it makes sense to limit it's scope to the related function. the static-storage duration of the array is kept intact. this also removes unnecessary explicit zeroing from the start and end of the array. anything that wasn't explicitly zero-ed will now be implicitly zero-ed instead. the validity of the new array can be easily confirmed via running this trivial loop: for (int i = 0; i < 255; ++i) assert(base64_digits[i] == base64_digits_old[i]); lastly, as pointed out by Roberto, the array needs to have 256 elements in order to able access it as any unsigned char as an index; the previous array had 255. however, this array will only be accessed at indexes which are isprint() || '=' (see `base64dec_getc()`), so reducing the size of the array to the highest printable ascii char (127 AFAIK) + 1 might also be a valid strategy. --- st.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/st.c b/st.c index 1307fdf..f43cfd3 100644 --- a/st.c +++ b/st.c @@ -349,21 +349,6 @@ utf8validate(Rune *u, size_t i) return i; } -static const char base64_digits[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, - 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, -1, 0, 0, 0, 0, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - char base64dec_getc(const char **src) { @@ -377,6 +362,13 @@ base64dec(const char *src) { size_t in_len = strlen(src); char *result, *dst; + static const char base64_digits[256] = { + [43] = 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, + 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 + }; if (in_len % 4) in_len += 4 - (in_len % 4); From 6f9d603bf58cff6adf3b078dc034db2940f79075 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 19 Mar 2022 17:30:21 +0100 Subject: [PATCH 4/4] Bumped pkgver --- PKGBUILD | 8 ++++---- config.mk | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index aef7351..eb68544 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,8 +1,8 @@ # Maintainer: Jef Roosens pkgname=jjr-st -pkgver=0.8.7 -pkgrel=2 +pkgver=0.8.8 +pkgrel=1 pkgdesc="My build of the st terminal" arch=("x86_64") @@ -22,13 +22,13 @@ sha256sums=('1a10fac42d03b3a1231cd6998a73fb4ab4f191694628953e7229f6de2053a985' '808dbefe40e81b88da173985e1bd5c0a0d88d517b7cc1c6d68753e586ffe1698' '49bff578b6c882123393c867689f4330d6ba7cfe85fe359ea7424b228b22970e' '6fa7874b83e98a30e8c66c8f7d5539d1b2ec6c2267ef2c3945620826187b6b64' - '42a38096ce2dcd3c44142fbd54c8024e4762cc17073b81e83351f7bfc9d07948' + '86613a3c3bd74fc44d364a4e611db1d93674b85351d2453e49a89e86304a1472' 'f4fae0ee42168f492ea59825928d1dbaceae5cf9e6fe2f820a429a68266000c7' '4a133d16a818379ab849b41c30cb4b4f989a00c9b1e96907a4d130d12c36a79e' '5c25b701b4482ccc8d5ea0770e553ad8a8c5c87650df07543b3b3f9456726d54' '7398527a5e5cf9fd53f56dba332a2565c680058bc329c6bd08f623a813baab27' '5b0d65d135fcc3d51f60e4fe4d86c5bbd1331266f9b38ecfb86914668c03921c' - '684c5bbcd7c657b55dfce156e881f93ef1ac05f3ebaab8912dbcb4b9b962ab6a' + '517dcc181f40aeb62ec35bcab0e7e51fd5a16d37331667c4dc9de68faf20a7a9' '285b883ebd0884467be95562885f4cf594cd72cf7b4925476538483fe4022f39' '2eb2f15957b8132a2d25129c24bb97f64657bd821447f36ef2cf0526b42846e8' 'd30e818fb119a94f23aac1684f7c50bc1cd49cd3364472e0d17d195ecdcd9240' diff --git a/config.mk b/config.mk index 23cead8..d7106b1 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # st version -VERSION = 0.8.6 +VERSION = 0.8.8 # Customize below to fit your system