aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
Commit message (Collapse)AuthorAgeFilesLines
* s/[Nn]ull/NUL/ in comments where appropriate;Ingo Schwarze2013-12-251-2/+2
| | | | suggested by Thomas Klausner <wiz @ NetBSD dot org>.
* The "value" argument to the roff(7) .nr requests ends right beforeIngo Schwarze2013-12-151-5/+18
| | | | | | | | the first non-digit character. While here, implement and document an optional sign, requesting increment or decrement, as documented in the Ossanna/Kernighan/Ritter troff manual and supported by groff. Reported by bentley@ on discuss@.
* Parse and ignore .hw (hyphenation points in words); this is safe becauseIngo Schwarze2013-10-221-1/+3
| | | | | | we don't do hyphenation anyway, so there is no point in throwing an ERROR when encountering .hw. Real-world usage of the request found by naddy@ in sysutils/dwdiff(1).
* Parse and ignore the .fam (font family) request.Ingo Schwarze2013-10-141-1/+3
| | | | | Fixes irunner(1) in devel/ipython and uim-xim(1) in inputmethods/uim. Thanks to naddy@ for bringing these to my attention.
* Support simple numerical conditions.Ingo Schwarze2013-10-051-4/+92
| | | | | | | | | | | Original code from Christos Zoulas, NetBSD rev. 1.11-1.13, April 3, 2013. I tweaked the code as follows: * In roff_getnum(), don't skip a minus that isn't followed by a digit. * In roff_getop(), do not handle "!=", groff doesn't support it either. * In roff_evalcond(), treat negative numbers as false, like groff. Besides, make the interfaces of roff_getnum() and roff_getop() more similar to each other and simplify parts of the code a bit.
* ROFFRULE_ALLOW = 0, ROFFRULE_DENY = 1 was confusing,Ingo Schwarze2013-10-051-3/+3
| | | | | so exchange the two entries in enum roffrule; no functional change; from Christos Zoulas, NetBSD rev. 1.11, April 4, 2013.
* Avoid code duplication in roff_parseln() as suggested byIngo Schwarze2013-10-051-11/+6
| | | | | | Christos Zoulas in NetBSD rev. 1.11; i'm even going a step further and making this yet a bit shorter. No functional change.
* Expand references to number registers in exactly the same way asIngo Schwarze2013-10-051-32/+53
| | | | | | | | | | references to user-defined strings. While here, make number registers signed int, like in groff. Inspired by NetBSD roff.c rev. 1.8 and read.c rev. 1.7 written by Christos Zoulas on March 21, 2013, but implemented in a completely different way, without hacking into read.c, where this functionality really doesn't belong.
* Support setting arbitrary roff(7) number registers,Ingo Schwarze2013-10-051-28/+57
| | | | | | | | | | | | | | preserving read support for the ".nr nS" SYNOPSIS state register. Inspired by NetBSD roff.c rev. 1.18 (Christos Zoulas, March 21, 2013), but implemented differently. I don't want to have yet another different implementation of a hash table in mandoc - it would be the second one in roff.c alone and the fifth one in mandoc grand total. Instead, i designed and implemented roff_setreg() and roff_getreg() to be similar to roff_setstrn() and roff_getstrn(). Once we feel the need to optimize, we can introduce one common hash table implementation for everything in mandoc.
* Cleanup suggested by gcc-4.8.1, following hints by Christos Zoulas:Ingo Schwarze2013-10-051-2/+2
| | | | | | | | - avoid bad qualifier casting in roff.c, roff_parsetext() by changing the mandoc_escape arguments to "const char const **" - avoid bad qualifier casting in mandocdb.c, index_merge() - do not complain about unused variables in test-*.c - garbage collect a few unused variables elsewhere
* Rudimentary implementation of the .it request (input line trap).Ingo Schwarze2013-07-131-11/+58
| | | | | | | | | | As with any low-level roff request involving subtle interactions with macro internals, this implementation is not exact, but it does handle the simplest cases. This request occurs in man(7) code generated from DocBook, for example mysql(1) and yasm_arch(7). Thanks to brad@ for reporting the issue back in January 2011.
* Parse for the closing delimiter `\}' for conditionalsIngo Schwarze2013-06-271-44/+32
| | | | | | | | | | | even when the conditional evaluated to false. While here, reshuffle the code to reduce indentation and make it more readable; that way, we can even trim down the comments because it becomes obvious what the code does. Found in zipinfo(1) - thanks to espie@ and naddy@ for making me look at that manual page.
* More cleanup: Consistently use the name "struct tbl_node *tbl"Ingo Schwarze2013-05-311-10/+10
| | | | | that is already used almost everywhere instead of gratuitiously inventing different names at four places. No functional change.
* In groff, trying to redefine standard man(7) macros before .TH has no effect;Ingo Schwarze2012-11-191-3/+68
| | | | | | | | | | | | | | after .TH, it works. Trying to redefine standard mdoc(7) macros before .Dd works when calling groff with the -mdoc command line option, but does not when calling groff with -mandoc; after .Dd, it always works. Arguably, one might call that buggy behaviour in groff, but it is very unlikely that anybody will change groff in this respect (certainly, i'm not volunteering). So let's be bug-compatible. This fixes the vertical spacing in sox(1). Merging from OpenBSD libmandoc.h 1.18, read.c 1.8, roff.c 1.47, June 2, 2012.
* Add `cc' support.Kristaps Dzonsons2012-06-121-2/+59
| | | | | | | | | | | | | | | This was reported by espie@ and in the TODO. Caveat: `cc' has buggy behaviour when invoked in groff(1) and followed by a line-breaking control character macro, e.g., in a -man doc, .cc | .B foo 'B foo |cc 'B foo will cause groff(1) to behave properly for `.B' but inline the macro definition for `B' when invoked with the line-breaking macro.
* Fix blank line handling in .if.Ingo Schwarze2012-05-311-34/+25
| | | | | | | | | | 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-9/+13
| | | | | | | 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-10/+3
| | | | | is both preceded and followed by an alphabetic character. ok kristaps@
* Fix another regression introduced in 1.11.7:Ingo Schwarze2011-09-181-3/+14
| | | | | | | | | | | | | | | | | 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-2/+2
| | | | found while syncing to OpenBSD
* Lint check.Kristaps Dzonsons2011-08-161-8/+1
|
* Use a character-table for quick per-character substitution in `tr'. AsKristaps Dzonsons2011-07-291-43/+72
| | | | suggested by joerg@.
* Renamed roffstr as roffkv (key-value) and split out char/size_t intoKristaps Dzonsons2011-07-291-44/+51
| | | | roffstr.
* Fix border condition in `tr' grokking arguments.Kristaps Dzonsons2011-07-281-2/+3
|
* An implementation of `tr'. This routes allocations of TEXT nodesKristaps Dzonsons2011-07-281-22/+177
| | | | | | | 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-4/+4
|
* Have roffstr keep track of string lengths.Kristaps Dzonsons2011-07-271-3/+10
|
* Fix a memory-offset bug that was hell tracking down.Kristaps Dzonsons2011-07-271-2/+2
|
* Rename some terms (incremental part of a larger set of check-ins).Kristaps Dzonsons2011-07-271-19/+19
|
* Fix hyphen-replacement loop.Kristaps Dzonsons2011-07-271-4/+6
|
* Critical fix to avoid looping forever.Kristaps Dzonsons2011-07-271-2/+4
|
* Clean up roff_getstrn() function.Kristaps Dzonsons2011-07-271-5/+6
|
* Disable in-line eqn processing for a bit.Kristaps Dzonsons2011-07-271-3/+7
|
* Move mandoc_hyph() into roff_parsetext() as a single conditional. WhileKristaps Dzonsons2011-07-271-21/+32
| | | | | 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-16/+47
| | | | | | | | | | | 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-11/+17
| | | | run even when `first_string' isn't defined.
* Move checking of escapes into roff.c, where we're already steppingKristaps Dzonsons2011-07-261-2/+14
| | | | | 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-13/+38
| | | | | | 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-2/+2
| | | | 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-2/+2
| | | | effect.
* Finish the eqn syntactic parser. This correctly parses terms and doesKristaps Dzonsons2011-07-211-2/+2
| | | | | | | 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-9/+38
| | | | | 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-4/+4
| | | | | | | | | 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-2/+2
| | | | messages.
* Fix two issues: the first, where a `.\}' wasn't being interpreted as aKristaps Dzonsons2011-07-081-4/+26
| | | | | | | | 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-1/+5
| | | | | 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-6/+7
| | | | | | 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-3/+22
| | | | | | | | | | | 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-26/+12
| | | | | | 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-10/+24
| | | | | | | | | | 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.