summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/libmdoc.h
AgeCommit message (Collapse)Author
2014-11-17Multiple fixes with respect to in-line macros:Ingo Schwarze
* .No selects the default font; relevant e.g. in .Bf blocks * no need to force empty .Li elements * closing delimiters as leading macro arguments do not suppress space * opening delimiters at the end of a macro line do not suppress space * correctly handle delimiter spacing in -Tman As a side effect, these fixes let mandoc warn about empty .No macros as requested by bentley@.
2014-08-08demacrify: get rid of man_nmsg(), man_pmsg(), mdoc_nmsg(), mdoc_pmsg()Ingo Schwarze
2014-08-08Simplify: replace one global flag by one local variableIngo Schwarze
and remove three unused global flags. No functional change.
2014-07-09mark defos as const; nobody needs to change it,Ingo Schwarze
and it is occasionally useful to be able to pass literal strings
2014-07-02Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze
since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
2014-04-20KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze
remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
2014-01-05Add an option -Q (quick) to mandocdb(8)Ingo Schwarze
for accelerated generation of reduced-size databases. Implement this by allowing the parsers to optionally abort the parse sequence after the NAME section. While here, garbage collect the unused void *arg attribute of struct mparse and mparse_alloc(). This reduces the processing time of mandocdb(8) on /usr/share/man by a factor of 2 and the database size by a factor of 4. However, it still takes 5 times the time and 6 times the space of makewhatis(8), so more work is clearly needed.
2013-10-21There are three kinds of input lines: text lines, macros takingIngo Schwarze
positional arguments (like Dt Fn Xr) and macros taking text as arguments (like Nd Sh Em %T An). In the past, even the latter put each word of their arguments into its own MDOC_TEXT node; instead, concatenate arguments unless delimiters, keeps or spacing mode prevent that. Regarding mandoc(1), this is internal refactoring, no output change intended. Once we will switch mandocdb(8) from DB to SQLite in the future, this is going to be required to support search expressions crossing word boundaries, and it will reduce both database sizes and build times by a bit more than 5% each.
2012-11-17Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze
Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta" and avoid the confusing "*m" which was sometimes this, sometimes that. No functional change. ok kristaps@ some time ago
2012-07-18Fix handling of paragraph macros inside lists:Ingo Schwarze
* When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. Improves formatting of 40 pages, e.g. grep(1), ksh(1), netstat(1), ath(4), bsd.port.mk(5), pf.conf(5), mount(8), crypto(9).
2012-05-24Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theIngo Schwarze
default value for the mdoc(7) .Os macro. Needed for man.cgi on the OpenBSD website. Problem with man.cgi first noticed by deraadt@; beck@ and deraadt@ agree with the way to solve the issue.
2011-12-02In man(7), when no explicit volume name is given, use the defaultIngo Schwarze
volume name for the respective manual section, just like in mdoc(7). This gives us nicer page headers for cvs(1), lynx(1), tic(1), mkhybrid(8), and many curses(3) manuals. ok kristaps@ To not break compatibility, i wrote a corresponding patch for GNU troff which Werner Lemberg accepted upstream at rev. 1.65 of: http://cvs.savannah.gnu.org/viewvc/groff/tmac/an-old.tmac?root=groff
2011-09-18sync to version 1.11.5:Ingo Schwarze
adding an implementation of the eqn(7) language by kristaps@ So far, only .EQ/.EN blocks are handled, in-line equations are not, and rendering is not yet very pretty, but the parser is fairly complete.
2011-05-29Merge release 1.11.3, almost all code by kristaps@:Ingo Schwarze
* Unicode output support (no Unicode input yet, though). * Refactoring: completely handle predefined strings in roff.c. - New function mandoc_escape() replaces a2roffdeco() and mandoc_special(). - Start using mandoc_getarg() in mdoc_argv.c. - Clean up parsing of delimiters in mdoc(7). * And many minor fixes and lots of cleanup.
2011-04-24Merge version 1.11.1:Ingo Schwarze
Again lots of cleanup and maintenance work by kristaps@. - simplify error reporting: less function pointers, more mandoc_[v]msg - main: split document parsing out of main.c into read.c - roff, mdoc, man: improved recognition of control characters - roff: better handling of if/else stack overflows - roff: add some predefined strings for backward compatibility - mdoc, man: empty sections are not errors - mdoc: move delimiter handling to libmdoc - some header restructuring and some minor features and fixes This merge causes two minor regressions that i will fix in separate commits right afterwards.
2011-04-21Merge version 1.10.10:Ingo Schwarze
lots of cleanup and maintenance work by kristaps@. - move some main.c globals into struct curparse - move mandoc_*alloc to mandoc.h such that all code can use them - make mandoc_isdelim available to formatting frontends - dissolve mdoc_strings.c, move the code where it is used - make all error reporting functions void, their return values were useless - and various minor cleanups and fixes
2010-12-01Merge mdoc_action.c into mdoc_validate.c, because having two places to doIngo Schwarze
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.
2010-08-20Implement a simple, consistent user interface for error handling.Ingo Schwarze
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.
2010-07-13Merge release 1.10.4 (all code by kristaps@), providing four new features:Ingo Schwarze
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.
2010-07-01In the mdoc(7) parser, inspect roff registers early such that all partsIngo Schwarze
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@
2010-06-29Support for badly nested blocks, written around the time ofIngo Schwarze
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@
2010-06-27Full .nr nS support, unbreaking the kernel manuals.Ingo Schwarze
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.
2010-06-06Merge bsd.lv version 1.10.1 (to be released soon).Ingo Schwarze
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.
2010-05-24Increase performance by saving the list type in struct mdoc_node.Ingo Schwarze
This will eventually be used so that mdoc_macro can know whether to dump list line arguments into the body (`Bl -column' overflowing). Remove a2list() and arg_listtype() because of this. From kristaps@. While merging, fix a regression in mdoc_term.c, print_bvspace(): The bsd.lv version of this broke vertical spacing in .Bl -column.
2010-05-23Unified error and warning message system for all of mandoc,Ingo Schwarze
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@.
2010-05-15allow non-numeric manual sections in -mdoc;Ingo Schwarze
while here, allow LIBRARY in section 9; by kristaps@
2010-05-15various improvements regarding errors and warnings Joerg Sonnenberger:Ingo Schwarze
* 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.
2010-05-15proper handling of quoted tab-separated column listsIngo Schwarze
by kristaps@
2010-05-15Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum).Ingo Schwarze
Only OPEN are drawn before the beginning of a macro; this is new, before this, MIDDLE ('|') were drawn in front, too. Only CLOSE are pushed after the end of a macro (as before). ok kristaps@ This allows us to finally enable handling of leading punctuation without regressions.
2010-05-14Merge 1.9.25, keeping local patches;Ingo Schwarze
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
2010-05-14merge 1.9.24, keeping local patches; some changes:Ingo Schwarze
* 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
2010-05-08handle text lines beginning with \." as comments, like groff does,Ingo Schwarze
even though this is not correct comment syntax (so warn, too) reported by Claus Assmann on misc@, fix by kristaps@
2010-04-07Merge the good parts of 1.9.23,Ingo Schwarze
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.
2010-04-03When two conflicting list types are specified for the same list,Ingo Schwarze
use the first, discard the second, and warn. No need to bail out. ok deraadt@
2010-04-02merge 1.9.22, keeping local patchesIngo Schwarze
* 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
2009-12-22sync to 1.9.12, mostly portability and refactoring:Ingo Schwarze
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/
2009-10-21sync to 1.9.9, featuring:Ingo Schwarze
* -Thtml output mode * roff scaling units * and some minor fixes for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/
2009-10-19sync to 1.9.6: multiple improvements to references (.Rs)Ingo Schwarze
* 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
2009-09-21sync to 1.9.5: lookup hashes are now static tablesIngo Schwarze
shortening the code, and, according to kristaps@, speeding it up
2009-08-22sync to 1.9.1: correctly flag delimiter whitespaceIngo Schwarze
2009-08-22sync to 1.9.1: set mdoc_next flags in mdoc_*_alloc routines, where they belongIngo Schwarze
2009-08-22sync to 1.9.0: polishing the core code of mdoc macro handlingIngo Schwarze
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.
2009-07-26sync to 1.8.1: rewrite quoted literal handling correctly,Ingo Schwarze
rewrite TABSEP handling in a simpler way, and retire ECOLEMPTY, ARGS_QUOTED and ARGS_ARGVLIKE
2009-07-26sync to 1.8.1: removed excessively verbose EARGVPARM warningIngo Schwarze
2009-07-18sync to 1.8.0: move mdoc_a2att, mdoc_a2st, and mdoc_a2lib to libmdocIngo Schwarze
2009-07-13sync to 1.7.24: mdoc_nwarn/mdoc_nerr got mixed up;Ingo Schwarze
fix from joerg at netbsd via kristaps@
2009-07-12sync to 1.7.23: pass warning code to mdoc_pwarn() instead of warning messageIngo Schwarze
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"
2009-07-12sync to 1.7.23: pass error code to mdoc_perr() instead of error stringIngo Schwarze
and use the so improved mdoc_nerr() at many places; get rid of now unused static functions perr()
2009-07-12sync to 1.7.23: pass error code to mdoc_nerr() instead of error stringIngo Schwarze
and use the so improved mdoc_nerr() at many places
2009-07-12sync to 1.7.23: unify the various "enum merr" into libman.h and libmdoc.h,Ingo Schwarze
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