Skip to content

Commit

Permalink
iwyu: tidy #includes
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Jul 16, 2019
1 parent 00dea7c commit 4604c11
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 82 deletions.
1 change: 0 additions & 1 deletion config/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <stdint.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "email/lib.h"
#include "address.h"
#include "set.h"
#include "types.h"
Expand Down
1 change: 0 additions & 1 deletion config/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mutt/mutt.h"
#include "dump.h"
#include "set.h"
Expand Down
7 changes: 1 addition & 6 deletions config/enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
#include <stddef.h>
#include <limits.h>
#include <stdint.h>
#include "mutt/buffer.h"
#include "mutt/hash.h"
#include "mutt/logging.h"
#include "mutt/mapping.h"
#include "mutt/memory.h"
#include "mutt/string2.h"
#include "mutt/mutt.h"
#include "enum.h"
#include "set.h"
#include "types.h"
Expand Down
121 changes: 60 additions & 61 deletions config/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,25 @@
#include <stdbool.h>
#include <stdint.h>
#include "mutt/mutt.h"
#include "regex2.h"
#include "set.h"
#include "types.h"

/**
* regex_free - Free a Regex object
* @param[out] r Regex to free
*/
void regex_free(struct Regex **r)
{
if (!r || !*r)
return;

FREE(&(*r)->pattern);
if ((*r)->regex)
regfree((*r)->regex);
FREE(&(*r)->regex);
FREE(r);
}

/**
* regex_destroy - Destroy a Regex object - Implements ::cst_destroy()
*/
Expand All @@ -52,6 +67,50 @@ static void regex_destroy(const struct ConfigSet *cs, void *var, const struct Co
regex_free(r);
}

/**
* regex_new - Create an Regex from a string
* @param str Regular expression
* @param flags Type flags, e.g. #DT_REGEX_MATCH_CASE
* @param err Buffer for error messages
* @retval ptr New Regex object
* @retval NULL Error
*/
struct Regex *regex_new(const char *str, int flags, struct Buffer *err)
{
if (!str)
return NULL;

int rflags = 0;
struct Regex *reg = mutt_mem_calloc(1, sizeof(struct Regex));

reg->regex = mutt_mem_calloc(1, sizeof(regex_t));
reg->pattern = mutt_str_strdup(str);

/* Should we use smart case matching? */
if (((flags & DT_REGEX_MATCH_CASE) == 0) && mutt_mb_is_lower(str))
rflags |= REG_ICASE;

if ((flags & DT_REGEX_NOSUB))
rflags |= REG_NOSUB;

/* Is a prefix of '!' allowed? */
if (((flags & DT_REGEX_ALLOW_NOT) != 0) && (str[0] == '!'))
{
reg->pat_not = true;
str++;
}

int rc = REG_COMP(reg->regex, str, rflags);
if ((rc != 0) && err)
{
regerror(rc, reg->regex, err->data, err->dsize);
regex_free(&reg);
return NULL;
}

return reg;
}

/**
* regex_string_set - Set a Regex by string - Implements ::cst_string_set()
*/
Expand Down Expand Up @@ -260,63 +319,3 @@ void regex_init(struct ConfigSet *cs)
};
cs_register_type(cs, DT_REGEX, &cst_regex);
}

/**
* regex_new - Create an Regex from a string
* @param str Regular expression
* @param flags Type flags, e.g. #DT_REGEX_MATCH_CASE
* @param err Buffer for error messages
* @retval ptr New Regex object
* @retval NULL Error
*/
struct Regex *regex_new(const char *str, int flags, struct Buffer *err)
{
if (!str)
return NULL;

int rflags = 0;
struct Regex *reg = mutt_mem_calloc(1, sizeof(struct Regex));

reg->regex = mutt_mem_calloc(1, sizeof(regex_t));
reg->pattern = mutt_str_strdup(str);

/* Should we use smart case matching? */
if (((flags & DT_REGEX_MATCH_CASE) == 0) && mutt_mb_is_lower(str))
rflags |= REG_ICASE;

if ((flags & DT_REGEX_NOSUB))
rflags |= REG_NOSUB;

/* Is a prefix of '!' allowed? */
if (((flags & DT_REGEX_ALLOW_NOT) != 0) && (str[0] == '!'))
{
reg->pat_not = true;
str++;
}

int rc = REG_COMP(reg->regex, str, rflags);
if ((rc != 0) && err)
{
regerror(rc, reg->regex, err->data, err->dsize);
regex_free(&reg);
return NULL;
}

return reg;
}

/**
* regex_free - Free a Regex object
* @param[out] r Regex to free
*/
void regex_free(struct Regex **r)
{
if (!r || !*r)
return;

FREE(&(*r)->pattern);
if ((*r)->regex)
regfree((*r)->regex);
FREE(&(*r)->regex);
FREE(r);
}
1 change: 0 additions & 1 deletion config/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "config.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mutt/mutt.h"
#include "set.h"
Expand Down
1 change: 0 additions & 1 deletion config/slist.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stddef.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include "mutt/mutt.h"
#include "set.h"
#include "types.h"
Expand Down
5 changes: 2 additions & 3 deletions config/subset.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
*/

#include "config.h"
#include <stddef.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "subset.h"
#include "dump.h"
#include "set.h"
#include "types.h"

/**
* cs_subset_free - Free a Config Subset
Expand Down
6 changes: 4 additions & 2 deletions config/subset.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#ifndef MUTT_CONFIG_SUBSET_H
#define MUTT_CONFIG_SUBSET_H

#include <stdio.h>
#include "set.h"
#include <stdint.h>

struct Buffer;
struct HashElem;

/**
* struct ConfigSubset - A set of inherited config items
Expand Down
1 change: 0 additions & 1 deletion conn/conn_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <unistd.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "email/lib.h"
#include "conn/connaccount.h"
#include "conn_globals.h"
#include "connection.h"
Expand Down
2 changes: 2 additions & 0 deletions conn/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef MUTT_CONN_SSL_H
#define MUTT_CONN_SSL_H

#include "config.h"

struct Connection;

#ifdef USE_SSL
Expand Down
1 change: 0 additions & 1 deletion core/account.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "config/lib.h"
#include "account.h"
#include "mailbox.h"
#include "neomutt.h"

/**
* account_new - Create a new Account
Expand Down
1 change: 0 additions & 1 deletion core/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include "config.h"
#include <sys/stat.h>
#include "config/lib.h"
#include "email/lib.h"
#include "mailbox.h"
#include "neomutt.h"
Expand Down
1 change: 0 additions & 1 deletion core/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <time.h>
#include "mutt/mutt.h"

struct ConfigSubset;
struct Email;

#define MB_NORMAL 0
Expand Down
2 changes: 0 additions & 2 deletions email/tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "tags.h"

/* These Config Variables are only used in email/tags.c */
Expand Down

0 comments on commit 4604c11

Please sign in to comment.