X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=color.c;h=dd29b7fbb39ee3b3c50ad900cbf5f78ff8a7dbc4;hp=9270516b00c16e369cb3cf5a9548bc783da33484;hb=0c12d960399d14b4143b2bb91a96bdaca64e4c56;hpb=814a01519c9605d479201b99eb16c97b0ad8635d diff --git a/color.c b/color.c index 9270516..dd29b7f 100644 --- a/color.c +++ b/color.c @@ -11,13 +11,16 @@ # include "config.h" #endif +#include +#include +#include +#include +#include + #include "mutt.h" #include "mutt_curses.h" #include "mapping.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/debug.h" #include @@ -96,7 +99,7 @@ static struct mapping_t Fields[] = { static COLOR_LINE *mutt_new_color_line (void) { - COLOR_LINE *p = safe_calloc (1, sizeof (COLOR_LINE)); + COLOR_LINE *p = p_new(COLOR_LINE, 1); p->fg = p->bg = -1; @@ -123,29 +126,29 @@ static void mutt_free_color_line (COLOR_LINE ** l, int free_colors) regfree (&tmp->rx); mutt_pattern_free (&tmp->color_pattern); - FREE (&tmp->pattern); - FREE (l); + p_delete(&tmp->pattern); + p_delete(l); } void ci_start_color (void) { - memset (ColorDefs, A_NORMAL, sizeof (int) * MT_COLOR_MAX); - ColorQuote = (int *) safe_malloc (COLOR_QUOTE_INIT * sizeof (int)); - memset (ColorQuote, A_NORMAL, sizeof (int) * COLOR_QUOTE_INIT); - ColorQuoteSize = COLOR_QUOTE_INIT; - ColorQuoteUsed = 0; - - /* set some defaults */ - ColorDefs[MT_COLOR_STATUS] = A_REVERSE; - ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE; - ColorDefs[MT_COLOR_SEARCH] = A_REVERSE; - ColorDefs[MT_COLOR_MARKERS] = A_REVERSE; - /* special meaning: toggle the relevant attribute */ - ColorDefs[MT_COLOR_BOLD] = 0; - ColorDefs[MT_COLOR_UNDERLINE] = 0; + memset(ColorDefs, A_NORMAL, sizeof(int) * MT_COLOR_MAX); + ColorQuote = p_new(int, COLOR_QUOTE_INIT); + memset(ColorQuote, A_NORMAL, sizeof(int) * COLOR_QUOTE_INIT); + ColorQuoteSize = COLOR_QUOTE_INIT; + ColorQuoteUsed = 0; + + /* set some defaults */ + ColorDefs[MT_COLOR_STATUS] = A_REVERSE; + ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE; + ColorDefs[MT_COLOR_SEARCH] = A_REVERSE; + ColorDefs[MT_COLOR_MARKERS] = A_REVERSE; + /* special meaning: toggle the relevant attribute */ + ColorDefs[MT_COLOR_BOLD] = 0; + ColorDefs[MT_COLOR_UNDERLINE] = 0; #ifdef HAVE_COLOR - start_color (); + start_color (); #endif } @@ -223,7 +226,7 @@ int mutt_alloc_color (int fg, int bg) i++; } - p = (COLOR_LIST *) safe_malloc (sizeof (COLOR_LIST)); + p = p_new(COLOR_LIST, 1); p->next = ColorList; ColorList = p; @@ -267,14 +270,14 @@ void mutt_free_color (int fg, int bg) if (p == ColorList) { ColorList = ColorList->next; - FREE (&p); + p_delete(&p); return; } q = ColorList; while (q) { if (q->next == p) { q->next = p->next; - FREE (&p); + p_delete(&p); return; } q = q->next; @@ -295,13 +298,13 @@ parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err) { char *eptr; - if (safe_strncasecmp (s, "bright", 6) == 0) { + if (str_ncasecmp (s, "bright", 6) == 0) { *attr |= brite; s += 6; } /* allow aliases for xterm color resources */ - if (safe_strncasecmp (s, "color", 5) == 0) { + if (str_ncasecmp (s, "color", 5) == 0) { s += 5; *col = strtol (s, &eptr, 10); if (!*s || *eptr || *col < 0 || @@ -361,7 +364,7 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, return (-1); } - if (safe_strncmp (buf->data, "index", 5) != 0) { + if (str_ncmp (buf->data, "index", 5) != 0) { snprintf (err->data, err->dsize, _("%s: command valid only for index object"), parse_uncolor ? "uncolor" : "unmono"); @@ -399,7 +402,7 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, do { mutt_extract_token (buf, s, 0); - if (!safe_strcmp ("*", buf->data)) { + if (!m_strcmp("*", buf->data)) { for (tmp = ColorIndexList; tmp;) { if (!do_cache) do_cache = 1; @@ -412,7 +415,7 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, else { for (last = NULL, tmp = ColorIndexList; tmp; last = tmp, tmp = tmp->next) { - if (!safe_strcmp (buf->data, tmp->pattern)) { + if (!m_strcmp(buf->data, tmp->pattern)) { if (!do_cache) do_cache = 1; debug_print (1, ("Freeing pattern \"%s\" from ColorIndexList\n", tmp->pattern)); @@ -454,11 +457,11 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, while (tmp) { if (sensitive) { - if (safe_strcmp (s, tmp->pattern) == 0) + if (m_strcmp(s, tmp->pattern) == 0) break; } else { - if (safe_strcasecmp (s, tmp->pattern) == 0) + if (str_casecmp (s, tmp->pattern) == 0) break; } tmp = tmp->next; @@ -507,7 +510,7 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, return (-1); } tmp->next = *top; - tmp->pattern = safe_strdup (s); + tmp->pattern = m_strdup(s); #ifdef HAVE_COLOR if (fg != -1 && bg != -1) { tmp->fg = fg; @@ -534,7 +537,7 @@ parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err) } mutt_extract_token (buf, s, 0); - if (!safe_strncmp (buf->data, "quoted", 6)) { + if (!str_ncmp (buf->data, "quoted", 6)) { if (buf->data[6]) { *ql = strtol (buf->data + 6, &eptr, 10); if (*eptr || q_level < 0) { @@ -698,7 +701,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, } else if (object == MT_COLOR_QUOTED) { if (q_level >= ColorQuoteSize) { - safe_realloc (&ColorQuote, (ColorQuoteSize += 2) * sizeof (int)); + p_realloc(&ColorQuote, ColorQuoteSize += 2); ColorQuote[ColorQuoteSize - 2] = ColorDefs[MT_COLOR_QUOTED]; ColorQuote[ColorQuoteSize - 1] = ColorDefs[MT_COLOR_QUOTED]; }