From 1c23c7567c4afe565b12468b80b55f8a608ac7a8 Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 16 Aug 2022 17:29:18 +0000 Subject: [PATCH] Even though the constant ASCII_ESC is only used in the roff pre-parser roff.c, move it to the top level include file mandoc.h to reduce the risk of causing clashes when introducing new ASCII_* constants in the future. --- usr.bin/mandoc/mandoc.h | 4 +++- usr.bin/mandoc/roff.c | 17 +++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index e989422fafe..c1dc9124343 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.222 2022/08/15 17:59:00 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.223 2022/08/16 17:29:18 schwarze Exp $ */ /* * Copyright (c) 2012-2022 Ingo Schwarze * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons @@ -23,6 +23,8 @@ #define ASCII_NBRZW 30 /* non-breaking zero-width space */ #define ASCII_BREAK 29 /* breakable zero-width space */ #define ASCII_HYPH 28 /* breakable hyphen */ +#define ASCII_ESC 27 /* escape sequence from copy-in processing */ +#define ASCII_TABREF 26 /* reset tab reference position */ /* * Status level. This refers to both internal status (i.e., whilst diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 856adb9ae57..3512ceda94c 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.266 2022/06/07 09:41:22 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.267 2022/08/16 17:29:18 schwarze Exp $ */ /* * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons @@ -38,14 +38,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 @@ -1638,8 +1630,13 @@ roff_getarg(struct roff *r, char **cpp, int ln, int *pos) 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; -- 2.20.1