gbranden pushed a commit to branch master
in repository groff.

commit 110f520e420c191125e99c18308f8ece897f29b0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Aug 13 05:51:58 2024 -0500

    [troff]: Clarify error diagnostics.
    
    * src/roff/troff/div.cpp (top_level_diversion::transparent_output)
      (continue_page_eject, top_level_diversion::set_diversion_trap)
      (top_level_diversion::clear_diversion_trap):
    * src/roff/troff/input.cpp (transparent_translate, get_delimited_name)
      (do_source, pipe_source, pipe_output, transparent_file)
      (charinfo_to_node_list):
    * src/roff/troff/node.cpp (troff_output_file::really_copy_file):
    * src/roff/troff/reg.cpp (reg::increment, reg::decrement)
      (reg::set_increment, reg::alter_format, reg::set_value): Clarify error
      diagnostics, and stop using contractions in wording.
    
    Also wrap an overlong source line.
---
 ChangeLog                | 14 ++++++++++++++
 src/roff/troff/div.cpp   | 11 ++++++-----
 src/roff/troff/input.cpp | 26 ++++++++++++++------------
 src/roff/troff/node.cpp  |  2 +-
 src/roff/troff/reg.cpp   | 13 +++++++------
 5 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d9a813d3c..142d182c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-08-13  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/div.cpp
+       (top_level_diversion::transparent_output, continue_page_eject)
+       (top_level_diversion::set_diversion_trap)
+       (top_level_diversion::clear_diversion_trap):
+       * src/roff/troff/input.cpp (transparent_translate)
+       (get_delimited_name, do_source, pipe_source, pipe_output,
+       transparent_file, charinfo_to_node_list):
+       * src/roff/troff/node.cpp (troff_output_file::really_copy_file):
+       * src/roff/troff/reg.cpp (reg::increment, reg::decrement)
+       (reg::set_increment, reg::alter_format, reg::set_value): Clarify
+       error diagnostics, and stop using contractions in wording.
+
 2024-08-13  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/div.cpp
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index d3ff8a488..49d29be5e 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -462,7 +462,7 @@ void top_level_diversion::transparent_output(node * /*n*/)
 {
   // TODO: When Savannah #63074 is fixed, the user will have a way to
   // avoid this error.
-  error("can't transparently output node at top level");
+  error("cannot write a node to device-independent output");
 }
 
 // Implement the internals of `.cf`.
@@ -654,9 +654,10 @@ void continue_page_eject()
 {
   if (topdiv->get_ejecting()) {
     if (curdiv != topdiv)
-      error("can't continue page ejection because of current diversion");
+      error("cannot continue page ejection while diverting output");
     else if (!vertical_position_traps_flag)
-      error("can't continue page ejection because vertical position traps 
disabled");
+      error("cannot continue page ejection while vertical position"
+           " traps disabled");
     else {
       push_page_ejector();
       topdiv->space(topdiv->get_page_length(), 1);
@@ -910,12 +911,12 @@ void macro_diversion::clear_diversion_trap()
 
 void top_level_diversion::set_diversion_trap(symbol, vunits)
 {
-  error("can't set diversion trap when no current diversion");
+  error("cannot set diversion trap when not diverting output");
 }
 
 void top_level_diversion::clear_diversion_trap()
 {
-  error("can't clear diversion trap when no current diversion");
+  error("cannot clear diversion trap when not diverting output");
 }
 
 void diversion_trap()
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index bc7df3340..ac9fbcd14 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2893,10 +2893,9 @@ static int transparent_translate(int cc)
        return c;
       // TODO: When Savannah #63074 is fixed, the user will have a way
       // to avoid this error.
-      error("can't translate %1 to special character '%2'"
-            " in transparent throughput",
-            input_char_description(cc),
-            ci->nm.contents());
+      error("cannot translate %1 to special character '%2' in"
+           " device-independent output", input_char_description(cc),
+           ci->nm.contents());
     }
   }
   return cc;
@@ -5352,7 +5351,7 @@ static symbol get_delimited_name()
     return NULL_SYMBOL;
   }
   if (start_token.is_newline()) {
-    error("can't delimit name with a newline");
+    error("a newline is not allowed to delimit a name");
     return NULL_SYMBOL;
   }
   int start_level = input_stack::get_level();
@@ -6223,7 +6222,7 @@ void do_source(bool quietly)
       // Suppress diagnostic only if we're operating quietly and it's an
       // expected problem.
       if (!(quietly && (ENOENT == errno)))
-       error("can't open '%1': %2", nm.contents(), strerror(errno));
+       error("cannot open '%1': %2", nm.contents(), strerror(errno));
     tok.next();
   }
 }
