diff options
author | Colin Watson <cjwatson@debian.org> | 2019-01-26 14:49:46 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2019-01-26 14:49:46 +0000 |
commit | 449ac91e70ad7ff7583eaab5b000de3563148f45 (patch) | |
tree | c96cbc907afa13c26f65f9cd45c049b62b7dd453 /lib/encodings.c | |
parent | 2beae0a82b4a70ddc565960840ebe53142c8746b (diff) |
Use bool type where appropriate
Now that we're using <stdbool.h> anyway due to gl_list (with Gnulib
providing <stdbool.h> if necessary), it makes sense to use it for our
own functions that have essentially boolean semantics.
* lib/encodings.c (compatible_encodings, is_roff_device): Return bool.
* lib/pathsearch.c (pathsearch, pathsearch_executable,
directory_on_path): Likewise.
* lib/sandbox.c (search_ld_preload, can_load_seccomp): Likewise.
* lib/security.c (running_setuid): Likewise.
* lib/wordfnmatch.c (word_fnmatch): Likewise. Update all callers.
* src/check_mandirs.c (sanity_check_db): Likewise.
* src/man.c (duplicate_candidates): Likewise.
* src/manp.c (is_global_mandir): Likewise. Update all callers.
* src/whatis.c (suitable_manpath, match): Likewise.
(any_set, all_set): Likewise. Update all callers.
* lib/encodings.h (is_roff_device): Update prototype.
* lib/pathsearch.h (pathsearch_executable, directory_on_path): Likewise.
* lib/security.h (running_setuid): Likewise.
* lib/wordfnmatch.h (word_fnmatch): Likewise.
* src/manp.h (is_global_mandir): Likewise.
* src/mandb.c (mandb, process_manpath): Change global_manpath parameter
type to bool.
Diffstat (limited to 'lib/encodings.c')
-rw-r--r-- | lib/encodings.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/encodings.c b/lib/encodings.c index ec8fb6bc..c033543f 100644 --- a/lib/encodings.c +++ b/lib/encodings.c @@ -25,6 +25,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include <stdbool.h> #include <string.h> #include <stdlib.h> #include <unistd.h> @@ -640,27 +641,27 @@ out: /* Can we take this input encoding and produce this output encoding, perhaps * with the help of some iconv pipes? */ -static int compatible_encodings (const char *input, const char *output) +static bool compatible_encodings (const char *input, const char *output) { if (STREQ (input, output)) - return 1; + return true; /* If the input is ASCII, recoding should be easy. Try it. */ if (STREQ (input, "ANSI_X3.4-1968")) - return 1; + return true; /* If the input is UTF-8, it's either a simple recoding of whatever * we want or else it probably won't work at all no matter what we * do. We might as well try it for now. */ if (STREQ (input, "UTF-8")) - return 1; + return true; /* If the output is ASCII, this is probably because the caller * explicitly asked for it, so we have little choice but to try. */ if (STREQ (output, "ANSI_X3.4-1968")) - return 1; + return true; #ifdef MULTIBYTE_GROFF /* Special case for some CJK UTF-8 locales, which take UTF-8 input @@ -673,10 +674,10 @@ static int compatible_encodings (const char *input, const char *output) STREQ (input, "EUC-KR") || STREQ (input, "EUC-TW")) && STREQ (output, "UTF-8")) - return 1; + return true; #endif /* MULTIBYTE_GROFF */ - return 0; + return false; } /* Return the default groff device for the given character set. This may be @@ -723,16 +724,16 @@ const char *get_default_device (const char *charset_from_locale, } /* Is this a known *roff device name? */ -int is_roff_device (const char *device) +bool is_roff_device (const char *device) { const struct device_entry *entry; for (entry = device_table; entry->roff_device; ++entry) { if (STREQ (entry->roff_device, device)) - return 1; + return true; } - return 0; + return false; } /* Find the input encoding expected by groff, and set the LESSCHARSET |