summaryrefslogtreecommitdiffstats
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>.
* merge pledge(2) support from OpenBSDIngo Schwarze2015-11-061-0/+20
|
* Use getprogname(3) rather than __progname.Ingo Schwarze2015-11-061-15/+18
| | | | | | | Suggested by Joerg@ Sonnenberger (NetBSD). Last year, deraadt@ confirmed on tech@ that this "has the potential to be more portable", and micro-optimizing for speed is not relevant here. Also gets rid of one global variable.
* move man(7) validation into the dedicated validation phase, tooIngo Schwarze2015-10-221-0/+1
|
* If no output device was allocated because no file wanted to produce output,Ingo Schwarze2015-10-221-15/+17
| | | | | refrain from dereferencing a NULL pointer during final deallocation. Fixing a recent regression reported by czarkoff@
* In order to become able to generate syntax tree nodes on the roff(7)Ingo Schwarze2015-10-201-0/+1
| | | | | | | | level, validation must be separated from parsing and rewinding. This first big step moves calling of the mdoc(7) post_*() functions out of the parser loop into their own mdoc_validate() pass, while using a new mdoc_state() module to make syntax tree state handling available to both the parser loop and the validation pass.
* Simplify, no functional change:Ingo Schwarze2015-10-191-35/+51
| | | | Delete the outmdoc, outman, and outfree function pointers.
* Major character table cleanup:Ingo Schwarze2015-10-131-17/+9
| | | | | | | | | | | | | * Use ohash(3) rather than a hand-rolled hash table. * Make the character table static in the chars.c module: There is no need to pass a pointer around, we most certainly never want to use two different character tables concurrently. * No need to keep the characters in a separate file chars.in; that merely encourages downstream porters to mess with them. * Sort the characters to agree with the mandoc_chars(7) manual page. * Specify Unicode codepoints in hex, not decimal (that's the detail that originally triggered this patch). No functional change, minus 100 LOC, and i don't see a performance change.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-5/+0
| | | | | | that were right between two adjacent case statement. Keep only those 24 where the first case actually executes some code before falling through to the next case.
* Finally use __progname, err(3) and warn(3).Ingo Schwarze2015-10-111-49/+32
| | | | | | | | | | That's more readable and less error-prone than fumbling around with argv[0], fprintf(3), strerror(3), perror(3), and exit(3). It's a bad idea to boycott good interfaces merely because standards committees ignore them. Instead, let's provide compatibility modules for archaic systems (like commercial Solaris) that still don't have them. The compat module has an UCB Copyright (c) 1993...
* Decide whether to use_pager as early as possible,Ingo Schwarze2015-10-101-3/+5
| | | | in preparation for pledge(2); no functional change intended.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-20/+20
|
* Remove the hack of scrolling forward and backward with +G1G thatIngo Schwarze2015-07-281-61/+32
| | | | | | | | | | many (jmc@, millert@, espie@, deraadt@) considered revolting. Instead, when using a pager, since we are using a temporary file for tags anyway, use another temporary file for the formatted page(s), as suggested by millert@ and similar to what the traditional BSD man(1) did, except that we use only one single temporary output file rather than one for each formatted manual page, such that searching (both with / and :t) works across all the displayed files.
* When creation of the temporary tags file fails, call the pagerIngo Schwarze2015-07-211-8/+11
| | | | | | | | without the -T option, because otherwise the pager won't even start. Fixing a bug reported by jca@. While here, shorten the code by two lines and delete one internal interface function.
* Do not fork and exec gunzip(1), just link with libz instead.Ingo Schwarze2015-07-191-4/+0
| | | | | | | As discussed with deraadt@, that's cleaner and will help tame(2). Something like this was also suggested earlier by bapt at FreeBSD. Minus 50 lines of code, deleting one interface function (mparse_wait), no functional change intended.
* If we aren't on a tty, clear the pager flag up front.Ingo Schwarze2015-07-191-2/+5
| | | | Just to clean up code structure, no functional change.
* Insist that manual page file name extensions must begin with a digit,Ingo Schwarze2015-07-181-1/+1
| | | | | lest pkg.conf(5) be shown when pkg(5) is asked for; issue reported by Michael Reed <m dot reed at mykolab dot com>.
* Initial, still somewhat experimental implementation to leverageIngo Schwarze2015-07-171-26/+43
| | | | | | | | | | | | | | | less(1) -T and :t ctags(1)-like functionality to jump to the definitions of various terms inside manual pages. To be polished in the tree, so bear with me and report issues. Technically, if less(1) is used as a pager, information is collected by the mdoc(7) terminal formatter, first stored using the ohash library, then ultimately written to a temporary file which is passed to less via -T. No change intended for other output formatters or when running without a pager. Based on an idea from Kristaps using feedback from many, in particular phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.
* Improve the error message in case somebody has configured an invalid PAGER.Ingo Schwarze2015-04-291-2/+2
| | | | Suggested by Lorenzo Beretta <lory dot fulgi at infinito dot it>.
* Fix previous: Don't let man(1) warn twice about non-existant names.Ingo Schwarze2015-04-201-5/+9
| | | | Again noticed by deraadt@.
* If apropos(1) finds no match, print "nothing appropriate" to stderrIngo Schwarze2015-04-191-0/+2
| | | | | similar to what the old apropos did. Requested by and OK deraadt@.
* Profit from the unified struct roff_man and reduce the number ofIngo Schwarze2015-04-181-5/+6
| | | | | arguments of mparse_result() by one. No functional change. Written on the ICE Bruxelles-Koeln on the way back from p2k15.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-4/+4
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* shorten "outdated mandoc.db" warning message; requested by deraadt@Ingo Schwarze2015-04-161-4/+2
|
* No need to hardcode /usr/bin/ as the path to more(1); helps portability.Ingo Schwarze2015-04-031-1/+1
| | | | | We don't hardcode the paths to gunzip(1) and cmp(1) either. Discussed with ajacoutot@.
* First step towards parser unification:Ingo Schwarze2015-04-021-2/+3
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* Actually use the new man.conf(5) "output" directive.Ingo Schwarze2015-03-271-8/+9
| | | | Additional functionality, yet minus 45 lines of code.
* Parse the new man.conf(5) "output" directive.Ingo Schwarze2015-03-271-10/+12
| | | | The next step will be to actually use the parsed data.
* Modernize documentation by inserting blanks between option lettersIngo Schwarze2015-03-271-3/+3
| | | | | | and option arguments, except for -m because "-m an" and "-m andoc" look just too weird. Of course, the traditional form without the blank will continue to work.
* Simplify: Now that rc is global anyway, no need to pass it aroundIngo Schwarze2015-03-171-26/+19
| | | | as an argument. No functional change.
* When the user exits the pager before the pager has drained all inputIngo Schwarze2015-03-171-1/+12
| | | | | | | | from man(1), man(1) dies from SIGPIPE. Exiting man(1) is fine in this case, generating more output would be pointless, but without handling SIGPIPE, the exit code from man(1) was wrong and csh(1) printed an ugly message "Broken pipe". Fix this by handling SIGPIPE explicitly. Issue noticed by deraadt@.
* We can keep track of the pager PID without additional complexity.Ingo Schwarze2015-03-101-26/+22
| | | | | No functional change for now, but more robust in case anybody should ever add additional child processes.
* Fix a regression caused in rev. 1.212, reported by kristaps@:Ingo Schwarze2015-03-101-3/+21
| | | | | | | | | | | | When using a pager and the first manual shown is gzip'ed, the gunzip(1) process ended up as a child of the pager process such that the man(1) process couldn't wait for it, preventing proper display of the manual. Solve this by making the pager a child of the man(1) process (instead of the other way round), which requires being a bit more careful about properly closing file descriptors after use and waiting for the pager before exiting man(1).