@@ -6281,7 +6280,8 @@ void pipe_source()
       if (fp)
        input_stack::push(new file_iterator(fp, symbol(buf).contents(), 1));
       else
-       error("can't open pipe to process '%1': %2", buf, strerror(errno));
+       error("cannot open pipe to process '%1': %2", buf,
+             strerror(errno));
       delete[] buf;
     }
     tok.next();
@@ -6468,7 +6468,7 @@ filename(fname), llx(0), lly(0), urx(0), ury(0), 
lastc(EOF)
   else
     // ...but in this case, we did not successfully open any input file.
     //
-    error("can't open '%1': %2", filename, strerror(errno));
+    error("cannot open '%1': %2", filename, strerror(errno));
 
   // Irrespective of whether or not we were able to successfully acquire the
   // bounding box properties, we ALWAYS update the associated gtroff registers.
@@ -7913,13 +7913,13 @@ void pipe_output()
   }
   else {
     if (the_output) {
-      error("can't pipe: output already started");
+      error("cannot honor pipe request: output already started");
       skip_line();
     }
     else {
       char *pc = read_string();
       if (0 /* nullptr */ == pc)
-       error("can't pipe to empty command");
+       error("cannot apply pipe request to empty command");
       // Are we adding to an existing pipeline?
       if (pipe_command != 0 /* nullptr */) {
        char *s = new char[strlen(pipe_command) + strlen(pc) + 1 + 1];
@@ -8002,7 +8002,8 @@ void transparent_file()
     errno = 0;
     FILE *fp = include_search_path.open_file_cautious(filename.contents());
     if (0 /* nullptr */ == fp)
-      error("can't open '%1': %2", filename.contents(), strerror(errno));
+      error("cannot open '%1': %2", filename.contents(),
+           strerror(errno));
     else {
       int bol = 1;
       for (;;) {
@@ -8799,7 +8800,8 @@ node *charinfo_to_node_list(charinfo *ci, const 
environment *envp)
     if (tok.is_eof())
       break;
     if (tok.is_newline()) {
-      error("composite character mustn't contain newline");
+      error("a newline is not allowed in a composite character"
+           " escape sequence");
       while (!tok.is_eof())
        tok.next();
       break;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 4472c04dd..12c028283 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -1569,7 +1569,7 @@ void troff_output_file::really_copy_file(hunits x, vunits 
y,
   errno = 0;
   FILE *ifp = include_search_path.open_file_cautious(filename);
   if (ifp == 0)
-    error("can't open '%1': %2", filename, strerror(errno));
+    error("cannot open '%1': %2", filename, strerror(errno));
   else {
     int c;
     while ((c = getc(ifp)) != EOF)
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 89063d490..40881c007 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -37,22 +37,22 @@ bool reg::get_value(units * /*d*/)
 
 void reg::increment()
 {
-  error("can't increment read-only register");
+  error("cannot increment read-only register");
 }
 
 void reg::decrement()
 {
-  error("can't decrement read-only register");
+  error("cannot decrement read-only register");
 }
 
 void reg::set_increment(units /*n*/)
 {
-  error("can't automatically increment read-only register");
+  error("cannot automatically increment read-only register");
 }
 
 void reg::alter_format(char /*f*/, int /*w*/)
 {
-  error("can't assign format of read-only register");
+  error("cannot assign format of read-only register");
 }
 
 const char *reg::get_format()
@@ -62,7 +62,7 @@ const char *reg::get_format()
 
 void reg::set_value(units /*n*/)
 {
-  error("can't write read-only register");
+  error("cannot write read-only register");
 }
 
 general_reg::general_reg() : format('1'), width(0), inc(0)
@@ -83,7 +83,8 @@ static char lowercase_array[] = {
   'y', 'z',
 };
 
-static const char *number_value_to_ascii(int value, char format, int width)
+static const char *number_value_to_ascii(int value, char format,
+                                        int width)
 {
   static char buf[128];                // must be at least 21
   switch (format) {

_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to