summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Groff allows the initial macro on a line to be delimited by a spaceschwarze2010-08-071-7/+16
| | | | | of by a tab; so allow the tab in mandoc, too. Bug found by me, fix by kristaps@, "sure" deraadt@.
* Text ending in a full stop, exclamation mark or question markschwarze2010-07-161-2/+2
| | | | | | | | | | | | | | | | | | should not flag the end of a sentence if: 1) The punctuation is followed by closing delimiters and not preceded by alphanumeric characters, like in "There is no full stop (.) in this sentence" or 2) The punctuation is a child of a macro and not preceded by alphanumeric characters, like in "There is no full stop .Pq \&. in this sentence" jmc@ and sobrado@ like this
* Merge release 1.10.4 (all code by kristaps@), providing four new features:schwarze2010-07-131-9/+25
| | | | | | | | | | 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.
* In the mdoc(7) parser, inspect roff registers early such that all partsschwarze2010-07-011-15/+19
| | | | | | | | | | | | of the parser can use the resulting cues. In particular, this allows to use .nr nS to force SYNOPSIS-style .Nm indentation outside the SYNOPSIS as needed by ifconfig(8). To actually make this useable, .Pp must rewind .Nm, or the rest of the section would end up indented. Implement a quick hack for now, a generic solution can be designed later. ok kristaps@ sobrado@
* Support for badly nested blocks, written around the time ofschwarze2010-06-291-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | the Rostock mandoc hackathon and tested and polished since, supporting constructs like: .Ao Bo Ac Bc (exp breaking exp) .Aq Bo eol Bc (imp breaking exp) .Ao Bq Ac eol (exp breaking imp) .Ao Bo So Bc Ac Sc (double break, inner before outer) .Ao Bo So Ac Bc Sc (double break, outer before inner) .Ao Bo Ac So Bc Sc (broken breaker) .Ao Bo So Bc Do Ac Sc Dc (broken double breaker) There are still two known issues which are tricky: 1) Breaking two identical explicit blocks (Ao Bo Bo Ac or Aq Bo Bo eol) fails outright, triggering a bogus syntax error. 2) Breaking a block by two identical explicit blocks (Ao Ao Bo Ac Ac Bc or Ao Ao Bq Ac Ac eol) still has a minor rendering error left: "<ao1 <ao2 [bo ac2> ac1> bc]>" should not have the final ">". We can fix these later in the tree, let's not grow this diff too large. "get it in" kristaps@
* Full .nr nS support, unbreaking the kernel manuals.schwarze2010-06-271-8/+28
| | | | | | | | | 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-5/+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
* Merge bsd.lv version 1.10.1 (to be released soon).schwarze2010-06-061-13/+86
| | | | | | | | | | | | | | | | | | | | 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.
* When a word does not fully fit onto the output line, but it containsschwarze2010-05-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | at least one hyphen, we already had support for breaking the line a the last fitting hyphen. This patch improves this functionality by only breaking at hyphens in free-form text, and by not breaking at hyphens * at the beginning or end of a word or * immediately preceded or followed by another hyphen or * escaped by a preceding backslash. Before this patch, differences in break-at-hyphen support were one of the major sources of noise in automatic comparisons to mdoc(7) groff output. Now, the remaining differences are hard to find among the noise coming from other sources. Where there are still differences, what we do seems to be better than what groff does, see e.g. the chio(1) exchange and position commands for one of the now rare examples. idea and coding by kristaps@ Besides, this was the last substantial code difference left between bsd.lv and openbsd.org. We are now in full sync.
* Unified error and warning message system for all of mandoc,schwarze2010-05-231-112/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-26/+31
| | | | | | | | | | | | | | | | | | | * 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.
* Rewrite the main mdoc text parser, mdoc_ptext()schwarze2010-05-161-38/+50
| | | | | | | | to make it easier to understand and to fix various bugs: * strip white space from the end MDOC_TEXT elements in literal mode * in literal mode, a line may be blank even when containing tabs * escaped backslashes do not escape following characters ok kristaps@
* allow the single quote as a control character in place of the dotschwarze2010-05-161-2/+2
| | | | | at all relevant places; from kristaps@
* allow non-numeric manual sections in -mdoc;schwarze2010-05-151-2/+4
| | | | | while here, allow LIBRARY in section 9; by kristaps@
* various improvements regarding errors and warnings Joerg Sonnenberger:schwarze2010-05-151-2/+1
| | | | | | | | | | | | * If the last -column .Bl isn't specified, it is auto-sized. * An invalid .St argument should be a warning, not an error. Just put the argument into the output. * An invalid .At argument should be a warning, not an error. Just print the argument, like new groff does. * Remove warnings concerning manual section (like 1, 6, 8). It was only used for .Ex and not really useful. * Remove warnings concerning page section (like SYNOPSIS). These were only used for .Fd and .Lb and not really useful.
* Integrate kristaps@' end-of-sentence (EOS) frameworkschwarze2010-05-141-35/+11
| | | | | | | | | | | | | which is simpler and more powerful than mine, and remove mine. * man(7) now has EOS handling, too * put EOS detection into its own function in libmandoc * use node and termp flags to communicate the EOS condition * no more EOS pseudo-macro * no more non-printable EOS marker character on the formatter level This slightly breaks EOS detection after trailing punctuation in mdoc(7) macros, but that will be restored soon.
* Merge 1.9.25, keeping local patches;schwarze2010-05-141-5/+11
| | | | | | | | | | | | | | this does not merge kristaps' end-of-sentences handling yet, i will check that separately. This one includes: * handle \*(Ba as a delimiter * introduce ARGS_PEND for .Bl -column .It end-of-line special casing * section ordering: expect EXIT STATUS at the right place * line break fixes in SYNOPSIS * allow literal contexts to have arbitrary line lengths * the input file column number can not be used to identify the beginning of a line because white space is allowed after the initial '.' * proper leading spaces in -man -Tascii mode * do not let Lb break lines in -mdoc -Thtml LIBRARY
* merge 1.9.24, keeping local patches; some changes:schwarze2010-05-141-72/+51
| | | | | | | | | * 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
* merge bsd.lv rev 1.123:schwarze2010-05-081-8/+8
| | | | sync mdoc.c's static function names with man.c
* handle text lines beginning with \." as comments, like groff does,schwarze2010-05-081-1/+7
| | | | | even though this is not correct comment syntax (so warn, too) reported by Claus Assmann on misc@, fix by kristaps@
* end-of-sentence markers at the end of .Fn argument listsschwarze2010-05-041-3/+6
| | | | | ruin indentation of the next line in the SYNOPSIS section; bug found by jacekm@ in err(3)
* Fix a subtle bug noticed by naddy@ in pftop(8), thanks!schwarze2010-04-271-2/+5
| | | | | | When converting blank lines to .Pp outside literal context, it could happen that the following node ended up as a child of the .Pp element, but it must always be a sibling.
* Fix a segfault reported by nicm@, introduced in rev. 1.38.schwarze2010-04-221-3/+2
| | | | | When finding a blank line, trying to parse it is a bad idea. Instead, after adding .Pp to the AST, just return from parsetext().
* Merge the good parts of 1.9.23,schwarze2010-04-071-10/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | avoid the bad parts of 1.9.23, and keep local patches. Input in general: * Basic handling of roff-style font escapes \f, \F. * Quoted punctuation does not count as punctuation. mdoc(7) parser: * Make .Pf callable; noted by Claus Assmann. * Let .Bd and .Bl ignore unknown arguments; noted by deraadt@. * Do not warn when .Er is used outside certain sections. * Replace mdoc_node_free[list] by mdoc_node_delete. * Replace #define by enum for rew*() return values. man(7) parser: * When .TH is missing, use default section and date. Output in general: * Curly braces do not count as punctuation. * No space after .Fl w/o args when a macro follows on the same line. HTML output: * Unify PAIR_*_INIT macros, introduce new PAIR_ID_INIT(). * Print whitespace after, not before .Vt .Fn .Ft .Fo. Checked that all manuals in base still build.
* When the prologue lacks required information, do not error out,schwarze2010-04-041-3/+15
| | | | | | but warn, set up some default values, and prod on. Unbreaking the ports build for textproc/sgmlformat; reported by naddy@, thanks.
* * outside literal context in mdoc(7), handle blank lines like .Ppschwarze2010-04-031-3/+7
| | | | | | * a missing NAME section in mdoc(7) need not be fatal ok deraadt@
* merge 1.9.22, keeping local patchesschwarze2010-04-021-12/+13
| | | | | | * convert mdoc tokens from #define to enum * fix a segfault with .Xo/.Xc in explicit blocks * Thorn is \*(Th, not \*(TH; noticed by Joerg Sonnenberger
* fix a stupid out-of-bounds read access introduced in the previousschwarze2010-03-251-2/+2
| | | | revision, in the code searching for the end of a sentence
* Proper inter-sentence spacing for mdoc(7).schwarze2010-03-021-2/+34
| | | | | | | | | When a text line or a non-block macro line in the source code ends in any of ".!?", consider that an end of sentence (EOS). This makes Jason's rule "new sentence, new line" even more important. Let the parser detect the EOS and insert a token into the AST. Let the -Tascii frontend render the EOS token as a double space before the next word.
* sync to release 1.9.15:schwarze2010-02-181-7/+30
| | | | | | | | | * corrected .Vt handling (spotted by Joerg Sonnenberger) * corrected .Xr argument handling (based on my patch) * removed \\ escape sequence (because it is for low-level roff only) * warn about trailing whitespace (suggested by jmc@) * -Txhtml support * and some general cleanup and doc improvements
* complete the sync to 1.9.15-pre2: mostly minor fixesschwarze2010-01-021-8/+7
| | | | | | | | * bugfix: do not restore TERMP flags when leaving lists, just reset them * and a few HTML fixes * clarity: return width from a2width, not width+2, and adapt to it * manual: document .Bl and .Fl * portability: no need to escape '%' in macro names
* sync to 1.9.12, mostly portability and refactoring:schwarze2009-12-221-46/+16
| | | | | | | | | | | | | | | | | | | correctness/functionality: - bugfix: do not die when overstep hits the right margin - new option: -fign-escape - and various HTML features portability: - replace bzero(3) by memset(3), which is ANSI C - replace err(3)/warn(3) by perror(3)/exit(3), which is ANSI C - iuse argv[0] instead of __progname - add time.h to various files for FreeBSD compilation simplicity: - do not allocate header/footer data dynamically in *_term.c - provide and use malloc frontends that error out on failure for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/
* sync to 1.9.11: adapt printing of dates to groff conventions,schwarze2009-10-271-3/+4
| | | | | NetBSD portability fixes and some minor bugfixes and feature enhancements; also checked that my hyphenation code still works on top of this
* sync to 1.9.9, featuring:schwarze2009-10-211-2/+3
| | | | | | | * -Thtml output mode * roff scaling units * and some minor fixes for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/
* sync to 1.9.6: multiple improvements to references (.Rs)schwarze2009-10-191-2/+3
| | | | | | | * validate and order .Rs child nodes * underline book title (.%B) and issuer (.%I) * enclose title of article (.%T) in quotes * avoid calling mdoc_verr directly, use a proper error code instead
* sync to 1.9.6: u_char lives in <sys/types.h>schwarze2009-10-191-1/+3
| | | | | noticed by uqs at spoerlein dot net on FreeBSD, where <stdlib.h> does not include <sys/types.h>
* sync to 1.9.5: lookup hashes are now static tablesschwarze2009-09-211-8/+5
| | | | shortening the code, and, according to kristaps@, speeding it up
* sync to 1.9.2: non-printable characters in macro names are errors;schwarze2009-09-181-1/+7
| | | | from joerg at netbsd dot org
* sync to 1.9.1: set mdoc_next flags in mdoc_*_alloc routines, where they belongschwarze2009-08-221-18/+29
|
* sync to 1.9.0: polishing the core code of mdoc macro handlingschwarze2009-08-221-19/+25
| | | | | | | | | | 1) If a macro is not parsed, do not parse it. Of course, without parsing it, we cannot produce "macro-like parameter" warnings, but these were useless anyway. 2) If a macro is not callable, do not print a useless warning when it occurs as a parameter, just display the raw characters. 3) Below .Bl -column, check whether macros are callable. 4) Like groff, allow whitespace after the initial dot on macro lines.
* sync to 1.8.5: Error string is now file:line:col: message.schwarze2009-08-221-3/+3
| | | | | Fixed column reporting (off by one). Use fprintf instead of warnx for parse errors (like cc).
* sync to 1.8.1: rewrite quoted literal handling correctly,schwarze2009-07-261-2/+1
| | | | | rewrite TABSEP handling in a simpler way, and retire ECOLEMPTY, ARGS_QUOTED and ARGS_ARGVLIKE
* sync to 1.8.1: removed excessively verbose EARGVPARM warningschwarze2009-07-261-2/+1
|
* sync to 1.8.1: support .br and .spschwarze2009-07-261-2/+2
|
* sync to 1.8.1: libmdoc now breaks up free-form lines into tokens;schwarze2009-07-261-34/+96
| | | | will simplify LITERAL mode in front-end
* sync to 1.8.0: move mdoc_a2att, mdoc_a2st, and mdoc_a2lib to libmdocschwarze2009-07-181-1/+2
|
* sync to 1.7.23: pass warning code to mdoc_pwarn() instead of warning messageschwarze2009-07-121-35/+2
| | | | | | define additional warning macro mdoc_nwarn() remove obsolete warning functions mdoc_warn(), pwarn(), vwarn(), nwarn() remove various now unused "enum mdoc_warn" and "enum mwarn"
* sync to 1.7.23: pass error code to mdoc_perr() instead of error stringschwarze2009-07-121-58/+9
| | | | | and use the so improved mdoc_nerr() at many places; get rid of now unused static functions perr()
* sync to 1.7.23: pass error code to mdoc_nerr() instead of error stringschwarze2009-07-121-23/+4
| | | | and use the so improved mdoc_nerr() at many places
* sync to 1.7.23: unify the various "enum merr" into libman.h and libmdoc.h,schwarze2009-07-121-19/+64
| | | | | use it as a new argument to mdoc_err(), the same way as for for man_err(), and use string tables instead of switch statements to select error messages