groff-commit
[Top][All Lists]
Advanced

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

[groff] 03/16: [preconv]: Trivially refactor.


From: G. Branden Robinson
Subject: [groff] 03/16: [preconv]: Trivially refactor.
Date: Mon, 31 Oct 2022 21:33:27 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 08cd74e2946ad1f107cbe0f0724519ab84d6e6eb
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Oct 30 18:49:20 2022 -0500

    [preconv]: Trivially refactor.
    
    * src/preproc/preconv/preconv.cpp: Trivially refactor.  Rename
      `default_encoding` to `fallback_encoding` for clarity.  Update
      comments and debugging diagnostic messages accordingly.
---
 ChangeLog                       |  6 ++++++
 src/preproc/preconv/preconv.cpp | 22 +++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dc7a12c74..761b45dd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-10-30  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/preconv/preconv.cpp: Trivially refactor.  Rename
+       `default_encoding` to `fallback_encoding` for clarity.  Update
+       comments and debugging diagnostic messages accordingly.
+
 2022-10-29  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [grolj4]: Absorb lj4_font(5) man page into grolj4(1).
diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp
index e50664e9f..460562771 100644
--- a/src/preproc/preconv/preconv.cpp
+++ b/src/preproc/preconv/preconv.cpp
@@ -49,7 +49,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 extern "C" const char *Version_string;
 
-char default_encoding[MAX_VAR_LEN];
+char fallback_encoding[MAX_VAR_LEN];
 char user_encoding[MAX_VAR_LEN];
 char encoding_string[MAX_VAR_LEN];
 bool is_debugging = false;
@@ -1147,7 +1147,7 @@ do_file(const char *filename)
       if (!file_encoding) {
         if (is_debugging)
           fprintf(stderr, "  could not detect encoding with uchardet\n");
-        file_encoding = default_encoding;
+        file_encoding = fallback_encoding;
       }
       else
         must_free_encoding = 1;
@@ -1217,7 +1217,7 @@ usage(FILE *stream)
 "can interpret, and send the result to the standard output stream.\n"
 "The default fallback encoding is '%s'.  See the preconv(1) manual"
 " page.\n",
-         default_encoding);
+         fallback_encoding);
     exit(EXIT_SUCCESS);
   }
 }
@@ -1229,16 +1229,16 @@ int
 main(int argc, char **argv)
 {
   program_name = argv[0];
-  // Determine the default encoding.  This must be done before
-  // getopt() is called since the usage message shows the default
+  // Determine the fallback encoding.  This must be done before
+  // getopt() is called since the usage message shows the fallback
   // encoding.
   setlocale(LC_ALL, "");
   char *locale = getlocale(LC_CTYPE);
   if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
-    strcpy(default_encoding, "latin1");
+    strcpy(fallback_encoding, "latin1");
   else {
-    strncpy(default_encoding, locale_charset(), MAX_VAR_LEN - 1);
-    default_encoding[MAX_VAR_LEN - 1] = 0;
+    strncpy(fallback_encoding, locale_charset(), MAX_VAR_LEN - 1);
+    fallback_encoding[MAX_VAR_LEN - 1] = 0;
   }
 
   program_name = argv[0];
@@ -1281,8 +1281,8 @@ main(int argc, char **argv)
       break;
     case 'D':
       if (optarg) {
-       strncpy(default_encoding, optarg, MAX_VAR_LEN - 1);
-       default_encoding[MAX_VAR_LEN - 1] = 0;
+       strncpy(fallback_encoding, optarg, MAX_VAR_LEN - 1);
+       fallback_encoding[MAX_VAR_LEN - 1] = 0;
       }
       break;
     case 'r':
@@ -1300,7 +1300,7 @@ main(int argc, char **argv)
     }
   int nbad = 0;
   if (is_debugging)
-    fprintf(stderr, "default encoding: '%s'\n", default_encoding);
+    fprintf(stderr, "fallback encoding: '%s'\n", fallback_encoding);
   if (optind >= argc)
     nbad += !do_file("-");
   else



reply via email to

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