summaryrefslogtreecommitdiffstats
path: root/roff.c
Commit message (Collapse)AuthorAgeFilesLines
* Ouch: predefined strings moved into roff.c weren't being reinitalisedKristaps Dzonsons2011-06-301-0/+4
| | | | | after the first parse. Do this, but note there are more efficient ways just waiting for a table of macros.
* If a predefined string is missing, emit a warning and make it an emptyKristaps Dzonsons2011-05-261-5/+6
| | | | | | string instead of passing it along to libmdoc/libman (where it'll be printed verbatim, now). This is what groff seems to do, too (of course without a warning).
* Most important move in getting predefined strings entirely containedKristaps Dzonsons2011-05-241-2/+21
| | | | | | | | | | | within roff.c. These are now grokked from a table in the roff allocation routine and rest in the newly-created predefs.in (for consistency with chars.in). This is a first implementation and will likely be optimised along with the ds/de lookup table itself. This allows mandoc-defined predefined strings to be correctly removed or whatnot; earlier they couldn't. What will follow is the stripping-away of all predefined-string crud in the other parts of the system.
* Have conditional closure for both text and macro lines call through toKristaps Dzonsons2011-05-241-25/+11
| | | | | | ccond(). Fix the text handler to behave like the macro handler regarding escaped \}. Make \} actually become a zero-width space, too, and clean up the documentation in this regard.
* Fix a TODO to the effect that `.if n \{\ foo .br \}' was failing due toKristaps Dzonsons2011-05-241-9/+23
| | | | | | | | | | the `\}' not being directly after the `.br'. Now we check for `\}' in arbitrary parts of the line, and account for if it's escaped in funny ways. This behaviour diverges somewhat from groff in that the text at and following the `\}' is lost, while groff keeps it (sort-of). I'll add a COMPATIBILITY note to this effect.
* Move roff.c's strtol into libmandoc.h for use by other parts of the codeKristaps Dzonsons2011-05-141-27/+5
| | | | (which will come).
* User defined macros may invoke high-level macros.Ingo Schwarze2011-04-241-2/+1
| | | | | The latter got lost due to a regression in rev. 1.130. ok kristaps@
* Clean up parsing of delimiters in -mdoc. First, remove the "dowarn"Kristaps Dzonsons2011-04-191-1/+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-1/+1
| | | | function a parameter to suppress warnings.
* Check in fix to roff conditional if/else stack running out of space.Kristaps Dzonsons2011-04-131-33/+24
| | | | | | | This transforms the stack pop to occur prior to body execution, instead of afterward. Floated to tech@ without response, but it makes sense that this is alright and doesn't cause problems during extensive testing.
* Back out commit to roff.c that needs to go in on its own.Kristaps Dzonsons2011-04-131-24/+33
|
* Remove TODO from prior commit of lifting warnings from `Sh', `Ss', `SH',Kristaps Dzonsons2011-04-131-33/+24
| | | | and `SS' bodies.
* On .de macro lines, after the macro name, space and tab are equivalent.Ingo Schwarze2011-04-051-5/+3
| | | | | Bug reported by Tristan dot LeGuern at gmail dot com in fvwm2(1). tweaks and ok kristaps@; earlier version looked good to espie@ as well
* Carefully let mandoc_getcontrol() handle libroff's detection of a macroKristaps Dzonsons2011-03-291-29/+21
| | | | | | | | | line. Note that we now properly ignore \.", which earlier would have been pushed through macro detection. This required attention to all entries of roff_parse(). This removes a TODO by schwarze@ to the effect that \. can be a control character, which is now handled in mandoc_getcontrol().
* Step 2: blow away roff.h, as all of its functions have been moved intoKristaps Dzonsons2011-03-221-1/+0
| | | | libmandoc.h and there's nothing left.
* 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.