summaryrefslogtreecommitdiffstats
path: root/libmdoc.h
Commit message (Collapse)AuthorAgeFilesLines
* In private header files, __BEGIN_DECLS and __END_DECLS are pointless.Ingo Schwarze2015-11-071-3/+0
| | | | | | | | | | | | Because these work slightly differently on different systems, they are becoming a maintenance burden in the portable version, so delete them. Besides, one of the chief design goals of the mandoc toolbox is to make sure that nothing related to documentation requires C++. Consequently, linking mandoc against any kind of C++ program would defeat the purpose and is not supported. I don't understand why kristaps@ added them in the first place.
* In order to become able to generate syntax tree nodes on the roff(7)Ingo Schwarze2015-10-201-1/+5
| | | | | | | | level, validation must be separated from parsing and rewinding. This first big step moves calling of the mdoc(7) post_*() functions out of the parser loop into their own mdoc_validate() pass, while using a new mdoc_state() module to make syntax tree state handling available to both the parser loop and the validation pass.
* Very tricky diff to fix macro interpretation and spacing around tabsIngo Schwarze2015-10-171-3/+1
| | | | | | | | | | | | | | in .Bl -column; it took me more than a day to get this right. Triggered by a loosely related bug report from tim@. The lesson for you is: Use .Ta macros in .Bl -column, avoid tabs, or you are in for surprises: The last word before a tab is not interpreted as a macro (unless there is a blank in between), the first word after a tab isn't either (unless there is a blank in between), and a blank after a tab causes a leading blank in the respective output cell. Yes, "blank", "tab", "blank tab" and "tab blank" all have different semantics; if you write code relying on that, good luck maintaining it afterwards...
* Get rid of two empty wrapper functions. No functional change.Ingo Schwarze2015-04-231-1/+0
|
* Unify some node handling functions that use TOKEN_NONE.Ingo Schwarze2015-04-191-5/+0
| | | | | | | | * 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.
* Unify node handling functions:Ingo Schwarze2015-04-191-2/+0
| | | | | | | | | | | * node_alloc() for mdoc and man_node_alloc() -> roff_node_alloc() * node_append() for mdoc and man_node_append() -> roff_node_append() * mdoc_head_alloc() and man_head_alloc() -> roff_head_alloc() * mdoc_body_alloc() and man_body_alloc() -> roff_body_alloc() * mdoc_node_unlink() and man_node_unlink() -> roff_node_unlink() * mdoc_node_free() and man_node_free() -> roff_node_free() * mdoc_node_delete() and man_node_delete() -> roff_node_delete() Minus 130 lines of code, no functional change.
* Unify {mdoc,man}_{alloc,reset,free}() into roff_man_{alloc,reset,free}().Ingo Schwarze2015-04-181-1/+0
| | | | | Minus 80 lines of code, no functional change. Written on the train from Koeln to Wolfsburg returning from p2k15.
* Move mdoc_hash_init() and man_hash_init() to libmandoc.hIngo Schwarze2015-04-181-1/+0
| | | | | and call them from mparse_alloc() and choose_parser(), preparing unified allocation of struct roff_man.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-46/+16
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Third step towards parser unification:Ingo Schwarze2015-04-021-1/+1
| | | | | Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
* Second step towards parser unification:Ingo Schwarze2015-04-021-23/+23
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* Get rid of all calls to rew_sub() in blk_exp_close(); only ten callsIngo Schwarze2015-02-021-1/+1
| | | | | | remain in other functions. As a bonus, this fixes an assertion failure jsg@ found some time ago with afl (test case 982) and improves minor details in error reporting.
* remove unneccessary inclusion protection; patch from deraadt@Ingo Schwarze2014-12-011-4/+0
|
* Provide a helper function macro_or_word() and use it to prune theIngo Schwarze2014-11-291-2/+0
| | | | | | | | | | same chunk of argument parsing code out of five of the eight callback functions. The other three have too much special handling to participate. As a bonus, let lookup() and mdoc_args() deal with line macros and retire the lookup_raw() helper and the mdoc_zargs() internal interface function. No functional change, minus 40 lines of code.
* Fold the loop around mdoc_argv() into the function itself,Ingo Schwarze2014-11-281-8/+1
| | | | | | it was the same in all four cases. As a bonus, get rid of one enum type that was used for internal communication. No functional change, minus 40 lines of code.
* Retire support for CSRG supplementary document titles. These areIngo Schwarze2014-11-281-1/+0
| | | | | long obsolete and were never written in mdoc(7) in the first place. Removes 100 lines from source files.
* Simplify by making the mdoc parser callbacks void, and some cleanup;Ingo Schwarze2014-11-281-3/+3
| | | | no functional change, minus 50 lines of code.
* Simplify the code by making various mdoc parser helper functions void.Ingo Schwarze2014-11-281-9/+8
| | | | No functional change, minus 130 lines of code.
* Simplify code by making mdoc validation handlers void.Ingo Schwarze2014-11-281-2/+2
| | | | No functional change, minus 90 lines of code.
* Multiple fixes with respect to in-line macros:Ingo Schwarze2014-11-171-1/+2
| | | | | | | | | | * .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@.
* demacrify: get rid of man_nmsg(), man_pmsg(), mdoc_nmsg(), mdoc_pmsg()Ingo Schwarze2014-08-011-4/+0
|
* garbage collect three unused global flags; no functional changeIngo Schwarze2014-07-301-1/+0
|
* mark defos as const; nobody needs to change it,Ingo Schwarze2014-07-091-1/+1
| | | | and it is occasionally useful to be able to pass literal strings
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze2014-07-021-0/+1
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-4/+4
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Add an option -Q (quick) to mandocdb(8)Ingo Schwarze2014-01-051-0/+1
| | | | | | | | | | | | | | | 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() and fix some errors in mandoc(3). 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.
* There are three kinds of input lines: text lines, macros takingIngo Schwarze2013-10-211-2/+6
| | | | | | | | | | | | | | | 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. Regarding mandocdb(8), this fixes yet another regression introduced when switching from DB to SQLite: The ability to search for strings crossing word boundaries was lost and is hereby restored. At the same time, database sizes and build times are both reduced by a bit more than 5% each.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-171-8/+7
| | | | | | | | 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
* Fix handling of paragraph macros inside lists:Ingo Schwarze2012-07-181-0/+1
| | | | | | | * When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. OpenBSD rev. mdoc_validate.c 1.107, mdoc.c 1.91
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theIngo Schwarze2012-05-271-0/+1
| | | | | | | | | | 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. "Please check them in and I'll look into them later!" kristaps@
* In man(7), when no explicit volume name is given, use the defaultIngo Schwarze2011-12-021-1/+0
| | | | | | | | | | | | 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
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Follow-up: forgot to remove useless regset structs.Kristaps Dzonsons2011-07-181-1/+0
|
* Make `struct roff' be passed into libmdoc and libman upon creation.Kristaps Dzonsons2011-07-181-0/+1
| | | | | This is required for supporting in-line equations. While here, push registers properly into roff and add an set/get/mod interface.
* Clean up parsing of delimiters in -mdoc. First, remove the "dowarn"Kristaps Dzonsons2011-04-191-7/+1
| | | | | | | | variable from mandoc_getarg() so that it prints the warning every time. Then, remove the warning from args_checkpunct(). This way, warnings are being posted at the correct time. This makes the flag argument to mdoc_zargs() superfluous, so make it be zero when it's invoked. Finally, move the args() flags into mdoc_argv.c and make them enums.
* Get mdoc_argv.c ready to use [some of] mandoc_getarg() by giving saidKristaps Dzonsons2011-04-171-10/+10
| | | | function a parameter to suppress warnings.
* libmdoc.h and libman.h were including mdoc.h and man.h, respectively.Kristaps Dzonsons2011-03-221-2/+0
| | | | | Don't have them do that (includes in header files = faugh), and have individual files directly include these files.
* mdoc_argn_free is only used local to mdoc_argv.c, so make it static.Kristaps Dzonsons2011-03-221-1/+0
|
* Move mandoc_isdelim() back into libmdoc.h. This fixes an unreportedKristaps Dzonsons2011-03-221-0/+20
| | | | | | | | | error where (1) -man pages were punctuating delimiters (e.g., `.B a ;') and where (2) standalone punctuation in -mdoc or -man (e.g., ";" on its own line) would also be punctuated. This introduces a small amount of complexity of mdoc_{html,term}.c must manage their own spacing with running print_word() or print_text(). The check for delimiting now happens in mdoc_macro.c's dword().
* Consolidate messages. Have all parse-time messages (in libmdoc,Kristaps Dzonsons2011-03-201-7/+4
| | | | | | | | | libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
* Clean-up in libmdoc: fix last checks for mdoc_*msg return value, thenKristaps Dzonsons2011-03-171-1/+1
| | | | | make mdoc_vmsg not return an int. libmdoc is now completely clean of return-value checks from the message subsystem.
* Kill off some unused function prototypes.Kristaps Dzonsons2011-03-171-3/+0
|
* Move mdoc_str2sec() into mdoc_validate.c as a2sec(), as that's the onlyKristaps Dzonsons2011-03-171-1/+0
| | | | place that it's being used.
* Move mdoc_isdelim() into mandoc.h as mandoc_isdelim(). This allows theKristaps Dzonsons2011-03-171-9/+0
| | | | | | removal of manual delimiter checks in html.c and term.c. Finally, add the escaped period as a closing delimiter, removing a TODO to this effect.
* Make args_checkpunct() use mdoc_isdelim() instead of mdoc_iscdelim(),Kristaps Dzonsons2011-03-171-1/+1
| | | | which is wrong. Then remove mdoc_iscdelim() alltogether.
* mdoc_action.c is no more. Attic it and remove it from the Makefile.Kristaps Dzonsons2010-11-301-3/+0
| | | | | Remove references to MDOC_ACTED (it was only assertions) and the pre- and post-action functions.
* Implement a simple, consistent user interface for error handling.Ingo Schwarze2010-08-201-1/+0
| | | | | | | | | | | | | | | | | 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.
* correct lots of copyright notices;Ingo Schwarze2010-07-131-1/+1
| | | | ok kristaps@
* Re-constitution of `ds' symbol processing. First, push theKristaps Dzonsons2010-07-071-1/+0
| | | | | | | | | roff_getstr() family of functions into roff.c with the "first_string" directly in struct roff. Second, pre-process each line for reserved words in libroff, splicing and re-running a line if it has one (this allows defined symbols to be macros). Remove term.c's invocation of the roff_getstrn() function. Removed function documentation in roff.3 and added roff.7 `ds' documentation.
* In the mdoc(7) parser, inspect roff registers early such that all partsIngo Schwarze2010-07-011-0/+1
| | | | | | | | | | | | 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@ and tested by sobrado@