[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 11/24: [troff]: More requests warn of missing arguments.
From: |
G. Branden Robinson |
Subject: |
[groff] 11/24: [troff]: More requests warn of missing arguments. |
Date: |
Sun, 10 Nov 2024 14:56:21 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit ca8c376830e8a59a7ca504e6b4845ed528e83066
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 9 03:12:03 2024 -0600
[troff]: More requests warn of missing arguments.
[troff]: Make more requests that take mandatory arguments--specifically
`pn`, `ti`, `rchar`, and `hpfcode`--throw warning diagnostics in
category "missing" when they aren't given any.
* src/roff/troff/div.cpp (page_number):
* src/roff/troff/env.cpp (temporary_indent):
* src/roff/troff/input.cpp (define_special_character)
(hyphenation_patterns_file_code): Do it.
---
ChangeLog | 11 +++++++++++
src/roff/troff/div.cpp | 6 ++++++
src/roff/troff/env.cpp | 19 ++++++++++++++-----
src/roff/troff/input.cpp | 12 ++++++++++++
4 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index deb929d67..93a2cfe6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Make more requests that take mandatory arguments--
+ specifically `pn`, `ti`, `rchar`, and `hpfcode`--throw warning
+ diagnostics in category "missing" when they aren't given any.
+
+ * src/roff/troff/div.cpp (page_number):
+ * src/roff/troff/env.cpp (temporary_indent):
+ * src/roff/troff/input.cpp (define_special_character)
+ (hyphenation_patterns_file_code): Do it.
+
2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (has_arg): Return false at EOF, too.
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 0f97c52fa..bc2fdfde7 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -885,6 +885,12 @@ void need_space()
void page_number()
{
+ if (!has_arg()) {
+ warning(WARN_MISSING, "page number assignment request expects an"
+ " argument");
+ skip_line();
+ return;
+ }
int n = 0;
// the ps4html register is set if we are using -Tps
// to generate images for html
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index ecb746d34..1282d2283 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1566,11 +1566,20 @@ void indent()
void temporary_indent()
{
bool is_valid = true;
- hunits temp;
- if (!get_hunits(&temp, 'm', curenv->get_indent()))
- is_valid = false;
- while (!tok.is_newline() && !tok.is_eof())
- tok.next();
+ hunits temp = H0;
+ if (!has_arg()) {
+ warning(WARN_MISSING, "temporary indentation request expects"
+ " argument");
+ skip_line();
+ // _Don't_ return early; when invoked with the ordinary control
+ // character this request still breaks the line.
+ }
+ else {
+ if (!get_hunits(&temp, 'm', curenv->get_indent()))
+ is_valid = false;
+ while (!tok.is_newline() && !tok.is_eof())
+ tok.next();
+ }
if (want_break)
curenv->do_break();
if (temp < H0) {
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index e6bb1f5f3..778b043cc 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4573,6 +4573,12 @@ void define_special_character()
static void remove_character()
{
tok.skip();
+ if (!has_arg()) {
+ warning(WARN_MISSING, "character definition removal request expects"
+ " arguments");
+ skip_line();
+ return;
+ }
while (!tok.is_newline() && !tok.is_eof()) {
if (!tok.is_space() && !tok.is_tab()) {
charinfo *ci = tok.get_char(true /* required */);
@@ -7879,6 +7885,12 @@ void hyphenation_patterns_file_code()
error("hyphenation pattern file code assignment request will be"
" withdrawn in a future groff release; migrate to 'hcode'");
tok.skip();
+ if (!has_arg()) {
+ warning(WARN_MISSING, "hyphenation pattern file code assignment"
+ " request expects arguments");
+ skip_line();
+ return;
+ }
while (!tok.is_newline() && !tok.is_eof()) {
int n1, n2;
if (get_integer(&n1) && (0 <= n1 && n1 <= 255)) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 11/24: [troff]: More requests warn of missing arguments.,
G. Branden Robinson <=