summaryrefslogtreecommitdiffstats
path: root/roff.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Consolidate messages. Have all parse-time messages (in libmdoc,Kristaps Dzonsons2011-03-201-30/+28
| | | | | | | | | 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.
* Make lint shut up a little bit.Kristaps Dzonsons2011-03-151-4/+4
|
* Allow EQN data to be pushed down into libmdoc via mdoc_addeqn(). OnlyKristaps Dzonsons2011-02-091-1/+1
| | | | the adding itself is implemented; equation data is not yet shown.
* Add initial EQN support to mandoc. This parses, then throws away, dataKristaps Dzonsons2011-02-061-9/+72
| | | | | | | | between EQ and EN roff blocks. EQN is different from TBL in that data after .EQ is unilaterally considered an equation until an .EN. Thus, there's no need to jump through hoops in having table spans and so on. This is ONLY the parse code framework in libroff. EQN is not yet passed into the backends.
* Ignore .ns (no-space mode), .ps (change point size), .ta (tab control)Ingo Schwarze2011-01-251-0/+6
| | | | | | for now. All of these just cause a bit too much or too little whitespace, but no serious formatting problems. Triggered by reports from brad@.
* When finding the roff .it request (line trap),Ingo Schwarze2011-01-221-0/+5
| | | | | make it clear that you cannot use mandoc to format that page (yet). Triggered by a report from brad@, ok kristaps@.
* Implement the roff .rm request (remove macro).Ingo Schwarze2011-01-161-11/+18
| | | | | | Using the new roff_getname() function, this is really simple. Breaks mandoc of the habit of reporting an error in each pod2man(1) preamble. Reminded by a report from brad@; ok kristaps@.
* Refactoring in preparation for .rm support:Ingo Schwarze2011-01-111-38/+45
| | | | | | | | | | 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@
* Calling a macro with fewer arguments than it is defined with is OK;Ingo Schwarze2011-01-031-1/+1
| | | | | the remaining ones default to the empty string, not to NULL. Regression reported and fix tested by kristaps@.
* Unify roff macro argument parsing (in roff.c, roff_userdef()) and man macroIngo Schwarze2011-01-031-43/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | argument parsing (in man_argv.c, man_args()), both having different bugs, to use one common macro argument parser (in mandoc.c, mandoc_getarg()), because from the point of view of roff, man macros are just roff macros, hence their arguments are parsed in exactly the same way. While doing so, fix these bugs: * Escaped blanks (i.e. those preceded by an odd number of backslashes) were mishandled as argument separators in unquoted arguments to user-defined roff macros. * Unescaped blanks preceded by an even number of backslashes were not recognized as argument separators in unquoted arguments to man macros. * Escaped backslashes (i.e. pairs of backslashes) were not reduced to single backslashes both in unquoted and quoted arguments both to user-defined roff macros and to man macros. * Escaped quotes (i.e. pairs of quotes inside quoted arguments) were not reduced to single quotes in man macros. OK kristaps@ Note that mdoc macro argument parsing is yet another beast for no good reason and is probably afflicted by similar bugs. But i don't attempt to fix that right now because it is intricately entangled with lots of unrelated high-level mdoc(7) functionality, like delimiter handling and column list phrase handling. Disentagling that would waste too much time now.
* Churn to get parts of 'struct tbl' visible from mandoc.h: rename theKristaps Dzonsons2011-01-021-5/+5
| | | | | | | existing 'struct tbl' as 'struct tbl_node', then move all option stuff into a 'struct tbl' in mandoc.h. This conflicted with a structure in chars.c, which was renamed.
* More checks for proper table exit.Kristaps Dzonsons2011-01-011-3/+8
|
* Raise an error if a table is closed without data.Kristaps Dzonsons2011-01-011-1/+1
|
* Add documentation bits for libroff's new roff_span().Kristaps Dzonsons2011-01-011-2/+6
| | | | | | Add bits to remember tbl's invocation point. Add ERROR class message if no data's in the table.
* Expose the parsed table API to the world and add accessors through theKristaps Dzonsons2010-12-311-0/+7
| | | | roff.h interface.
* Put parsed tables into a queue that's cleared at the end of parsing.Kristaps Dzonsons2010-12-311-10/+20
| | | | This completes the parsing phase of the new tbl implementation.
* Add handling for `T&', which restarts a table except for its options.Kristaps Dzonsons2010-12-291-0/+16
|
* Significant update to options handling, which now departs almostKristaps Dzonsons2010-12-291-1/+1
| | | | | | | | | | | | | completely with the BSD.lv code due to performance issues and flat-out errors. Performance issues: functions called per character. Ugly. Flat-out errors: disallowing "reserved" tokens as arguments to those options accepting arguments. Also added are two mandoc.h error codes for general tbl syntax errors and for bad options.
* Temporarily remove check for r->tbl at end of parse since we need theKristaps Dzonsons2010-12-281-1/+2
| | | | original parse point to generate a useful error message.
* Initial tbl framework. Parse point is in libroff, which keeps aKristaps Dzonsons2010-12-281-57/+65
| | | | | | | | | | | | | | | | | | | | | | | | | reference to a current tbl parse and routes ALL text into the tbl parse after stripping reserved words and making block-level pre-processing (e.g., `ig'). This is consistent with an analysis of embedded `TS/TE' in manuals with sprinkled -mdoc, roff, and -man macros. Fact of a parse is exposed to main.c by a return value (ROFF_TBL), which will trigger main.c to add a foreign parsed body to the -mdoc or -man parse stream. This interface isn't in yet, but will follow the parse-text functions in both libraries. I put this login in main.c because I don't want libroff calling directly into libmdoc or libman. As a consequence, a parsed row can be pushed directly into any -mdoc or -man context (put a `Bd -literal -offset indent' into a `TE/TS' block to see why this is necessary). It will then absorb formatting cues in the front-ends. A note on naming. I decided on libroff.h instead of tbl.h because this is purely within the roff layer. Separate tbl implementations will need, then, to interface with libroff. This is "how it should be" because tbl is tightly linked with roff in terms of `ds' and other formatting macros, as well as, of course, special characters and other roffisms.
* Sync to OpenBSD:Ingo Schwarze2010-12-211-11/+43
| | | | | | | | | 1) Now that growing buffers in main.c is safe, bring back the bugfix distinguishing empty and undefined macros that was backed out in the previous roff.c commit: `de' initializes to "", not to NULL. 2) Roff only interpolates \* strings when the leading backslash is not escaped; using optimizations suggested by joerg@ and kristaps@. ok kristaps@
* Track down a bug of empty `de XX' macros causing uncertain behaviour byKristaps Dzonsons2010-12-061-9/+21
| | | | | | | | | | returning empty strings in roff_getstrn() instead of NULL. This caused maddeningly irregular segfaults in the pod2man preamble for `de IX'. But only on DEC alpha. Also integrate the kinda-probably-safe assertion relaxation in term.c, field-tested by schwarze@. This allows ALL [unpreprocessed] base and xenocara manuals for all BSD systems to run without segfault.
* Merge schwarze@'s changes to allow for user-defined strings. ThisKristaps Dzonsons2010-12-021-72/+213
| | | | | | | | primarily adds a roff_userdef() function for parsing new defines and modifies the look-up procedure. NOTE: there is a bug hidden away in this update that causes an infinite loop in some pages. The cause is for the moment unknown.
* Merge OpenBSD's `so' handling (plus some documentation). Great work toKristaps Dzonsons2010-12-011-0/+27
| | | | schwarze@ and joerg@ for his comments!
* Re-ordering of roff requests as per OpenBSD.Kristaps Dzonsons2010-12-011-4/+12
| | | | Made `rm' be an error (again, OpenBSD...).
* Low-hanging fruit: add OpenBSD's `ad', `hy', `ne', and `nh' handling.Kristaps Dzonsons2010-12-011-4/+12
| | | | Rename roff_line() -> roff_line_ignore().
* Churny commit to quiet lint. No functional changes.Kristaps Dzonsons2010-09-041-2/+0
|
* Fix premature return from sub-conditional roff statements. This fixKristaps Dzonsons2010-09-041-5/+3
| | | | fully accomodates for the pod2man standard preamble!
* Allow `.xx\}' where xx is a macro (e.g., `.br\}') to close scope. This isKristaps Dzonsons2010-08-291-2/+9
| | | | | | experimental and hasn't been rigorously tested. It's only implemented in -mdoc for the time being. This is absolutely required for pod2man. It does, however, make the pod2man preamble be processed in full.
* Have the `ds' processor strip out `\\' as stipulated in groff.7. I onlyKristaps Dzonsons2010-08-241-2/+25
| | | | care because pod2man uses this construct.
* Implement a simple, consistent user interface for error handling.Ingo Schwarze2010-08-201-24/+8
| | | | | | | | | | | | | | | | | 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.
* No-op to shut up lint.Kristaps Dzonsons2010-07-271-1/+1
|
* Fix `ds' handling. This was stripping characters from "val", when theKristaps Dzonsons2010-07-271-12/+23
| | | | | | syntax of `ds' is such that ALL text following the first non-space/non-double-quote is part of the value. This also fixes the warning of *(string++) = NULL report by kristaps@ and joerg@.
* Lint-fixes (NetBSD).Kristaps Dzonsons2010-07-211-5/+5
|
* Re-constitution of `ds' symbol processing. First, push theKristaps Dzonsons2010-07-071-63/+122
| | | | | | | | | 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.
* Assert my copyright, making it explicit that i'm granting the same licenseIngo Schwarze2010-07-041-0/+1
| | | | | on those parts of the code and text that i have written as Kristaps is. "fine with me" kristaps@
* Rudimentary implementation of user-defined strings;Ingo Schwarze2010-07-031-1/+114
| | | | | | no time for more refinement right now. In particular, fixes terminfo(3) and mdoc.samples(7). ok kristaps@, who will add the HTML frontend bits
* Allow registers to be unset. Implement and document the `.nr nS val'.Kristaps Dzonsons2010-06-271-8/+11
|
* Downstream maintainers: this removes UGLY! I don't want divergingKristaps Dzonsons2010-06-271-17/+18
| | | | | | | | | functionality and UGLY works quite well thanks to schwarze@'s careful attention. This also backs out function-prototype changes for struct regset, instead stuffing a pointer to the regset directly into struct mdoc/man/roff.
* First step of adding register support. This is inspired by a significantKristaps Dzonsons2010-06-261-8/+79
| | | | | | patch by schwarze@. This commit adds support to libroff parsing `nr' into register set defined in regs.h. This will propogate into libmdoc and libman in later commits.
* Fix adding some minimal intelligence to conditional parser. See roff.7Kristaps Dzonsons2010-06-101-33/+88
| | | | | | | | | | for what's supported. This simplified the roff_cond() function quite nicely. From a bug report by uqs@. Added regression test based on bug-report example by uqs@. Also added ROFF_DEBUG to see what the hell the parser is actually doing. Obviously turned off by default.
* Make "sub" for conditionals run roffnode_cleanscope() before callingKristaps Dzonsons2010-06-091-1/+11
| | | | down to sub-arguments. From a bug report by Ulrich Spoerlein.
* Fixed condition of `\}' closing a conditional at the start of the line.Kristaps Dzonsons2010-06-011-3/+1
| | | | | | | | Fixed flushed-out condition of \} causing subsequent arguments to be truncated, when in fact the whole line should be passed through (if the conditional succeeds) to the front-end and the \} ignored there. Added regression test of this behaviour.
* Give libroff an extremely simple table-lookup instead of iterating overKristaps Dzonsons2010-05-291-21/+71
| | | | | each and every macro. The table keys on the first character then walks a chain. Good enough for now.
* recognize ".if n" as true;Ingo Schwarze2010-05-241-5/+16
| | | | | | nothing fancy yet, no negation, no grammer, just that one letter; from OpenBSD; "looks fine" kristaps@
* provide stubs to ignore .ds, .rm and .tr,Ingo Schwarze2010-05-241-0/+16
| | | | | | which occur in the standard pod2man preamble; from OpenBSD; "sounds good" joerg@, "can be checked in" kristaps@
* Full support for ie/el. This completes the initial roff support.Kristaps Dzonsons2010-05-171-60/+114
| | | | | Added test files for ie/el. Using `if 0' as a baseline for "false" roff instructions instead of `if t'.
* Oops: forgot to make roff_cblock() understand the new macros.Kristaps Dzonsons2010-05-171-1/+16
|
* libroff now intelligently throws away `am', `ami', `am1', `de', `dei',Kristaps Dzonsons2010-05-171-13/+32
| | | | and `de1'. This is also documented in roff.7.
* libroff now is aware of which sub-nodes should be interpreted even in aKristaps Dzonsons2010-05-171-80/+143
| | | | | | | | | | conditional-negative context so as to preserve structural integrity. Initial "rules" (deny/allow) are now inherited for future work in evaluating conditionals. Lint-fix noted by Joerg. Added regression tests for zany constructs.