summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--decode.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/decode.c b/decode.c
index 2604f73..8578c41 100644
--- a/decode.c
+++ b/decode.c
@@ -90,11 +90,6 @@ static const char Base64[64] = {
 	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
 };
 
-static uint8_t unbase64(char ch) {
-	const char *ptr = strchr(Base64, ch);
-	return (ptr ? ptr - Base64 : 0);
-}
-
 static void decodeBase64(struct Buffer *dst, const char *src) {
 	while (src[0] && src[1] && src[2] && src[3]) {
 		if (!strchr(Base64, src[0])) {
@@ -104,7 +99,7 @@ static void decodeBase64(struct Buffer *dst, const char *src) {
 		uint32_t bits = 0;
 		for (int i = 0; i < 4; ++i) {
 			bits <<= 6;
-			bits |= unbase64(src[i]);
+			bits |= strchr(Base64, src[i]) - Base64;
 		}
 		*bufferDest(dst, 1) = bits >> 16;
 		if (src[2] != '=') *bufferDest(dst, 1) = bits >> 8;
@@ -116,8 +111,7 @@ static void decodeBase64(struct Buffer *dst, const char *src) {
 static char unhex(char ch) {
 	if (ch <= '9') return ch - '0';
 	if (ch <= 'F') return 0xA + ch - 'A';
-	if (ch <= 'f') return 0xA + ch - 'a';
-	return 0;
+	return 0xA + ch - 'a';
 }
 
 static void decodeQ(struct Buffer *dst, const char *src) {
olspan='3' class='logmsg'> 2022-04-13Swap dates so the difference is always positiveJune McEnroe 2022-04-04Update "Care"June McEnroe 2022-04-03Publish "Care"June McEnroe 2022-03-31Publish "Compassion"June McEnroe 2022-03-24Skip matches with ident chars on either sideJune McEnroe This fixes, for example, where the link gets placed on static regex_t regex(const char *pattern, int flags) in title.c. 2022-03-24Add The Invisible Life of Addie LaRueJune McEnroe So good, but so long. Reminded me of The Ten Thousand Doors of January at the beginning, and more of that N. K. Jemisin series about gods later. I like this interacting with gods and becoming something like one sort of thing. God, it took me a whole month (more?) to read and this is only my third book of the year :( I need some more novellas to read, but the other books I have from the library currently are also thick. 2022-03-22Source ~/.profile.local if it existsJune McEnroe 2022-03-18Publish "Addendum 2021"June McEnroe 2022-03-16Remove wcwidth portJune McEnroe DYLD_FORCE_FLAT_NAMESPACE no longer exists in macOS 12 so this approach doesn't work anymore. Moved to <https://git.causal.agency/jorts/tree/wcwidth> and compiled into <https://git.causal.agency/jorts/tree/ncurses>. 2022-03-16Remove -j4 from ./PlanJune McEnroe Plan learned to set this automatically! 2022-03-15Rewrite Linux install.sh for DebianJune McEnroe 2022-03-15Remove dashJune McEnroe