if (length <= q_list->length) {
/* case 1: check the top level nodes */
- if (safe_strncmp (qptr, q_list->prefix, length) == 0) {
+ if (str_ncmp (qptr, q_list->prefix, length) == 0) {
if (length == q_list->length)
return q_list; /* same prefix: return the current class */
/* tmp != NULL means we already found a shorter prefix at case 1 */
if (tmp == NULL
- && safe_strncmp (qptr, q_list->prefix, q_list->length) == 0) {
+ && str_ncmp (qptr, q_list->prefix, q_list->length) == 0) {
/* ok, it's a subclass somewhere on this branch */
ptr = q_list;
while (q_list) {
if (length <= q_list->length) {
- if (safe_strncmp (tail_qptr, (q_list->prefix) + offset, tail_lng)
+ if (str_ncmp (tail_qptr, (q_list->prefix) + offset, tail_lng)
== 0) {
/* same prefix: return the current class */
if (length == q_list->length)
else {
/* longer than the current prefix: try subclassing it */
if (tmp == NULL
- && safe_strncmp (tail_qptr, (q_list->prefix) + offset,
+ && str_ncmp (tail_qptr, (q_list->prefix) + offset,
q_list->length - offset) == 0) {
/* still a subclass: go down one level */
ptr = q_list;
}
}
}
- else if (safe_strncmp ("\033[0m", raw, 4) == 0) /* a little hack... */
+ else if (str_ncmp ("\033[0m", raw, 4) == 0) /* a little hack... */
lineInfo[n].type = MT_COLOR_NORMAL;
#if 0
- else if (safe_strncmp ("[-- ", buf, 4) == 0)
+ else if (str_ncmp ("[-- ", buf, 4) == 0)
lineInfo[n].type = MT_COLOR_ATTACHMENT;
#else
else if (check_attachment_marker ((char *) raw) == 0)
lineInfo[n].type = MT_COLOR_ATTACHMENT;
#endif
- else if (safe_strcmp ("-- \n", buf) == 0
- || safe_strcmp ("-- \r\n", buf) == 0) {
+ else if (str_cmp ("-- \n", buf) == 0
+ || str_cmp ("-- \r\n", buf) == 0) {
i = n + 1;
lineInfo[n].type = MT_COLOR_SIGNATURE;
return pos;
}
+/* trim tail of buf so that it contains complete multibyte characters */
+static int trim_incomplete_mbyte(unsigned char *buf, size_t len) {
+ mbstate_t mbstate;
+ size_t k;
+
+ memset (&mbstate, 0, sizeof (mbstate));
+ for (; len > 0; buf += k, len -= k) {
+ k = mbrtowc (NULL, (char *) buf, len, &mbstate);
+ if (k == -2)
+ break;
+ else if (k == -1 || k == 0)
+ k = 1;
+ }
+ *buf = '\0';
+
+ return len;
+}
+
static int
fill_buffer (FILE * f, long *last_pos, long offset, unsigned char *buf,
unsigned char *fmt, size_t blen, int *buf_ready)
b_read = (int) (*last_pos - offset);
*buf_ready = 1;
+ /* incomplete mbyte characters trigger a segfault in regex processing for
+ * certain versions of glibc. Trim them if necessary. */
+ if (b_read == blen - 2)
+ b_read -= trim_incomplete_mbyte(buf, b_read);
+
/* copy "buf" to "fmt", but without bold and underline controls */
p = buf;
while (*p) {
/* skip trailing blanks */
while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r'))
ch--;
- cnt = ch + 1;
+ /* a very long word with leading spaces causes infinite wrapping */
+ if ((!ch) && (flags & M_PAGER_NSKIP))
+ buf_ptr = buf + cnt;
+ else
+ cnt = ch + 1;
}
else
buf_ptr = buf + cnt; /* a very long word... */
move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
option (OPTSTATUSONTOP) ? 0 : SidebarWidth);
SETCOLOR (MT_COLOR_STATUS);
+ BKGDSET (MT_COLOR_STATUS);
mutt_paddstr (COLS - (option (OPTSTATUSONTOP) ? 0 : SidebarWidth),
buffer);
SETCOLOR (MT_COLOR_NORMAL);
+ BKGDSET (MT_COLOR_NORMAL);
}
/* if we're not using the index, update every time */
if (index == 0)
else
followup_to = extra->hdr->env->followup_to;
- if (!followup_to || safe_strcasecmp (followup_to, "poster") ||
+ if (!followup_to || str_casecmp (followup_to, "poster") ||
query_quadoption (OPT_FOLLOWUPTOPOSTER,
_("Reply by mail as poster prefers?")) != M_YES) {
if (extra->ctx && extra->ctx->magic == M_NNTP