summaryrefslogtreecommitdiff
path: root/src/manp.h
Commit message (Collapse)AuthorAge
* Use bool for boolean command-line optionsColin Watson2019-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/manconfig.h.in (debug_level): Change type to bool. Update all definitions and users. * lib/encodings.c (get_roff_encoding): Change type of "found" to bool. * libdb/db_lookup.c (dblookup_all, dblookup_exact): Change "match_case" parameter type to bool. Update all callers. (dblookup_pattern): Change "match_case", "pattern_regex", and "try_descriptions" parameter types to bool. Update all callers. * libdb/db_storage.h (dblookup_all, dblookup_exact, dblookup_pattern): Update prototypes. * src/descriptions_store.c (store_descriptions): Change types of "found_real_page" and "found_external" to bool. * src/lexgrog_test.c (main): Change types of "some_failed" and "found" to bool. * src/man.c (parse_opt): Change types of "apropos" and "whatis" to bool. (add_roff_line_length): Change "save_cat_p" parameter type to bool *. Update all callers. (make_browser): Change "found_percent_s" type to bool. (display): Change "display_to_stdout" type to bool. (try_db): Change "found_stale" type to bool. (local_man_loop): Change "local_mf" type to bool. (main): Change "found_subpage" type to bool. * src/manp.c (read_config_file): Change "optional" parameter type to bool. Update all callers. * src/manp.h (read_config_file): Update prototype. * src/check_mandirs.c (opt_test, force_rescan): Change types to bool. Update all users. * src/globbing_test.c (match_case, regex_opt, wildcard): Likewise. * src/lexgrog_test.c (parse_man, parse_cat, show_whatis, show_filters): Likewise. * src/man.c (disable_cache, troff, global_apropos, print_where, print_where_cat, catman, local_man_file, findall, update, match_case, regex_opt, wildcard, names_only, no_hyphenation, no_justification, subpages, ascii, save_cat, ditroff, htmlout): Likewise. * src/mandb.c (opt_test, force_rescan, check_for_strays, purge, user, create): Likewise. * src/manp.c (disable_cache): Likewise. * src/manpath.c (cat, global): Likewise. * src/whatis.c (am_apropos, regex_opt, exact, wildcard, require_all, long_output): Likewise.
* Port get_sections to gl_listColin Watson2019-01-30
| | | | | | | | | | * src/manp.c (get_sections): Convert to gl_list. * src/manp.h (get_sections): Update prototype. * src/man.c (is_section, compare_candidates, do_global_apropos, man, get_section_list): Convert to gl_list. (compare_candidates): Sort sections missing from section_list to the end. (main): Free section_list.
* Use bool type where appropriateColin Watson2019-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove arbitrary limit on manpath sizeColin Watson2019-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes Savannah bug #50324. * bootstrap.conf (gnulib_modules): Add hash-pjw-bare, linkedhash-list, stdbool, and xlist. * include/manconfig.h.in (MAXDIRS): Remove. * src/manp.c (tmplist): Remove. (string_equals, string_hash, string_free): New functions. (gripe_overlong_list): Remove. (insert_override_dir, get_manpath_from_path, add_expanded_dir_to_list, add_dir_to_list, add_man_subdirs, add_dir_to_path_list, create_pathlist, free_pathlist): Port manpath list handling to gl_list_t. * src/catman.c (main): Likewise. * src/man.c (do_global_apropos, local_man_loop, locate_page_in_manpath, main): Likewise. * src/mandb.c (main): Likewise. * src/whatis.c (suitable_manpath, search, main): Likewise. * src/zsoelim.l (<<EOF>>, zsoelim_parse_file, zsoelim_open_file, zsoelim_stdin, zsoelim_stdin_data_new): Likewise. * src/zsoelim_main.c (main): Likewise. * src/manp.h (create_pathlist, free_pathlist): Update prototypes. * src/zsoelim.h (zsoelim_open_file, zsoelim_parse_file, zsoelim_stdin_data_new): Likewise. * NEWS: Document this.
* Reduce number of MAN_OWNER ifdefsColin Watson2018-02-07
| | | | | | | | | | | | | | | | | * lib/security.c (init_security, running_setuid): Define unconditionally, with stub behaviour if MAN_OWNER is undefined. * lib/security.h (get_man_owner): Only declare prototype if MAN_OWNER is defined. * src/check_mandirs.c (chown_if_possible) [!MAN_OWNER]: Mark path argument as unused. * src/lexgrog_test.c (main): Call init_security unconditionally. * src/man.c (main): Likewise. * src/manconv_client.c (manconv_pre_exec): Define unconditionally. (add_manconv): Simplify, since running_setuid is now always defined. * src/mandb.c (main): Call init_security unconditionally. Use get_man_owner rather than equivalent inline code. * src/manp.c (get_def): Define unconditionally. * src/manp.h (get_def): Drop macro alternative.
* Rename SECURE_MAN_UID to MAN_OWNERColin Watson2016-12-13
| | | | | | | | | | The latter had always been defined to the former anyway, and now that the cache owner can be changed without actually installing setuid the latter is more descriptive. * m4/man-arg-cache-owner.m4: Define MAN_OWNER rather than SECURE_MAN_UID. Update all users. * include/manconfig.h.in (MAN_OWNER): Remove definition.
* * src/manp.c (add_nls_manpaths): Duplicate manpathlist in the caseColin Watson2013-06-27
| | | | | | | where locales is NULL or empty, allowing the manpathlist parameter to be made const. * src/manp.h (add_nls_manpaths): Update prototype. * src/man.c (locale_manpath): Make manpath parameter const. * src/whatis.c (locale_manpath): Likewise.
* Improve .so searching (Debian bug #503472).Colin Watson2010-12-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/Makefile.am (zsoelim_SOURCES): Add manp.c and manp.h. * src/zsoelim.l (zsoelim_parse_file): Take manpathlist and parent_path arguments, and save those to pass on to zsoelim_open_file. (try_compressed): New function, split out from zsoelim_open_file. (zsoelim_open_file): Take manpathlist and parent_path arguments. Rearrange search logic as follows: (1) if there is no parent_path, try opening directly; (2) look up filename within each manpath entry, treating filenames without directory parts as full manual page lookups; (3) if there is a parent_path, try opening directly. (zsoelim_stdin): Pass path and manpathlist from input data to zsoelim_open_file and zsoelim_parse_file. (zsoelim_stdin_data_new, zsoelim_stdin_data_free): New functions. * src/zsoelim.h (zsoelim_open_file, zsoelim_parse_file): Update prototypes. (zsoelim_stdin_data_new, zsoelim_stdin_data_free): Add prototypes. * src/zsoelim_main.c (main): Initialise locale and manpath. Pass manpath to zsoelim_open_file and zsoelim_parse_file. * src/man.c (main): Calculate manpath before handling -l option. (make_roff_command): Pass dir and manpathlist to zsoelim_stdin. * src/tests/zsoelim-1: New test. * src/tests/Makefile.am (ALL_TESTS): Add zsoelim-1. * NEWS: Document this. * src/manp.c (get_def): If not setuid, make this identical to get_def_user. * src/manp.h (get_def): Likewise.
* * src/manp.c (mkcatdirs): Move to ...Colin Watson2010-09-26
| | | | | | | * src/check_mandirs.c (mkcatdirs): ... here, as it's only used by testmandirs. Removes dependency of manp.c on security.h. * src/manp.h (mkcatdirs): Remove prototype. * src/Makefile.am (catman_SOURCES, manpath_SOURCES, whatis_SOURCES): Remove fake_security.c.
* Do what the user probably means when the full path to an executableColin Watson2009-11-14
| | | | | | | | | | | | | | | | is given as an argument (Debian bug #505465). * lib/pathsearch.c (directory_on_path): New function. * lib/pathsearch.h (directory_on_path): Add prototype. * src/manp.c (get_manpath_from_path): Make external. Add 'mandatory' argument to control the addition of MANDATORY_MANPATH entries. (guess_manpath): Update caller. * src/manp.h (get_manpath_from_path): Add prototype. * src/man.c (main): Move locale manpath expansion to ... (locale_manpath): ... here (new function). (local_man_loop): If the argument is an executable, try looking up the corresponding manual page in the appropriate part of the manpath, rather than just trying to format the text of the executable as a manual page. * NEWS: Document this.
* Don't create unnecessary database directories (Debian bug #472919).Colin Watson2009-06-28
| | | | | | | | | | | | | | | | | | | | * src/check_mandirs.c (testmandirs): Add catpath and create arguments. Create the database when it first seems to be needed. Use mkcatdirs rather than make_database_directory. (make_database_directory): Remove. (create_db): Add catpath argument. Don't create the database here; let testmandirs do it when needed instead. (update_db): Add catpath argument. Don't create the database directory; either it exists already in which case there's nothing to do, or it's missing in which case there'll be no database to update anyway. * src/check_mandirs.h (create_db, update_db): Update prototypes. * src/mandb.c (update_db_wrapper): Add catpath argument. (mandb): Update calls to functions that now take the catpath too. * src/manp.c (add_mandb_map): Don't create the cat hierarchy here; testmandirs will do it on demand. (mkcatdirs): Make external for use by check_mandirs.c. * src/manp.h (mkcatdirs): Add prototype. * docs/NEWS: Document this.
* * man/Makefile.am (EXTRA_DIST): Distribute check-man.Colin Watson2009-03-14
| | | | | | | | | | | | * src/manp.c (read_config_file): Add argument to control whether the main configuration file is optional. Use a static variable to track whether we'\''ve been called already. (get_manpath): read_config_file will keep track of whether it'\''s been called already for itself. Pass new argument. * src/manp.h (read_config_file): Update prototype. * src/man.c (main): Treat the main configuration file as optional if -l was given, since in that case we can get by well enough without it. This makes it easier to run '\''make check'\'' without first running '\''make install'\''.
* Partially rewrite building of manpath according to locale. TheColin Watson2009-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | previous code was completely wrong: as well as handling duplicates rather oddly, it effectively handled LANGUAGE in reverse order (Debian bug #516133). * src/manp.c (add_nls_manpath): Rename to ... (get_nls_manpath): ... this. Some minor adjustments. Make manpathlist argument const and always return a freshly-allocated string. Explicitly add the top-level directory to the string in the case of English locales (although we still look for subdirectories in case of things like en_GB.UTF-8); C and POSIX already just return a copy of manpathlist. (add_nls_manpaths): New function to iterate over a colon-separated list of locales, concatenating the result of get_nls_manpath for each. Stop worrying about deduplication at this point as we used to; instead, we let create_pathlist sort that out. (create_pathlist): Keep the first of any set of duplicates rather than the last, in order to keep item order stable. * src/manp.h (add_nls_manpath): Remove prototype. (add_nls_manpaths): Add prototype. * src/man.c (main), src/whatis.c (main): Call add_nls_manpaths rather than add_nls_manpath, with appropriate adjustments. * src/man.c (main), src/whatis.c (main): Don'\''t set internal_locale to the first component of multiple_locale. We will account for this in search paths, but shouldn'\''t forget about internal_locale entirely.
* Back out the last two non-merge revisions on this branch. Instead:Colin Watson2007-09-02
| | | | | | | | | | | | | | | | | | | | | | | | * src/man.c (duplicate_candidates): New function to determine whether candidates are substantially duplicated, and if so in which direction. The logic is better than before: it now knows how to compare locales and pick the best available candidate for each language, and prefers UTF-8 candidates if everything else is equal. (add_candidate): Move duplication logic to duplicate_candidates. Adjust insertion handling so that we can drop old candidates in favour of new candidates. * src/manp.c (check_and_give): Remove. (unpack_locale_bits): New function, inspired by _nl_explode_name in libintl. (free_locale_bits): New function. (add_nls_manpath): Instead of trying individual directories (which doesn't work so well with character set aliasing), iterate over all subdirectories of each manpath entry and add all those matching the current locale's language and (if specified) territory. This now includes ll.CODESET as well as more conventional locale names. * src/manp.h: Declare 'struct locale_bits'. Prototype unpack_locale_bits and free_locale_bits.
* Eliminate variable and function shadowing.Colin Watson2007-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (CFLAGS): Add -Wshadow if the compiler is GCC. * src/manp.c: Don't declare manpathlist here, as it's never used in this file. * src/catman.c, src/man.c, src/mandb.c, src/whatis.c: Declare it here instead. * lib/pipeline.c (pipeline_start): Remove duplicate declarations of set and oset. * libdb/db_ver.c (dbver): Merge into ... (dbver_rd): ... this, eliminating a global variable. (dbver_rd, dbver_wr): Rename dbf to dbfile. * src/accessdb.c (main): Don't redeclare dbf locally. * src/check_mandirs.c (gripe_rwopen_failed): Use global database rather than passing it as an argument. Update all callers. * src/man.c (gripe_no_name): Rename section to sect. (add_roff_line_length): Rename save_cat to save_cat_p. (make_roff_command): Declare cmd only once. (make_browser): Rename command to pattern. (display): Rename pause to prompt. * src/manp.c (get_manpath): Rename to ... (get_manpath_from_path): ... this. Update all callers. (manpath): Rename to ... (get_manpath): ... this. Update all callers. (add_system_manpath): Rename system to one_system. * src/manp.h (manpath): Rename to ... (get_manpath): ... this. * src/ult_src.c (ult_hardlink): Rename link to base. (ult_src): Rename basename to base. * src/whatis.c (apropos): Rename match to got_match. (search): Return found rather than setting the global variable status based on it. (main): Use search's return value, eliminating a global variable. * src/zsoelim.l (usage): Rename status to exit_status. (open_file): Rename decompress to decomp.
* Fix a slew of memory leaks, including a nasty per-search leak inColin Watson2007-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | apropos (Debian bug #368749). * include/manconfig.h.in (ATTRIBUTE_UNUSED): Define to an attribute marking a variable as unused if using GCC 2.4 or newer. * lib/error.c (error): Free program_name before exiting. * src/accessdb.c (main): Put program_name in allocated memory. * src/wrapper.c (main): Likewise. * src/Makefile.in: Link wrapper against libman. * libdb/db_gdbm.c (man_gdbm_firstkey): Register cleanup function to free parent_sortkey_hash on exit. * src/globbing.c (update_directory_cache): Register cleanup function to free dirent_hash on exit. (look_for_file): Register cleanup function to free gbuf on exit. Move freeing of gbuf before each search to ... (match_in_directory): ... here. * src/manp.c (free_config_file): New function. (read_config_file): Register cleanup function to free configuration file structures on exit. * lib/cleanup.c (do_cleanups): Free the stack after processing it. * lib/hashtable.c (hash_free): Free ht->hashtab as well. * libdb/db_lookup.c (free_mandata_elements): Add TODO comment about strange memory handling. * src/catman.c (parse_for_sec): Free entry. (main): Free various variables before exiting. * src/check_mandirs.c (count_glob_matches): Free info.name. (purge_missing): Free entry rather than just content.dptr (== entry.addr). * src/globbing.c (parse_layout): Free upper_layout. (match_in_directory): Free pattern_start.pattern in early return case. * src/man.c (main): Free various variables before exiting. * src/mandb.c (finish_up, cleanup, mandb, main): Free various database file names properly. (main): Remember to assign the result of getcwd_allocated somewhere. Free various variables before exiting. * src/manp.c (add_sections): Free section_list; comment was incorrect. (add_nls_manpath): Free temp_locale. (guess_manpath): Constify path. Free result of get_manpath before returning. (get_manpath): Constify path. Free tmplist elements. (create_pathlist): Free result of xstrndup. (free_pathlist): New function. * src/manp.h (free_pathlist): Add prototype. * src/util.c (mkdbname): Don't allocate mkdbname statically; it's less confusing just to free it each time. * src/whatis.c (apropos): Initialise and free info. (search): Free database. (main): Free regular expression after each search. Free various variables before exiting.
* * docs/COPYING, docs/COPYING.LIB: Update from www.gnu.org to pick upColin Watson2005-07-31
| | | | | | the FSF's new address. * Update all other GPL and LGPL notices with the new address (apart from those in externally-maintained files).
* Fix vulnerability due to over-permissiveness of DEFINE directive.Colin Watson2003-08-01
| | | | | | | | | | | | | | | | | * src/manp.c (DEFINE_USER): New list flag. (get_def): Note that this must not return DEFINEs set in ~/.manpath. (get_def_user): New function, which may return DEFINEs set in ~/.manpath. (add_def): Use DEFINE or DEFINE_USER depending on context. (add_to_dirlist): Update call to add_def(). * src/manp.h (get_def_user): Add prototype. * src/man.c (main): pager and cat are safe for the user to define. (make_display_command): cat, tr, and decompressor are safe. * src/straycats.c (check_for_stray): col and decompressor are safe. * src/whatis.c (use_grep): whatis_grep_flags, apropos_regex_grep_flags, apropos_grep_flags, and grep are safe.
* Remove all assumptions that string literals have type 'char *' rather thanColin Watson2003-05-01
| | | | 'const char *'. Add -Wwrite-strings for gcc.
* Apply proper copyright and licence notices to all source files. There areColin Watson2002-10-23
| | | | | no functional changes here, either to the code or to the applicable licences, merely clarifications.
* Pass through much of the code adding 'const' where appropriate. This shouldColin Watson2002-04-28
| | | | help me avoid various memory management bugs.
* A week's worth of hotel room hacking. Highlights:Colin Watson2001-09-18
| | | | | | | | | * man sorts names returned from filesystem/database lookups. * man checks the filesystem before checking the database. * Several const-related cleanups. * configure works with ash as /bin/sh. * Prevent lexgrog from sometimes accidentally eating the next line of input when it sees '.' on a line by itself.
* Make sure that configuration in ~/.manpath is not trusted.Colin Watson2001-07-04
|
* Add SECTIONS directive in configuration file. Other tweaks.Colin Watson2001-06-18
|
* Merge Wilf's 2.3b12 release. Not yet functional due to several excitingColin Watson2001-05-02
| | | | conflicts with later code.
* Initial revisionColin Watson2001-04-26