Compare commits

...

5 Commits

Author SHA1 Message Date
Jef Roosens 6f9d603bf5
Bumped pkgver
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-03-19 17:30:21 +01:00
Jef Roosens 8c355be5f1
Merge branch 'master' of https://git.suckless.org/st 2022-03-19 17:28:42 +01:00
NRK ef0551932f 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.
2022-03-18 12:20:27 +01:00
NRK af3bb68add 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.
2022-03-18 12:11:27 +01:00
Zacchary Dempsey-Plante 2aefa348ba make underlines and strikethroughs respect `chscale` 2022-03-13 10:45:34 +01:00
3 changed files with 13 additions and 21 deletions

View File

@ -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'

View File

@ -1,5 +1,5 @@
# st version
VERSION = 0.8.6
VERSION = 0.8.8
# Customize below to fit your system

24
st.c
View File

@ -356,25 +356,10 @@ 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)
{
while (**src && !isprint(**src))
while (**src && !isprint((unsigned char)**src))
(*src)++;
return **src ? *((*src)++) : '='; /* emulate padding if string ends */
}
@ -384,6 +369,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);