summaryrefslogtreecommitdiffstats
path: root/read.c
Commit message (Collapse)AuthorAgeFilesLines
* First step towards parser unification:Ingo Schwarze2015-04-021-4/+5
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* When the user exits the pager before the pager has drained all inputIngo Schwarze2015-03-171-0/+2
| | | | | | | | from man(1), man(1) dies from SIGPIPE. Exiting man(1) is fine in this case, generating more output would be pointless, but without handling SIGPIPE, the exit code from man(1) was wrong and csh(1) printed an ugly message "Broken pipe". Fix this by handling SIGPIPE explicitly. Issue noticed by deraadt@.
* Fix previous: size_t is often narrower than off_t.Ingo Schwarze2015-03-111-1/+1
| | | | Cluestick applied by joerg at NetBSD.
* The st_size member of struct stat is off_t, which is signed,Ingo Schwarze2015-03-101-1/+1
| | | | | all required by POSIX. So don't compare it against against an unsigned constant.
* If a non-gz manual is read after a gzipped manual, refrainIngo Schwarze2015-03-021-0/+1
| | | | | | from throwing a bogus error "wait: No child processes". As reported by Baptiste Daroussin <bapt at FreeBSD dot org>, clearing the state variable curp->child after use was forgotten.
* improve NAME section diagnostics;Ingo Schwarze2015-02-231-1/+4
| | | | confusing messages reported by Jan Stary <hans at stare dot cz>
* Completely delete all carriage return characters from the input.Ingo Schwarze2015-02-201-1/+2
| | | | | | | No change to messages about them (ignore them right before line feeds, report errors elsewhere). naddy@ found a manual in the wild containing lots of these (ysm(1)), and i can't imagine a situation where dropping them could be problematic.
* replace the last legacy generic message type, "argument count wrong",Ingo Schwarze2015-02-061-1/+2
| | | | by more specific messages, improving diagnostics for .cc .tr .Bl -column
* better error reporting regarding .OP .RS .UR .TH argumentsIngo Schwarze2015-02-061-0/+2
|
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze2015-02-061-1/+1
| | | | | replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
* better handle .Fo and .Fd without argumentIngo Schwarze2015-02-061-0/+1
| | | | better handle .Fo with more than one argument
* discard .Rs head arguments and improve .Rs diagnosticsIngo Schwarze2015-02-041-0/+1
|
* more specific .Nd diagnostics, allowing to get rid of enum check_lvlIngo Schwarze2015-02-041-0/+1
| | | | and the respective argument of check_count()
* Clean up eqn(7) error handling:Ingo Schwarze2015-01-281-6/+0
| | | | | | | | * When "define" fails, do not drop the whole equation. * Free memory after "undef". * Use standard mandoc error types instead of rolling our own. * Delete obfuscating EQN_MSG() macro. * Add function prototypes while here.
* * Polish tbl(7) error reporting.Ingo Schwarze2015-01-281-5/+5
| | | | | | * Do not print out macro names in tbl(7) data blocks. * Like with GNU tbl, let empty tables cause a blank line. * Avoid producing empty tables in -Tman.
* Rework tbl(7) layout parsing:Ingo Schwarze2015-01-261-2/+9
| | | | | | | | | | | * Continue parsing even if part of the input is invalid. * Do not require whitespace between cell specifications. * Allow tabs as well as blanks between modifiers. * Mark the 'm' modifier as unsupported. * Parse and ignore the 'p' and 'v' modifiers. * Better warning and error messages. * Get rid of a static buffer. Improved functionality but minus 50 lines of code.
* More improvements regarding tbl(7) options.Ingo Schwarze2015-01-261-0/+1
| | | | | | | | | * Treat "allbox" as an alias for "box" for now. * Parse and ignore the GNU tbl "nowarn" option. * For separation, allow spaces, tabs, and commas only. * Mark eqn(7) within tbl(7) as unsupported. * Simplify the option table. * Improve and sort documentation.
* Improve (or rather, rewrite) tbl(7) option parsing.Ingo Schwarze2015-01-261-2/+4
| | | | | | | | | | | | * Allow the layout to start after the semicolon on the options line. * Ignore leading commas. * Option arguments cannot contain closing parentheses. * Avoid needless UNSUPP messages. * Better ERROR reporting. * Delete unused "linesize" field in struct tbl_opts. * No need for static buffers. * Garbage collect one almost empty wrapper function. Improved functionality, but minus 40 lines of code.
* Support .RE with an argument; needed for audio/pms(1).Ingo Schwarze2015-01-241-0/+1
|
* Traditional roff(7) explicitly allows certain control charactersIngo Schwarze2015-01-221-6/+8
| | | | | | | in the input stream (SOH, STX, ETX, ENQ, ACK, BEL, BS) for specific purposes (leaders, backspace, delimiters, .tr), but making sure these don't leak through to the output is tricky, so mark them as unsupported for now.
* Don't let a failing mparse_open() clobber the filename pointer;Ingo Schwarze2015-01-221-2/+6
| | | | | fixes error message content and a use after free for .so with non-existent target when -Wall or -Tlint is given.
* Split the -Werror message level into -Werror (broken manual, probablyIngo Schwarze2015-01-201-8/+12
| | | | | | | | | | | | | using mandoc is better than using groff) and -Wunsupp (manual using unsupported low-level roff(7) feature, probably using groff is better than using mandoc). Once this feature is complete, it is intended to help porting, making the decision whether to USE_GROFF easier. As a first step, distinguish four classes of roff(7) requests: 1. Supported (currently 24 requests) 2. Currently ignored because unimportant (120) -> no message 3. Ignored for good because insecure (14) -> -Werror 4. Currently unsupported (68) -> these trigger the new -Wunsupp messages
* Fatal errors no longer exist.Ingo Schwarze2015-01-151-40/+11
| | | | | | 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-15/+17
|
* downgrade ".so with absolute path" from FATAL to ERROR;Ingo Schwarze2015-01-141-4/+1
| | | | allows to get rid of ROFF_ERR
* To get rid of SYSERR entries in enum mandocerr, downgrade problems withIngo Schwarze2015-01-141-31/+14
| | | | | | 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-34/+15
| | | | | 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-3/+6
| | | | | | 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-0/+1
| | | | | 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-3/+2
| | | | | | | 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-0/+1
| | | | | | | * 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-0/+1
| | | | inspired by a similar warning in the groff_mdoc(7) macros
* Drop useless architecture table. Validating architecture namesIngo Schwarze2014-11-281-1/+0
| | | | | | 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-29/+16
| | | | no functional change, minus 15 lines of code.
* Downgrade .Bd -file from FATAL to ERROR.Ingo Schwarze2014-11-271-1/+1
| | | | | 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-22/+42
| | | | | | | | 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-7/+10
| | | | | 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-2/+1
| | | | | | 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-37/+31
| | | | | | 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-3/+5
| | | | | | | | 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-19/+52
| | | | 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-0/+1
|
* plug file descriptor leaks on read or write failure;Ingo Schwarze2014-10-181-11/+9
| | | | hinted at by Steffen Nurpmeso <sdaoden at yandex dot com>.
* Improve error handling in the eqn(7) parser.Ingo Schwarze2014-10-121-1/+1
| | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | | 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-0/+1
|
* warn about botched .Xr ordering and punctuation below SEE ALSO;Ingo Schwarze2014-09-111-0/+2
| | | | inspired by mdoclint(1)
* warn about AUTHORS sections without .An macros, inspired by mdoclint(1)Ingo Schwarze2014-09-071-0/+1
|
* always use the right buffer, and fix one evil typoIngo Schwarze2014-09-071-1/+4
|
* Simplify by handling empty request lines at the one logical placeIngo Schwarze2014-09-061-15/+4
| | | | | in the roff parser instead of in three other places in other parsers. No functional change.