diff options
-rw-r--r-- | include/manconfig.h.in | 4 | ||||
-rw-r--r-- | lib/debug.c | 5 | ||||
-rw-r--r-- | lib/encodings.c | 4 | ||||
-rw-r--r-- | libdb/db_lookup.c | 8 | ||||
-rw-r--r-- | libdb/db_storage.h | 8 | ||||
-rw-r--r-- | src/accessdb.c | 3 | ||||
-rw-r--r-- | src/catman.c | 3 | ||||
-rw-r--r-- | src/check_mandirs.c | 24 | ||||
-rw-r--r-- | src/descriptions_store.c | 11 | ||||
-rw-r--r-- | src/globbing_test.c | 17 | ||||
-rw-r--r-- | src/lexgrog_test.c | 26 | ||||
-rw-r--r-- | src/man.c | 161 | ||||
-rw-r--r-- | src/manconv_main.c | 3 | ||||
-rw-r--r-- | src/mandb.c | 36 | ||||
-rw-r--r-- | src/manp.c | 8 | ||||
-rw-r--r-- | src/manp.h | 2 | ||||
-rw-r--r-- | src/manpath.c | 11 | ||||
-rw-r--r-- | src/straycats.c | 2 | ||||
-rw-r--r-- | src/whatis.c | 44 | ||||
-rw-r--r-- | src/zsoelim_main.c | 3 |
20 files changed, 198 insertions, 185 deletions
diff --git a/include/manconfig.h.in b/include/manconfig.h.in index db24db78..d9605c9b 100644 --- a/include/manconfig.h.in +++ b/include/manconfig.h.in @@ -33,6 +33,8 @@ #ifndef MANCONFIG_H #define MANCONFIG_H +#include <stdbool.h> + #include "xvasprintf.h" /* STD_SECTIONS must contain all of your man hierarchy subdirectories. The @@ -336,7 +338,7 @@ extern struct compression comp_list[]; extern char *create_tempdir (const char *template) ATTRIBUTE_WARN_UNUSED_RESULT; -extern int debug_level; /* shows whether -d issued */ +extern bool debug_level; /* shows whether -d issued */ extern void init_debug (void); extern void debug (const char *message, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); extern void debug_error (const char *message, ...) diff --git a/lib/debug.c b/lib/debug.c index 1b75e63d..dd5ade86 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -23,6 +23,7 @@ # include "config.h" #endif +#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h> @@ -31,13 +32,13 @@ #include "manconfig.h" -int debug_level = 0; +bool debug_level = false; void init_debug (void) { const char *man_debug = getenv ("MAN_DEBUG"); if (man_debug && STREQ (man_debug, "1")) - debug_level = 1; + debug_level = true; } static void vdebug (const char *message, va_list args) diff --git a/lib/encodings.c b/lib/encodings.c index c033543f..ccccdbb1 100644 --- a/lib/encodings.c +++ b/lib/encodings.c @@ -742,13 +742,13 @@ bool is_roff_device (const char *device) const char *get_roff_encoding (const char *device, const char *source_encoding) { const struct device_entry *entry; - int found = 0; + bool found = false; const char *roff_encoding = NULL; if (device) { for (entry = device_table; entry->roff_device; ++entry) { if (STREQ (entry->roff_device, device)) { - found = 1; + found = true; roff_encoding = entry->roff_encoding; break; } diff --git a/libdb/db_lookup.c b/libdb/db_lookup.c index 4631729e..ff5e2310 100644 --- a/libdb/db_lookup.c +++ b/libdb/db_lookup.c @@ -372,14 +372,14 @@ static gl_list_t dblookup (MYDBM_FILE dbf, const char *page, } gl_list_t dblookup_all (MYDBM_FILE dbf, const char *page, - const char *section, int match_case) + const char *section, bool match_case) { return dblookup (dbf, page, section, ALL | (match_case ? MATCH_CASE : 0)); } struct mandata *dblookup_exact (MYDBM_FILE dbf, const char *page, - const char *section, int match_case) + const char *section, bool match_case) { gl_list_t infos = dblookup (dbf, page, section, EXACT | (match_case ? MATCH_CASE : 0)); @@ -395,8 +395,8 @@ struct mandata *dblookup_exact (MYDBM_FILE dbf, const char *page, } gl_list_t dblookup_pattern (MYDBM_FILE dbf, const char *pattern, - const char *section, int match_case, - int pattern_regex, int try_descriptions) + const char *section, bool match_case, + bool pattern_regex, bool try_descriptions) { gl_list_t infos; struct mandata *tail = NULL; diff --git a/libdb/db_storage.h b/libdb/db_storage.h index 77982492..a04196bc 100644 --- a/libdb/db_storage.h +++ b/libdb/db_storage.h @@ -79,12 +79,12 @@ struct name_ext { /* used by the world */ extern gl_list_t dblookup_all (MYDBM_FILE dbf, const char *page, - const char *section, int match_case); + const char *section, bool match_case); extern struct mandata *dblookup_exact (MYDBM_FILE dbf, const char *page, - const char *section, int match_case); + const char *section, bool match_case); extern gl_list_t dblookup_pattern (MYDBM_FILE dbf, const char *page, - const char *section, int match_case, - int pattern_regex, int try_descriptions); + const char *section, bool match_case, + bool pattern_regex, bool try_descriptions); extern int dbstore (MYDBM_FILE dbf, struct mandata *in, const char *base); extern int dbdelete (MYDBM_FILE dbf, const char *name, struct mandata *in); extern void dbprintf (const struct mandata *info); diff --git a/src/accessdb.c b/src/accessdb.c index 21f18cb8..ff3fef5e 100644 --- a/src/accessdb.c +++ b/src/accessdb.c @@ -27,6 +27,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdio.h> #include <errno.h> #include <string.h> @@ -70,7 +71,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'h': argp_state_help (state, state->out_stream, diff --git a/src/catman.c b/src/catman.c index 01e4a313..c58ef6c0 100644 --- a/src/catman.c +++ b/src/catman.c @@ -31,6 +31,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdio.h> #include <assert.h> #include <sys/types.h> @@ -112,7 +113,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'M': manp = arg; diff --git a/src/check_mandirs.c b/src/check_mandirs.c index 7e22dcbe..5aba37cb 100644 --- a/src/check_mandirs.c +++ b/src/check_mandirs.c @@ -72,9 +72,9 @@ #include "ult_src.h" #include "check_mandirs.h" -int opt_test; /* don't update db */ +bool opt_test; /* don't update db */ int pages; -int force_rescan = 0; +bool force_rescan = false; gl_map_t whatis_map = NULL; @@ -161,7 +161,7 @@ void test_manfile (MYDBM_FILE dbf, const char *file, const char *path) * save both an ult_src() and a find_name(), amongst other wastes of * time. */ - exists = dblookup_exact (dbf, manpage_base, info.ext, 1); + exists = dblookup_exact (dbf, manpage_base, info.ext, true); /* Ensure we really have the actual page. Gzip keeps the mtime the * same when it compresses, so we have to compare compression @@ -205,8 +205,8 @@ void test_manfile (MYDBM_FILE dbf, const char *file, const char *path) */ { /* Avoid too much noise in debug output */ - int save_debug = debug_level; - debug_level = 0; + bool save_debug = debug_level; + debug_level = false; ult = ult_src (file, path, &buf, SOFT_LINK | HARD_LINK, NULL); debug_level = save_debug; } @@ -844,7 +844,7 @@ static int purge_whatis (MYDBM_FILE dbf, const char *path, int cat, debug ("%s(%s): whatis replaced by real page; " "forcing a rescan just in case\n", name, info->ext); - force_rescan = 1; + force_rescan = true; return 0; } else if (STREQ (info->pointer, "-")) { /* This is broken; a WHATIS_MAN should never have an empty @@ -862,16 +862,16 @@ static int purge_whatis (MYDBM_FILE dbf, const char *path, int cat, debug ("%s(%s): whatis had empty pointer; " "forcing a rescan just in case\n", name, info->ext); - force_rescan = 1; + force_rescan = true; return 1; } else { /* Does the real page still exist? */ gl_list_t real_found; - int save_debug = debug_level; + bool save_debug = debug_level; struct timespec t; int count; - debug_level = 0; + debug_level = false; real_found = look_for_file (path, info->ext, info->pointer, cat, LFF_MATCHCASE); debug_level = save_debug; @@ -918,7 +918,7 @@ static int check_multi_key (const char *name, const char *content) if (!valid) { debug ("%s: broken multi key \"%s\", " "forcing a rescan\n", name, content); - force_rescan = 1; + force_rescan = true; return 1; } @@ -980,7 +980,7 @@ int purge_missing (const char *manpath, const char *catpath, datum content, nextkey; struct mandata entry; char *nicekey, *tab; - int save_debug; + bool save_debug; gl_list_t found; /* Ignore db identifier keys. */ @@ -1020,7 +1020,7 @@ int purge_missing (const char *manpath, const char *catpath, split_content (MYDBM_DPTR (content), &entry); save_debug = debug_level; - debug_level = 0; /* look_for_file() is quite noisy */ + debug_level = false; /* look_for_file() is quite noisy */ if (entry.id <= WHATIS_MAN) found = look_for_file (manpath, entry.ext, entry.name ? entry.name diff --git a/src/descriptions_store.c b/src/descriptions_store.c index d7c6a277..47d0b912 100644 --- a/src/descriptions_store.c +++ b/src/descriptions_store.c @@ -24,6 +24,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -80,14 +81,14 @@ void store_descriptions (MYDBM_FILE dbf, gl_list_t descs, struct mandata *info, /* Either it's the real thing or merely a reference. Get the * id and pointer right in either case. */ - int found_real_page = 0; - int found_external = 0; + bool found_real_page = false; + bool found_external = false; if (STREQ (base, desc->name)) { info->id = save_id; info->pointer = NULL; info->whatis = desc->whatis; - found_real_page = 1; + found_real_page = true; } else if (trace) { size_t i = 0; GL_LIST_FOREACH_START (trace, trace_name) { @@ -103,7 +104,7 @@ void store_descriptions (MYDBM_FILE dbf, gl_list_t descs, struct mandata *info, * hierarchy; skip this * description. */ - found_external = 1; + found_external = true; free (trace_info.name); free (buf); break; @@ -115,7 +116,7 @@ void store_descriptions (MYDBM_FILE dbf, gl_list_t descs, struct mandata *info, info->id = save_id; info->pointer = NULL; info->whatis = desc->whatis; - found_real_page = 1; + found_real_page = true; } free (trace_info.name); diff --git a/src/globbing_test.c b/src/globbing_test.c index 94a8c1d2..5f0878fa 100644 --- a/src/globbing_test.c +++ b/src/globbing_test.c @@ -25,6 +25,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -46,9 +47,9 @@ man_sandbox *sandbox; /* unused, but needed by libman */ extern const char *extension; -static int match_case = 0; -static int regex_opt = 0; -static int wildcard = 0; +static bool match_case = false; +static bool regex_opt = false; +static bool wildcard = false; static char **remaining_args; const char *argp_program_version = "globbing " PACKAGE_VERSION; @@ -72,22 +73,22 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'e': extension = arg; return 0; case 'i': - match_case = 0; + match_case = false; return 0; case 'I': - match_case = 1; + match_case = true; return 0; case 'r': - regex_opt = 1; + regex_opt = true; return 0; case 'w': - wildcard = 1; + wildcard = true; return 0; case 'h': argp_state_help (state, state->out_stream, diff --git a/src/lexgrog_test.c b/src/lexgrog_test.c index 6c6183fd..4fb39fd1 100644 --- a/src/lexgrog_test.c +++ b/src/lexgrog_test.c @@ -26,6 +26,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -55,7 +56,8 @@ int quiet = 1; man_sandbox *sandbox; -static int parse_man = 0, parse_cat = 0, show_whatis = 0, show_filters = 0; +static bool parse_man = false, parse_cat = false; +static bool show_whatis = false, show_filters = false; static const char *encoding = NULL; static char **files; static int num_files; @@ -82,19 +84,19 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'm': - parse_man = 1; + parse_man = true; return 0; case 'c': - parse_cat = 1; + parse_cat = true; return 0; case 'w': - show_whatis = 1; + show_whatis = true; return 0; case 'f': - show_filters = 1; + show_filters = true; return 0; case 'E': encoding = arg; @@ -121,9 +123,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) "-m -c"); /* defaults: --man, --whatis */ if (!parse_man && !parse_cat) - parse_man = 1; + parse_man = true; if (!show_whatis && !show_filters) - show_whatis = 1; + show_whatis = true; return 0; } return ARGP_ERR_UNKNOWN; @@ -150,7 +152,7 @@ int main (int argc, char **argv) { int type = 0; int i; - int some_failed = 0; + bool some_failed = false; set_program_name (argv[0]); @@ -175,7 +177,7 @@ int main (int argc, char **argv) for (i = 0; i < num_files; ++i) { lexgrog lg; const char *file; - int found = 0; + bool found = false; lg.type = type; @@ -212,7 +214,7 @@ int main (int argc, char **argv) GL_LIST_FOREACH_START (descs, desc) { if (!desc->name || !desc->whatis) continue; - found = 1; + found = true; printf ("%s", files[i]); if (show_filters) printf (" (%s)", lg.filters); @@ -228,7 +230,7 @@ int main (int argc, char **argv) if (!found) { printf ("%s: parse failed\n", files[i]); - some_failed = 1; + some_failed = true; } } @@ -179,7 +179,7 @@ int quiet = 1; char *database = NULL; extern const char *extension; /* for globbing.c */ extern char *user_config_file; /* defined in manp.c */ -extern int disable_cache; +extern bool disable_cache; extern int min_cat_width, max_cat_width, cat_width; man_sandbox *sandbox; @@ -199,31 +199,31 @@ static char *manp; static const char *external; static gl_map_t db_map = NULL; -static int troff; +static bool troff; static const char *roff_device = NULL; static const char *want_encoding = NULL; #ifdef NROFF_WARNINGS static const char default_roff_warnings[] = "mac"; static gl_list_t roff_warnings; #endif /* NROFF_WARNINGS */ -static int global_apropos; -static int print_where, print_where_cat; -static int catman; -static int local_man_file; -static int findall; -static int update; -static int match_case; -static int regex_opt; -static int wildcard; -static int names_only; +static bool global_apropos; +static bool print_where, print_where_cat; +static bool catman; +static bool local_man_file; +static bool findall; +static bool update; +static bool match_case; +static bool regex_opt; +static bool wildcard; +static bool names_only; static int ult_flags = SO_LINK | SOFT_LINK | HARD_LINK; static const char *recode = NULL; -static int no_hyphenation; -static int no_justification; -static int subpages = 1; +static bool no_hyphenation; +static bool no_justification; +static bool subpages = true; -static int ascii; /* insert tr in the output pipe */ -static int save_cat; /* security breach? Can we save the cat? */ +static bool ascii; /* insert tr in the output pipe */ +static bool save_cat; /* security breach? Can we save the cat? */ static int first_arg; @@ -238,9 +238,9 @@ static struct timespec man_modtime; /* modtime of man page, for * commit_tmp_cat() */ # ifdef TROFF_IS_GROFF -static int ditroff; +static bool ditroff; static const char *gxditview; -static int htmlout; +static bool htmlout; static const char *html_pager; # endif /* TROFF_IS_GROFF */ @@ -342,7 +342,7 @@ static void init_html_pager (void) static error_t parse_opt (int key, char *arg, struct argp_state *state) { - static int apropos, whatis; /* retain values between calls */ + static bool apropos, whatis; /* retain values between calls */ /* Please keep these keys in the same order as in options above. */ switch (key) { @@ -350,7 +350,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) user_config_file = arg; return 0; case 'd': - debug_level = 1; + debug_level = true; return 0; case 'D': /* discard all preset options */ @@ -359,11 +359,11 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) print_where = print_where_cat = ascii = match_case = regex_opt = wildcard = names_only = - no_hyphenation = no_justification = 0; + no_hyphenation = no_justification = false; #ifdef TROFF_IS_GROFF - ditroff = 0; + ditroff = false; gxditview = NULL; - htmlout = 0; + htmlout = false; init_html_pager (); #endif roff_device = want_encoding = extension = pager = @@ -391,26 +391,26 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) case 'f': external = WHATIS; - whatis = 1; + whatis = true; return 0; case 'k': external = APROPOS; - apropos = 1; + apropos = true; return 0; case 'K': - global_apropos = 1; + global_apropos = true; return 0; case 'w': - print_where = 1; + print_where = true; return 0; case 'W': - print_where_cat = 1; + print_where_cat = true; return 0; case 'l': - local_man_file = 1; + local_man_file = true; return 0; case 'c': - catman = 1; + catman = true; return 0; case 'R': recode = arg; @@ -435,30 +435,30 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) extension = arg; return 0; case 'i': - match_case = 0; + match_case = false; return 0; case 'I': - match_case = 1; + match_case = true; return 0; case OPT_REGEX: - regex_opt = 1; - findall = 1; + regex_opt = true; + findall = true; return 0; case OPT_WILDCARD: - wildcard = 1; - findall = 1; + wildcard = true; + findall = true; return 0; case OPT_NAMES: - names_only = 1; + names_only = true; return 0; case 'a': - findall = 1; + findall = true; return 0; case 'u': - update = 1; + update = true; return 0; case OPT_NO_SUBPAGES: - subpages = 0; + subpages = false; return 0; case 'P': @@ -468,7 +468,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) prompt_string = arg; return 0; case '7': - ascii = 1; + ascii = true; return 0; case 'E': want_encoding = arg; @@ -476,17 +476,17 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) roff_device = want_encoding; return 0; case OPT_NO_HYPHENATION: - no_hyphenation = 1; + no_hyphenation = true; return 0; case OPT_NO_JUSTIFICATION: - no_justification = 1; + no_justification = true; return 0; case 'p': preprocessors = arg; return 0; #ifdef HAS_TROFF case 't': - troff = 1; + troff = true; return 0; case 'T': /* Traditional nroff knows -T; troff does not (gets @@ -494,27 +494,27 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) * does -T imply -t? */ roff_device = (arg ? arg : "ps"); - troff = 1; + troff = true; return 0; case 'H': # ifdef TROFF_IS_GROFF if (arg) html_pager = arg; - htmlout = 1; - troff = 1; + htmlout = true; + troff = true; roff_device = "html"; # endif /* TROFF_IS_GROFF */ return 0; case 'X': # ifdef TROFF_IS_GROFF - troff = 1; + troff = true; gxditview = (arg ? arg : "75"); # endif /* TROFF_IS_GROFF */ return 0; case 'Z': # ifdef TROFF_IS_GROFF - ditroff = 1; - troff = 1; + ditroff = true; + troff = true; # endif /* TROFF_IS_GROFF */ return 0; #endif /* HAS_TROFF */ @@ -525,8 +525,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) break; case ARGP_KEY_SUCCESS: /* check for incompatible options */ - if (troff + whatis + apropos + catman + - (print_where || print_where_cat) > 1) { + if ((int) troff + (int) whatis + (int) apropos + + (int) catman + + (int) (print_where || print_where_cat) > 1) { char *badopts = xasprintf ("%s%s%s%s%s%s", troff ? "-[tTZH] " : "", @@ -539,7 +540,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) _("%s: incompatible options"), badopts); } - if (regex_opt + wildcard > 1) { + if ((int) regex_opt + (int) wildcard > 1) { char *badopts = xasprintf ("%s%s", regex_opt ? "--regex " : "", @@ -660,7 +661,7 @@ static void heirloom_line_length (void *data) } #endif /* HEIRLOOM_NROFF */ -static pipecmd *add_roff_line_length (pipecmd *cmd, int *save_cat_p) +static pipecmd *add_roff_line_length (pipecmd *cmd, bool *save_cat_p) { int length; pipecmd *ret = NULL; @@ -677,7 +678,7 @@ static pipecmd *add_roff_line_length (pipecmd *cmd, int *save_cat_p) debug ("Terminal width %d not within cat page range " "[%d, %d]\n", line_length, min_cat_width, max_cat_width); - *save_cat_p = 0; + *save_cat_p = false; } } @@ -1011,27 +1012,27 @@ static char *get_preprocessors (pipeline *decomp, const char *dbfilters, if (dbfilters && (dbfilters[0] != '-') && !preprocessors) { pp_string = xstrdup (dbfilters); pp_source = "database"; - save_cat = 1; + save_cat = true; } else if (preprocessors) { pp_string = xstrdup (preprocessors); pp_source = "command line"; - save_cat = 0; + save_cat = false; } else if ((pp_string = get_preprocessors_from_file (decomp, prefixes))) { pp_source = "file"; - save_cat = 1; + save_cat = true; } else if ((env = getenv ("MANROFFSEQ"))) { pp_string = xstrdup (env); pp_source = "environment"; - save_cat = 0; + save_cat = false; } else if (!dbfilters) { pp_string = xstrdup (DEFAULT_MANROFFSEQ); pp_source = "default"; - save_cat = 1; + save_cat = true; } else { pp_string = xstrdup (""); pp_source = "no filters"; - save_cat = 1; + save_cat = true; } debug ("pre-processors `%s' from %s\n", pp_string, pp_source); @@ -1303,7 +1304,7 @@ static pipeline *make_roff_command (const char *dir, const char *file, if (troff) { cmd = pipecmd_new_argstr (get_def ("troff", TROFF)); - save_cat = 0; + save_cat = false; } else cmd = pipecmd_new_argstr (get_def ("nroff", NROFF)); @@ -1422,7 +1423,7 @@ static pipeline *make_browser (const char *pattern, const char *file) pipeline *p; pipecmd *cmd; char *browser = xmalloc (1); - int found_percent_s = 0; + bool found_percent_s = false; char *percent; char *esc_file; @@ -1446,7 +1447,7 @@ static pipeline *make_browser (const char *pattern, const char *file) browser = appendstr (browser, esc_file, (void *) 0); free (esc_file); - found_percent_s = 1; + found_percent_s = true; break; default: len = strlen (browser); /* cannot be NULL */ @@ -2148,7 +2149,7 @@ static int display (const char *dir, const char *man_file, int prefixes = 0; pipeline *format_cmd; /* command to format man_file to stdout */ char *formatted_encoding = NULL; - int display_to_stdout; + bool display_to_stdout; pipeline *decomp = NULL; int decomp_errno = 0; @@ -2252,10 +2253,10 @@ static int display (const char *dir, const char *man_file, display_to_stdout = troff; #ifdef TROFF_IS_GROFF if (htmlout) - display_to_stdout = 0; + display_to_stdout = false; #endif if (recode) - display_to_stdout = 1; + display_to_stdout = true; if (display_to_stdout) { /* If we're reading stdin via '-l -', man_file is "". See @@ -2311,7 +2312,7 @@ static int display (const char *dir, const char *man_file, || local_man_file || recode || disable_cache) - save_cat = 0; + save_cat = false; if (!man_file) { /* Stray cat. */ @@ -2319,7 +2320,7 @@ static int display (const char *dir, const char *man_file, format = 0; } else if (!cat_file) { assert (man_file); - save_cat = 0; + save_cat = false; format = 1; } else if (format && save_cat) { char *cat_dir; @@ -2363,7 +2364,7 @@ static int display (const char *dir, const char *man_file, (format ? man_file : cat_file, R_OK); debug ("format: %d, save_cat: %d, found: %d\n", - format, save_cat, found); + format, (int) save_cat, found); if (!found) { pipeline_free (format_cmd); @@ -3381,7 +3382,7 @@ static int try_db (const char *manpath, const char *sec, const char *name, char *catpath; int found = 0; #ifdef MAN_DB_UPDATES - int found_stale = 0; + bool found_stale = false; #endif /* MAN_DB_UPDATES */ /* find out where our db for this manpath should be */ @@ -3452,7 +3453,7 @@ static int try_db (const char *manpath, const char *sec, const char *name, (!extension || STREQ (extension, loc->ext) || STREQ (extension, loc->ext + strlen (sec)))) if (maybe_update_file (manpath, name, loc)) - found_stale = 1; + found_stale = true; GL_LIST_FOREACH_END (matches); if (found_stale) { @@ -3713,10 +3714,10 @@ static int man (const char *name, int *found); static int local_man_loop (const char *argv) { int exit_status = OK; - int local_mf = local_man_file; + bool local_mf = local_man_file; drop_effective_privs (); - local_man_file = 1; + local_man_file = true; if (strcmp (argv, "-") == 0) display (NULL, "", NULL, "(stdin)", NULL); else { @@ -4233,14 +4234,14 @@ int main (int argc, char *argv[]) if (global_apropos) status = do_global_apropos (nextarg, &found); else { - int found_subpage = 0; + bool found_subpage = false; if (subpages && first_arg < argc) { char *subname = xasprintf ( "%s-%s", nextarg, argv[first_arg]); status = man (subname, &found); free (subname); if (status == OK) { - found_subpage = 1; + found_subpage = true; ++first_arg; } } @@ -4250,7 +4251,7 @@ int main (int argc, char *argv[]) status = man (subname, &found); free (subname); if (status == OK) { - found_subpage = 1; + found_subpage = true; ++first_arg; } } @@ -4269,7 +4270,7 @@ int main (int argc, char *argv[]) /* Maybe the section wasn't a section after * all? e.g. 'man 9wm fvwm'. */ - int found_subpage = 0; + bool found_subpage = false; debug ("\nRetrying section %s as name\n", section); tmp = section; @@ -4280,7 +4281,7 @@ int main (int argc, char *argv[]) status = man (subname, &found); free (subname); if (status == OK) { - found_subpage = 1; + found_subpage = true; ++first_arg; } } diff --git a/src/manconv_main.c b/src/manconv_main.c index 39cf638c..949c6b6f 100644 --- a/src/manconv_main.c +++ b/src/manconv_main.c @@ -24,6 +24,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -111,7 +112,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) (void *) 0); return 0; case 'd': - debug_level = 1; + debug_level = true; return 0; case 'q': quiet = 1; diff --git a/src/mandb.c b/src/mandb.c index cad77edb..0a06c714 100644 --- a/src/mandb.c +++ b/src/mandb.c @@ -79,11 +79,11 @@ #include "manp.h" int quiet = 1; -extern int opt_test; /* don't update db */ +extern bool opt_test; /* don't update db */ char *manp; char *database = NULL; extern char *extension; /* for globbing.c */ -extern int force_rescan; /* for check_mandirs.c */ +extern bool force_rescan; /* for check_mandirs.c */ static char *single_filename = NULL; extern char *user_config_file; /* for manp.c */ #ifdef MAN_OWNER @@ -94,10 +94,10 @@ man_sandbox *sandbox; static int purged = 0; static int strays = 0; -static int check_for_strays = 1; -static int purge = 1; -static int user; -static int create; +static bool check_for_strays = true; +static bool purge = true; +static bool user; +static bool create; static const char *arg_manp; struct tried_catdirs_entry { @@ -131,32 +131,32 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'q': ++quiet_temp; return 0; case 's': - check_for_strays = 0; + check_for_strays = false; return 0; case 'p': - purge = 0; + purge = false; return 0; case 'u': - user = 1; + user = true; return 0; case 'c': - create = 1; - purge = 0; + create = true; + purge = false; return 0; case 't': - opt_test = 1; + opt_test = true; return 0; case 'f': single_filename = arg; - create = 0; - purge = 0; - check_for_strays = 0; + create = false; + purge = false; + check_for_strays = false; return 0; case 'C': user_config_file = arg; @@ -595,7 +595,7 @@ static int process_manpath (const char *manpath, bool global_manpath, } else run_mandb = 1; - force_rescan = 0; + force_rescan = false; if (purge) { database = mkdbname (catpath); purged += purge_missing (manpath, catpath, run_mandb); @@ -826,7 +826,7 @@ int main (int argc, char *argv[]) #ifdef MAN_OWNER man_owner = get_man_owner (); if (!user && euid != 0 && euid != man_owner->pw_uid) - user = 1; + user = true; #endif /* MAN_OWNER */ read_config_file (user); @@ -100,7 +100,7 @@ struct config_item { static gl_list_t config; char *user_config_file = NULL; -int disable_cache; +bool disable_cache; int min_cat_width = 80, max_cat_width = 80, cat_width = 0; static void add_man_subdirs (gl_list_t list, const char *p); @@ -714,7 +714,7 @@ char *get_manpath (const char *systems) char *manpathlist; /* need to read config file even if MANPATH set, for mandb(8) */ - read_config_file (0); + read_config_file (false); manpathlist = getenv ("MANPATH"); if (manpathlist && *manpathlist) { @@ -795,7 +795,7 @@ static void add_to_dirlist (FILE *config_file, int user) if (*bp == '#' || *bp == '\0') goto next; else if (strncmp (bp, "NOCACHE", 7) == 0) - disable_cache = 1; + disable_cache = true; else if (strncmp (bp, "NO", 2) == 0) goto next; /* match any word starting with NO */ else if (sscanf (bp, "MANBIN %*s") == 1) @@ -840,7 +840,7 @@ static void free_config_file (void *unused ATTRIBUTE_UNUSED) gl_list_free (config); } -void read_config_file (int optional) +void read_config_file (bool optional) { static int done = 0; char *dotmanpath = NULL; @@ -45,7 +45,7 @@ extern void free_pathlist (gl_list_t list); extern char *get_mandb_manpath (void); extern char *get_catpath (const char *name, int cattype); extern bool is_global_mandir (const char *dir); -extern void read_config_file (int optional); +extern void read_config_file (bool optional); extern const char *get_def (const char *thing, const char *def); extern const char *get_def_user (const char *thing, const char *def); extern gl_list_t get_sections (void); diff --git a/src/manpath.c b/src/manpath.c index de3a2948..97e27376 100644 --- a/src/manpath.c +++ b/src/manpath.c @@ -27,6 +27,7 @@ #include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -51,8 +52,8 @@ int quiet = 0; man_sandbox *sandbox; /* unused, but needed by libman */ -static int cat = 0; -static int global = 0; +static bool cat = false; +static bool global = false; static const char *alt_system = ""; extern char *user_config_file; @@ -75,14 +76,14 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'c': - cat = 1; + cat = true; return 0; case 'g': - global = 1; + global = true; quiet = 1; return 0; case 'd': - debug_level = 1; + debug_level = true; return 0; case 'q': quiet = 1; diff --git a/src/straycats.c b/src/straycats.c index 6a2f7171..56352c8d 100644 --- a/src/straycats.c +++ b/src/straycats.c @@ -194,7 +194,7 @@ static int check_for_stray (MYDBM_FILE dbf) further */ mandir_base = base_name (mandir); exists = dblookup_exact (dbf, mandir_base, info.ext, - 1); + true); if (exists && compare_ids (STRAY_CAT, exists->id, 0) >= 0) goto next_exists; diff --git a/src/whatis.c b/src/whatis.c index e137ce61..1d529245 100644 --- a/src/whatis.c +++ b/src/whatis.c @@ -89,7 +89,7 @@ extern char *user_config_file; static char **keywords; static int num_keywords; -int am_apropos; +bool am_apropos; char *database; int quiet = 1; man_sandbox *sandbox; @@ -99,14 +99,14 @@ iconv_t conv_to_locale; #endif /* HAVE_ICONV */ static regex_t *preg; -static int regex_opt; -static int exact; +static bool regex_opt; +static bool exact; -static int wildcard; +static bool wildcard; -static int require_all; +static bool require_all; -static int long_output; +static bool long_output; static char **sections; @@ -171,33 +171,33 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'v': quiet = 0; return 0; case 'r': - regex_opt = 1; + regex_opt = true; return 0; case 'e': /* Only makes sense for apropos, but has * historically been accepted by whatis anyway. */ - regex_opt = 0; - exact = 1; + regex_opt = false; + exact = true; return 0; case 'w': - regex_opt = 0; - wildcard = 1; + regex_opt = false; + wildcard = true; return 0; case 'a': if (am_apropos) - require_all = 1; + require_all = true; else argp_usage (state); return 0; case 'l': - long_output = 1; + long_output = true; return 0; case 's': sections = split_sections (arg); @@ -216,11 +216,11 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) return 0; case 'f': /* helpful override if program name detection fails */ - am_apropos = 0; + am_apropos = false; return 0; case 'k': /* helpful override if program name detection fails */ - am_apropos = 1; + am_apropos = true; return 0; case 'h': argp_state_help (state, state->out_stream, @@ -237,7 +237,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) exit (FAIL); case ARGP_KEY_SUCCESS: if (am_apropos && !exact && !wildcard) - regex_opt = 1; + regex_opt = true; return 0; } return ARGP_ERR_UNKNOWN; @@ -391,7 +391,7 @@ static struct mandata *resolve_pointers (MYDBM_FILE dbf, struct mandata *info, * arbitrary: it's just there to avoid an infinite loop. */ newpage = info->pointer; - info = dblookup_exact (dbf, newpage, info->ext, 1); + info = dblookup_exact (dbf, newpage, info->ext, true); for (rounds = 0; rounds < 10; rounds++) { struct mandata *newinfo; @@ -404,7 +404,7 @@ static struct mandata *resolve_pointers (MYDBM_FILE dbf, struct mandata *info, STREQ (info->pointer, newpage))) return info; - newinfo = dblookup_exact (dbf, info->pointer, info->ext, 1); + newinfo = dblookup_exact (dbf, info->pointer, info->ext, true); free_mandata_struct (info); info = newinfo; } @@ -507,7 +507,7 @@ static int do_whatis_section (MYDBM_FILE dbf, struct mandata *info; int count = 0; - infos = dblookup_all (dbf, page, section, 0); + infos = dblookup_all (dbf, page, section, false); GL_LIST_FOREACH_START (infos, info) { display (dbf, info, page); count++; @@ -900,11 +900,11 @@ int main (int argc, char *argv[]) set_program_name (argv[0]); program_base_name = base_name (program_name); if (STREQ (program_base_name, APROPOS_NAME)) { - am_apropos = 1; + am_apropos = true; argp_program_version = "apropos " PACKAGE_VERSION; } else { struct argp_option *optionp; - am_apropos = 0; + am_apropos = false; argp_program_version = "whatis " PACKAGE_VERSION; for (optionp = (struct argp_option *) whatis_argp.options; optionp->name || optionp->key || optionp->arg || diff --git a/src/zsoelim_main.c b/src/zsoelim_main.c index 2dd59391..da0b0fa0 100644 --- a/src/zsoelim_main.c +++ b/src/zsoelim_main.c @@ -27,6 +27,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <stdlib.h> #include "argp.h" @@ -76,7 +77,7 @@ static error_t parse_opt (int key, char *arg ATTRIBUTE_UNUSED, { switch (key) { case 'd': - debug_level = 1; + debug_level = true; return 0; case 'C': return 0; /* compatibility with GNU soelim */ |