summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/read.c
AgeCommit message (Collapse)Author
2015-10-11Finally use __progname, err(3) and warn(3).Ingo Schwarze
That's more readable and less error-prone than fumbling around with argv[0], fprintf(3), strerror(3), perror(3), and exit(3). It also shortens the code by 50 lines. It's a bad idea to boycott good interfaces merely because standards committees ignore them. Instead, it's the job of the portable distribution to provide compatibility modules for archaic systems (like commercial Solaris) that still don't have them. Actually, the compat code for the portable distribution already exists and will be committed right after this.
2015-10-06modernize style: "return" is not a function; ok cmp(1)Ingo Schwarze
2015-09-14Remove the warning about children of .Vt blocks because actually,Ingo Schwarze
.Vt type global_variable No = Dv defined_constant ; is the best way to specify in the SYNOPSIS how a global variable is initialized in the rare case where that matters. Issue noticed by jmc@.
2015-07-19Do not fork and exec gunzip(1), just link with libz instead.Ingo Schwarze
As discussed with deraadt@, that's cleaner and will help tame(2). Something like this was also suggested earlier by bapt at FreeBSD. Minus 50 lines of code, deleting one interface function (mparse_wait), no functional change intended.
2015-04-19Unify some node handling functions that use TOKEN_NONE.Ingo Schwarze
* mdoc_word_alloc(), man_word_alloc() -> roff_word_alloc() * mdoc_word_append(), man_word_append() -> roff_word_append() * mdoc_addspan(), man_addspan() -> roff_addtbl() * mdoc_addeqn(), man_addeqn() -> roff_addeqn() Minus 50 lines of code, no functional change.
2015-04-19Decouple the token code for "no request or macro" from the individualIngo Schwarze
high-level parsers to allow further unification of functions that only need to recognize this code, but that don't care about different high-level macrosets beyond that.
2015-04-18Unify {mdoc,man}_{alloc,reset,free}() into roff_man_{alloc,reset,free}().Ingo Schwarze
Minus 80 lines of code, no functional change. Written on the train from Koeln to Wolfsburg returning from p2k15.
2015-04-18Move mdoc_hash_init() and man_hash_init() to libmandoc.hIngo Schwarze
and call them from mparse_alloc() and choose_parser(), preparing unified allocation of struct roff_man.
2015-04-18Profit from the unified struct roff_man and reduce the number ofIngo Schwarze
arguments of mparse_result() by one. No functional change. Written on the ICE Bruxelles-Koeln on the way back from p2k15.
2015-04-18Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze
Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
2015-04-02First step towards parser unification:Ingo Schwarze
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.
2015-03-17When the user exits the pager before the pager has drained all inputIngo Schwarze
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@.
2015-03-11Fix previous: size_t is often narrower than off_t.Ingo Schwarze
Cluestick applied by joerg at NetBSD.
2015-03-10The st_size member of struct stat is off_t, which is signed,Ingo Schwarze
all required by POSIX. So don't compare it against against an unsigned constant.
2015-03-02If a non-gz manual is read after a gzipped manual, refrainIngo Schwarze
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.
2015-02-23improve NAME section diagnostics;Ingo Schwarze
confusing messages reported by Jan Stary <hans at stare dot cz>
2015-02-20Completely delete all carriage return characters from the input.Ingo Schwarze
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.
2015-02-06replace the last legacy generic message type, "argument count wrong",Ingo Schwarze
by more specific messages, improving diagnostics for .cc .tr .Bl -column
2015-02-06better error reporting regarding .OP .RS .UR .TH argumentsIngo Schwarze
2015-02-06Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze
replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
2015-02-06better handle .Fo and .Fd without argumentIngo Schwarze
better handle .Fo with more than one argument
2015-02-04discard .Rs head arguments and improve .Rs diagnosticsIngo Schwarze
2015-02-04more specific .Nd diagnostics, allowing to get rid of enum check_lvlIngo Schwarze
and the respective argument of check_count()
2015-01-28Clean up eqn(7) error handling:Ingo Schwarze
* 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.
2015-01-28* Polish tbl(7) error reporting.Ingo Schwarze
* 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.
2015-01-26Rework tbl(7) layout parsing:Ingo Schwarze
* 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.
2015-01-26More improvements regarding tbl(7) options.Ingo Schwarze
* 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.
2015-01-26Improve (or rather, rewrite) tbl(7) option parsing.Ingo Schwarze
* 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.
2015-01-24Support .RE with an argument; needed for audio/pms(1).Ingo Schwarze
2015-01-22Traditional roff(7) explicitly allows certain control charactersIngo Schwarze
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.
2015-01-22Don't let a failing mparse_open() clobber the filename pointer;Ingo Schwarze
fixes error message content and a use after free for .so with non-existent target when -Wall or -Tlint is given.
2015-01-20Split the -Werror message level into -Werror (broken manual, probablyIngo Schwarze
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
2015-01-15Fatal errors no longer exist.Ingo Schwarze
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.
2015-01-15downgrade .so failure from FATAL to ERRORIngo Schwarze
2015-01-14downgrade ".so with absolute path" from FATAL to ERROR;Ingo Schwarze
allows to get rid of ROFF_ERR
2015-01-14To get rid of SYSERR entries in enum mandocerr, downgrade problems withIngo Schwarze
missing and unreadable files from SYSERR to ERROR. Needed for upcoming work. As a bonus, this minimally simplifies code and documentation.
2015-01-14Simplify handling of system errors: just exit(3).Ingo Schwarze
We already do the same for malloc(3) failure. The is no virtue in trying to survive failure of fork(2) and the like.
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.