=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.393 retrieving revision 1.396 diff -u -p -r1.393 -r1.396 --- mandoc/roff.c 2022/06/03 12:15:55 1.393 +++ mandoc/roff.c 2023/04/28 19:11:04 1.396 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.393 2022/06/03 12:15:55 schwarze Exp $ */ +/* $Id: roff.c,v 1.396 2023/04/28 19:11:04 schwarze Exp $ */ /* * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons @@ -40,14 +40,6 @@ #include "tbl_parse.h" #include "eqn_parse.h" -/* - * ASCII_ESC is used to signal from roff_getarg() to roff_expand() - * that an escape sequence resulted from copy-in processing and - * needs to be checked or interpolated. As it is used nowhere - * else, it is defined here rather than in a header file. - */ -#define ASCII_ESC 27 - /* Maximum number of string expansions per line, to break infinite loops. */ #define EXPAND_LIMIT 1000 @@ -1457,7 +1449,7 @@ roff_expand(struct roff *r, struct buf *buf, int ln, i break; /* - * If not overriden, + * If not overridden, * let \*(.T through to the formatters. */ @@ -1640,8 +1632,13 @@ roff_getarg(struct roff *r, char **cpp, int ln, int *p cp++; break; case '\\': - newesc = 1; + /* + * Signal to roff_expand() that an escape + * sequence resulted from copy-in processing + * and needs to be checked or interpolated. + */ cp[-pairs] = ASCII_ESC; + newesc = 1; pairs++; cp++; break; @@ -2482,7 +2479,7 @@ roff_getnum(const char *v, int *pos, int *res, int fla * Evaluate a string comparison condition. * The first character is the delimiter. * Succeed if the string up to its second occurrence - * matches the string up to its third occurence. + * matches the string up to its third occurrence. * Advance the cursor after the third occurrence * or lacking that, to the end of the line. */ @@ -3740,7 +3737,6 @@ roff_tr(ROFF_ARGS) { const char *p, *first, *second; size_t fsz, ssz; - enum mandoc_esc esc; p = buf->buf + pos; @@ -3754,23 +3750,15 @@ roff_tr(ROFF_ARGS) first = p++; if (*first == '\\') { - esc = mandoc_escape(&p, NULL, NULL); - if (esc == ESCAPE_ERROR) { - mandoc_msg(MANDOCERR_ESC_BAD, ln, - (int)(p - buf->buf), "%s", first); + if (mandoc_escape(&p, NULL, NULL) == ESCAPE_ERROR) return ROFF_IGN; - } fsz = (size_t)(p - first); } second = p++; if (*second == '\\') { - esc = mandoc_escape(&p, NULL, NULL); - if (esc == ESCAPE_ERROR) { - mandoc_msg(MANDOCERR_ESC_BAD, ln, - (int)(p - buf->buf), "%s", second); + if (mandoc_escape(&p, NULL, NULL) == ESCAPE_ERROR) return ROFF_IGN; - } ssz = (size_t)(p - second); } else if (*second == '\0') { mandoc_msg(MANDOCERR_TR_ODD, ln, @@ -4383,7 +4371,7 @@ roff_getformat(const struct roff *r) * return zero and don't change the current position. * If the control character has been set with `.cc', then let that grain * precedence. - * This is slighly contrary to groff, where using the non-breaking + * This is slightly contrary to groff, where using the non-breaking * control character when `cc' has been invoked will cause the * non-breaking macro contents to be printed verbatim. */