summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/main.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Split the -Werror message level into -Werror (broken manual, probablyschwarze2015-01-201-4/+8
| | | | | | | | | | | | | 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,schwarze2015-01-161-1/+6
| | | | | and support the MACHINE environment variable as documented in man(1). Missing feature reported by pascal@.
* Fatal errors no longer exist.schwarze2015-01-151-8/+3
| | | | | | 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,schwarze2015-01-141-7/+13
| | | | do not allow later files to reset it to zero
* Be developer-friendly, 'cause OpenBSD devs like to:schwarze2015-01-131-5/+102
| | | | | | | | | | | | | 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@schwarze2015-01-131-24/+29
|
* If man(1) only has one single argument, always interpret it as a name,schwarze2015-01-011-2/+3
| | | | | | 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 linesschwarze2014-12-311-2/+6
| | | | | | 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)schwarze2014-12-211-8/+8
| | | | | | 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;jmc2014-12-181-3/+5
| | | | ok schwarze
* Be a bit more lenient in what to accept for section names givenschwarze2014-12-171-6/+7
| | | | | | 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,schwarze2014-12-151-4/+5
| | | | | show the open(n) Tcl manual, as documented in man(1). Issue reported by Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
* slightly reshuffle some code to reduce the diff with portable;schwarze2014-12-111-5/+6
| | | | no functional change
* implement help(1)schwarze2014-12-051-9/+22
|
* Switch the default output mode from -Tascii to -Tlocale.schwarze2014-12-021-2/+2
| | | | | | | | 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.schwarze2014-11-261-8/+4
| | | | | 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 treeschwarze2014-11-111-1/+5
| | | | | 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).schwarze2014-11-111-1/+2
| | | | | | 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;schwarze2014-11-111-15/+55
| | | | requested by tedu@
* mandoc.1: fix a macro error in previousjmc2014-10-301-3/+3
| | | | | | main.c: add -K to usage() and wrap nicely ok schwarze
* support UTF-8 and ISO-8859-1 input by integrating modified partsschwarze2014-10-301-3/+29
| | | | | of kristaps@' version of the preconv(1) utility into mandoc(1); positive feedback from bentley@ and no concern raised when shown on tech@
* Make the character table available to libroff so it can check theschwarze2014-10-281-18/+20
| | | | | | | | 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.
* plug file descriptor leaks on read or write failure;schwarze2014-10-181-4/+5
| | | | hinted at by Steffen Nurpmeso <sdaoden at yandex dot com>.
* Add *.gz support to apropos(1) -a, manm(1), and even mandoc(1).schwarze2014-09-031-15/+23
| | | | 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) takeschwarze2014-09-031-2/+2
| | | | | | | 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.schwarze2014-09-031-5/+9
| | | | | | | 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,schwarze2014-09-011-4/+6
| | | | | | | | | 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. This lets man(1) find more Xenocara manuals, but not all of them yet. Other issues remain that need to be fixed, too.
* Introduce a man(1) -l option as an alias for mandoc -a.schwarze2014-08-301-9/+14
| | | | | | | | | | | | | 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.
* Add an implementation of man(1) into the /usr/bin/mandoc binary andschwarze2014-08-271-40/+364
| | | | | | | | | | | | | | | | | | | | | | | | | provide a unified set of command line options for mandoc(1), man(1), apropos(1), and whatis(1), each option doing the same for all four. Not adding any completely new options, only extending exiting ones from one tool to the others. New options are: * apropos & whatis -acfkw (in the past, these were man(1) only) * apropos & whatis -a -IOTW (in the past, mandoc(1) only) * mandoc -ac (in the past, man(1) only) * man -IOTW (in the past, mandoc(1) only) Before we can decide whether or not we want to replace src/usr.bin/man with this implementation, considerable bugfixing, testing, and performance measurements are needed, which i'd rather do in the tree than outside. Note that these bugs only affect the new man(1) mode, existing mandoc(1), apropos(1), and whatis(1) is fine. The new functionality in mandoc(1), apropos(1), and whatis(1) is fully enabled. To play with the new man(1), you can try: # mv /usr/bin/man /usr/bin/oman # ln -s /usr/bin/mandoc /usr/bin/man Positive feedback about the general direction from sthen@ and jmc@, and deraadt@ is not against it.
* Reduce the verbosity of error messages caused by open(2) failures.schwarze2014-06-211-3/+6
| | | | Suggested by and ok jmc@.
* Prefix messages about bad command line options and argumentsschwarze2014-06-211-7/+11
| | | | | 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 messagesschwarze2014-06-201-4/+8
| | | | | | | | | | | | | | 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: "schwarze2014-06-201-2/+3
| | | | | | | 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 */,schwarze2014-04-201-45/+44
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* The files mandoc.c and mandoc.h contained both specialised low-levelschwarze2014-03-211-1/+2
| | | | | | | 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 aschwarze2014-03-191-2/+2
| | | | | | 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 givingschwarze2014-03-191-11/+11
| | | | | | | | 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 toschwarze2014-01-061-1/+2
| | | | | | 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)schwarze2014-01-051-2/+2
| | | | | | | | | | | | | | | 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(). 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.
* sync usage(), and tidy up the output a little; ok schwarzejmc2012-11-191-4/+4
|
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theschwarze2012-05-241-4/+20
| | | | | | | | default value for the mdoc(7) .Os macro. Needed for man.cgi on the OpenBSD website. Problem with man.cgi first noticed by deraadt@; beck@ and deraadt@ agree with the way to solve the issue.
* Accept "makewhatis" as an alias for "mandocdb".schwarze2011-12-251-2/+3
|
* Implement whatis(1) as a special apropos(1) mode as a part ofschwarze2011-11-281-2/+3
| | | | | | | | | | | | the mandoc(1) binary; not yet enabled for the general public. Intended to replace src/usr.bin/whatis at a later time. Coded by kristaps@, with a few tweaks by me. To test this: $ mandocdb # unless you have already done so earlier $ sudo ln -s /usr/bin/mandoc /usr/bin/whatis.m $ whatis.m mandoc apropos whatis $ whatis.m man
* Sync to version 1.12.0; all code by kristaps@:schwarze2011-10-091-1/+8
| | | | | | | | Implement .Rv in -Tman. Let -man -Tman work a bit like cat(1). Add the -Ofragment option to -T[x]html. Minor fixes in -T[x]html. Lots of apropos(1) and -Tman code cleanup.
* 1) Import the future apropos(1) replacement written by kristaps@.schwarze2011-10-061-1/+9
| | | | | | | | | | | | 2) Link both that one and mandocdb(8) into the mandoc(1) binary. 3) Install a /usr/bin/mandocdb hardlink and the mandocdb(8) manual. Do not replace /usr/bin/apropos by a hardlink yet because it is not ready for production, and ports integration is still missing. Development will be done in the tree, even the user interfaces are still subject to change at this point. Both jmc@ and deraadt@ agree with getting this in.
* Initial, incomplete support for -Tmanschwarze2011-09-171-1/+7
| | | | | | | | to convert mdoc(7) documents to the man(7) language. This is work in progress and will be developed in tree. It does already handle the cat(1) manual, but will hardly handle all your fancy manuals yet. go ahead kristaps@ jmc@ millert@ deraadt@
* Merge release 1.11.3, almost all code by kristaps@:schwarze2011-05-291-2/+21
| | | | | | | | | * Unicode output support (no Unicode input yet, though). * Refactoring: completely handle predefined strings in roff.c. - New function mandoc_escape() replaces a2roffdeco() and mandoc_special(). - Start using mandoc_getarg() in mdoc_argv.c. - Clean up parsing of delimiters in mdoc(7). * And many minor fixes and lots of cleanup.
* Merge version 1.11.1:schwarze2011-04-241-753/+66
| | | | | | | | | | | | | | Again lots of cleanup and maintenance work by kristaps@. - simplify error reporting: less function pointers, more mandoc_[v]msg - main: split document parsing out of main.c into read.c - roff, mdoc, man: improved recognition of control characters - roff: better handling of if/else stack overflows - roff: add some predefined strings for backward compatibility - mdoc, man: empty sections are not errors - mdoc: move delimiter handling to libmdoc - some header restructuring and some minor features and fixes This merge causes two minor regressions that i will fix in separate commits right afterwards.
* Merge version 1.10.10:schwarze2011-04-211-45/+38
| | | | | | | | | | lots of cleanup and maintenance work by kristaps@. - move some main.c globals into struct curparse - move mandoc_*alloc to mandoc.h such that all code can use them - make mandoc_isdelim available to formatting frontends - dissolve mdoc_strings.c, move the code where it is used - make all error reporting functions void, their return values were useless - and various minor cleanups and fixes
* Import the foundation for eqn(7) support.schwarze2011-03-201-11/+19
| | | | | | | | Written by kristaps@. For now, i'm adding one line to each of the four frontends to just pass the input text through to the output, not yet interpreting any of then eqn keywords.