]> granicus.if.org Git - neomutt/commitdiff
tidy code
authorRichard Russon <rich@flatcap.org>
Thu, 3 Oct 2019 22:10:08 +0000 (23:10 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 8 Oct 2019 22:45:05 +0000 (23:45 +0100)
color.c
color.h

diff --git a/color.c b/color.c
index 924033f6a7789307f678a938d4ecad52e5ddd7ef..8f4a8e01dd2e9c1dcd26beee07c83372b9ee4cce 100644 (file)
--- a/color.c
+++ b/color.c
 #include <assert.h>
 #endif
 
+/**
+ * typedef parser_callback_t - Prototype for a function to parse color config
+ * @param[in]  buf Temporary Buffer space
+ * @param[in]  s    Buffer containing string to be parsed
+ * @param[out] fg   Foreground colour (set to -1)
+ * @param[out] bg   Background colour (set to -1)
+ * @param[out] attr Attribute flags
+ * @param[out] err  Buffer for error messages
+ * @retval  0 Success
+ * @retval -1 Error
+ */
+typedef int (*parser_callback_t)(struct Buffer *buf, struct Buffer *s, uint32_t *fg,
+                                 uint32_t *bg, int *attr, struct Buffer *err);
+
 /* globals */
 int *ColorQuote = NULL;
 int ColorQuoteUsed;
@@ -76,7 +90,7 @@ static int ColorQuoteSize;
  *
  * Note that no flag means it's a palette color.
  */
-#define RGB24 (1u << 24)
+#define RGB24 (1U << 24)
 
 /**
  * struct ColorList - A set of colors
@@ -300,7 +314,6 @@ int mutt_color_alloc(uint32_t fg, uint32_t bg)
   char fgc[128], bgc[128];
 #endif
   struct ColorList *p = ColorList;
-  int i;
 
   /* check to see if this color is already allocated to save space */
   while (p)
@@ -318,7 +331,7 @@ int mutt_color_alloc(uint32_t fg, uint32_t bg)
     return A_NORMAL;
 
   /* find the smallest available index (object) */
-  i = 1;
+  int i = 1;
   while (true)
   {
     p = ColorList;
@@ -669,22 +682,17 @@ static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s,
     return MUTT_CMD_WARNING;
   }
 
-  if (
 #ifdef HAVE_COLOR
-      /* we're running without curses */
-      OptNoCurses || /* we're parsing an uncolor command, and have no colors */
-      (uncolor && !has_colors())
-      /* we're parsing an unmono command, and have colors */
-      || (!uncolor && has_colors())
+  if (OptNoCurses ||                // running without curses
+      (uncolor && !has_colors()) || // parsing an uncolor command, and have no colors
+      (!uncolor && has_colors())) // parsing an unmono command, and have colors
 #else
-      /* We don't even have colors compiled in */
-      uncolor
+  if (uncolor) // We don't even have colors compiled in
 #endif
-  )
   {
-    /* just eat the command, but don't do anything real about it */
     do
     {
+      /* just eat the command, but don't do anything real about it */
       mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
     } while (MoreArgs(s));
 
@@ -760,8 +768,7 @@ static enum CommandResult add_pattern(struct ColorLineList *top, const char *s,
                                       bool sensitive, uint32_t fg, uint32_t bg, int attr,
                                       struct Buffer *err, bool is_index, int match)
 {
-  /* is_index used to store compiled pattern
-   * only for 'index' color object
+  /* is_index used to store compiled pattern only for 'index' color object
    * when called from mutt_parse_color() */
 
   struct ColorLine *tmp = NULL;
@@ -917,20 +924,6 @@ static int parse_object(struct Buffer *buf, struct Buffer *s, uint32_t *o,
   return 0;
 }
 
-/**
- * typedef parser_callback_t - Prototype for a function to parse color config
- * @param[in]  buf Temporary Buffer space
- * @param[in]  s    Buffer containing string to be parsed
- * @param[out] fg   Foreground colour (set to -1)
- * @param[out] bg   Background colour (set to -1)
- * @param[out] attr Attribute flags
- * @param[out] err  Buffer for error messages
- * @retval  0 Success
- * @retval -1 Error
- */
-typedef int (*parser_callback_t)(struct Buffer *buf, struct Buffer *s, uint32_t *fg,
-                                 uint32_t *bg, int *attr, struct Buffer *err);
-
 #ifdef HAVE_COLOR
 /**
  * parse_color_pair - Parse a pair of colours - Implements ::parser_callback_t
@@ -1043,7 +1036,7 @@ static int fgbgattr_to_color(int fg, int bg, int attr)
 }
 
 /**
- * parse_color - Parse a "color" command
+ * parse_color - Parse a 'color' command
  * @param buf      Temporary Buffer space
  * @param s        Buffer containing string to be parsed
  * @param err      Buffer for error messages
@@ -1091,8 +1084,6 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
     return MUTT_CMD_WARNING;
   }
 
-  /* dry run? */
-
   if (dry_run)
   {
     *s->dptr = '\0'; /* fake that we're done parsing */
diff --git a/color.h b/color.h
index 7ad4fef410225abcde6c2b91df34b6fffff515b8..e221ed80b11d01d7e755970901d14f0252eb8cd7 100644 (file)
--- a/color.h
+++ b/color.h
@@ -38,12 +38,12 @@ struct ColorLine
   regex_t regex;                     ///< Compiled regex
   int match;                         ///< Substring to match, 0 for old behaviour
   char *pattern;                     ///< Pattern to match
-  struct PatternList *color_pattern; ///< compiled pattern to speed up index color calculation
+  struct PatternList *color_pattern; ///< Compiled pattern to speed up index color calculation
   uint32_t fg;                       ///< Foreground colour
   uint32_t bg;                       ///< Background colour
   int pair;                          ///< Colour pair index
 
-  bool stop_matching : 1;            ///< used by the pager for body patterns, to prevent the color from being retried once it fails
+  bool stop_matching : 1;            ///< Used by the pager for body patterns, to prevent the color from being retried once it fails
 
   STAILQ_ENTRY(ColorLine) entries;   ///< Linked list
 };