groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 17/25: [troff]: Trivially refactor (`hla` request).


From: G. Branden Robinson
Subject: [groff] 17/25: [troff]: Trivially refactor (`hla` request).
Date: Sat, 4 Nov 2023 01:02:56 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit f8bd3a19cc3909053d7e22308a9f4a58acd1f4f8
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Nov 3 15:17:15 2023 -0500

    [troff]: Trivially refactor (`hla` request).
    
    * src/roff/troff/env.cpp: Add diagnostic and trivially refactor.
      (set_hyphenation_language): Rename this...
      (select_hyphenation_language): ...to this.
      (init_hyphen_requests): Update call site.
    
      (select_hyphenation_language): Throw more helpful diagnostic when not
      given an argument; promote "missing identifier" warning to a
      context-rich error.
---
 ChangeLog              | 11 +++++++++++
 src/roff/troff/env.cpp | 11 ++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 279dbcf0a..51d11b2eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-11-03  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/env.cpp: Add diagnostic and trivially refactor.
+       (set_hyphenation_language): Rename this...
+       (select_hyphenation_language): ...to this.
+       (init_hyphen_requests): Update call site.
+
+       (select_hyphenation_language): Throw more helpful diagnostic
+       when not given an argument; promote "missing identifier" warning
+       to a context-rich error.
+
 2023-11-03  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * doc/groff.texi (Line Continuation): Drop concept index entry
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 93d90f059..0509f6423 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3596,9 +3596,14 @@ struct hyphenation_language {
 dictionary language_dictionary(5);
 hyphenation_language *current_language = 0;
 
-static void set_hyphenation_language()
+static void select_hyphenation_language()
 {
-  symbol nm = get_name(true /* required */);
+  if (!has_arg()) {
+    error("hyphenation language selection request requires argument");
+    skip_line();
+    return;
+  }
+  symbol nm = get_name();
   if (!nm.is_null()) {
     current_language = (hyphenation_language *)language_dictionary.lookup(nm);
     if (!current_language) {
@@ -4153,7 +4158,7 @@ const char *hyphenation_language_reg::get_string()
 void init_hyphen_requests()
 {
   init_request("hw", hyphen_word);
-  init_request("hla", set_hyphenation_language);
+  init_request("hla", select_hyphenation_language);
   init_request("hpf", hyphenation_patterns_file);
   init_request("hpfa", hyphenation_patterns_file_append);
   register_dictionary.define(".hla", new hyphenation_language_reg);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]