summaryrefslogtreecommitdiffstats
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Compatibility with man-db:Ingo Schwarze2018-04-191-12/+56
| | | | | | | | | In page name mode (= man(1) default mode), also try to interpret names containing slashes as absolute or relative file names. Missing feature reported by Nate Bargmann on <groff at gnu dot org>, and the man-db maintainer Colin Watson <cjwatson at debian dot org> kindly explained to me how this is supposed to work.
* Use TIOCGWINSZ to reduce the default -Owidth during interactive useIngo Schwarze2018-04-131-1/+13
| | | | | | | on terminals narrower than 79 columns and the default -Oindent on terminals narrower than 66 columns. Requested by and feedback from pirofti@; mpi@ and juanfra@ also like the general direction.
* Invalidate the tag_files.tfd after fclose(3)ing the stram associatedIngo Schwarze2018-02-231-1/+1
| | | | | | with it. In main() assert that the tfd was actually invalidated. This avoids closing an invalid fd. From tb@; OK deraadt@ on an earlier version.
* When the stdout stream gets broken, there is no point in readingIngo Schwarze2017-08-211-0/+11
| | | | | | | | | any more input files, and it would be misleading to start a parser, because that would show randomly truncated text. Instead, print an error message and exit the program. Issue found by Leah Neukirchen <leah at vuxu dot org>, who was surprised to see half a manpage when her /tmp/ overflew.
* Cast the return value of chdir(2) to void. We already have a commentIngo Schwarze2017-07-261-1/+1
| | | | | | above explaining to human auditors why no error checking is needed here, so it's only fair to tell the compiler, too. Worried compiler reported by Michael <Stapelberg at debian>.
* For -Tlint, put parser messages on stdout instead of stderr.Ingo Schwarze2017-07-201-6/+9
| | | | | | | | | | | Originally, naddy@ requested this in 2011 (or maybe even earlier). It was discussed with joerg@, kristaps@, naddy@, and espie@ in 2011, and everybody agreed in principle, but it was postponed because kristaps@ wanted to do some cleanup of the message system first. Meanwhile, message infrastructure was improved about a dozen times... This makes long, tedious commands like "mandoc -Tlint *.1 2>&1 | less" unnecessary and allows simple ones like "man -l -Tlint *.1".
* Printing "BASE:" in messages about violations of base system conventionsIngo Schwarze2017-07-041-2/+1
| | | | | is confusing, simply print "STYLE:", which is intuitive and does not sound excessively alarming; suggested by jmc@, OK tedu@ jmc@.
* If a single page references the same non-existent manual more thanIngo Schwarze2017-07-021-1/+5
| | | | | | once, print "(N times)" after the message "referenced manual not found", to lessen the risk that people fix the first instance and miss the others; jmc@ confirmed that this is useful.
* add warning "cross reference to self"; inspired by mdoclintIngo Schwarze2017-07-021-3/+5
|
* When checking cross references with -Tlint, ultimately fall back toIngo Schwarze2017-07-011-2/+11
| | | | | | | | | | | | | | | | | looking in the current working directory. Not a security issue because the files are never open(2)ed, only access(2)ed. Requested by jmc@ and inspired by mdoclint(1). This cannot be perfect because it only works for files having the exact filename ./pagename.sec - mandoc has no way to figure out which files might contain a manual for multiple names, or that files in autohell might be called ./pagename.man.in instead, or which subdirectories might contain additional source files. Also, it may hide messages if you have bogus stuff lying around in the directory where you run mandoc -Tlint. But jmc@ considers it important, and good enough for everyday use. Also avoid leaking the memory for the file name while here.
* When checking the validity of cross references with -Tlint,Ingo Schwarze2017-07-011-6/+12
| | | | | | | | | | | | | fall back from database search to file system search just like man(1) does when looking up manuals. This is not too expensive because on a system having up-to-date mandoc.db(5) files, it only prolongs the time needed to check *invalid* references - and you are not supposed to have many of those, right? And on a system with missing or invalid mandoc.db(5) files, spending a bit of time and warning loudly about the real problem is also better than quickly issuing bogus warnings about cross references that are actually valid.
* Basic reporting of .Xrs to manual pages that don't existIngo Schwarze2017-07-011-0/+33
| | | | | | | | | | | | in the base system, inspired by mdoclint(1). We are able to do this because (1) the -mdoc parser, the -Tlint validator, and the man(1) manual page lookup code are all in the same program and (2) the mandoc.db(5) database format allows fast lookup. Feedback from, previous versions tested by, and OK jmc@. A few features will be added to this in the tree, step by step.
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addIngo Schwarze2017-06-241-25/+42
| | | | | | | | | | | | | | | -Wopenbsd and -Wnetbsd to check conventions for the base system of a specific operating system. Mark operating system specific messages with "(OpenBSD)" at the end. Please use just "-Tlint" to check base system manuals (defaulting to -Wall, which is now -Wbase), but prefer "-Tlint -Wstyle" for the manuals of portable software projects you maintain that are not part of OpenBSD base, to avoid bogus recommendations about base system conventions that do not apply. Issue originally reported by semarie@, solution using an idea from tedu@, discussed with jmc@ and jca@.
* enable -Wstyle by default in -Tlint; OK jmc@Ingo Schwarze2017-06-031-1/+1
|
* Delete the -T xhtml command line option.Ingo Schwarze2017-05-171-2/+0
| | | | | It has been obsolete for more than two years. Use -T html.
* Introduce a new mandoc(1) message level, -W style, below -W warning.Ingo Schwarze2017-05-161-10/+13
| | | | | | | | | | | | | Switch -W all from meaning -W warning to meaning -W style. The meaning of -T lint does *not* change, it still implies -W warning. No messages on the new level yet, but they will come. Usually, i do not lightly make the user interface larger. But this has been planned for years, and EXIT STATUS 1 was reserved for it all the time. The message system is now stable enough to finally implement it. jmc@ regarding the concept: "really good idea"
* Now that global -i is gone, pass -i through to the apropos(1)Ingo Schwarze2017-04-181-2/+6
| | | | | | expression parser, such that "apropos -i 'Nm~dump\>'" finds kdump(1) and WCOREDUMP(2) and you don't need to type the counter-intuitive "apropos -- -i 'Nm~dump\>'".
* Delete the undocumented and unimplemented man(1) -i (interactiveIngo Schwarze2017-04-181-4/+0
| | | | | apropos) option. It will not be implemented. Featurism isn't the plan for the future; simplicity is.
* simplify the SYNOPSIS as well, just like the option lists;Ingo Schwarze2017-03-271-9/+7
| | | | suggested by and OK jmc@
* Silently ignore invalid -m input formats rather than erroring out.Ingo Schwarze2017-03-201-15/+7
| | | | | | As observed by Jan Stary <hans at stare dot cz>, this is useful such that after 'alias man="man -m $HOME/man"', 'man -l foo.1' still works. Simplify and shorten the description of -m, and use .Ic for macros.
* new -mdoc -Tmarkdown output mode; OK millert@ reyk@ tb@;Ingo Schwarze2017-03-031-0/+6
| | | | thanks to reyk@ and to Vsevolod at FreeBSD for suggesting it
* Since SQLite is gone, we no longer need the "flock" pledge.Ingo Schwarze2017-02-221-2/+2
| | | | Patch from semarie@, OK tb@.
* Be consistent in protecting __attribute__ attributes with __;Ingo Schwarze2017-02-171-1/+1
| | | | from Christos Zoulas <christos @ NetBSD>.
* Fix rev. 1.280: -O syntax is different in default apropos(1) outputIngo Schwarze2017-02-161-17/+22
| | | | | mode and in other output modes, so do not error out prematurely. Also sort local variables in main() while here.
* In -Ttree output mode, show the BROKEN node flag andIngo Schwarze2017-02-101-2/+4
| | | | provide a -Onoval output option to show the unvalidated tree.
* warn about invalid output optionsIngo Schwarze2017-01-271-3/+9
| | | | | and error out if they occur on the command line; missing feature found in the TODO file
* Use stdout rather than stdin for controlling the terminalIngo Schwarze2017-01-091-5/+5
| | | | | | | such that "cat foo.mdoc | man -l" works. Issue reported by Christian Neukirchen <chneukirchen at gmail dot com> and also tested by him on Void Linux with both glibc and musl. The patch makes sense to millert@.
* Warnings and errors that occur during mdoc_validate()Ingo Schwarze2017-01-091-1/+2
| | | | | | or during man_validate() have to affect the mandoc(1) EXIT STATUS. Many thanks to <Yuri dot Pankov at gmail dot com> (illumos developer) for reporting this regression.
* We cannot use fputs(3) in passthrough() because the stdout streamIngo Schwarze2016-09-181-4/+14
| | | | | | | | | | | | might be in stdio wide orientation due to prior formatting of an unformatted manual in man -aTutf8 mode. So for now, use fflush(3) followed by unbuffered write(2) instead. Fixes output corruption on glibc discovered on Linux while testing a diff to fix a loosely related bug reported by <jmates at ee dot washington dot edu>. I detest the concept of stdio stream orientation. One day, i will rewrite term_ascii.c to always use narrow streams, even in UTF-8 output mode. But that's too much work for today.
* Make sure an output device is allocated before calling terminal_sepline(),Ingo Schwarze2016-09-181-27/+34
| | | | | | fixing a NULL pointer access that happened when the first of multiple pages shown was preformatted, as in "man -a groff troff". Crash reported by <jmates at ee dot washington dot edu> on bugs@, thanks!
* fix printf("%s", NULL);Ingo Schwarze2016-08-091-1/+2
| | | | found while investigating an unrelated bug report from jsg@
* Remove the dependency on SQLite without loss of functionality.Ingo Schwarze2016-07-191-24/+3
| | | | | Stop supporting systems that don't have mmap(3). Drop the obsolete names_check() now that we deleted MLINKS.
* Use __attribute__((__format__ throughout.Ingo Schwarze2016-07-191-6/+0
| | | | | | | Triggered by a smaller patch from Christos Zoulas. While here, unify style, move several config tests to config.h, and delete the useless MANDOC_CONFIG_H.
* To remove the const qualifier from a pointer to an object - eitherIngo Schwarze2016-07-151-1/+1
| | | | | | | | | because we know it is actually mutable or because we are passing it to a function that doesn't accept a const object but won't actually attempt to modify it - simply casting from (const type *) to (type *) is legal C and clearly expresses the intent. So get rid of the obfuscating UNCONST macro. Basic idea discussed with guenther@.
* Fix previous: the mandocdb() prototype was already there, it justIngo Schwarze2016-07-151-3/+2
| | | | hid among static functions, as noticed by tedu@ (my bad).
* add missing prototypes, no code change;Ingo Schwarze2016-07-151-0/+3
| | | | noticed by Christos Zoulas with -Wmissing-prototypes
* Add support for Mac OS X's sandbox_init(3) sandbox functionality, whichKristaps Dzonsons2016-07-121-0/+8
| | | | | | | is marked as DEPRECATED in OS X after 2011 or so, but has not been removed and has no replacement. ok schwarze@
* On OpenBSD, more(1) is actually less(1) with a small number ofIngo Schwarze2016-07-101-2/+2
| | | | | | | compatibility features - so we can safely use more -T on OpenBSD. But don't do that in the portable version: more -T is unlikely to work elsewhere. Issue reported by Svyatoslav Mishyn <juef at openmailbox dot org>.
* ISO C99 7.19.2.5 doesn't like mixing putchar(3) and putwchar(3) onIngo Schwarze2016-07-081-1/+1
| | | | | | the same stream, and actually, it fails spectacularly on glibc. Portability issue pointed out by Svyatoslav Mishyn <juef at openmailbox dot org> after testing on Void Linux.
* Do not hardcode "makewhatis" in a warning message, use BINM_MAKEWHATIS.Ingo Schwarze2016-05-181-2/+2
| | | | Patch from Peter Bray <pdb_ml at yahoo dot com dot au>.
* Fix a process group race.Ingo Schwarze2016-04-141-2/+8
| | | | | | | It could occasionally happen that the child process spawned less(1) before the parent process passed the control of the terminal to the child, and in that case, less(1) sometimes complained "Stopped (tty output)". Issue reported by naddy@.
* Give manuals in purely numerical sections priority over manuals ofIngo Schwarze2016-04-131-8/+10
| | | | | | | | | the same name in sections with an alphabetical suffix (on OpenBSD, mostly 3p), restoring behaviour of the traditional BSD man(1) that got lost in the switch to the mandoc-based implementation. Issue reported by jsg@, using an idea by mikeb@ for the solution, and at least afresh1@ and jasper@ also seem in favour of the direction.
* unbreak reading from stdin after recent parse() restructuring;Ingo Schwarze2016-01-161-1/+1
| | | | patch from florian@
* Simplify the mparse_open() interface.Ingo Schwarze2016-01-081-8/+4
| | | | | | Just return the file descriptor or -1 on error; there is just one kind of error anyway. Suggested by Christos Zoulas (NetBSD).
* It was very surprising that a function called mparse_readfd()Ingo Schwarze2016-01-081-1/+3
| | | | | | | | | | | | | closed the file descriptor passed to it after completing its work, in particular considering the fact that it required its callers to call open(2) or mparse_open() beforehand. Change mparse_readfd() to not call close(2) and change the callers to call close(2) afterwards, more or less bringing open and close to the same level of the code and making review easier. Note that man.cgi(8) already did that, even though it was wrong in the past. Small restructuring suggested by Christos Zoulas (NetBSD).
* pledge(2) style:Ingo Schwarze2015-12-151-5/+10
| | | | | | | Make sure to always use the idiom 'if (pledge("' such that it can easily be searched for. No functional change. Requested by deraadt@ some time ago.
* Fix multiple issues regarding process group and signal mask handlingIngo Schwarze2015-11-201-18/+41
| | | | | found by tb@ and millert@; parts of the code, in particular in tag.c, by millert@; OK millert@.
* Fix an issue reported by deraadt@: When hitting Ctrl-Backslash (= SIGQUIT)Ingo Schwarze2015-11-141-4/+34
| | | | | | | | | | | | | | | in the less(1) spawned by man(1), man(1) died uncleanly, leaving behind its temp files, and killed less(1) uncleanly as well with SIGPIPE, leaving the terminal in the wrong state. Fix this by giving less(1) its own process group and handing it control of the terminal, but in such a way that Ctrl-z (= SIGSTOP) still works: In that case, let man(1) stop itself, too, and let it continue the pager when it continues itself. Joint work with millert@ who contributed most of the expertise required, and also most parts of the code. OK deraadt@ millert@
* Modernization, no functional change intended:Ingo Schwarze2015-11-071-23/+19
| | | | | | Use the POSIX function getline(3) rather than the slightly dangerous BSD function fgetln(3). Remove the related compatibility code.
* Without HAVE_ERR, don't try to include <err.h>, it probably isn't there.Ingo Schwarze2015-11-071-0/+2
| | | | | In that case, the required prototypes are in "config.h". Patch from Peter Bray <pdb_ml at yahoo dot com dot au>.