summary refs log tree commit diff
path: root/decode.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--decode.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/decode.c b/decode.c
index 8578c41..8fd005d 100644
--- a/decode.c
+++ b/decode.c
@@ -86,20 +86,30 @@ static void convertCharset(
 	iconv_close(conv);
 }
 
-static const char Base64[64] = {
+static const uint8_t Base64[64] = {
 	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
 };
+static uint8_t Table64[256];
+
+static uint8_t unbase64(char ch) {
+	if (!Table64[Base64[1]]) {
+		for (size_t i = 0; i < sizeof(Base64); ++i) {
+			Table64[Base64[i]] = i;
+		}
+	}
+	return Table64[(uint8_t)ch];
+}
 
 static void decodeBase64(struct Buffer *dst, const char *src) {
 	while (src[0] && src[1] && src[2] && src[3]) {
-		if (!strchr(Base64, src[0])) {
+		if (!unbase64(src[0]) && src[0] != Base64[0]) {
 			src++;
 			continue;
 		}
 		uint32_t bits = 0;
 		for (int i = 0; i < 4; ++i) {
 			bits <<= 6;
-			bits |= strchr(Base64, src[i]) - Base64;
+			bits |= unbase64(src[i]);
 		}
 		*bufferDest(dst, 1) = bits >> 16;
 		if (src[2] != '=') *bufferDest(dst, 1) = bits >> 8;
td>2012-01-29Don't show Syntastic errors automaticallyJune McEnroe 2012-01-28Update to Quicktask 1.1June McEnroe 2012-01-22Use space-test branch of quicktaskJune McEnroe 2012-01-22Enable syntax-based foldingJune McEnroe 2012-01-22Update quicktaskJune McEnroe 2012-01-22Revert "Add AutoClose"June McEnroe This reverts commit 39cfdd62ba82f93f68a2b5fa7b5771303d8b9dee. This fixes the delay when leaving insert mode 2012-01-22Revert "Disable powerline for now"June McEnroe This reverts commit fa48f5965c57272e616721d92475cd2f1e35f667. 2012-01-22Revert "Add VCS repo directories to wildignore"June McEnroe This reverts commit 41cb1db33ba7b64d8af63bf55bb82f7e8a617518. This fixes not being able to commit with vim-fugitive 2012-01-22Disable powerline for nowJune McEnroe 2012-01-22Update some pluginsJune McEnroe 2012-01-22Add VCS repo directories to wildignoreJune McEnroe 2012-01-22Map ,e and ,b to CtrlP file and buffer respectivelyJune McEnroe 2012-01-22Add vim-spaceJune McEnroe 2012-01-22Add AutoCloseJune McEnroe 2012-01-22Add binding for GundoJune McEnroe 2012-01-22Add GundoJune McEnroe 2012-01-22Add Jellybeans colorschemeJune McEnroe 2012-01-22Add syntasticJune McEnroe 2012-01-21Add PowerlineJune McEnroe 2012-01-21Add quicktaskJune McEnroe 2012-01-15Moved comments out of mapsJune McEnroe 2012-01-14Disable scrollbarsJune McEnroe