summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fatal errors no longer exist.schwarze2015-01-151-3/+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.
* Simplify by making the eqn and tbl steering functions void;schwarze2014-11-281-5/+3
| | | | no functional change, minus 15 lines of code.
* Simplify by making the mdoc parser callbacks void, and some cleanup;schwarze2014-11-281-15/+19
| | | | no functional change, minus 50 lines of code.
* Simplify the code by making various mdoc parser helper functions void.schwarze2014-11-281-26/+16
| | | | No functional change, minus 130 lines of code.
* Simplify code by making mdoc validation handlers void.schwarze2014-11-281-38/+18
| | | | No functional change, minus 90 lines of code.
* Escape sequences terminate high-level macro names, and when doing so,schwarze2014-11-191-8/+18
| | | | | | they are ignored, just in the same way as for request names and for low-level macro names. This also cures a warning in the pod2man(1) preamble.
* correct the spacing after in-line equationsschwarze2014-10-201-2/+3
| | | | | that start at the beginning of an input line but end before the end of an input line
* correct spacing before inline equationsschwarze2014-10-201-1/+3
|
* Implement in-line equations, much needed by Xenocara manuals.schwarze2014-10-161-58/+1
| | | | | | | | Put the steering into the roff parser rather than into the mdoc parser such that it works for all macro languages and on both text and macro lines. Line breaks and blank characters generated before and after in-line equations are not perfect yet, but let's do one thing at a time.
* Simplify by handling empty request lines at the one logical placeschwarze2014-09-061-10/+1
| | | | | in the roff parser instead of in three other places in other parsers. No functional change.
* Bring the handling of defective prologues even closer to groff,schwarze2014-08-081-39/+22
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* mention requests and macros in more messagesschwarze2014-08-081-3/+3
|
* Simplify: replace one global flag by one local variableschwarze2014-08-081-35/+7
| | | | and remove three unused global flags. No functional change.
* mark defos as const; nobody needs to change it,schwarze2014-07-091-2/+2
| | | | and it is occasionally useful to be able to pass literal strings
* no need to skip content before first section headerschwarze2014-07-071-22/+1
|
* Clean up messages related to plain text and to escape sequences.schwarze2014-07-061-5/+9
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,schwarze2014-07-021-1/+3
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* Clean up the warnings related to document structure.schwarze2014-07-011-3/+3
| | | | | | | | | * Hierarchical naming of the related enum mandocerr items. * Mention the offending macro, section title, or string. While here, improve some wordings: * Descriptive instead of imperative style. * Uniform style for "missing" and "skipping". * Where applicable, mention the fallback used.
* Start systematic improvements of error reporting.schwarze2014-06-201-3/+5
| | | | | | | | | | | So far, this covers all WARNINGs related to the prologue. 1) hierarchical naming of MANDOCERR_* constants 2) mention the macro name in messages where that adds clarity 3) add one missing MANDOCERR_DATE_MISSING msg 4) fix the wording of one message related to the man(7) prologue Started on the plane back from Ottawa.
* Fix a minor optimization i broke in bsd.lv rev. 1.163 on August 20, 2010:schwarze2014-04-251-2/+2
| | | | | | Do not bother looking into the hash table when the length of the macro already tells us it's invalid. No functional change. Noticed by jsg@, thanks!
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-90/+67
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Implement the roff(7) .ll (line length) request.schwarze2014-03-301-2/+2
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* If an .Nd block contains macros, avoid fragmented entries in mandocdb(8),schwarze2014-03-231-1/+41
| | | | | instead use the .Nd content recursively. Improves a couple of index entries in base.
* avoid repetitive code for asprintf error handlingschwarze2014-03-211-5/+2
|
* 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.
* Add an option -Q (quick) to mandocdb(8)schwarze2014-01-051-3/+11
| | | | | | | | | | | | | | | 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.
* Simplify: Remove an unused argument from the mandoc_eos() function.schwarze2013-12-301-2/+2
| | | | No functional change.
* When deciding whether two consecutive macros are on the same input line,schwarze2013-12-241-1/+2
| | | | | | | | we have to compare the line where the first one *ends* (not where it begins) to the line where the second one starts. This fixes the bug that .Bk allowed output line breaks right after block macros spanning more than one input line, even when the next macro follows on the same line.
* There are three kinds of input lines: text lines, macros takingschwarze2013-10-211-2/+19
| | | | | | | | | | | | | | positional arguments (like Dt Fn Xr) and macros taking text as arguments (like Nd Sh Em %T An). In the past, even the latter put each word of their arguments into its own MDOC_TEXT node; instead, concatenate arguments unless delimiters, keeps or spacing mode prevent that. Regarding mandoc(1), this is internal refactoring, no output change intended. Once we will switch mandocdb(8) from DB to SQLite in the future, this is going to be required to support search expressions crossing word boundaries, and it will reduce both database sizes and build times by a bit more than 5% each.
* Support setting arbitrary roff(7) number registers,schwarze2013-10-031-7/+5
| | | | | | | | | | | | | | | preserving read support for the ".nr nS" SYNOPSIS state register; read support for arbitrary registers is still not available. Inspired by NetBSD roff.c rev. 1.18 (Christos Zoulas, March 21, 2013), but implemented differently. I don't want to have yet another different implementation of a hash table in mandoc - it would be the second one in roff.c alone and the fifth one in mandoc grand total. Instead, i designed and implemented roff_setreg() and roff_getreg() to be similar to roff_setstrn() and roff_getstrn(). Once we feel the need to optimize, we can introduce one common hash table implementation for everything in mandoc.
* Cleanup naming of local variables to make the code easier on the eye:schwarze2012-11-171-141/+141
| | | | | | | | Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta" and avoid the confusing "*m" which was sometimes this, sometimes that. No functional change. ok kristaps@ some time ago
* Fix a crash triggered by .Bl -tag .It Xo .El .Sh found by florian@.schwarze2012-11-161-1/+4
| | | | | | | | | | | * When allocating a body end marker, copy the pointer to the normalized block information from the body block, avoiding the risk of subsequent null pointer derefence. * When inserting the body end marker into the syntax tree, do not try to copy that pointer from the parent block, because not being a direkt child of the block it belongs to is the whole point of a body end marker. * Even non-callable blocks (like Bd and Bl) can break other blocks; when this happens, postpone closing them out in the usual way.
* Fix handling of paragraph macros inside lists:schwarze2012-07-181-2/+10
| | | | | | | | * When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. Improves formatting of 40 pages, e.g. grep(1), ksh(1), netstat(1), ath(4), bsd.port.mk(5), pf.conf(5), mount(8), crypto(9).
* The mdoc(7) \*(Ba predefined string actually forces roman font;schwarze2012-07-181-2/+2
| | | | | | | | | | | | | that's stupid because it may break enclosing font changes, but let's do the same for groff bug compatibility. --> Never use \*(Ba, use just plain "|"! <-- Also, predefined strings are already expanded by the roff(7) parser, so the mdoc(7) parser has to look for the expanded string. Formatting improvements in ksh(1), less(1), atan2(3), hostapd.conf(5), snmpd.conf(5), and mknod(8).
* Several -mdoc parser improvements related to vertical spacing:schwarze2012-07-161-2/+3
| | | | | | | | | * So far, .Pp and .Lp were removed before paragraph type blocks. * Now also remove .br before paragraph type blocks. * Treat .Lp as a paragraph like .Pp, so remove .Pp, .Lp, .br before it. * Do not treat .sp as a paragraph, don't remove anything before it. * After .Sh, .Ss, .Pp, and .Lp, remove .Pp, .Lp, .sp, .br, and blank lines. * After .sp and .br, remove .br.
* Support the .cc request; code by kristaps@, tests by me.schwarze2012-07-071-2/+2
| | | | Needed for sqlite3(1) as reported by espie@.
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theschwarze2012-05-241-2/+3
| | | | | | | | 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.
* implement .Ap .Bd .Bo .Bq .D1 .Ic .Lp .Oo .Pf .Po .Ss .Sx .Sy .br .spschwarze2011-09-301-1/+2
| | | | | | | | implement .Bl -bullet add more information to the .TH line escape dots at the beginnings of lines add trailing newline character at the end of the file do not misinterpret the ROOT block as .Ap
* sync to version 1.11.7 from kristaps@schwarze2011-09-181-14/+2
| | | | | | | | main new feature: support the roff(7) .tr request plus various bugfixes and some refactoring regressions are so minor that it's better to get this in and fix them in the tree
* sync to version 1.11.5:schwarze2011-09-181-7/+63
| | | | | | | | adding an implementation of the eqn(7) language by kristaps@ So far, only .EQ/.EN blocks are handled, in-line equations are not, and rendering is not yet very pretty, but the parser is fairly complete.
* Merge version 1.11.1:schwarze2011-04-241-64/+76
| | | | | | | | | | | | | | 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-3/+5
| | | | | | | | | | 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-1/+25
| | | | | | | | 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.
* Clean up date handling,schwarze2011-03-071-3/+4
| | | | | | | | | | | | 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@
* Tbl code maintenance by kristaps@.schwarze2011-02-101-24/+11
| | | | | | - Remember the line-number of a tbl_span, and use it in messages. - Put *_span_alloc() functions right into the *_addspan() ones, since these are the only places they are called from.
* Make sure coding errors cannot make us miss fatal parsing errorsschwarze2011-01-091-10/+9
| | | | | by assert(3)ing valid parser state in the main parsing functions; from kristaps@.
* Merge kristaps@' cleaner tbl integration, removing mine;schwarze2011-01-041-25/+41
| | | | there are still a few bugs, but fixing these will be easier in tree.
* Clean up {mdoc,man}_{p,v}msg invocations:schwarze2011-01-011-15/+17
| | | | | Ignore the return values, they are constant anyway. From kristaps@.
* Reorg by Kristaps: In libmdoc, replace the union of pointers to structsschwarze2010-12-291-29/+53
| | | | | | | of macro-specific data by a pointer to a union of structs, which makes the code simpler and more robust at the expense of a small memory overhead. Merging was somewhat difficult because we mustn't break tbl(1) support which the bsd.lv version does not yet have.
* Behave more like groff (both old and new): Specifying both .%T and .%J inschwarze2010-12-261-1/+4
| | | | | | an .Rs block causes the title to be quoted instead of underlined, such that journal title and article title appear visually different. Original diff from kristaps@, simplified by me, tweaked again by kristaps@.