summaryrefslogtreecommitdiffstats
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Allow EQN data to be pushed down into libmdoc via mdoc_addeqn(). OnlyKristaps Dzonsons2011-02-091-0/+3
| | | | the adding itself is implemented; equation data is not yet shown.
* Add initial EQN support to mandoc. This parses, then throws away, dataKristaps Dzonsons2011-02-061-0/+2
| | | | | | | | between EQ and EN roff blocks. EQN is different from TBL in that data after .EQ is unilaterally considered an equation until an .EN. Thus, there's no need to jump through hoops in having table spans and so on. This is ONLY the parse code framework in libroff. EQN is not yet passed into the backends.
* If `Ns' is specified on its own line, it should be ignored. This isKristaps Dzonsons2011-02-021-0/+1
| | | | | shitty groff behaviour. Do the same, but raise a warning to this effect. This from a TODO noted by schwarze@.
* Since tbl_data() can now produce multiple spans, let parsebuf()Ingo Schwarze2011-01-251-5/+7
| | | | | | | generate man(7) or mdoc(7) nodes for all these spans, not only for the last one. Restores the horizontal lines in the cpu(4/hppa) tables. ok kristaps@
* Skip carriage return before newline, if any.Ingo Schwarze2011-01-241-3/+20
| | | | | | As pointed out by Joerg Sonnenberger, this is useful because we use mmap(3) and look for '\n' by hand. "check it in" kristaps@
* When finding the roff .it request (line trap),Ingo Schwarze2011-01-221-1/+1
| | | | | make it clear that you cannot use mandoc to format that page (yet). Triggered by a report from brad@, ok kristaps@.
* Make out-of-context `fi' invocations not cause an error, but just aKristaps Dzonsons2011-01-121-0/+1
| | | | warning. From a TODO by schwarze@, originally noted by Brad Smith.
* Refactoring in preparation for .rm support:Ingo Schwarze2011-01-111-0/+1
| | | | | | | | | | Unify parsing of names given as roff request arguments into a new function roff_getname(), which is rather different from the parsing function for normal arguments, mandoc_getarg(), because names cannot be quoted and cannot contain whitespace or escaped characters. The new function now throws an ERROR when finding escaped characters in a name. "I'm fine with this." kristaps@
* First, make extra data cells be thrown away. This makes "dp->layout"Kristaps Dzonsons2011-01-101-3/+1
| | | | | | | | | | | | always hold, which cleans up the table stuff a bit. Second, set a "spans" value per data cell consisting of the number of skipped TBL_CELL_SPAN layout cells. Third, make tbl_term.c understand how to skip over spanned sections when iterating over the header queue. What remains is to calculate the widths of spanned cells.
* Support `T{' and `T}' data blocks. When a standalone `T{' isKristaps Dzonsons2011-01-041-0/+1
| | | | | | | encountered as a line's last data cell, move into TBL_PART_CDATA mode whilst leaving the cell's designation as TBL_DATA_NONE. When new data arrives that's not a standalone `T}', append it to the cell contends. Close out and warn appropriately.
* Fix to make horizontal spanners in the layout be properly printed.Kristaps Dzonsons2011-01-041-0/+2
| | | | | | | mandoc also now warns (so does tbl(1)) if a horizontal spanner is specified along with data. While here, fix up some documentation and uncomment the tbl reference.
* Partial cleanup of argument count validation in mdoc(7):Ingo Schwarze2011-01-031-1/+2
| | | | | | | | | | | | * Do not segfault on empty .Db, .Rs, .Sm, and .St. * Let check_count() really throw the requested level, not always ERROR. * Downgrade most bad argument counts from ERROR to WARNING. * And some related internal cleanup. Looks fine to kristaps@. Note that the macros using eerr_ge1() still need to be checked at a later time; but as all the others are done, let's use what we already have.
* Make sure we don't continue recursively parsing once we've exited withKristaps Dzonsons2011-01-031-0/+8
| | | | | failure (this had caused some segfaults with the new assert() call in MAN_HALT and MDOC_HALT).
* Add a warning if a data cell has no layout. Also make -Ttree show thisKristaps Dzonsons2011-01-011-0/+4
| | | | with a little star next to the entry (yeah, this is mostly for testing).
* More checks for proper table exit.Kristaps Dzonsons2011-01-011-4/+1
|
* Add documentation bits for libroff's new roff_span().Kristaps Dzonsons2011-01-011-0/+1
| | | | | | Add bits to remember tbl's invocation point. Add ERROR class message if no data's in the table.