summaryrefslogtreecommitdiffstats
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* sync usage(), and tidy up the output a little; from jmc@Ingo Schwarze2012-11-191-3/+3
|
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theIngo Schwarze2012-05-271-3/+19
| | | | | | | | | | 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. "Please check them in and I'll look into them later!" kristaps@
* If -Tman is specified and input is -man, echo the preprocessed (`so'Kristaps Dzonsons2011-10-061-0/+7
| | | | | | | | | | | | | | replaced by file) input. This replaces earlier behaviour of doing nothing, which I found unexpected (mandoc should always output). This requires a buffer in read.c that saves the input lines before being parsed, with a special hook if `so' is invoked. This buffer is just flushed to output if -mman is the input. While mucking around doing this, I also alpha-ordered the mandoc.h functions. Ok schwarze@, with no screaming when the polished patch was published.
* Initial, incomplete support for -TmanIngo Schwarze2011-09-171-0/+6
| | | | | | | | 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@
* Turn on -Tutf8 in the frontend. Here we go!Kristaps Dzonsons2011-05-201-0/+9
|
* Add mode for -Tlocale. This mode, with this commit, behaves exactlyKristaps Dzonsons2011-05-171-1/+11
| | | | | | | like -Tascii. While adding this, inline term_alloc() (was a one-liner), remove some switches around the terminal encoding for the symbol table (unnecessary), and split out ascii_alloc() into ascii_init(), which is also called from locale_init().
* Make -Werr be -Wlevel, keeping it in sync with mandoc.1. Noted byKristaps Dzonsons2011-03-311-1/+1
| | | | Alexander Schrijver---thanks!
* Put mandocerrs and mandoclevels arrays into libmandoc with accessorsKristaps Dzonsons2011-03-281-119/+2
| | | | mparse_strerror() and mparse_strlevel().
* Make (e.g.) `SM' before `B' be only a warning. In reality, this refersKristaps Dzonsons2011-03-231-1/+1
| | | | | | | to ELINE macros ("next-line", but not unbreakable like the next-line paragraph macros) followed by other macros. This addresses a report by Christian Weisgerber, posted in the TODO by schwarze@, and aired on discuss@ (22/03/2011) for whether a fix is warranted.
* Add a FATAL error for when no manual type was assigned (you can repeatKristaps Dzonsons2011-03-221-0/+1
| | | | this for yourself by having a file consisting only of comments).
* main.c doesn't need roff.h anymore.Kristaps Dzonsons2011-03-211-1/+0
|
* Let read.c worry about the currently-open file instead of having thisKristaps Dzonsons2011-03-201-21/+1
| | | | | | information duplicated in main.c. For the time being, remove evt_close and evt_open, as the only known mparse interface (main.c) doesn't need them.
* Consolidate messages. Have all parse-time messages (in libmdoc,Kristaps Dzonsons2011-03-201-29/+8
| | | | | | | | | libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
* Split the document parsing sequence out of main.c and into read.c,Kristaps Dzonsons2011-03-201-605/+70
| | | | | | | | putting the interface into mandoc.h. This effectively makes the function of main.c be command-line handling, invoking the parser, and sending its output to the output handler. The sequence of parsing (pfile(), pdesc(), etc.) has changed very little but for clean-up of some state variables (curp->fd, etc.).
* mandocmsg finally has no return value.Kristaps Dzonsons2011-03-171-5/+3
|
* Move mandoc_{realloc,malloc,calloc} out of libmandoc.h and into mandoc.hKristaps Dzonsons2011-03-171-5/+1
| | | | | | | | so that everybody can use them. This follows the convention of libXXXX.h being internal to a library and XXXX.h being the external interface. Not only does this allow the removal of lots of redundant NULL-checking code, it also sets the tone for adding new mandoc-global routines.
* Push exit_status into struct curparse alongside file_status.Kristaps Dzonsons2011-03-161-6/+7
|
* Make lint shut up a little bit.Kristaps Dzonsons2011-03-151-1/+1
|
* Remove duplicate UNCONST definition.Kristaps Dzonsons2011-03-151-1/+0
|
* Clean-up: make file_status global be local to curparse. "I agree withKristaps Dzonsons2011-03-151-28/+27
| | | | the direction of this particular patch", schwarze@.
* Clean up date handling,Ingo Schwarze2011-03-071-1/+2
| | | | | | | | | | | | as a first step to get rid of the frequent petty warnings in this area: - always store dates as strings, not as seconds since the Epoch - for input, try the three most common formats everywhere - for unrecognized format, just pass the date though verbatim - when there is no date at all, still use the current date Originally triggered by a one-line patch from Tim van der Molen, <tbvdm at xs4all dot nl>, which is included here. Feedback and OK on manual parts from jmc@. "please check this in" kristaps@
* Consolidate "rc" value in main.c around addspan, addeqn, and parseln.Kristaps Dzonsons2011-02-091-13/+13
|
* Allow -man to process EQN as well. Also fix a segfault in missing caseKristaps Dzonsons2011-02-091-2/+5
| | | | statements in the post-handler for EQN in -mdoc and -man.