From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Split the excessively generic diagnostic message "invalid escape
Date: Tue, 7 Jun 2022 04:55:15 -0500 (EST) [thread overview]
Message-ID: <3365ab4f581fb9c0@mandoc.bsd.lv> (raw)
Log Message:
-----------
Split the excessively generic diagnostic message "invalid escape sequence"
into the more specific messages "invalid escape argument delimiter"
and "invalid escape sequence argument".
Modified Files:
--------------
mandoc:
mandoc.1
mandoc.h
mandoc_msg.c
roff_escape.c
mandoc/regress/char/space:
invalid.out_lint
mandoc/regress/roff/esc:
O1.out_lint
h.out_lint
l.in
l.out_ascii
l.out_lint
Revision Data
-------------
Index: invalid.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/char/space/invalid.out_lint,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/char/space/invalid.out_lint -Lregress/char/space/invalid.out_lint -u -p -r1.2 -r1.3
--- regress/char/space/invalid.out_lint
+++ regress/char/space/invalid.out_lint
@@ -1,4 +1,4 @@
-mandoc: invalid.in:7:15: WARNING: invalid escape sequence: \[
+mandoc: invalid.in:7:15: WARNING: invalid escape sequence argument: \[
mandoc: invalid.in:8:14: ERROR: invalid special character: \[%]
mandoc: invalid.in:9:16: ERROR: invalid special character: \[&]
mandoc: invalid.in:10:12: ERROR: invalid special character: \[:]
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.1,v
retrieving revision 1.259
retrieving revision 1.260
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.259 -r1.260
--- mandoc.1
+++ mandoc.1
@@ -1797,10 +1797,9 @@ it is hard to predict which tab stop pos
.Pq mdoc
A new sentence starts in the middle of a text line.
Start it on a new input line to help formatters produce correct spacing.
-.It Sy "invalid escape sequence"
+.It Sy "invalid escape sequence argument"
.Pq roff
-An escape sequence has an invalid opening argument delimiter
-or the argument is of an invalid form.
+The argument of an escape sequence is of an invalid form.
Invalid escape sequences are ignored.
.It Sy "undefined escape, printing literally"
.Pq roff
@@ -2314,6 +2313,18 @@ The escape sequence is ignored.
The name given in a special character escape sequence is not known to
.Nm .
The escape sequence is ignored.
+.It Sy "invalid escape argument delimiter"
+.Pq roff
+An escape sequence that expects a numerical argument
+attempts to employ one of the characters
+.Qq " %&()*+-./0123456789:<=>"
+as an argument delimiter.
+The escape sequence is ignored including the invalid opening delimiter
+and the rest of the argument may appear as output text.
+While various charcters can be used as argument delimiters,
+using the apostrophe-quote character
+.Pq Sq \(aq
+is recommended for readability and robustness.
.El
.Ss Unsupported features
.Bl -ohang
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.h,v
retrieving revision 1.278
retrieving revision 1.279
diff -Lmandoc.h -Lmandoc.h -u -p -r1.278 -r1.279
--- mandoc.h
+++ mandoc.h
@@ -172,7 +172,7 @@ enum mandocerr {
MANDOCERR_FI_BLANK, /* blank line in fill mode, using .sp */
MANDOCERR_FI_TAB, /* tab in filled text */
MANDOCERR_EOS, /* new sentence, new line */
- MANDOCERR_ESC_BAD, /* invalid escape sequence: esc */
+ MANDOCERR_ESC_ARG, /* invalid escape sequence argument: esc */
MANDOCERR_ESC_UNDEF, /* undefined escape, printing literally: char */
MANDOCERR_STR_UNDEF, /* undefined string, using "": name */
@@ -239,6 +239,7 @@ enum mandocerr {
MANDOCERR_ESC_INCOMPLETE, /* incomplete escape sequence: esc */
MANDOCERR_ESC_BADCHAR, /* invalid special character: esc */
MANDOCERR_ESC_UNKCHAR, /* unknown special character: esc */
+ MANDOCERR_ESC_DELIM, /* invalid escape argument delimiter: esc */
MANDOCERR_UNSUPP, /* ===== start of unsupported features ===== */
Index: mandoc_msg.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_msg.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lmandoc_msg.c -Lmandoc_msg.c -u -p -r1.19 -r1.20
--- mandoc_msg.c
+++ mandoc_msg.c
@@ -173,7 +173,7 @@ static const char *const type_message[MA
"blank line in fill mode, using .sp",
"tab in filled text",
"new sentence, new line",
- "invalid escape sequence",
+ "invalid escape sequence argument",
"undefined escape, printing literally",
"undefined string, using \"\"",
@@ -240,6 +240,7 @@ static const char *const type_message[MA
"incomplete escape sequence",
"invalid special character",
"unknown special character",
+ "invalid escape argument delimiter",
"unsupported feature",
"input too large",
Index: roff_escape.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_escape.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lroff_escape.c -Lroff_escape.c -u -p -r1.12 -r1.13
--- roff_escape.c
+++ roff_escape.c
@@ -272,6 +272,7 @@ roff_escape(const char *buf, const int l
if (term == '\b') {
if (strchr("BDHLRSvxNhl", buf[inam]) != NULL &&
strchr(" %&()*+-./0123456789:<=>", buf[iarg]) != NULL) {
+ err = MANDOCERR_ESC_DELIM;
if (rval != ESCAPE_EXPAND)
rval = ESCAPE_ERROR;
if (buf[inam] != 'D') {
@@ -291,6 +292,7 @@ roff_escape(const char *buf, const int l
case '[':
if (buf[++iarg] == ' ') {
iendarg = iend = iarg + 1;
+ err = MANDOCERR_ESC_ARG;
rval = ESCAPE_ERROR;
goto out;
}
@@ -368,13 +370,23 @@ roff_escape(const char *buf, const int l
case '2':
case '3':
case '4':
- rval = argl == 1 ? ESCAPE_IGNORE : ESCAPE_ERROR;
+ if (argl == 1)
+ rval = ESCAPE_IGNORE;
+ else {
+ err = MANDOCERR_ESC_ARG;
+ rval = ESCAPE_ERROR;
+ }
break;
case '5':
- rval = buf[iarg - 1] == '[' ? ESCAPE_UNSUPP :
- ESCAPE_ERROR;
+ if (buf[iarg - 1] == '[')
+ rval = ESCAPE_UNSUPP;
+ else {
+ err = MANDOCERR_ESC_ARG;
+ rval = ESCAPE_ERROR;
+ }
break;
default:
+ err = MANDOCERR_ESC_ARG;
rval = ESCAPE_ERROR;
break;
}
@@ -386,6 +398,8 @@ roff_escape(const char *buf, const int l
switch (rval) {
case ESCAPE_FONT:
rval = mandoc_font(buf + iarg, argl);
+ if (rval == ESCAPE_ERROR)
+ err = MANDOCERR_ESC_ARG;
break;
case ESCAPE_SPECIAL:
@@ -487,10 +501,6 @@ out:
*resc = iesc;
switch (rval) {
- case ESCAPE_ERROR:
- if (err == MANDOCERR_OK)
- err = MANDOCERR_ESC_BAD;
- break;
case ESCAPE_UNSUPP:
err = MANDOCERR_ESC_UNSUPP;
break;
Index: O1.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/O1.out_lint,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/esc/O1.out_lint -Lregress/roff/esc/O1.out_lint -u -p -r1.1 -r1.2
--- regress/roff/esc/O1.out_lint
+++ regress/roff/esc/O1.out_lint
@@ -1,5 +1,5 @@
-mandoc: O1.in:11:6: WARNING: invalid escape sequence: \O5
-mandoc: O1.in:12:7: WARNING: invalid escape sequence: \O(52
+mandoc: O1.in:11:6: WARNING: invalid escape sequence argument: \O5
+mandoc: O1.in:12:7: WARNING: invalid escape sequence argument: \O(52
mandoc: O1.in:13:7: UNSUPP: unsupported escape sequence: \O[5dummy]
-mandoc: O1.in:14:6: WARNING: invalid escape sequence: \O6
+mandoc: O1.in:14:6: WARNING: invalid escape sequence argument: \O6
mandoc: O1.in:15:6: UNSUPP: unsupported escape sequence: \O0
Index: l.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/l.out_lint,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lregress/roff/esc/l.out_lint -Lregress/roff/esc/l.out_lint -u -p -r1.4 -r1.5
--- regress/roff/esc/l.out_lint
+++ regress/roff/esc/l.out_lint
@@ -1 +1 @@
-mandoc: l.in:23:21: WARNING: invalid escape sequence: \h-
+mandoc: l.in:23:21: ERROR: invalid escape argument delimiter: \l-
Index: l.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/l.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/roff/esc/l.in -Lregress/roff/esc/l.in -u -p -r1.2 -r1.3
--- regress/roff/esc/l.in
+++ regress/roff/esc/l.in
@@ -1,4 +1,4 @@
-.\" $OpenBSD: l.in,v 1.2 2017/07/04 14:53:27 schwarze Exp $
+.\" $OpenBSD: l.in,v 1.3 2022/06/07 09:51:03 schwarze Exp $
.Dd $Mdocdate$
.Dt ESC-L 1
.Os
@@ -20,4 +20,4 @@ default unit and escape char: >\l'7n\(at
.br
rounding: >\l'0.26ix'<
.br
-invalid delimiter: >\h-<
+invalid delimiter: >\l-<
Index: l.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/l.out_ascii,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/roff/esc/l.out_ascii -Lregress/roff/esc/l.out_ascii -u -p -r1.2 -r1.3
--- regress/roff/esc/l.out_ascii
+++ regress/roff/esc/l.out_ascii
@@ -13,4 +13,4 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
rounding: >xxx<
invalid delimiter: ><
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD June 7, 2022 OpenBSD
Index: h.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/h.out_lint,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lregress/roff/esc/h.out_lint -Lregress/roff/esc/h.out_lint -u -p -r1.7 -r1.8
--- regress/roff/esc/h.out_lint
+++ regress/roff/esc/h.out_lint
@@ -1 +1 @@
-mandoc: h.in:23:21: WARNING: invalid escape sequence: \h-
+mandoc: h.in:23:21: ERROR: invalid escape argument delimiter: \h-
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2022-06-07 9:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3365ab4f581fb9c0@mandoc.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).