From: Richard Russon Date: Wed, 25 Jul 2018 12:27:43 +0000 (+0100) Subject: boolify params X-Git-Tag: 2019-10-25~732^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9ac261f8f68abbe895f4fff93142881056b7eec;p=neomutt boolify params --- diff --git a/color.c b/color.c index 8ca73e0be..690fef5ce 100644 --- a/color.c +++ b/color.c @@ -164,7 +164,7 @@ static struct ColorLine *new_color_line(void) * @param tmp ColorLine to free * @param free_colors If true, free its colours too */ -static void free_color_line(struct ColorLine *tmp, int free_colors) +static void free_color_line(struct ColorLine *tmp, bool free_colors) { if (!tmp) return; @@ -439,7 +439,7 @@ void mutt_free_color(int fg, int bg) * * Parse a colour name, such as "red", "brightgreen", "color123". */ -static int parse_color_name(const char *s, int *col, int *attr, int is_fg, struct Buffer *err) +static int parse_color_name(const char *s, int *col, int *attr, bool is_fg, struct Buffer *err) { char *eptr = NULL; int is_alert = 0, is_bright = 0; @@ -510,7 +510,7 @@ static int parse_color_name(const char *s, int *col, int *attr, int is_fg, struc * @param[in] parse_uncolor If true, 'uncolor', else 'unmono' */ static void do_uncolor(struct Buffer *buf, struct Buffer *s, - struct ColorLineHead *cl, int *do_cache, bool parse_uncolor) + struct ColorLineHead *cl, bool *do_cache, bool parse_uncolor) { struct ColorLine *np = NULL, *tmp = NULL; do @@ -524,7 +524,7 @@ static void do_uncolor(struct Buffer *buf, struct Buffer *s, tmp = STAILQ_NEXT(np, entries); if (!*do_cache) { - *do_cache = 1; + *do_cache = true; } free_color_line(np, parse_uncolor); np = tmp; @@ -541,7 +541,7 @@ static void do_uncolor(struct Buffer *buf, struct Buffer *s, { if (!*do_cache) { - *do_cache = 1; + *do_cache = true; } mutt_debug(1, "Freeing pattern \"%s\" from ColorList\n", buf->data); if (tmp) @@ -572,9 +572,10 @@ static void do_uncolor(struct Buffer *buf, struct Buffer *s, * * unmono index pattern [pattern...] */ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, - struct Buffer *err, short parse_uncolor) + struct Buffer *err, bool parse_uncolor) { - int object = 0, do_cache = 0; + int object = 0; + bool do_cache = false; mutt_extract_token(buf, s, 0); @@ -673,7 +674,7 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat int mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err) { - return parse_uncolor(buf, s, data, err, 1); + return parse_uncolor(buf, s, data, err, true); } #endif @@ -690,7 +691,7 @@ int mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, int mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err) { - return parse_uncolor(buf, s, data, err, 0); + return parse_uncolor(buf, s, data, err, false); } /** @@ -707,8 +708,8 @@ int mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data, * @retval 0 Success * @retval -1 Error */ -static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive, int fg, - int bg, int attr, struct Buffer *err, int is_index, int match) +static int add_pattern(struct ColorLineHead *top, const char *s, bool sensitive, int fg, + int bg, int attr, struct Buffer *err, bool is_index, int match) { /* is_index used to store compiled pattern * only for `index' color object @@ -759,7 +760,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive, tmp->color_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, err); if (!tmp->color_pattern) { - free_color_line(tmp, 1); + free_color_line(tmp, true); return -1; } } @@ -775,7 +776,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive, if (r != 0) { regerror(r, &tmp->regex, err->data, err->dsize); - free_color_line(tmp, 1); + free_color_line(tmp, true); return -1; } } @@ -893,7 +894,7 @@ static int parse_color_pair(struct Buffer *buf, struct Buffer *s, int *fg, mutt_extract_token(buf, s, 0); - if (parse_color_name(buf->data, fg, attr, 1, err) != 0) + if (parse_color_name(buf->data, fg, attr, true, err) != 0) return -1; if (!MoreArgs(s)) @@ -904,7 +905,7 @@ static int parse_color_pair(struct Buffer *buf, struct Buffer *s, int *fg, mutt_extract_token(buf, s, 0); - if (parse_color_name(buf->data, bg, attr, 0, err) != 0) + if (parse_color_name(buf->data, bg, attr, false, err) != 0) return -1; return 0; @@ -1053,11 +1054,11 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, #endif if (object == MT_COLOR_HEADER) - r = add_pattern(&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0, match); + r = add_pattern(&ColorHdrList, buf->data, false, fg, bg, attr, err, false, match); else if (object == MT_COLOR_BODY) - r = add_pattern(&ColorBodyList, buf->data, 1, fg, bg, attr, err, 0, match); + r = add_pattern(&ColorBodyList, buf->data, true, fg, bg, attr, err, false, match); else if (object == MT_COLOR_ATTACH_HEADERS) - r = add_pattern(&ColorAttachList, buf->data, 1, fg, bg, attr, err, 0, match); + r = add_pattern(&ColorAttachList, buf->data, true, fg, bg, attr, err, false, match); else if ((object == MT_COLOR_STATUS) && MoreArgs(s)) { /* 'color status fg bg' can have up to 2 arguments: @@ -1081,31 +1082,31 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, return -1; } - r = add_pattern(&ColorStatusList, buf->data, 1, fg, bg, attr, err, 0, match); + r = add_pattern(&ColorStatusList, buf->data, true, fg, bg, attr, err, false, match); } else if (object == MT_COLOR_INDEX) { - r = add_pattern(&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1, match); + r = add_pattern(&ColorIndexList, buf->data, true, fg, bg, attr, err, true, match); mutt_menu_set_redraw_full(MENU_MAIN); } else if (object == MT_COLOR_INDEX_AUTHOR) { - r = add_pattern(&ColorIndexAuthorList, buf->data, 1, fg, bg, attr, err, 1, match); + r = add_pattern(&ColorIndexAuthorList, buf->data, true, fg, bg, attr, err, true, match); mutt_menu_set_redraw_full(MENU_MAIN); } else if (object == MT_COLOR_INDEX_FLAGS) { - r = add_pattern(&ColorIndexFlagsList, buf->data, 1, fg, bg, attr, err, 1, match); + r = add_pattern(&ColorIndexFlagsList, buf->data, true, fg, bg, attr, err, true, match); mutt_menu_set_redraw_full(MENU_MAIN); } else if (object == MT_COLOR_INDEX_SUBJECT) { - r = add_pattern(&ColorIndexSubjectList, buf->data, 1, fg, bg, attr, err, 1, match); + r = add_pattern(&ColorIndexSubjectList, buf->data, true, fg, bg, attr, err, true, match); mutt_menu_set_redraw_full(MENU_MAIN); } else if (object == MT_COLOR_INDEX_TAG) { - r = add_pattern(&ColorIndexTagList, buf->data, 1, fg, bg, attr, err, 1, match); + r = add_pattern(&ColorIndexTagList, buf->data, true, fg, bg, attr, err, true, match); mutt_menu_set_redraw_full(MENU_MAIN); } else if (object == MT_COLOR_QUOTED) diff --git a/commands.c b/commands.c index 5f42ac7be..9254b4424 100644 --- a/commands.c +++ b/commands.c @@ -385,7 +385,7 @@ void ci_bounce_message(struct Header *h) * @param[out] cmflags Copy message flags, e.g. MUTT_CM_DECODE * @param[out] chflags Copy header flags, e.g. CH_DECODE */ -static void pipe_set_flags(int decode, int print, int *cmflags, int *chflags) +static void pipe_set_flags(bool decode, bool print, int *cmflags, int *chflags) { if (decode) { diff --git a/compose.c b/compose.c index c803644f3..5ca933ae3 100644 --- a/compose.c +++ b/compose.c @@ -198,7 +198,7 @@ static struct Mapping ComposeNewsHelp[] = { * @param header Header string * @param calc_max If true, calculate the maximum width */ -static void calc_header_width_padding(int idx, const char *header, int calc_max) +static void calc_header_width_padding(int idx, const char *header, bool calc_max) { int width; @@ -226,12 +226,12 @@ static void init_header_padding(void) done = 1; for (int i = 0; i <= HDR_XCOMMENTTO; i++) - calc_header_width_padding(i, _(Prompts[i]), 1); + calc_header_width_padding(i, _(Prompts[i]), true); /* Don't include "Sign as: " in the MaxHeaderWidth calculation. It * doesn't show up by default, and so can make the indentation of * the other fields look funny. */ - calc_header_width_padding(HDR_CRYPTINFO, _(Prompts[HDR_CRYPTINFO]), 0); + calc_header_width_padding(HDR_CRYPTINFO, _(Prompts[HDR_CRYPTINFO]), false); for (int i = 0; i <= HDR_XCOMMENTTO; i++) { @@ -619,7 +619,7 @@ static void mutt_gen_compose_attach_list(struct AttachCtx *actx, struct Body *m, * @param menu Current menu * @param init If true, initialise the attachment list */ -static void mutt_update_compose_menu(struct AttachCtx *actx, struct Menu *menu, int init) +static void mutt_update_compose_menu(struct AttachCtx *actx, struct Menu *menu, bool init) { if (init) { @@ -655,7 +655,7 @@ static void update_idx(struct Menu *menu, struct AttachCtx *actx, struct AttachP actx->idx[actx->idxlen - 1]->content->next = new->content; new->content->aptr = new; mutt_actx_add_attach(actx, new); - mutt_update_compose_menu(actx, menu, 0); + mutt_update_compose_menu(actx, menu, false); menu->current = actx->vcount - 1; } @@ -939,7 +939,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, struct AttachCtx *actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1); actx->hdr = msg; - mutt_update_compose_menu(actx, menu, 1); + mutt_update_compose_menu(actx, menu, true); while (loop) { @@ -1119,7 +1119,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, if (actx->idxlen && actx->idx[actx->idxlen - 1]->content->next) { mutt_actx_free_entries(actx); - mutt_update_compose_menu(actx, menu, 1); + mutt_update_compose_menu(actx, menu, true); } menu->redraw = REDRAW_FULL; @@ -1532,7 +1532,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, CURATTACH->content->unlink = 0; if (delete_attachment(actx, menu->current) == -1) break; - mutt_update_compose_menu(actx, menu, 0); + mutt_update_compose_menu(actx, menu, false); if (menu->current == 0) msg->content = actx->idx[0]->content; diff --git a/curs_main.c b/curs_main.c index 1ded70331..c58d13653 100644 --- a/curs_main.c +++ b/curs_main.c @@ -356,7 +356,7 @@ static void resort_index(struct Menu *menu) } if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0) - menu->current = mutt_parent_message(Context, current, 0); + menu->current = mutt_parent_message(Context, current, false); if (menu->current < 0) menu->current = ci_first_message(); diff --git a/edit.c b/edit.c index 9a8287498..113bb82e0 100644 --- a/edit.c +++ b/edit.c @@ -126,7 +126,7 @@ static char **be_snarf_data(FILE *f, char **buf, int *bufmax, int *buflen, * @param[in] verbose If true, report the file and bytes read * @retval ptr Pointer to allocated buffer */ -static char **be_snarf_file(const char *path, char **buf, int *max, int *len, int verbose) +static char **be_snarf_file(const char *path, char **buf, int *max, int *len, bool verbose) { char tmp[LONG_STRING]; struct stat sb; @@ -399,7 +399,7 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur addstr(_("(End message with a . on a line by itself)\n")); - buf = be_snarf_file(path, buf, &bufmax, &buflen, 0); + buf = be_snarf_file(path, buf, &bufmax, &buflen, false); tmp[0] = '\0'; while (!done) @@ -478,7 +478,7 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur { strncpy(tmp, p, sizeof(tmp)); mutt_expand_path(tmp, sizeof(tmp)); - buf = be_snarf_file(tmp, buf, &bufmax, &buflen, 1); + buf = be_snarf_file(tmp, buf, &bufmax, &buflen, true); } else addstr(_("missing filename.\n")); @@ -525,7 +525,7 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur else mutt_edit_file(NONULL(Visual), path); - buf = be_snarf_file(path, buf, &bufmax, &buflen, 0); + buf = be_snarf_file(path, buf, &bufmax, &buflen, false); addstr(_("(continue)\n")); } diff --git a/mutt_thread.c b/mutt_thread.c index fff6053d1..5ec6f6676 100644 --- a/mutt_thread.c +++ b/mutt_thread.c @@ -1098,7 +1098,7 @@ int mutt_aside_thread(struct Header *hdr, short dir, short subthreads) * @retval >=0 Virtual index number of parent/root message * @retval -1 Error */ -int mutt_parent_message(struct Context *ctx, struct Header *hdr, int find_root) +int mutt_parent_message(struct Context *ctx, struct Header *hdr, bool find_root) { struct MuttThread *thread = NULL; struct Header *parent = NULL; diff --git a/mutt_thread.h b/mutt_thread.h index fa6f602ba..a3e475113 100644 --- a/mutt_thread.h +++ b/mutt_thread.h @@ -69,7 +69,7 @@ void mutt_draw_tree(struct Context *ctx); void mutt_clear_threads(struct Context *ctx); struct MuttThread *mutt_sort_subthreads(struct MuttThread *thread, bool init); void mutt_sort_threads(struct Context *ctx, bool init); -int mutt_parent_message(struct Context *ctx, struct Header *hdr, int find_root); +int mutt_parent_message(struct Context *ctx, struct Header *hdr, bool find_root); void mutt_set_virtual(struct Context *ctx); struct Hash *mutt_make_id_hash(struct Context *ctx); diff --git a/pager.c b/pager.c index ba55a3496..70dd2f4e1 100644 --- a/pager.c +++ b/pager.c @@ -837,7 +837,7 @@ static int check_attachment_marker(char *p) */ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, int last, struct QClass **quote_list, int *q_level, - int *force_redraw, int q_classify) + int *force_redraw, bool q_classify) { struct ColorLine *color_line = NULL; regmatch_t pmatch[1], smatch[1]; @@ -1825,7 +1825,7 @@ out: * @param hiding true if lines have been hidden * @retval num New current line number */ -static int up_n_lines(int nlines, struct Line *info, int cur, int hiding) +static int up_n_lines(int nlines, struct Line *info, int cur, bool hiding) { while (cur > 0 && nlines > 0) { diff --git a/query.c b/query.c index 13d7b370f..90563a97f 100644 --- a/query.c +++ b/query.c @@ -349,7 +349,7 @@ static int query_tag(struct Menu *menu, int n, int m) * @param results Query List * @param retbuf If true, populate the results */ -static void query_menu(char *buf, size_t buflen, struct Query *results, int retbuf) +static void query_menu(char *buf, size_t buflen, struct Query *results, bool retbuf) { struct Menu *menu = NULL; struct Header *msg = NULL; @@ -613,7 +613,7 @@ int mutt_query_complete(char *buf, size_t buflen) return 0; } /* multiple results, choose from query menu */ - query_menu(buf, buflen, results, 1); + query_menu(buf, buflen, results, true); } return 0; } @@ -635,10 +635,10 @@ void mutt_query_menu(char *buf, size_t buflen) { char buffer[STRING] = ""; - query_menu(buffer, sizeof(buffer), NULL, 0); + query_menu(buffer, sizeof(buffer), NULL, false); } else { - query_menu(buf, buflen, NULL, 1); + query_menu(buf, buflen, NULL, true); } } diff --git a/recvcmd.c b/recvcmd.c index af79946a4..14700a62e 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -386,7 +386,7 @@ static struct AttachPtr *find_parent(struct AttachCtx *actx, struct Body *cur, s * @param ofp File to write to * @param prefix Prefix for each line (OPTIONAL) */ -static void include_header(int quote, FILE *ifp, struct Header *hdr, FILE *ofp, char *prefix) +static void include_header(bool quote, FILE *ifp, struct Header *hdr, FILE *ofp, char *prefix) { int chflags = CH_DECODE; char prefix2[SHORT_STRING]; @@ -991,7 +991,7 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx, st.flags |= MUTT_WEED; if (Header) - include_header(1, parent_fp, parent_hdr, tmpfp, prefix); + include_header(true, parent_fp, parent_hdr, tmpfp, prefix); if (cur) { diff --git a/remailer.c b/remailer.c index 420621d6a..631c551dd 100644 --- a/remailer.c +++ b/remailer.c @@ -310,7 +310,7 @@ static void mix_screen_coordinates(struct Remailer **type2_list, struct Coord ** * @param selected true, if this item is selected */ static void mix_redraw_ce(struct Remailer **type2_list, struct Coord *coords, - struct MixChain *chain, int i, short selected) + struct MixChain *chain, int i, bool selected) { if (!coords || !chain) return; @@ -625,8 +625,8 @@ void mix_make_chain(struct ListHead *chainhead) } else if (c_cur != c_old) { - mix_redraw_ce(type2_list, coords, chain, c_old, 0); - mix_redraw_ce(type2_list, coords, chain, c_cur, 1); + mix_redraw_ce(type2_list, coords, chain, c_old, false); + mix_redraw_ce(type2_list, coords, chain, c_cur, true); } c_old = c_cur; diff --git a/rfc3676.c b/rfc3676.c index 924d594b4..32262293f 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -217,7 +217,7 @@ static int quote_width(struct State *s, int ql) * @param term If true, terminate with a new line */ static void print_flowed_line(char *line, struct State *s, int ql, - struct FlowedState *fst, int term) + struct FlowedState *fst, bool term) { size_t width, w, words = 0; char *p = NULL; @@ -352,7 +352,7 @@ int rfc3676_handler(struct Body *a, struct State *s) /* a fixed line either has no trailing space or is the * signature separator */ - const int fixed = buf_len == buf_off || buf[buf_len - 1] != ' ' || sigsep; + const bool fixed = (buf_len == buf_off) || (buf[buf_len - 1] != ' ') || sigsep; /* print fixed-and-standalone, fixed-and-empty and sigsep lines as * fixed lines */