version 1.393, 2022/06/03 12:15:55 |
version 1.396, 2023/04/28 19:11:04 |
|
|
#include "tbl_parse.h" |
#include "tbl_parse.h" |
#include "eqn_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. */ |
/* Maximum number of string expansions per line, to break infinite loops. */ |
#define EXPAND_LIMIT 1000 |
#define EXPAND_LIMIT 1000 |
|
|
Line 1457 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
Line 1449 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
break; |
break; |
|
|
/* |
/* |
* If not overriden, |
* If not overridden, |
* let \*(.T through to the formatters. |
* let \*(.T through to the formatters. |
*/ |
*/ |
|
|
Line 1640 roff_getarg(struct roff *r, char **cpp, int ln, int *p |
|
Line 1632 roff_getarg(struct roff *r, char **cpp, int ln, int *p |
|
cp++; |
cp++; |
break; |
break; |
case '\\': |
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; |
cp[-pairs] = ASCII_ESC; |
|
newesc = 1; |
pairs++; |
pairs++; |
cp++; |
cp++; |
break; |
break; |
Line 2482 roff_getnum(const char *v, int *pos, int *res, int fla |
|
Line 2479 roff_getnum(const char *v, int *pos, int *res, int fla |
|
* Evaluate a string comparison condition. |
* Evaluate a string comparison condition. |
* The first character is the delimiter. |
* The first character is the delimiter. |
* Succeed if the string up to its second occurrence |
* 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 |
* Advance the cursor after the third occurrence |
* or lacking that, to the end of the line. |
* or lacking that, to the end of the line. |
*/ |
*/ |
Line 3740 roff_tr(ROFF_ARGS) |
|
Line 3737 roff_tr(ROFF_ARGS) |
|
{ |
{ |
const char *p, *first, *second; |
const char *p, *first, *second; |
size_t fsz, ssz; |
size_t fsz, ssz; |
enum mandoc_esc esc; |
|
|
|
p = buf->buf + pos; |
p = buf->buf + pos; |
|
|
Line 3754 roff_tr(ROFF_ARGS) |
|
Line 3750 roff_tr(ROFF_ARGS) |
|
|
|
first = p++; |
first = p++; |
if (*first == '\\') { |
if (*first == '\\') { |
esc = mandoc_escape(&p, NULL, NULL); |
if (mandoc_escape(&p, NULL, NULL) == ESCAPE_ERROR) |
if (esc == ESCAPE_ERROR) { |
|
mandoc_msg(MANDOCERR_ESC_BAD, ln, |
|
(int)(p - buf->buf), "%s", first); |
|
return ROFF_IGN; |
return ROFF_IGN; |
} |
|
fsz = (size_t)(p - first); |
fsz = (size_t)(p - first); |
} |
} |
|
|
second = p++; |
second = p++; |
if (*second == '\\') { |
if (*second == '\\') { |
esc = mandoc_escape(&p, NULL, NULL); |
if (mandoc_escape(&p, NULL, NULL) == ESCAPE_ERROR) |
if (esc == ESCAPE_ERROR) { |
|
mandoc_msg(MANDOCERR_ESC_BAD, ln, |
|
(int)(p - buf->buf), "%s", second); |
|
return ROFF_IGN; |
return ROFF_IGN; |
} |
|
ssz = (size_t)(p - second); |
ssz = (size_t)(p - second); |
} else if (*second == '\0') { |
} else if (*second == '\0') { |
mandoc_msg(MANDOCERR_TR_ODD, ln, |
mandoc_msg(MANDOCERR_TR_ODD, ln, |
Line 4383 roff_getformat(const struct roff *r) |
|
Line 4371 roff_getformat(const struct roff *r) |
|
* return zero and don't change the current position. |
* return zero and don't change the current position. |
* If the control character has been set with `.cc', then let that grain |
* If the control character has been set with `.cc', then let that grain |
* precedence. |
* 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 |
* control character when `cc' has been invoked will cause the |
* non-breaking macro contents to be printed verbatim. |
* non-breaking macro contents to be printed verbatim. |
*/ |
*/ |