aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
Commit message (Collapse)AuthorAgeFilesLines
* Strangely, ignoring the roff(7) .na request was implemented in the man(7)Ingo Schwarze2015-01-241-2/+3
| | | | | parser. Simplify the code by moving it into the roff(7) parser, also making it work for mdoc(7).
* While ignoring the .ta (set tab stops) and .ti (temp indent) requestsIngo Schwarze2015-01-231-4/+4
| | | | | | is sometimes harmless, it often causes seriously ugly output, so flag these requests as unsupported rather than ignoring them. Discussed with naddy@.
* Wonders of roff(7): Integer numbers in numerical expressions can carryIngo Schwarze2015-01-231-3/+41
| | | | | scaling units, and some manuals (e.g. in devel/grcs) actually use that, so let's support it. Missing feature reported by naddy@.
* Slightly improve \w width measurements:Ingo Schwarze2015-01-221-2/+20
| | | | | | | Count special characters with the same width as ASCII characters and treat all other escape sequences as if they had a width of 0. Certainly not perfect, but a bit better. For example, GNU RCS ci(1) needs this; reported by naddy@.
* pass empty request lines through to tbl(7); sometimes, they end a layoutIngo Schwarze2015-01-211-11/+10
|
* Split the -Werror message level into -Werror (broken manual, probablyIngo Schwarze2015-01-201-19/+457
| | | | | | | | | | | | | using mandoc is better than using groff) and -Wunsupp (manual using unsupported low-level roff(7) feature, probably using groff is better than using mandoc). Once this feature is complete, it is intended to help porting, making the decision whether to USE_GROFF easier. As a first step, distinguish four classes of roff(7) requests: 1. Supported (currently 24 requests) 2. Currently ignored because unimportant (120) -> no message 3. Ignored for good because insecure (14) -> -Werror 4. Currently unsupported (68) -> these trigger the new -Wunsupp messages
* Parse and ignore .IX (generate index entry) macros because pod2man(1)Ingo Schwarze2015-01-161-1/+3
| | | | | emits them, by default without defining them, relying on the roff(7) quirk that undefined macros have no effect.
* downgrade ".so with absolute path" from FATAL to ERROR;Ingo Schwarze2015-01-141-3/+8
| | | | allows to get rid of ROFF_ERR
* Bugfix: When the invocation of a user-defined macro follows a roffIngo Schwarze2015-01-071-1/+2
| | | | | conditional request on the same input line, don't skip the first few bytes of its content.
* Fix a buffer overrun triggered by a trailing backslash at EOF inIngo Schwarze2015-01-011-5/+7
| | | | | | | an unclosed conditional body. If the memory contained the byte sequence "\}" after the end of the buffer before the next NUL, this could even write beyond the end of the buffer, specifically '&' to the location of the '}'. Found by jsg@ with afl.
* improve previous: do the size check up front to avoid leaking memoryIngo Schwarze2014-12-281-7/+5
|
* Reduce memory and time consumption on certain malformed input filesIngo Schwarze2014-12-251-1/+8
| | | | | | by limiting the length of expanded input lines during the (usually recursive) expansion of user defined strings. Resource hogging found by jsg@ with afl.
* Don't let the modulo operator divide by zero.Ingo Schwarze2014-12-181-2/+8
| | | | Found by jsg@ with afl.
* Ignore mdoc(7) and man(7) macros inside tbl(7) code because theyIngo Schwarze2014-12-161-5/+20
| | | | | would abort the table in an unclean way, causing assertion failures found by jsg@.
* When a string comparison condition contains no mismatching characterIngo Schwarze2014-12-161-2/+2
| | | | | | | | but ends without the final delimiter, the parse point was advanced one character too far and the invalid pointer returned to the caller of roff_parseln(). Later use could potentially advance the pointer even further and maybe even write to it. Fixing a buffer overrun found by jsg@ with afl (the most severe so far).
* When a numerical condition errors out after consuming at least oneIngo Schwarze2014-12-161-3/+6
| | | | | | | character of input, treat it as false, do not retry it as a string comparison condition. This also fixes a read buffer overrun that happened when the numerical condition advanced to the end of the input line before erroring out, found by jsg@ with afl.
* Empty conditions count as false.Ingo Schwarze2014-12-151-1/+3
| | | | | | When negated, they still count as false. Found when investigating crashes jsg@ found with afl. Not completely fixing the crashes yet.
* Support the ".if v" conditional operator (vroff mode, always false)Ingo Schwarze2014-11-191-1/+3
| | | | | | | for groff compatibility because pod2man(1) uses it that way. Weirdly, groff documents it as "for compatibility with other troff versions" but neither Heirloom nor Plan 9 have it. Issue reported by giovanni@ via sthen@.
* Use struct buf in libroff, it is very natural thereIngo Schwarze2014-11-011-167/+165
| | | | | | and reduces the number of arguments of many functions. While here, sprinkle some KNF. No functional change.
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-3/+10
| | | | | | | | validity of character escape names and warn about unknown ones. This requires mchars_spec2cp() to report unknown names again. Fortunately, that doesn't require changing the calling code because according to groff, invalid character escapes should not produce output anyway, and now that we warn about them, that's fine.
* With the current architecture, we can't support inline equationsIngo Schwarze2014-10-251-2/+3
| | | | | | | inside tables, sorry. So don't even try to parse tbl(7) blocks for eqn(7) delimiters. Broken table layout found in glPixelMap(3) while investigating a bug report by Theo Buehler <theo at math dot ethz dot ch>.
* Report arguments to .EQ as an error, and simplify the code:Ingo Schwarze2014-10-251-21/+10
| | | | | | | * drop trivial wrapper function roff_openeqn() * drop unused first arg of function eqn_alloc() * drop usused member "name" of struct eqn_node While here, sync to OpenBSD by killing some trailing blanks.
* Protect the roff parser from dividing by zero. ok schwarze@Kristaps Dzonsons2014-10-201-14/+25
|
* correctly parse spacing around in-line equationsIngo Schwarze2014-10-201-6/+37
| | | | | at the beginning and at the end of input lines; issue reported by kristaps@
* correct spacing before inline equationsIngo Schwarze2014-10-201-12/+4
|
* oops, don't escape the first token of inline equationsIngo Schwarze2014-10-161-3/+3
|
* Implement in-line equations, much needed by Xenocara manuals.Ingo Schwarze2014-10-161-12/+59
| | | | | | | | Put the steering into the roff parser rather than into the mdoc parser such that it works for all macro languages and on both text and macro lines. Line breaks and blank characters generated before and after in-line equations are not perfect yet, but let's do one thing at a time.
* Parse and ignore the .pl (page length) request;Ingo Schwarze2014-09-071-1/+3
| | | | Daniel Levai reports that Slackware Linux uses this.
* Simplify by handling empty request lines at the one logical placeIngo Schwarze2014-09-061-1/+10
| | | | | in the roff parser instead of in three other places in other parsers. No functional change.
* Move main format autodetection from the parser dispatcher to theIngo Schwarze2014-09-061-3/+19
| | | | | | | | | | | roff parser where .Dd and .TH are already detected, anyway. This improves robustness because it correctly handles whitespace or an alternate control character before Dd. In the parser dispatcher, provide a fallback looking ahead in the input buffer instead of always assuming man(7). This corrects autodetection when Dd is preceded by other macros or macro-like handled requests like .ll. Triggered by reports from Daniel Levai about issues on Slackware Linux.
* libroff depends on libmandoc and so libmandoc should be included first;Ingo Schwarze2014-08-191-2/+2
| | | | merge from OpenBSD, patch by daniel@
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+3
| | | | | | Include <sys/types.h> where needed, it does not belong in config.h. Remove <stdio.h> from config.h; if it is missing somewhere, it should be added, but i cannot find a *.c file where it is missing.
* mention requests and macros in more messagesIngo Schwarze2014-08-011-3/+4
|
* Dynamically allocate the stack of roff(7) .ie condition valuesIngo Schwarze2014-08-011-17/+18
| | | | and thus get rid of the last useless fatal error.
* better name and wording for the last two non-generic errorsIngo Schwarze2014-07-301-2/+2
|
* Clean up ERROR messages related to document structure and macros:Ingo Schwarze2014-07-071-16/+25
| | | | Hierarchical naming and mention macro names in messages.
* implement .dei and .amiIngo Schwarze2014-07-071-33/+55
|
* Clean up messages related to plain text and to escape sequences.Ingo Schwarze2014-07-061-13/+13
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Fix expansion of escape sequences with incomplete arguments.Ingo Schwarze2014-07-061-8/+15
| | | | | | * For \* and \n, discard the incomplete arg, expand to empty string. * For \B, discard the incomplete arg, expand to the digit 0. * For \w, use the incomplete arg (behaviour unchanged).
* Clean up messages regarding excess arguments:Ingo Schwarze2014-07-041-3/+5
| | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
* MANDOCERR_NOARGS reported three completely unrelated classes of problems.Ingo Schwarze2014-07-031-3/+5
| | | | Split the roff(7) parts out of it and report the request names for these cases.
* The previous commit to this file broke the control flow keywords \{ and \}Ingo Schwarze2014-07-011-2/+4
| | | | | | | | when they immediately follow a request or macro name, without intervening whitespace. Minimal fix. The lesson learnt here is that, despite their appearance, \{ and \} are not escape sequences, so never skip them when parsing for names.
* Use the freshly improved roff_getname() functionIngo Schwarze2014-06-291-17/+16
| | | | | | | | for the main roff request parsing routine, roff_parse(). In request or macro invocations, escape sequences now terminate the request or macro name; what follows is treated as arguments. Besides, the names of user-defined macros can now contain backslashes (eek!).
* Use the freshly improved roff_getname() functionIngo Schwarze2014-06-291-39/+19
| | | | | | for the .de parsing routine, roff_block(), to correctly handle names terminated by escape sequences. Besides, this saves us 20 lines of code.
* Major roff_getname() cleanup.Ingo Schwarze2014-06-291-36/+52
| | | | | | | | | * Return the name even if it is terminated by an escape sequence, not a blank. * Skip the full escape sequence using mandoc_escape(), not just the first byte. * Make it non-destructive, return the length instead of writing a '\0'. * Let .ds and .as cope with the above changes to the internal interface. * Fix .rm and .rr to accept an escape sequence as the end of a name. * Fix .nr and .rr to not set/delete a register with an empty name.
* Bugfix in roff_setstrn():Ingo Schwarze2014-06-291-2/+3
| | | | Do not call strcmp() on an array of char that might not be NUL-terminated.
* Improve messages related to the roff(7) .so request.Ingo Schwarze2014-06-251-4/+5
| | | | | | | | | | | | | In all these messages, show the filename argument that was passed to the .so request. In case of failure, show an additional message reporting the file and the line number where the failing request was found. The existing message reporting the reason for the failure - for example, "Permission denied" - is left in place, unchanged. Inspired by a question asked by Nick@ after he saw the confusing old messages that used to be emitted in this area.
* Audit strlcpy(3)/strlcat(3) usage.Ingo Schwarze2014-04-231-20/+10
| | | | | | | | | | | | | * Repair three instances of silent truncation, use asprintf(3). * Change two instances of strlen(3)+malloc(3)+strlcpy(3)+strlcat(3)+... to use asprintf(3) instead to make them less error prone. * Cast the return value of four instances where the destination buffer is known to be large enough to (void). * Completely remove three useless instances of strlcpy(3)/strlcat(3). * Mark two places in -Thtml with XXX that can cause information loss and crashes but are not easy to fix, requiring design changes of some internal interfaces. * The file mandocdb.c remains to be audited.
* make sure static buffers for snprintf(3) are large enoughIngo Schwarze2014-04-201-4/+4
| | | | and cast snprintf return value to (void) where they are
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-163/+121
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change