aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
Commit message (Collapse)AuthorAgeFilesLines
* Fatal errors no longer exist.Ingo Schwarze2015-01-151-41/+12
| | | | | | 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.
* downgrade .so failure from FATAL to ERRORIngo Schwarze2015-01-151-16/+18
|
* downgrade ".so with absolute path" from FATAL to ERROR;Ingo Schwarze2015-01-141-5/+2
| | | | allows to get rid of ROFF_ERR
* To get rid of SYSERR entries in enum mandocerr, downgrade problems withIngo Schwarze2015-01-141-32/+15
| | | | | | missing and unreadable files from SYSERR to ERROR. Needed for upcoming work. As a bonus, this minimally simplifies code and documentation.
* Simplify handling of system errors: just exit(3).Ingo Schwarze2015-01-141-35/+16
| | | | | We already do the same for malloc(3) failure. The is no virtue in trying to survive failure of fork(2) and the like.
* mdoc(7) already uses the mandoc(1) -Ios argument in the footer lineIngo Schwarze2014-12-281-4/+7
| | | | | | 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>.
* Ignore mdoc(7) and man(7) macros inside tbl(7) code because theyIngo Schwarze2014-12-161-1/+2
| | | | | would abort the table in an unclean way, causing assertion failures found by jsg@.
* The file read.c is part of the parser, so it cannot include main.h,Ingo Schwarze2014-12-011-4/+3
| | | | | | | which is not part of the parser. Besides, the parser *does* modify the input buffer, so marking it "const" in the mparse_readmem() interface is an outright lie. Fix all this by killing the const, the UNCONST, and the bogus inclusion.
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-1/+2
| | | | | | | * 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.
* warn about attempts to call non-callable macros;Ingo Schwarze2014-11-301-1/+2
| | | | inspired by a similar warning in the groff_mdoc(7) macros
* Drop useless architecture table. Validating architecture namesIngo Schwarze2014-11-281-2/+1
| | | | | | 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@.
* Simplify by making the eqn and tbl steering functions void;Ingo Schwarze2014-11-281-30/+17
| | | | no functional change, minus 15 lines of code.
* Downgrade .Bd -file from FATAL to ERROR.Ingo Schwarze2014-11-271-2/+2
| | | | | Since this was the last remaining FATAL error in this area, this change will allow major simplifications in the mdoc(7) parser.
* Let mparse_readfd() use mparse_open() and mparse_wait()Ingo Schwarze2014-11-261-23/+43
| | | | | | | | 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.
* Simplify the mparse_open()/mparse_wait() interface.Ingo Schwarze2014-11-261-8/+11
| | | | | Don't bother the user with the PID of the child process, store it inside the opaque mparse handle.
* Use struct buf in libroff, it is very natural thereIngo Schwarze2014-11-011-3/+2
| | | | | | and reduces the number of arguments of many functions. While here, sprinkle some KNF. No functional change.
* Refactor, no functional change: Remove the parse point from struct buf.Ingo Schwarze2014-11-011-38/+32
| | | | | | 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.
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-4/+6
| | | | | | | | 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.
* integrate preconv(1) into mandoc(1);Ingo Schwarze2014-10-251-20/+53
| | | | enhances functionality and reduces code and docs by more than 300 lines
* Protect the roff parser from dividing by zero. ok schwarze@Kristaps Dzonsons2014-10-201-1/+2
|
* plug file descriptor leaks on read or write failure;Ingo Schwarze2014-10-181-12/+10
| | | | hinted at by Steffen Nurpmeso <sdaoden at yandex dot com>.
* Improve error handling in the eqn(7) parser.Ingo Schwarze2014-10-121-2/+2
| | | | | | | | | | | | | | | | | | | 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.
* warn about parentheses in function names after .Fn and .Fo;Ingo Schwarze2014-10-111-1/+2
| | | | | particularly useful when converting from other languages to mdoc(7); feature suggested by bentley@
* warn about commas in function arguments; inspired by mdoclint(1)Ingo Schwarze2014-09-121-1/+2
|
* warn about botched .Xr ordering and punctuation below SEE ALSO;Ingo Schwarze2014-09-111-1/+3
| | | | inspired by mdoclint(1)
* warn about AUTHORS sections without .An macros, inspired by mdoclint(1)Ingo Schwarze2014-09-071-1/+2
|
* always use the right buffer, and fix one evil typoIngo Schwarze2014-09-071-2/+5
|
* Simplify by handling empty request lines at the one logical placeIngo Schwarze2014-09-061-16/+5
| | | | | in the roff parser instead of in three other places in other parsers. No functional change.
* Move main format autodetection from the parser dispatcher to theIngo Schwarze2014-09-061-27/+42
| | | | | | | | | | | 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.
* Add *.gz support to apropos(1) -a, man(1), and even mandoc(1).Ingo Schwarze2014-09-031-3/+96
| | | | Implemented by moving the zip code from makewhatis(8) to the parser lib.
* Improve build system and autodetection.Ingo Schwarze2014-08-161-4/+4
| | | | | | | | | * Make ./configure standalone, that's what people expect. * Let people write a ./configure.local from scratch, not edit existing files. * Autodetect wchar, sqlite3, and manpath and act accordingly. * Autodetect the need for -L/usr/local/lib and -lutil. * Get rid of config.h.p{re,ost}, let ./configure only write what's needed. * Let ./configure write a Makefile.local snippet, that's quite flexible.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-5/+4
| | | | | | 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.
* Bring the handling of defective prologues even closer to groff,Ingo Schwarze2014-08-061-5/+8
| | | | | | | | | | | | 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 messagesIngo Schwarze2014-08-011-9/+9
|
* Dynamically allocate the stack of roff(7) .ie condition valuesIngo Schwarze2014-08-011-2/+1
| | | | and thus get rid of the last useless fatal error.
* Split MANDOCERR_IGNARGV into one message for .An and one for .BlIngo Schwarze2014-07-311-2/+3
| | | | and report the macro name and argument.
* In .Bl -column, if some of the column width declarations are givenIngo Schwarze2014-07-311-2/+1
| | | | | | | | | | | | | 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 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.
* Remove the useless FATAL error "argument count wrong, violates syntax".Ingo Schwarze2014-07-301-2/+1
| | | | | | 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.
* Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze2014-07-301-2/+2
| | | | | When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out.
* Remove two useless FATAL errors.Ingo Schwarze2014-07-301-18/+22
| | | | | 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.
* better name and wording for the last two non-generic errorsIngo Schwarze2014-07-301-4/+4
|
* Various improvements related to .Ex and .Rv:Ingo Schwarze2014-07-301-2/+3
| | | | | | | | | | * 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
* mark defos as const; nobody needs to change it,Ingo Schwarze2014-07-091-3/+3
| | | | and it is occasionally useful to be able to pass literal strings
* Clean up ERROR messages related to document structure and macros:Ingo Schwarze2014-07-071-6/+9
| | | | Hierarchical naming and mention macro names in messages.
* no need to delete any content from .Rs blocks,Ingo Schwarze2014-07-071-2/+2
| | | | and downgrade the related message from ERROR to WARNING
* no need to skip content before first section headerIngo Schwarze2014-07-071-2/+1
|
* implement .dei and .amiIngo Schwarze2014-07-071-2/+1
|
* Clean up messages related to plain text and to escape sequences.Ingo Schwarze2014-07-061-6/+7
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Cleanup with respect to bad macro arguments.Ingo Schwarze2014-07-051-7/+6
| | | | | | | | * 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.
* Cleanup regarding -offset and -width:Ingo Schwarze2014-07-051-1/+2
| | | | | | | * 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().