gbranden pushed a commit to branch master
in repository groff.

commit 1ecabc49dd2119c2cbf2f5b21812078007d15c86
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Thu Dec 7 18:52:33 2023 -0600

    [troff]: Improve hyphenation diagnostics.
    
    * src/roff/troff/env.cpp (select_hyphenation_language): Demote missing
      argument diagnostic from error to warning.
    
      (add_hyphenation_exceptions, hyphenation_patterns_file)
      (hyphenation_patterns_file_append): Throw warning in category
      `missing` if given no arguments.
---
 ChangeLog              |  8 ++++++++
 src/roff/troff/env.cpp | 22 +++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 5093883d7..fa734e5a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-12-07  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/roff/troff/env.cpp (select_hyphenation_language): Demote
+       missing argument diagnostic from error to warning.
+       (add_hyphenation_exceptions, hyphenation_patterns_file)
+       (hyphenation_patterns_file_append): Throw warning in category
+       `missing` if given no arguments.
+
 2023-12-02  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        [libgroff]: Drop unused function parameter.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 5d844ed20..6930c1045 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3599,7 +3599,8 @@ hyphenation_language *current_language = 0;
 static void select_hyphenation_language()
 {
   if (!has_arg()) {
-    error("hyphenation language selection request requires argument");
+    warning(WARN_MISSING, "hyphenation language selection request"
+           " expects argument");
     skip_line();
     return;
   }
@@ -3619,6 +3620,12 @@ const int WORD_MAX = 256;        // we use unsigned char 
for offsets in
 
 static void add_hyphenation_exceptions()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "hyphenation exception request expects one or"
+           " more arguments");
+    skip_line();
+    return;
+  }
   if (!current_language) {
     error("cannot add hyphenation exceptions when no hyphenation"
          " language is set");
@@ -4160,6 +4167,7 @@ void hyphenate(hyphen_list *h, unsigned flags)
 
 static void do_hyphenation_patterns_file(bool append)
 {
+  // TODO: Read a file name, not a groff identifier.
   symbol name = get_long_name(true /* required */);
   if (!name.is_null()) {
     if (!current_language)
@@ -4174,11 +4182,23 @@ static void do_hyphenation_patterns_file(bool append)
 
 static void hyphenation_patterns_file()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "hyphenation pattern load request expects"
+           " argument");
+    skip_line();
+    return;
+  }
   do_hyphenation_patterns_file(false /* append */);
 }
 
 static void hyphenation_patterns_file_append()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "hyphenation pattern appendment request"
+           " expects argument");
+    skip_line();
+    return;
+  }
   do_hyphenation_patterns_file(true /* append */);
 }
 

_______________________________________________
Groff-commit mailing list
Groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to