Skip to content

Commit

Permalink
config: add 'C_' prefix
Browse files Browse the repository at this point in the history
Each config variable has a global variable backing it.
The name of the global is the MixedCase transform of the config name.
While this is useful for remembering their names, it makes some
variables hard to search for, giving many false positives.

- Copy
- From
- Help
- Move
- Sort

Prefixing the globals with `C_` prevents this problem.
  • Loading branch information
flatcap committed Mar 1, 2019
1 parent becc5cc commit df08e6c
Show file tree
Hide file tree
Showing 162 changed files with 2,796 additions and 2,774 deletions.
15 changes: 8 additions & 7 deletions addrbook.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
#include "sort.h"

/* These Config Variables are only used in addrbook.c */
char *AliasFormat; ///< Config: printf-like format string for the alias menu
short SortAlias; ///< Config: Sort method for the alias menu
char *C_AliasFormat; ///< Config: printf-like format string for the alias menu
short C_SortAlias; ///< Config: Sort method for the alias menu

#define RSORT(x) ((SortAlias & SORT_REVERSE) ? -x : x)
#define RSORT(x) ((C_SortAlias & SORT_REVERSE) ? -x : x)

static const struct Mapping AliasHelp[] = {
{ N_("Exit"), OP_EXIT }, { N_("Del"), OP_DELETE },
Expand Down Expand Up @@ -109,7 +109,8 @@ static const char *alias_format_str(char *buf, size_t buflen, size_t col, int co
*/
static void alias_make_entry(char *buf, size_t buflen, struct Menu *menu, int line)
{
mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols, NONULL(AliasFormat), alias_format_str,
mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols,
NONULL(C_AliasFormat), alias_format_str,
(unsigned long) ((struct Alias **) menu->data)[line],
MUTT_FORMAT_ARROWCURSOR);
}
Expand Down Expand Up @@ -235,10 +236,10 @@ void mutt_alias_menu(char *buf, size_t buflen, struct AliasList *aliases)
i++;
}

if ((SortAlias & SORT_MASK) != SORT_ORDER)
if ((C_SortAlias & SORT_MASK) != SORT_ORDER)
{
qsort(AliasTable, menu->max, sizeof(struct Alias *),
(SortAlias & SORT_MASK) == SORT_ADDRESS ? alias_sort_address : alias_sort_alias);
(C_SortAlias & SORT_MASK) == SORT_ADDRESS ? alias_sort_address : alias_sort_alias);
}

