return (int) (*p - *q);
}
+/* Checks if buf matches the QuoteRegex and doesn't match Smileys.
+ * pmatch, if non-null, is populated with the regexec match against
+ * QuoteRegex. This is used by the pager for calling classify_quote.
+ */
+int mutt_is_quote_line(char *buf, regmatch_t *pmatch)
+{
+ int is_quote = 0;
+ regmatch_t pmatch_internal[1], smatch[1];
+ char c;
+
+ if (!pmatch)
+ pmatch = pmatch_internal;
+
+ if (QuoteRegex && QuoteRegex->regex && regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
+ {
+ if (Smileys && Smileys->regex && regexec(Smileys->regex, buf, 1, smatch, 0) == 0)
+ {
+ if (smatch[0].rm_so > 0)
+ {
+ c = buf[smatch[0].rm_so];
+ buf[smatch[0].rm_so] = 0;
+
+ if (regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
+ is_quote = 1;
+
+ buf[smatch[0].rm_so] = c;
+ }
+ }
+ else
+ is_quote = 1;
+ }
+
+ return is_quote;
+}
+
/**
* resolve_types - Determine the style for a line of text
* @param buf Formatted text
bool *force_redraw, bool q_classify)
{
struct ColorLine *color_line = NULL;
- regmatch_t pmatch[1], smatch[1];
+ regmatch_t pmatch[1];
bool found;
bool null_rx;
int offset, i = 0;
}
else if (check_sig(buf, line_info, n - 1) == 0)
line_info[n].type = MT_COLOR_SIGNATURE;
- else if (QuoteRegex && QuoteRegex->regex &&
- regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
- {
- if (Smileys && Smileys->regex && (regexec(Smileys->regex, buf, 1, smatch, 0) == 0))
- {
- if (smatch[0].rm_so > 0)
- {
- char c;
-
- /* hack to avoid making an extra copy of buf */
- c = buf[smatch[0].rm_so];
- buf[smatch[0].rm_so] = 0;
-
- if (regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
- {
- if (q_classify && !line_info[n].quote)
- {
- line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so,
- pmatch[0].rm_eo - pmatch[0].rm_so,
- force_redraw, q_level);
- }
- line_info[n].type = MT_COLOR_QUOTED;
- }
- else
- line_info[n].type = MT_COLOR_NORMAL;
+ else if (mutt_is_quote_line(buf, pmatch))
- buf[smatch[0].rm_so] = c;
- }
- else
- line_info[n].type = MT_COLOR_NORMAL;
- }
- else
+ {
+ if (q_classify && line_info[n].quote == NULL)
{
- if (q_classify && !line_info[n].quote)
- {
- line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so,
- pmatch[0].rm_eo - pmatch[0].rm_so,
- force_redraw, q_level);
- }
- line_info[n].type = MT_COLOR_QUOTED;
+ line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so,
+ pmatch[0].rm_eo - pmatch[0].rm_so,
+ force_redraw, q_level);
}
+ line_info[n].type = MT_COLOR_QUOTED;
}
else
line_info[n].type = MT_COLOR_NORMAL;