From 3b52bb8d03ff61274832867c905a80a2761859aa Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 2 Jun 2022 14:51:41 +0000 Subject: Since \. is not a character escape sequence, re-classify it from the wrong parsing class ESCAPE_SPECIAL to the better-suited parsing class ESCAPE_UNDEF, exactly like it is already done for the similar \\, which isn't a character escape sequence either. No formatting change is intended just yet, but this will matter for upcoming improvements in the parser for roff(7) macro, string, and register names. See the node "5.23.2 Copy Mode" in "info groff" regarding what \\ and \. really mean. --- chars.c | 3 +-- mandoc_char.7 | 21 +++++++++++++-------- roff_escape.c | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/chars.c b/chars.c index d54fc458..ea84c0c5 100644 --- a/chars.c +++ b/chars.c @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.79 2020/02/13 16:18:29 schwarze Exp $ */ +/* $Id: chars.c,v 1.80 2022/06/02 14:51:41 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2014, 2015, 2017, 2018, 2020 @@ -92,7 +92,6 @@ static struct ln lines[] = { { "en", "-", 0x2013 }, { "hy", "-", 0x2010 }, { "e", "\\", 0x005c }, - { ".", ".", 0x002e }, { "r!", "!", 0x00a1 }, { "r?", "?", 0x00bf }, diff --git a/mandoc_char.7 b/mandoc_char.7 index eb9e65ac..de546496 100644 --- a/mandoc_char.7 +++ b/mandoc_char.7 @@ -1,8 +1,9 @@ -.\" $Id: mandoc_char.7,v 1.78 2020/10/31 11:45:16 schwarze Exp $ +.\" $Id: mandoc_char.7,v 1.79 2022/06/02 14:51:41 schwarze Exp $ .\" .\" Copyright (c) 2003 Jason McIntyre .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons -.\" Copyright (c) 2011,2013,2015,2017-2020 Ingo Schwarze +.\" Copyright (c) 2011, 2013, 2015, 2017-2020, 2022 +.\" Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -16,7 +17,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 31 2020 $ +.Dd $Mdocdate: June 2 2022 $ .Dt MANDOC_CHAR 7 .Os .Sh NAME @@ -220,13 +221,18 @@ where it introduces a request or a macro, and when appearing alone as a macro argument in .Xr mdoc 7 . In such situations, prepend a zero-width space -.Pq Sq \e&. +.Pq Sq \e&.\& to make it behave like normal text. .Pp -Do not use the +Do not use the character pair .Sq \e. -escape sequence. -It does not prevent special handling of the period. +to escape a period because +.Sq \e. +is not a character escape sequence, does not prevent special handling +of the period under normal circumstances, and is only intended to +be used in the very special situation of defining a user-defined +macro that, when called, defines another user-defined macro, which +no manual page is ever supposed to do. .Ss Backslashes To include a literal backslash .Pq Sq \e @@ -326,7 +332,6 @@ Punctuation: .It \e(en Ta \(en Ta en-dash .It \e(hy Ta \(hy Ta hyphen .It \ee Ta \e Ta back-slash -.It \e. Ta \. Ta period .It \e(r! Ta \(r! Ta upside-down exclamation .It \e(r? Ta \(r? Ta upside-down question .El diff --git a/roff_escape.c b/roff_escape.c index 39011cde..9d02054d 100644 --- a/roff_escape.c +++ b/roff_escape.c @@ -127,6 +127,7 @@ roff_escape(const char *buf, const int ln, const int aesc, case '\0': iendarg = --iend; /* FALLTHROUGH */ + case '.': case '\\': default: iarg--; @@ -136,7 +137,6 @@ roff_escape(const char *buf, const int ln, const int aesc, case ' ': case '\'': case '-': - case '.': case '0': case ':': case '_': @@ -481,7 +481,7 @@ out: err = MANDOCERR_ESC_UNSUPP; break; case ESCAPE_UNDEF: - if (buf[inam] == '\\') + if (buf[inam] == '\\' || buf[inam] == '.') return rval; err = MANDOCERR_ESC_UNDEF; break; -- cgit v1.2.3-56-ge451