for (i = 0; i < menu->max; i++)
Expand Down Expand Up @@ -270,7 +271,7 @@ void mutt_alias_menu(char *buf, size_t buflen, struct AliasList *aliases)
{
AliasTable[menu->current]->del = (op == OP_DELETE);
menu->redraw |= REDRAW_CURRENT;
if (Resolve && menu->current < menu->max - 1)
if (C_Resolve && menu->current < menu->max - 1)
{
menu->current++;
menu->redraw |= REDRAW_INDEX;
Expand Down
4 changes: 2 additions & 2 deletions addrbook.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
struct AliasList;

/* These Config Variables are only used in addrbook.c */
extern char *AliasFormat;
extern short SortAlias;
extern char *C_AliasFormat;
extern short C_SortAlias;

void mutt_alias_menu(char *buf, size_t buflen, struct AliasList *aliases);

Expand Down
12 changes: 6 additions & 6 deletions alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static struct Address *expand_aliases_r(struct Address *a, struct ListHead *expn
last->next = NULL;
}

if (UseDomain && (fqdn = mutt_fqdn(true)))
if (C_UseDomain && (fqdn = mutt_fqdn(true)))
{
/* now qualify all local addresses */
mutt_addr_qualify(head, fqdn);
Expand Down Expand Up @@ -186,13 +186,13 @@ static void write_safe_address(FILE *fp, char *s)
*/
static void recode_buf(char *buf, size_t buflen)
{
if (!ConfigCharset || !*ConfigCharset || !Charset)
if (!C_ConfigCharset || !*C_ConfigCharset || !C_Charset)
return;

char *s = mutt_str_strdup(buf);
if (!s)
return;
if (mutt_ch_convert_string(&s, Charset, ConfigCharset, 0) == 0)
if (mutt_ch_convert_string(&s, C_Charset, C_ConfigCharset, 0) == 0)
mutt_str_strfcpy(buf, s, buflen);
FREE(&s);
}
Expand Down Expand Up @@ -476,7 +476,7 @@ void mutt_alias_create(struct Envelope *cur, struct Address *iaddr)

TAILQ_INSERT_TAIL(&Aliases, new, entries);

mutt_str_strfcpy(buf, AliasFile, sizeof(buf));
mutt_str_strfcpy(buf, C_AliasFile, sizeof(buf));
if (mutt_get_field(_("Save to file: "), buf, sizeof(buf), MUTT_FILE) != 0)
return;
mutt_expand_path(buf, sizeof(buf));
Expand Down Expand Up @@ -713,9 +713,9 @@ bool mutt_addr_is_user(struct Address *addr)
return true;
}

if (From && (mutt_str_strcasecmp(From->mailbox, addr->mailbox) == 0))
if (C_From && (mutt_str_strcasecmp(C_From->mailbox, addr->mailbox) == 0))
{
mutt_debug(5, "#5 yes, %s = %s\n", addr->mailbox, From->mailbox);
mutt_debug(5, "#5 yes, %s = %s\n", addr->mailbox, C_From->mailbox);
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions bcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "muttlib.h"

/* These Config Variables are only used in bcache.c */
char *MessageCachedir; ///< Config: (imap/pop) Directory for the message cache
char *C_MessageCachedir; ///< Config: (imap/pop) Directory for the message cache

/**
* struct BodyCache - Local cache of email bodies
Expand All @@ -68,7 +68,7 @@ static int bcache_path(struct ConnAccount *account, const char *mailbox, char *d
struct Url url = { U_UNKNOWN };
int len;

if (!account || !MessageCachedir || !*MessageCachedir || !dst || (dstlen == 0))
if (!account || !C_MessageCachedir || !*C_MessageCachedir || !dst || (dstlen == 0))
return -1;

/* make up a Url we can turn into a string */
Expand All @@ -84,7 +84,7 @@ static int bcache_path(struct ConnAccount *account, const char *mailbox, char *d
}

size_t mailboxlen = mutt_str_strlen(mailbox);
len = snprintf(dst, dstlen, "%s/%s%s%s", MessageCachedir, host, NONULL(mailbox),
len = snprintf(dst, dstlen, "%s/%s%s%s", C_MessageCachedir, host, NONULL(mailbox),
(mailboxlen != 0 && mailbox[mailboxlen - 1] == '/') ? "" : "/");

mutt_encode_path(dst, dstlen, dst);
Expand Down
2 changes: 1 addition & 1 deletion bcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct ConnAccount;
struct BodyCache;

/* These Config Variables are only used in bcache.c */
extern char *MessageCachedir;
extern char *C_MessageCachedir;

/**
* typedef bcache_list_t - Prototype for mutt_bcache_list() callback
Expand Down
74 changes: 37 additions & 37 deletions browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
#endif

/* These Config Variables are only used in browser.c */
bool BrowserAbbreviateMailboxes; ///< Config: Abbreviate mailboxes using '~' and '=' in the browser
char *FolderFormat; ///< Config: printf-like format string for the browser's display of folders
char *GroupIndexFormat; ///< Config: (nntp) printf-like format string for the browser's display of newsgroups
char *NewsgroupsCharset; ///< Config: (nntp) Character set of newsgroups' descriptions
bool ShowOnlyUnread; ///< Config: (nntp) Only show subscribed newsgroups with unread articles
short SortBrowser; ///< Config: Sort method for the browser
char *VfolderFormat; ///< Config: (notmuch) printf-like format string for the browser's display of virtual folders
bool C_BrowserAbbreviateMailboxes; ///< Config: Abbreviate mailboxes using '~' and '=' in the browser
char *C_FolderFormat; ///< Config: printf-like format string for the browser's display of folders
char *C_GroupIndexFormat; ///< Config: (nntp) printf-like format string for the browser's display of newsgroups
char *C_NewsgroupsCharset; ///< Config: (nntp) Character set of newsgroups' descriptions
bool C_ShowOnlyUnread; ///< Config: (nntp) Only show subscribed newsgroups with unread articles
short C_SortBrowser; ///< Config: Sort method for the browser
char *C_VfolderFormat; ///< Config: (notmuch) printf-like format string for the browser's display of virtual folders

static const struct Mapping FolderHelp[] = {
{ N_("Exit"), OP_EXIT },
Expand Down Expand Up @@ -143,7 +143,7 @@ static int browser_compare_subject(const void *a, const void *b)
int r = mutt_inbox_cmp(pa->name, pb->name);
if (r == 0)
r = mutt_str_strcoll(pa->name, pb->name);
return (SortBrowser & SORT_REVERSE) ? -r : r;
return (C_SortBrowser & SORT_REVERSE) ? -r : r;
}

/**
Expand All @@ -161,7 +161,7 @@ static int browser_compare_desc(const void *a, const void *b)

int r = mutt_str_strcoll(pa->desc, pb->desc);

return (SortBrowser & SORT_REVERSE) ? -r : r;
return (C_SortBrowser & SORT_REVERSE) ? -r : r;
}

/**
Expand All @@ -179,7 +179,7 @@ static int browser_compare_date(const void *a, const void *b)

int r = pa->mtime - pb->mtime;

return (SortBrowser & SORT_REVERSE) ? -r : r;
return (C_SortBrowser & SORT_REVERSE) ? -r : r;
}

/**
Expand All @@ -197,7 +197,7 @@ static int browser_compare_size(const void *a, const void *b)

int r = pa->size - pb->size;

return (SortBrowser & SORT_REVERSE) ? -r : r;
return (C_SortBrowser & SORT_REVERSE) ? -r : r;
}

/**
Expand All @@ -221,7 +221,7 @@ static int browser_compare_count(const void *a, const void *b)
else
r = 1;

return (SortBrowser & SORT_REVERSE) ? -r : r;
return (C_SortBrowser & SORT_REVERSE) ? -r : r;
}

/**
Expand All @@ -245,7 +245,7 @@ static int browser_compare_count_new(const void *a, const void *b)
else
r = 1;

return (SortBrowser & SORT_REVERSE) ? -r : r;
return (C_SortBrowser & SORT_REVERSE) ? -r : r;
}

/**
Expand All @@ -270,7 +270,7 @@ static int browser_compare(const void *a, const void *b)
if ((mutt_str_strcoll(pb->desc, "../") == 0) || (mutt_str_strcoll(pb->desc, "..") == 0))
return 1;

switch (SortBrowser & SORT_MASK)
switch (C_SortBrowser & SORT_MASK)
{
case SORT_COUNT:
return browser_compare_count(a, b);
Expand All @@ -297,7 +297,7 @@ static int browser_compare(const void *a, const void *b)
*/
static void browser_sort(struct BrowserState *state)
{
switch (SortBrowser & SORT_MASK)
switch (C_SortBrowser & SORT_MASK)
{
/* Also called "I don't care"-sort-method. */
case SORT_ORDER:
Expand Down Expand Up @@ -382,7 +382,7 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c

if (op == 'D')
{
t_fmt = NONULL(DateFormat);
t_fmt = NONULL(C_DateFormat);
if (*t_fmt == '!')
{
t_fmt++;
Expand Down Expand Up @@ -689,8 +689,8 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
continue;
if (prefix && *prefix && !mutt_str_startswith(mdata->group, prefix, CASE_MATCH))
continue;
if (Mask && Mask->regex &&
!((regexec(Mask->regex, mdata->group, 0, NULL, 0) == 0) ^ Mask->not))
if (C_Mask && C_Mask->regex &&
!((regexec(C_Mask->regex, mdata->group, 0, NULL, 0) == 0) ^ C_Mask->not))
{
continue;
}
Expand Down Expand Up @@ -748,8 +748,8 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
{
continue;
}
if (Mask && Mask->regex &&
!((regexec(Mask->regex, de->d_name, 0, NULL, 0) == 0) ^ Mask->not))
if (C_Mask && C_Mask->regex &&
!((regexec(C_Mask->regex, de->d_name, 0, NULL, 0) == 0) ^ C_Mask->not))
{
continue;
}
Expand Down Expand Up @@ -806,7 +806,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state)
for (unsigned int i = 0; i < adata->groups_num; i++)
{
struct NntpMboxData *mdata = adata->groups_list[i];
if (mdata && (mdata->new || (mdata->subscribed && (mdata->unread || !ShowOnlyUnread))))
if (mdata && (mdata->new || (mdata->subscribed && (mdata->unread || !C_ShowOnlyUnread))))
{
add_folder(menu, state, mdata->group, NULL, NULL, NULL, mdata);
}
Expand All @@ -832,7 +832,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state)

char buffer[PATH_MAX];
mutt_str_strfcpy(buffer, np->mailbox->path, sizeof(buffer));
if (BrowserAbbreviateMailboxes)
if (C_BrowserAbbreviateMailboxes)
mutt_pretty_mailbox(buffer, sizeof(buffer));

switch (np->mailbox->magic)
Expand Down Expand Up @@ -907,14 +907,14 @@ static void folder_make_entry(char *buf, size_t buflen, struct Menu *menu, int l
if (OptNews)
{
mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols,
NONULL(GroupIndexFormat), group_index_format_str,
NONULL(C_GroupIndexFormat), group_index_format_str,
(unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
}
else
#endif
{
mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols,
NONULL(FolderFormat), folder_format_str,
NONULL(C_FolderFormat), folder_format_str,
(unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
}
}
Expand Down Expand Up @@ -995,7 +995,7 @@ static void init_menu(struct BrowserState *state, struct Menu *menu,
mutt_str_strfcpy(path, LastDir, sizeof(path));
mutt_pretty_mailbox(path, sizeof(path));
snprintf(title, titlelen, _("Directory [%s], File mask: %s"), path,
NONULL(Mask ? Mask->pattern : NULL));
NONULL(C_Mask ? C_Mask->pattern : NULL));
}
}

Expand Down Expand Up @@ -1100,7 +1100,7 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
bool mailbox = (flags & MUTT_SEL_MAILBOX);

/* Keeps in memory the directory we were in when hitting '='
* to go directly to $folder (Folder)
* to go directly to $folder (#C_Folder)
*/
char GotoSwapper[PATH_MAX] = "";

Expand Down Expand Up @@ -1195,7 +1195,7 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
*/
bool browser_track = false;

switch (SortBrowser & SORT_MASK)
switch (C_SortBrowser & SORT_MASK)
{
case SORT_DESC:
case SORT_SUBJECT:
Expand Down Expand Up @@ -1233,10 +1233,10 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
case MUTT_MBOX:
case MUTT_MH:
case MUTT_MMDF:
if (Folder)
mutt_str_strfcpy(LastDir, Folder, sizeof(LastDir));
else if (Spoolfile)
mutt_browser_select_dir(Spoolfile);
if (C_Folder)
mutt_str_strfcpy(LastDir, C_Folder, sizeof(LastDir));
else if (C_Spoolfile)
mutt_browser_select_dir(C_Spoolfile);
break;
default:
mutt_browser_select_dir(CurrentFolder);
Expand Down Expand Up @@ -1699,7 +1699,7 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int

case OP_ENTER_MASK:
{
mutt_str_strfcpy(buf, Mask ? Mask->pattern : NULL, sizeof(buf));
mutt_str_strfcpy(buf, C_Mask ? C_Mask->pattern : NULL, sizeof(buf));
if (mutt_get_field(_("File Mask: "), buf, sizeof(buf), 0) != 0)
break;

Expand Down Expand Up @@ -1825,17 +1825,17 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
if (op == OP_BROWSER_GOTO_FOLDER)
{
/* When in mailboxes mode, disables this feature */
if (Folder)
if (C_Folder)
{
mutt_debug(LL_DEBUG3, "= hit! Folder: %s, LastDir: %s\n", Folder, LastDir);
mutt_debug(LL_DEBUG3, "= hit! Folder: %s, LastDir: %s\n", C_Folder, LastDir);
if (GotoSwapper[0] == '\0')
{
if (mutt_str_strcmp(LastDir, Folder) != 0)
if (mutt_str_strcmp(LastDir, C_Folder) != 0)
{
/* Stores into GotoSwapper LastDir, and swaps to Folder */
/* Stores into GotoSwapper LastDir, and swaps to C_Folder */
mutt_str_strfcpy(GotoSwapper, LastDir, sizeof(GotoSwapper));
mutt_str_strfcpy(OldLastDir, LastDir, sizeof(OldLastDir));
mutt_str_strfcpy(LastDir, Folder, sizeof(LastDir));
mutt_str_strfcpy(LastDir, C_Folder, sizeof(LastDir));
}
}
else
Expand Down
14 changes: 7 additions & 7 deletions browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
#include <time.h>

/* These Config Variables are only used in browser.c */
extern bool BrowserAbbreviateMailboxes;
extern char *FolderFormat;
extern char *GroupIndexFormat;
extern char *NewsgroupsCharset;
extern bool ShowOnlyUnread;
extern short SortBrowser;
extern char *VfolderFormat;
extern bool C_BrowserAbbreviateMailboxes;
extern char *C_FolderFormat;
extern char *C_GroupIndexFormat;
extern char *C_NewsgroupsCharset;
extern bool C_ShowOnlyUnread;
extern short C_SortBrowser;
extern char *C_VfolderFormat;

/* flags to mutt_select_file() */
#define MUTT_SEL_MAILBOX (1 << 0)
Expand Down
Loading

0 comments on commit df08e6c

Please sign in to comment.