summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/read.c
AgeCommit message (Collapse)Author
2014-12-28mdoc(7) already uses the mandoc(1) -Ios argument in the footer lineIngo Schwarze
when .Os has no argument, so do the same for man(7) when .TH has less than four arguments; there is no reason to treat both differently. Issue found following a question from Thomas Klausner <wiz at NetBSD>.
2014-12-16Ignore mdoc(7) and man(7) macros inside tbl(7) code because theyIngo Schwarze
would abort the table in an unclean way, causing assertion failures found by jsg@.
2014-11-30Multiple fixes with respect to .Pf:Ingo Schwarze
* The first argument of .Pf is not parsed. * Normal delimiter handling does not apply to the first argument of .Pf. * Warn if nothing follows a prefix (inspired by groff_mdoc(7)). * In that case, do not suppress spacing.
2014-11-30warn about attempts to call non-callable macros;Ingo Schwarze
inspired by a similar warning in the groff_mdoc(7) macros
2014-11-28Drop useless architecture table. Validating architecture namesIngo Schwarze
is a job for makewhatis(8)/mandoc.db(5), not for the parser. Removes 150 lines from source files and 4k (1%) from the binary. Bloat found by deraadt@.
2014-11-28Simplify by making the eqn and tbl steering functions void;Ingo Schwarze
no functional change, minus 15 lines of code.
2014-11-27Downgrade .Bd -file from FATAL to ERROR.Ingo Schwarze
Since this was the last remaining FATAL error in this area, this change will allow major simplifications in the mdoc(7) parser.
2014-11-26Let mparse_readfd() use mparse_open() and mparse_wait()Ingo Schwarze
and let mparse_open() fall back to .gz files such that .so works even when the target is zipped, requested by and in part using ideas from <bapt at FreeBSD>. While here, make sure files are readable before forking, both for efficiency and for better error reporting.
2014-11-26Simplify the mparse_open()/mparse_wait() interface.Ingo Schwarze
Don't bother the user with the PID of the child process, store it inside the opaque mparse handle.
2014-11-01Use struct buf in libroff, it is very natural thereIngo Schwarze
and reduces the number of arguments of many functions. While here, sprinkle some KNF. No functional change.
2014-11-01Refactor, no functional change: Remove the parse point from struct buf.Ingo Schwarze
Some functions need multiple parse points, some none at all, and it varies whether any of them need to be passed around. So better pass them as a separate argument, and only when needed.
2014-10-30support UTF-8 and ISO-8859-1 input by integrating modified partsIngo Schwarze
of kristaps@' version of the preconv(1) utility into mandoc(1); positive feedback from bentley@ and no concern raised when shown on tech@
2014-10-28Make the character table available to libroff so it can check theIngo Schwarze
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.
2014-10-20protect the roff parser from dividing by zero;Ingo Schwarze
issue found and patch written by kristaps@
2014-10-18plug file descriptor leaks on read or write failure;Ingo Schwarze
hinted at by Steffen Nurpmeso <sdaoden at yandex dot com>.
2014-10-12Improve error handling in the eqn(7) parser.Ingo Schwarze
Get rid of the first fatal error, MANDOCERR_EQNSYNT. In eqn(7), there is no need to be bug-compatible with groff, so there is no need to abondon the whole equation in case of a syntax error. In particular: * Skip "back", "delim", "down", "fwd", "gfont", "gsize", "left", "right", "size", and "up" without arguments. * Skip "gsize" and "size" with a non-numeric argument. * Skip closing delimiters that are not open. * Skip "above" outside piles. * For diacritic marks and binary operators without a left operand, default to an empty box. * Let piles and matrices take one argument rather than insisting on a braced list. Let HTML output handle that, too. * When rewinding, if the root box is guaranteed to match the termination condition, no error handling is needed.
2014-10-11warn about parentheses in function names after .Fn and .Fo;Ingo Schwarze
particularly useful when converting from other languages to mdoc(7); feature suggested by bentley@
2014-09-12warn about commas in function arguments; inspired by mdoclint(1)Ingo Schwarze
2014-09-11warn about botched .Xr ordering and punctuation below SEE ALSO;Ingo Schwarze
inspired by mdoclint(1)
2014-09-07warn about AUTHORS sections without .An macros, inspired by mdoclint(1)Ingo Schwarze
2014-09-07always use the right buffer, and fix one evil typoIngo Schwarze
2014-09-06Simplify by handling empty request lines at the one logical placeIngo Schwarze
in the roff parser instead of in three other places in other parsers. No functional change.
2014-09-06Move main format autodetection from the parser dispatcher to theIngo Schwarze
roff parser where .Dd and .TH are already detected, anyway. This improves robustness because it correctly handles whitespace or an alternate control character before Dd. In the parser dispatcher, provide a fallback looking ahead in the input buffer instead of always assuming man(7). This corrects autodetection when Dd is preceded by other macros or macro-like handled requests like .ll. Triggered by reports from Daniel Levai about issues on Slackware Linux.
2014-09-03Add *.gz support to apropos(1) -a, manm(1), and even mandoc(1).Ingo Schwarze
Implemented by moving the zip code from makewhatis(8) to the parser lib.
2014-08-08Bring the handling of defective prologues even closer to groff,Ingo Schwarze
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.
2014-08-08mention requests and macros in more messagesIngo Schwarze
2014-08-08Dynamically allocate the stack of roff(7) .ie condition valuesIngo Schwarze
and thus get rid of the last useless fatal error.
2014-08-08Split MANDOCERR_IGNARGV into one message for .An and one for .BlIngo Schwarze
and report the macro name and argument.
2014-08-08In .Bl -column, if some of the column width declarations are givenIngo Schwarze
right after the -column argument and some at the very end of the argument list, after some other arguments like -compact, concatenate the column lists. This gets rid of one of the last useless FATAL errors and actually shortens the code by a few lines. This fixes an issue introduced more than five years ago, at first causing an assert() since bsd.lv mdoc_action.c rev. 1.14 (June 17, 2009), then later a FATAL error since mdoc_validate rev. 1.130 (Nov. 30, 2010), and marked as "TODO" ever since.
2014-08-08Remove the useless FATAL error "argument count wrong, violates syntax".Ingo Schwarze
The last remaining instance was .It in .Bl -column with more than one excessive .Ta. However, simply downgrading from FATAL to ERROR, it just works fine, almost the same way as in groff, without any other changes.
2014-08-08Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze
When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out.
2014-08-08Remove two useless FATAL errors.Ingo Schwarze
When a file contains neither text nor macros, treat it as an empty document. When the mdoc(7) document prologue is incomplete, use some default values.
2014-08-08better name and wording for the last two non-generic errorsIngo Schwarze
2014-08-08Various improvements related to .Ex and .Rv:Ingo Schwarze
* let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
2014-07-09mark defos as const; nobody needs to change it,Ingo Schwarze
and it is occasionally useful to be able to pass literal strings
2014-07-07Clean up ERROR messages related to document structure and macros:Ingo Schwarze
Hierarchical naming and mention macro names in messages.
2014-07-07no need to delete any content from .Rs blocks,Ingo Schwarze
and downgrade the related message from ERROR to WARNING
2014-07-07no need to skip content before first section headerIngo Schwarze
2014-07-07implement .dei and .amiIngo Schwarze
2014-07-06Clean up messages related to plain text and to escape sequences.Ingo Schwarze
* Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
2014-07-05Cleanup with respect to bad macro arguments.Ingo Schwarze
* Fix .Sm with invalid arg: move arg out and toggle mode. * Promote "unknown standard" from WARNING to ERROR, it loses information. * Delete MANDOCERR_BADWIDTH, it would only indicate a mandoc(1) bug. * Do not report MANDOCERR_BL_LATETYPE when there is no type at all. * Mention macro names, arguments and fallbacks.
2014-07-05Cleanup regarding -offset and -width:Ingo Schwarze
* Bugfix: Last one wins, not first one. * Fix .Bl -width without argument: it means 0n, so do not ignore it. * Report macro names, argument names and fallbacks in related messages. * Simplify: Garbage collect auxiliary variables in pre_bd() and pre_bl().
2014-07-04Clean up messages regarding excess arguments:Ingo Schwarze
* Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming. Also fix the handling of excess .It head arguments in -Tman.
2014-07-04Clean up messages related to missing arguments.Ingo Schwarze
* Do not warn about empty -column cells, they seem valid to me. * Downgrade empty item and missing -std from ERROR to WARNING. * Hierarchical naming. * Descriptive, not imperative style. * Mention macro names, argument names, and fallbacks. * Garbage collect some unreachable code in post_it().
2014-07-03Fix formatting of empty .Bl -inset item heads.Ingo Schwarze
Downgrade empty item heads from ERROR to WARNING. Show the list type in the error message. Choose better variable names for nodes in post_it().
2014-07-03MANDOCERR_NOARGS reported three completely unrelated classes of problems.Ingo Schwarze
Split the roff(7) parts out of it and report the request names for these cases.
2014-07-02Disentangle the MANDOCERR_CHILD message, which reported threeIngo Schwarze
completely different things, into three distinct messages. Also mention the macro names we are talking about.
2014-07-02Clean up warnings related to macros and nesting.Ingo Schwarze
* Hierarchical naming of enum mandocerr items. * Improve the wording to make it comprehensible. * Mention the offending macro. * Garbage collect one chunk of ancient, long unreachable code.
2014-07-02Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze
since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
2014-07-01Clean up the warnings related to document structure.Ingo Schwarze
* 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.