static size_t choose_block(char *d, size_t dlen, int col, const char *fromcode,
const char *tocode, encoder_t *encoder, size_t *wlen)
{
- const int utf8 = fromcode && (mutt_str_strcasecmp(fromcode, "utf-8") == 0);
+ const bool utf8 = fromcode && (mutt_str_strcasecmp(fromcode, "utf-8") == 0);
size_t n = dlen;
while (true)
}
/**
- * rfc2047_decode_word - Decode an RFC2047-encoded string
+ * decode_word - Decode an RFC2047-encoded string
* @param s String to decode
* @param len Length of the string
* @param enc Encoding type
*
* @note The caller must free the returned string
*/
-static char *rfc2047_decode_word(const char *s, size_t len, enum ContentEncoding enc)
+static char *decode_word(const char *s, size_t len, enum ContentEncoding enc)
{
const char *it = s;
const char *end = s + len;
}
/**
- * rfc2047_encode2 - RFC2047-encode a string
+ * encode - RFC2047-encode a string
* @param d String to convert
* @param dlen Length of string
* @param col Starting column to convert
* @param specials Special characters to be encoded
* @retval 0 Success
*/
-static int rfc2047_encode2(const char *d, size_t dlen, int col,
+static int encode(const char *d, size_t dlen, int col,
const char *fromcode, const char *charsets, char **e,
size_t *elen, const char *specials)
{
if (icode)
while (CONTINUATION_BYTE(t[n]))
n--;
- if (!n)
+ if (n == 0)
{
/* This should only happen in the really stupid case where the
- only word that needs encoding is one character long, but
- there is too much us-ascii stuff after it to use a single
- encoded word. We add the next word to the encoded region
- and try again. */
+ * only word that needs encoding is one character long, but
+ * there is too much us-ascii stuff after it to use a single
+ * encoded word. We add the next word to the encoded region
+ * and try again. */
assert(t1 < (u + ulen));
for (t1++; (t1 < (u + ulen)) && !HSPACE(*t1); t1++)
;
*/
void rfc2047_encode(char **pd, const char *specials, int col, const char *charsets)
{
- char *e = NULL;
- size_t elen;
-
if (!Charset || !*pd)
return;
if (!charsets || !*charsets)
charsets = "utf-8";
- rfc2047_encode2(*pd, strlen(*pd), col, Charset, charsets, &e, &elen, specials);
+ char *e = NULL;
+ size_t elen = 0;
+ encode(*pd, strlen(*pd), col, Charset, charsets, &e, &elen, specials);
FREE(pd);
*pd = e;
{
/* Some encoded text was found */
text[textlen] = '\0';
- char *decoded = rfc2047_decode_word(text, textlen, enc);
+ char *decoded = decode_word(text, textlen, enc);
if (!decoded)
{
return;
{
rfc2047_decode(&a->personal);
}
- else if (a->group && a->mailbox && (strstr(a->mailbox, "=?") != NULL))
+ else if (a->group && a->mailbox && strstr(a->mailbox, "=?"))
rfc2047_decode(&a->mailbox);
a = a->next;
}