summaryrefslogtreecommitdiffstats
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* Split the -Werror message level into -Werror (broken manual, probablyIngo Schwarze2015-01-201-3/+7
| | | | | | | | | | | | | using mandoc is better than using groff) and -Wunsupp (manual using unsupported low-level roff(7) feature, probably using groff is better than using mandoc). Once this feature is complete, it is intended to help porting, making the decision whether to USE_GROFF easier. As a first step, distinguish four classes of roff(7) requests: 1. Supported (currently 24 requests) 2. Currently ignored because unimportant (120) -> no message 3. Ignored for good because insecure (14) -> -Werror 4. Currently unsupported (68) -> these trigger the new -Wunsupp messages
* Let man(1) show manuals for the current architecture by default,Ingo Schwarze2015-01-161-0/+5
| | | | | and support the MACHINE environment variable as documented in man(1). Missing feature reported by pascal@.
* Fatal errors no longer exist.Ingo Schwarze2015-01-151-7/+2
| | | | | | If a file can be opened, mandoc will produce some output; at worst, the output may be almost empty. Simplifies error handling and frees a message type for future use.
* if earlier files set a non-zero exit status,Ingo Schwarze2015-01-141-6/+12
| | | | do not allow later files to reset it to zero
* Be developer-friendly, 'cause OpenBSD devs like to:Ingo Schwarze2015-01-131-4/+105
| | | | | | | | | | | | | cd /usr/src/share/man/man4; vi newdev.4 Makefile; make install; man newdev When a manual is missing from an outdated database, let man(1) show it anyway, using a KISS file system lookup as a fallback. Requested by deraadt@. 87 new lines of code doesn't seem too much bloat to me. Of course, keeping your mandoc.db(5) files up to date with makewhatis(8) or weekly(8) is still required for apropos(1) to find your new pages.
* do not spawn a pager when there is no output; issue pointed out by deraadt@Ingo Schwarze2015-01-131-24/+35
|
* If man(1) only has one single argument, always interpret it as a name,Ingo Schwarze2015-01-011-1/+2
| | | | | | never as a section. Who would have thought that people call their manual pages 7z(1), 9c(1), 9p(1), and 9p(3)... Patch from Sebastien Marie <semarie dash openbsd at latrappe dot fr>.
* When showing more than one formatted manual page, insert horizontal linesIngo Schwarze2014-12-311-1/+5
| | | | | | between pages. Suggested by Theo Buehler <theo at math dot ethz dot ch>. Even in UTF-8 output mode, do not use fancy line drawing characters such that you can easily use /^--- to skip to the next manual in your pager.
* Use -m for macro set selection in mandoc(1) mode only, not in man(1)Ingo Schwarze2014-12-211-7/+7
| | | | | | and apropos(1) mode. While here, put a space character between options and option arguments in error messages. Both reported by Alessandro DE LAURENZIS <just22 dot adl at gmail dot com>.
* update usage() and the list of non-standard (i.e. non-posix) options;Ingo Schwarze2014-12-181-2/+4
| | | | from jmc@
* Be a bit more lenient in what to accept for section names givenIngo Schwarze2014-12-171-5/+6
| | | | | | as the first man(1) command line argument without -s: Accept digits like "1", "2"; digit+letter like "3p", "1X"; and "n". Issue reported by Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
* Let "man n open" do the same as "man -s n open" again, that is,Ingo Schwarze2014-12-151-3/+4
| | | | | show the open(n) Tcl manual, as documented in man(1). Issue reported by Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
* Guard some come needed for database support only by #if HAVE_SQLITE3.Ingo Schwarze2014-12-111-4/+19
| | | | Compiler warnings about unused code reported by wiz@NetBSD.
* Support choosing alternative binary and manual names from configure.local,Ingo Schwarze2014-12-091-5/+4
| | | | to help downstream distributions avoid naming conflicts.
* Integrate the makewhatis binary into the mandoc binaryIngo Schwarze2014-12-091-0/+9
| | | | | just like we do it on OpenBSD. Smaller and neater. While here, let ./configure set INSTALL_TARGETS.
* implement help(1)Ingo Schwarze2014-12-051-8/+21
|
* Switch the default output mode from -Tascii to -Tlocale.Ingo Schwarze2014-12-021-1/+1
| | | | | | | | This doesn't change anything unless LC_CTYPE is set, but it helps when running with LC_TYPE=something.UTF-8. OK tedu@ and earlier positive feedback from: bentley@ deraadt@ naddy@ stsp@ uqs@freebsd wiz@netbsd
* Simplify the mparse_open()/mparse_wait() interface.Ingo Schwarze2014-11-261-7/+3
| | | | | Don't bother the user with the PID of the child process, store it inside the opaque mparse handle.
* In man(1) mode without -a, stop searching after the first manual treeIngo Schwarze2014-11-111-0/+4
| | | | | that contained at least one match in order to not prefer mdoc(1) from ports over mdoc(7). As a bonus, this results in a speedup.
* Let -h imply -c (that is, not use the pager).Ingo Schwarze2014-11-111-0/+1
| | | | | | Usually, -h output is short, so the pager is just a nuisance. Also, traditional man(1) does not use a pager for -h. Triggered by a remark of deraadt@ on ICB.
* implement -h (synopsis only) for preformatted (cat) pages;Ingo Schwarze2014-11-111-14/+54
| | | | requested by tedu@
* add -K to usage() and wrap nicely; from jmc@Ingo Schwarze2014-10-301-2/+2
|
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-17/+19
| | | | | | | | validity of character escape names and warn about unknown ones. This requires mchars_spec2cp() to report unknown names again. Fortunately, that doesn't require changing the calling code because according to groff, invalid character escapes should not produce output anyway, and now that we warn about them, that's fine.
* integrate preconv(1) into mandoc(1);Ingo Schwarze2014-10-251-2/+28
| | | | enhances functionality and reduces code and docs by more than 300 lines
* plug file descriptor leaks on read or write failure;Ingo Schwarze2014-10-181-3/+4
| | | | hinted at by Steffen Nurpmeso <sdaoden at yandex dot com>.
* Add *.gz support to apropos(1) -a, man(1), and even mandoc(1).Ingo Schwarze2014-09-031-13/+22
| | | | Implemented by moving the zip code from makewhatis(8) to the parser lib.
* If a manual page is installed gzip(1)ed, let makewhatis(8) takeIngo Schwarze2014-09-031-1/+1
| | | | | | | note in mandoc.db(5), such that man(1) -w and apropos(1) -w can report the correct filename. This is a prerequisite for letting apropos -a and man support gzip'ed manuals in the future, which doesn't work yet.
* Implement the traditional -h option for man(1): show the SYNOPSIS only.Ingo Schwarze2014-09-031-4/+8
| | | | | | | As usual, we get mandoc -h and apropos -h for free. Try stuff like "apropos -h In=dirent" or "apropos -h Fa=timespec". Only useful for terminal output, so -Tps, -Tpdf, -Thtml ignore -h for now.
* In man(1) mode, change to the right directory before starting the parser,Ingo Schwarze2014-09-011-3/+5
| | | | | | | just like traditional man(1) does, such that .so links have a chance to work. After this point, we don't need the current directory for anything else before exit, so we don't need to worry about getting back and we can safely ignore failure.
* Introduce a man(1) -l option as an alias for mandoc -a.Ingo Schwarze2014-08-301-8/+13
| | | | | | | | | | | | | Basically, this does the same as man -l in Linux man-db. The point is that now all functionality of the combined tool is reachable from the man(1) command name: apropos = man -k, whatis = man -f, mandoc = man -cl. Originally suggested by Carsten dot Kunze at arcor dot de, current maintainer of the Heirloom Documentation Tools. While here, add various missing information to the usage() and to the manuals.
* without search results, skip the processing loops and the parserIngo Schwarze2014-08-231-0/+8
|
* Let man(1) display preformatted manuals by simply reading themIngo Schwarze2014-08-231-19/+55
| | | | | | | from the file and copying them to the standard output. This works even for mixed formats: "man -a groff mandoc" displays groff(1) [formatted], mandoc(1) [unformatted], groff(7) [formatted], and mandoc(7) [unformatted] in that order.
* implement man(1) quirk: section argument without -sIngo Schwarze2014-08-221-0/+16
|
* implement MANPAGER and PAGERIngo Schwarze2014-08-221-10/+48
|
* mandoc -a, man, apropos -a, whatis -a now paginate by defaultIngo Schwarze2014-08-221-2/+52
| | | | | but provide an option -c to not paginate; taking inspiration from manpage.c, hence adding (c) 2012 kristaps@
* Implement classic man(1) output mode showing only one manual evenIngo Schwarze2014-08-211-7/+68
| | | | | | if there is more than one match, using traditional section priorities, and implement man(1) -a (show all) output mode, not just for man(1), but also for apropos(1) and whatis(1).
* Parse the new -a, -i, and -w options.Ingo Schwarze2014-08-201-4/+43
| | | | Implement -w (list manual page filenames).
* Fully integrate apropos(1) into mandoc(1).Ingo Schwarze2014-08-171-36/+119
| | | | | | | | | Switch the argmode on the progname, including man(1). Provide -f and -k options to switch the argmode. Store the argmode inside struct search, generalizing the flags. Derive the deftype from the argmode when needed instead of storing it. Store the outkey inside struct search instead of passing it alone. While here, get rid of the trailing blanks in Makefile.depend.
* When BUILD_DB is active, link apropos(1) into the mandoc binary.Ingo Schwarze2014-08-161-0/+10
| | | | | This is the first step on the way to a man(1) implementation. The new ./configure is flexible enough to make this step quite easy.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-2/+2
| | | | | | Include <sys/types.h> where needed, it does not belong in config.h. Remove <stdio.h> from config.h; if it is missing somewhere, it should be added, but i cannot find a *.c file where it is missing.
* Reduce the verbosity of error messages caused by open(2) failures.Ingo Schwarze2014-06-211-2/+5
| | | | Suggested by and ok jmc@.
* Prefix messages about bad command line options and argumentsIngo Schwarze2014-06-211-6/+10
| | | | | with "mandoc: " or "makewhatis: ", respectively, similar to what we already do for other messages.
* As suggested by jmc@, only include line and column numbers into messagesIngo Schwarze2014-06-201-3/+7
| | | | | | | | | | | | | | when they are meaningful, to avoid confusing stuff like this: $ mandoc /dev/null mandoc: /dev/null:0:1: FATAL: not a manual Instead, just say: mandoc: /dev/null: FATAL: not a manual Another example this applies to is documents having a prologue, but lacking a body. Do not throw a FATAL error for these; instead, issue a WARNING and show the empty document, in the man(7) case with the same amount of blank lines as groff does. Also downgrade mdoc(7) documents having content before the first .Sh from FATAL to WARNING.
* Prefix error messages from mandoc(1) with "mandoc: "Ingo Schwarze2014-06-201-1/+2
| | | | | | | just like almost all other utility programs do. Suggested by nick@ who wondered where messages came from when calling mandoc(1) from inside a Perl script. ok jmc@ nick@
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-44/+43
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze2014-03-231-0/+1
| | | | | | | functions used for multiple languages (mdoc, man, roff), for example mandoc_escape(), mandoc_getarg(), mandoc_eos(), and generic auxiliary functions. Split the auxiliaries out into their own file and header. While here, do some #include cleanup.
* Without the MPARSE_SO option, if the file contains nothing but aIngo Schwarze2014-03-191-1/+1
| | | | | | single .so request, do not read the file pointed to, but instead let mparse_result() provide the file name pointed to as a return value. To be used by makewhatis(8) in the future.
* Generalize the mparse_alloc() and roff_alloc() functions by givingIngo Schwarze2014-03-191-10/+10
| | | | | | | | them an "options" argument, replacing the existing "inttype" and "quick" arguments, preparing for a future MPARSE_SO option. Store this argument in struct mparse and struct roff, replacing the existing "inttype", "parsetype", and "quick" members. No functional change except one tiny cosmetic fix in roff_TH().
* Joerg Sonnenberger contributed copyrightable amounts of text toIngo Schwarze2014-01-061-0/+1
| | | | | | some files. To make it clear that he also put his contributions under the ISC license, with his explicit permission, add his Copyright notice to the relevant files. No code change.
* Add an option -Q (quick) to mandocdb(8)Ingo Schwarze2014-01-051-1/+1
| | | | | | | | | | | | | | | for accelerated generation of reduced-size databases. Implement this by allowing the parsers to optionally abort the parse sequence after the NAME section. While here, garbage collect the unused void *arg attribute of struct mparse and mparse_alloc() and fix some errors in mandoc(3). This reduces the processing time of mandocdb(8) on /usr/share/man by a factor of 2 and the database size by a factor of 4. However, it still takes 5 times the time and 6 times the space of makewhatis(8), so more work is clearly needed.