X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=7c7ddffd7b7c53cb976f1e2521d453e415ef471a;hb=c1d23afa9c44cc29818c538126790ae90a64a3c5;hp=8d4a9f2f48eb7b1c07773dfaf6611e1ed237d290;hpb=6cb6d61525931c88971cce323f63e40451a6d365;p=st.git diff --git a/st.c b/st.c index 8d4a9f2..7c7ddff 100644 --- a/st.c +++ b/st.c @@ -386,6 +386,13 @@ static const char base64_digits[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +char +base64dec_getc(const char **src) +{ + while (**src && !isprint(**src)) (*src)++; + return *((*src)++); +} + char * base64dec(const char *src) { @@ -393,13 +400,13 @@ base64dec(const char *src) char *result, *dst; if (in_len % 4) - return NULL; + in_len += 4 - (in_len % 4); result = dst = xmalloc(in_len / 4 * 3 + 1); while (*src) { - int a = base64_digits[(unsigned char) *src++]; - int b = base64_digits[(unsigned char) *src++]; - int c = base64_digits[(unsigned char) *src++]; - int d = base64_digits[(unsigned char) *src++]; + int a = base64_digits[(unsigned char) base64dec_getc(&src)]; + int b = base64_digits[(unsigned char) base64dec_getc(&src)]; + int c = base64_digits[(unsigned char) base64dec_getc(&src)]; + int d = base64_digits[(unsigned char) base64dec_getc(&src)]; *dst++ = (a << 2) | ((b & 0x30) >> 4); if (c == -1) @@ -1402,9 +1409,6 @@ tsetattr(int *attr, int l) case 9: term.c.attr.mode |= ATTR_STRUCK; break; - case 21: - term.c.attr.mode &= ~ATTR_BOLD; - break; case 22: term.c.attr.mode &= ~(ATTR_BOLD | ATTR_FAINT); break;