summaryrefslogtreecommitdiffstats
path: root/roff.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix blank line handling in .if.Ingo Schwarze2012-05-311-33/+24
| | | | | | | | | | In particular, two cases were wrong: - single-line .if with trailing whitespace gave no blank line - multiline .if with \{ but without \{\ gave no blank line While here, simplify roff_cond() by partially reordering the code. "good one" kristaps@
* Handle infinite recursion the same way as groff:Ingo Schwarze2011-10-241-8/+12
| | | | | | | When string expansion exceeds the recursion limit, drop the whole input line, instead of leaving just the string unexpanded. ok kristaps@
* Breaking the line at a hyphen is only allowed if the hyphenIngo Schwarze2011-09-191-9/+2
| | | | | is both preceded and followed by an alphabetic character. ok kristaps@
* Fix another regression introduced in 1.11.7:Ingo Schwarze2011-09-181-2/+13
| | | | | | | | | | | | | | | | | If a string is defined in terms of itself, the REPARSE_LIMIT in read.c used to break the cycle. This no longer works since all the work is now done in the function roff_res(), looping indefinitely. Make this loop finite by arbitrarily limiting the number of times one string may be expanded; when that limit is reached, leave the remaining string references unexpanded. This changes behaviour compared to 1.11.5, where the whole line would have been dropped. The new behaviour is better because it loses less information. We don't want to imitate groff-1.20.1 behaviour anyway because groff aborts parsing of the whole file. ok kristaps@
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Lint check.Kristaps Dzonsons2011-08-161-7/+0
|
* Use a character-table for quick per-character substitution in `tr'. AsKristaps Dzonsons2011-07-291-42/+71
| | | | suggested by joerg@.
* Renamed roffstr as roffkv (key-value) and split out char/size_t intoKristaps Dzonsons2011-07-291-43/+50
| | | | roffstr.
* Fix border condition in `tr' grokking arguments.Kristaps Dzonsons2011-07-281-1/+2
|
* An implementation of `tr'. This routes allocations of TEXT nodesKristaps Dzonsons2011-07-281-21/+176
| | | | | | | through libroff, which does the appropriate translations of `tr'. This is SLOW: it uses the backend of `ds' and `de', which is a simple linear list. However, unlike `ds' and `de', it iterates over EACH CHARACTER of the entire file looking for replacements.
* Correctly set valsz this time.Kristaps Dzonsons2011-07-271-3/+3
|
* Have roffstr keep track of string lengths.Kristaps Dzonsons2011-07-271-2/+9
|
* Fix a memory-offset bug that was hell tracking down.Kristaps Dzonsons2011-07-271-1/+1
|
* Rename some terms (incremental part of a larger set of check-ins).Kristaps Dzonsons2011-07-271-18/+18
|
* Fix hyphen-replacement loop.Kristaps Dzonsons2011-07-271-3/+5
|
* Critical fix to avoid looping forever.Kristaps Dzonsons2011-07-271-1/+3
|
* Clean up roff_getstrn() function.Kristaps Dzonsons2011-07-271-4/+5
|
* Disable in-line eqn processing for a bit.Kristaps Dzonsons2011-07-271-2/+6
|
* Move mandoc_hyph() into roff_parsetext() as a single conditional. WhileKristaps Dzonsons2011-07-271-20/+31
| | | | | here, do some function renames for clarity and make all function prototypes be in one place.
* First, roff_res() has no need to invoke ROFF_RERUN: since it's executedKristaps Dzonsons2011-07-271-15/+46
| | | | | | | | | | | before any other roff processing occurs, it's Ok to just let it do its thing and pass through. Also, make sure this function is ALWAYS called, not just when first_string is defined. Second, add a new function, roff_parsetext(), that post-processes non-macro lines. This, for the time being, amounts to detecting soft hyphens. This fixes a long-standing bug in that -man now has proper hyphen breaking!
* Use correct column of warning messages and make sure this function isKristaps Dzonsons2011-07-261-10/+16
| | | | run even when `first_string' isn't defined.
* Move checking of escapes into roff.c, where we're already steppingKristaps Dzonsons2011-07-261-1/+13
| | | | | through looking for user-defined escapes. This clears up a nice bit of validation code.
* Implement the first steps of equation parsing from within libmdoc.Kristaps Dzonsons2011-07-251-12/+37
| | | | | | This consists of a shim around the text parser that calls out to libroff if equation components exist on the line. Right now this will do nothing, as the equation delimiter always returns nil.
* Add support for tdefine and ndefine. Consolidate some error messages. AddKristaps Dzonsons2011-07-231-1/+1
| | | | somem more version notes (getting there). Have the equation nanme be captured.
* Support `size' constructs in eqn.7. Generalise mandoc_strontou to thisKristaps Dzonsons2011-07-211-1/+1
| | | | effect.
* Finish the eqn syntactic parser. This correctly parses terms and doesKristaps Dzonsons2011-07-211-1/+1
| | | | | | | the proper `define' dance, which amounts to pure word-replace (you can, say, define `foo' as `define' then define `define' as something else). eqn.c is now ready for some semantic parsing of `box' and `eqn' productions as defined by the grammar.
* Make `struct roff' be passed into libmdoc and libman upon creation.Kristaps Dzonsons2011-07-181-8/+37
| | | | | This is required for supporting in-line equations. While here, push registers properly into roff and add an set/get/mod interface.
* Add initial `define' support for eqn(7).Kristaps Dzonsons2011-07-171-3/+3
| | | | | | | | | This works by iterating over a simple list. It's a slow, auditable early implementation. Data is read (the reading function will be reused) then parsed, then the line re-run if remaining stuff exists. Note this function isn't the same as mandoc_getarg(), as eqn(7) uses a different system for reading quoted strings. This doesn't actually use the defines.
* Have equation be allocated with mparse. Will be needed for logging ofKristaps Dzonsons2011-07-121-1/+1
| | | | messages.
* Fix two issues: the first, where a `.\}' wasn't being interpreted as aKristaps Dzonsons2011-07-081-3/+25
| | | | | | | | proper macro in some conditions, resulting in strange parse errors. The second, where `\}' was being re-written as `\&'. Instead, we re-write this as two spaces OR nothing at all, if at the end of line. This isn't exactly what groff does (who knows...) but is a much safer and better way than how I was doing it before.
* 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@.