summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/main.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Clean up date handling,schwarze2011-03-071-2/+3
| | | | | | | | | | | | 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@
* If .Ns is specified on its own line, ignore it, like groff does;schwarze2011-02-061-1/+2
| | | | from kristaps@.
* Since tbl_data() can now produce multiple spans, let parsebuf()schwarze2011-01-251-6/+8
| | | | | | | generate man(7) or mdoc(7) nodes for all these spans, not only for the last one. Restores the horizontal lines in the cpu(4/hppa) tables. ok kristaps@
* Skip carriage return before newline, if any.schwarze2011-01-241-4/+21
| | | | | | As pointed out by Joerg Sonnenberger, this is useful because we use mmap(3) and look for '\n' by hand. "check it in" kristaps@
* When finding the roff .it request (line trap),schwarze2011-01-201-2/+2
| | | | | make it clear that you cannot use mandoc to format that page (yet). Triggered by a report from brad@.
* Some improvements to error handling from kristaps@:schwarze2011-01-161-1/+2
| | | | | | | * Make out-of-context .fi invocations not cause an error, but just a warning. * Downgrade -man message about ignored empty paragraph to MANDOC_IGNPAR. * Avoid syntax tree corruption when removing empty block macros. Triggered by some reports from brad@.
* Various tbl improvements from kristaps@:schwarze2011-01-161-4/+2
| | | | | | | * horizontal lines do not consume layout lines * skip excessive data cells * prepare rendering of spanned cells * support vertical spans
* Refactoring in preparation for .rm support:schwarze2011-01-101-1/+2
| | | | | | | | | | Unify parsing of names given as roff request arguments into a new function roff_getname(), which is rather different from the parsing function for normal arguments, mandoc_getarg(), because names cannot be quoted and cannot contain whitespace or escaped characters. The new function now throws an ERROR when finding escaped characters in a name. "I'm fine with this." kristaps@
* Make sure coding errors cannot make us miss fatal parsing errorsschwarze2011-01-091-1/+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-9/+28
| | | | there are still a few bugs, but fixing these will be easier in tree.
* Partial cleanup of argument count validation in mdoc(7):schwarze2011-01-031-1/+2
| | | | | | | | | | | | * Do not segfault on empty .Db, .Rs, .Sm, and .St. * Let check_count() really throw the requested level, not always ERROR. * Downgrade most bad argument counts from ERROR to WARNING. * And some related internal cleanup. Looks fine to kristaps@. Note that the macros using eerr_ge1() still need to be checked at a later time; but as all the others are done, let's use what we already have.
* Sane behaviour for the growing of very small buffers:schwarze2010-12-211-2/+2
| | | | | | | Always grow at least to the minimum requested size. Before this, a buffer of 1 byte was grown to 2 bytes, which was too small and sometimes caused segfaults. ok kristaps@
* Abort endless loops during roff macro and string expansion.schwarze2010-12-091-3/+12
| | | | | | For now, use the simplest conceivable approach, like groff does: Just a fixed, ugly input stack limit. Kristaps@ agrees.
* Track the parser status both per file (file_status), such thatschwarze2010-12-021-14/+19
| | | | | | | | we can for example skip rendering on FATAL parsing errors, and globally (exit_status), such that we know what to return. Without this, following files produced no rendered output once a single file suffered from a FATAL error. Bug reported by kristaps@, fix by me.
* Cleanup by kristaps@:schwarze2010-12-011-86/+158
| | | | | * When autodetecting the format, don't assume all files are the same. * Add more comments and apply some whitespace beautifications.
* Merge mdoc_action.c into mdoc_validate.c, because having two places to doschwarze2010-12-011-2/+1
| | | | | | basically the same things just causes code duplication and confusion. Work by kristaps@, including a few bugfixes he found during the merge, and reapplying OpenBSD changes on top.
* Implement the roff .ft (change font) request for man(7).schwarze2010-11-291-1/+2
| | | | | | | | Of course, we don't want to encourage low-level physical markup, but pod2man(1) writes such requests, so Perl manuals contain them, and some Xenocara and lots and lots of ports manuals use them as well. In base and Xenocara, this will reduce mandoc -Tlint ERROR noise; in ports, it will improve rendering of many manuals.
* To avoid FATAL errors, we have been parsing and ignoring the roffschwarze2010-11-281-3/+4
| | | | | | | | | | | | | | | requests .am, .ami, .am1, .dei, and .rm for a long time. Since ignoring them can (rarely) cause information loss and serious misformatting, throw an ERROR: NOT IMPLEMENTED when finding them. Implementing them would not be too difficult, but they are so rare in practice that i can find better use for my time right now. In this context, - Put the string "NOT IMPLEMENTED" into two other error messages as well, to distinguish them from those caused by broken input. - Print the string "unknown macro" once, not twice in the error message associated with MANDOCERR_MACRO, and begin printing the buffer at the point where the unknown macro really is, not at the start of line.
* Implement the .de (define macro) roff instruction.schwarze2010-11-251-40/+72
| | | | | | | | | | | | | | This fixes various Xenocara manuals. Do not define your own macros in new manuals, though: this code exists purely to cope with existing and old stuff. Like in both traditional and GNU roff, the .de and .ds (define string) roff instructions share the same string table, so one can abuse strings as macros and vice versa. This implementation supports multi-line user-defined macros and user-defined macros taking up to 9 arguments. Project started near the end of p2k10, now mature for production, but there is still room for future improvements in various respects.
* Warn developers that .so is fragile and suggest using ln(1) instead;schwarze2010-10-261-1/+2
| | | | throwing a warning here was suggested by Joerg Sonnenberger.
* Downgrade nearly 20 ERRORS to WARNINGS.schwarze2010-10-261-42/+52
| | | | | | | | All these indicate problems in the mdoc(7) or man(7) source code, but they can't cause relevant information loss or clobbered formatting. While here, error message improve wording and make it more uniform, don't throw MANDOCERR_NOWIDTHARG twice when there is one single issue, and consolidate MANDOCERR_WIDTHARG into MANDOCERR_IGNARGV.
* Support .so (low-level roff "switch source file"),schwarze2010-10-261-1/+37
| | | | | | | needed for Xenocara and various ports. Accept only relative paths and no ascension to the parent directory as suggested by Joerg Sonnenberger; code looked over by Joerg, too. Useful discussions with various people, among others espie@.
* Refactoring, no functional change:schwarze2010-10-261-108/+125
| | | | | | Seperate the code to read and parse a PART of a page (new function pdesc()) from the code to finish and output a FULL page (function fdesc()); in preparation for .so support.
* Do not throw FATAL errors when there is no need to:schwarze2010-10-241-5/+4
| | | | | | | | - when encountering nested displays (.Bd containing .Bd, .D1, .D1) - when a block end macro was forgotten - when ending a block that was never started - when the uname(3) system call failed along with a little related cleanup
* Do not abort() on tbl errors, reduce the risk that tbl stuff kills a build,schwarze2010-10-161-1/+2
| | | | and provide more useful tbl error messages in a non-intrusive way.
* Merge the last bits of 1.10.6 (released today), most were already in:schwarze2010-09-271-1/+2
| | | | | | | | | | | | * ignore double-.Pp * ignore .Pp before .Bd and .Bl (unless -compact in specified) * avoid double blank line upon .Pp, .br and friends in literal context * cast enums to int when passing them to exit(3) to please lint(1) While merging, fix a regression introduced by kristaps@: Outside literal mode, double blank lines must both be printed. To achieve this again after kristaps@ improvements in 1.10.6, treat such blank lines as .sp (instead of .Pp as in 1.10.5) and drop .Pp before .sp just like dropping .Pp before .Pp.
* If an explicit scope is still open at the end of an input file,schwarze2010-09-261-10/+10
| | | | | | | | | | | report an ERROR: We can still render the page by just closing the open scope, but it is likely that information will be missing or document structure mangled. Before, man(7) only reported a WARNING (which is dangerous because we cannot be sure rendering is correct) and mdoc(7) ran into FATAL (which is too drastic, there is no reason not to show what we have). While here, add a few explicit casts to appease lint. "looks good" kristaps@
* fix previous: when bailing out due to -Wstop,schwarze2010-08-201-9/+9
| | | | | skip output functions, but not *_endparse; problem reported by kristaps@
* Implement a simple, consistent user interface for error handling.schwarze2010-08-201-230/+137
| | | | | | | | | | | | | | | | | We now have sufficient practical experience to know what we want, so this is intended to be final: - provide -Wlevel (warning, error or fatal) to select what you care about - provide -Wstop to stop after parsing a file with warnings you care about - provide consistent exit status codes for those warnings you care about - fully document what warnings, errors and fatal errors mean - remove all other cruft from the user interface, less is more: - remove all -f knobs along with the whole -f option - remove the old -Werror because calling warnings "fatal" is silly - always finish parsing each file, unless fatal errors prevent that This commit also includes a couple of related simplifications behind the scenes regarding error handling. Feedback and OK kristaps@; Joerg Sonnenberger (NetBSD) and Sascha Wildner (DragonFly BSD) agree with the general direction.
* Use isascii(3) to make sure we really throw away non-ASCII characters,schwarze2010-08-181-3/+4
| | | | | because isgraph(3) returns true for some eight-bit characters. ok kristaps@
* Sync to bsd.lv; in particular, pull in lots of bug fixes.schwarze2010-07-251-3/+34
| | | | | | | | | | | | | | | | | | | | | new features: * support the .in macro in man(7) * support minimal PDF output * support .Sm in mdoc(7) HTML output * support .Vb and .nf in man(7) HTML output * complete the mdoc(7) manual bug fixes: * do not let mdoc(7) .Pp produce a newline before/after .Sh; reported by jmc@ * avoid double blank lines related to man(7) .sp and .br * let man(7) .nf and .fi flush the line; reported by jsg@ and naddy@ * let "\ " produce a non-breaking space; reported by deraadt@ * discard \m colour escape sequences; reported by J.C. Roberts * map undefined 1-character-escapes to the literal character itself maintenance: * express mdoc(7) arguments in terms of an enum for additional type-safety * simplify mandoc_special() and a2roffdeco() * use strcspn in term_word() in place of a manual loop * minor optimisations in the -Tps and -Thtml formatting frontends
* Merge release 1.10.4 (all code by kristaps@), providing four new features:schwarze2010-07-131-4/+4
| | | | | | | | | | 1) Proper .Bk support: allow output line breaks at input line breaks, but keep input lines together in the output, finally fixing synopses like aucat(1), mail(1) and tmux(1). 2) Mostly finished -Tps (PostScript) output. 3) Implement -Thtml output for .Nm blocks and .Bk -words. 4) Allow iterative interpolation of user-defined roff(7) strings. Also contains some minor bugfixes and some performance improvements.
* Improve .Nm indentation in the SYNOPSIS;schwarze2010-07-011-3/+4
| | | | | | | kristaps@ will do the missing HTML part soon. "looks nicer" jmc@ "seems perfect to me" sobrado@ "slap it in" kristaps@
* improve error reporting:schwarze2010-06-301-28/+44
| | | | | | | | | * avoid error exit code after mere warnings * add ERROR: and FATAL: to messages when appropriate * sort the code in mmsg() to make it easier on the eye * make the mandocerrs[] list easier to maintain * update a few comments in mandoc.h ok kristaps@
* sync to bsd.lv version 1.10.3:schwarze2010-06-291-2/+2
| | | | | * support -Tps -Opaper=a4 and -Opaper=letter * lots of mandoc.1 manual improvements
* Full .nr nS support, unbreaking the kernel manuals.schwarze2010-06-271-5/+9
| | | | | | | | | Kristaps coded this from scratch after reading my .nr patch; it is simpler and more powerful. Registers live in struct regset in regs.h, struct man and struct mdoc contain pointers to it. The nS register is cleared when parsing .Sh. Frontends respect the MDOC_SYNPRETTY flag set in mdoc node_alloc.
* merge release 1.10.2schwarze2010-06-261-3/+5
| | | | | | | | | | | | * bug fixes: - interaction of ASCII_HYPH with special chars (found by Ulrich Spoerlein) - handling of roff conditionals (found by Ulrich Spoerlein) - .Bd -offset will no more default to 6n * maintenance: - more caching of .Bd and .Bl arguments for efficiency - deconstify man(7) validation routines - add FreeBSD library names (provided by Ulrich Spoerlein) * start PostScript font-switching
* minimal initial -Tps support, from kristaps@ GSOCschwarze2010-06-101-10/+27
| | | | | so far, monospace without font decoration, but it already has page headers and footers
* Merge more bits that will be going into 1.10.1:schwarze2010-06-081-3/+3
| | | | | | | | | | | | Clean up vertical spacing in the SYNOPSIS, making the code much more systematic; this doesn't solve all SYNOPSIS problems yet, in particular not those related to keeps, indentation and the low-level .nr roff instruction, but it's a nice step forward and i couldn't find relevant regressions. (from kristaps) Besides, * make the output width configurable (default: -Owidth=80) (kristaps) * use mmap with MAP_SHARED (from Joerg Sonnenberger)
* Merge bsd.lv version 1.10.1 (to be released soon).schwarze2010-06-061-5/+5
| | | | | | | | | | | | | | | | | | | | The main step forward is that this now has *much* better .Bl -column support, now supporting many manuals that previously errored out without producing any output. Other fixes include: * do not die from multiple list types, use the first and warn * in .Bl without a type, default to -item * various tweaks to .Dt * fix .In, .Fd, .Ft, .Fn and .Fo formatting * some documentation fixes and additions * and fix a couple of bugs reported by Ulrich Spoerlein: * better support for roff block-end "\}" without a preceding dot * .In must not break the line outside SYNOPSIS * spelling in some error messages While merging, fix one regression in .In spacing that needs to go to bsd.lv, too.
* Unified error and warning message system for all of mandoc,schwarze2010-05-231-79/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | featuring three message levels, as agreed during the mandoc hackathon: * FATAL parser failure, cannot produce any output from this input file: eventually, we hope to convert most of these to ERRORs. * ERROR, meaning mandoc cannot cope fully with the input syntax and will probably lose information or produce structurally garbled output; it will try to produce output anyway but exit non-zero at the end, which is eventually intended to make the ports infrastructure happy. * WARNING, meaning you should clean up the input file, but output is probably mostly OK, so this will not cause error-exit at the end. This commit is mostly just converting the old system to the new one; before the classification will become really reliable, we must check all messages. In particular, * set up a new central message string table in main.c * drop the old message string tables from man.c and mdoc.c * get rid of the piece-meal merr enums in libman and libmdoc * reduce number of error/warning functions from 16 to 6 (still a lot...) While here, handle a few problems more gracefully: * allow .Rv and .Ex to work without a prior .Nm * allow .An to ignore extra arguments * allow undeclared columns in .Bl -column Written by kristaps@.
* Support nested roff instructions:schwarze2010-05-201-10/+33
| | | | | | | | | | | | | | | | | | | * allow roff_parseln() to be re-run * allow roff_parseln() to manipulate the line buffer offset * support the offset in the man and mdoc libraries * adapt .if, .ie, .el, .ig, .am* and .de* support * interpret some instructions even in conditional-negative context Coded by kristaps during the last day of the mandoc hackathon. To avoid regressions in the OpenBSD tree, commit this together with some small local additions: * detect roff block end "\}" even on macro lines * actually implement the ".if n" conditional * ignore .ds, .rm and .tr in libroff Also back my old .if/.ie/.el-handling out of libman, reverting: man.h 1.15 man.c 1.25 man_macro.c 1.15 man_validate.c 1.19 man_action.c 1.15 man_term.c 1.28 man_html.c 1.9.
* allow the single quote as a control character in place of the dotschwarze2010-05-161-2/+2
| | | | | at all relevant places; from kristaps@
* In theory, Kristaps never intended to write a roff parser,schwarze2010-05-161-18/+85
| | | | | | | | | | | | | | | | | | but in practice, most real legacy man(7)uals are using so much low level roff that we can't really get away without at least partially handling some roff instructions. As doing this in man(7) only has become messy and as even some mdoc(7) pages need it, start a minimal partial roff preprocessor. As a first step, move handling of .am[i], .de[i] and .ig there. Do not use the roff preprocessor for new manuals! Now that we have three main parser libraries - roff, man and mdoc - each one having its own error handling is becoming messy, too. Thus, start unifying message handling in one central place, introducing a new generic function mmsg(). coded by kristaps@
* Joerg Sonnenberger rewrote the comment stripping and line mergingschwarze2010-05-151-51/+53
| | | | to be easier to follow and slightly faster.
* More systematic output width handling by Joerg Sonnenberger:schwarze2010-05-151-2/+2
| | | | | | | * save and restore the output width when switching to MANT_LITERAL * add an argument to ascii_alloc to specify the output width * set the default output width to 80 minus 2 characters * OpenBSD local: set the output width to 65 characters for -man
* Bugfxing and cleanup by Joerg Sonnenberger, edited by kristaps@:schwarze2010-05-151-156/+209
| | | | | | | | | * Flag errors and warnings in global variables. * Exit with error code if either is not null on exit. * Push down the buffers to the functions using them. * Handle the stdin/file argument in one function. * Use mmap when possible or else read the whole file into a single buffer. * Push buffer resizing into its own function.
* merge bsd.lv 1.63:schwarze2010-05-151-3/+3
| | | | | fix stripping of whitespace before trailing comments; by Joerg Sonnenberger
* merge 1.9.24, keeping local patches; some changes:schwarze2010-05-141-1/+7
| | | | | | | | | * preserve multiple consecutive space characters in input * do not restrict .Cd and .Rv to certain sections (requested by Joerg) * do not run lookup() on quoted words * enum return types for mdoc_args and mdoc_argv * fix auto-closing of LINK tag in -Txhtml (from Daniel Friesel) * various lint and manual fixes
* Remove the command line option -fno-ign-chars.schwarze2010-05-131-20/+10
| | | | | | | | | This option was not useful, you never want mandoc to die just because there is an invalid character in the input file, neither in production nor when linting: a warning is sufficient. This was particularly annoying because it was part of -fstrict and could not be switched off. "less is more" kristaps@