Update of bug #68719 (group groff):

                 Summary: [soelim] appends a newline to included files lacking
them, inconsistently with troff => [PATCH] [soelim] appends a newline to
included files lacking them, inconsistently with troff

    _______________________________________________________

Follow-up Comment #7:


commit 466b528e1104bc2bef7137d56e79c9d4791f56e0
Author: G. Branden Robinson <[email protected]>
Date:   Mon Nov 2 11:02:11 2026 -0600

    XXX [soelim]: Fix Savannah #68719 (1/2).
    
    In raw mode, don't add a newline to the end of file lacking one.

diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp
index 463057567..db9004caa 100644
--- a/src/preproc/soelim/soelim.cpp
+++ b/src/preproc/soelim/soelim.cpp
@@ -233,10 +233,15 @@ static bool do_file(const char *filename)
         SEEN_DOT_lf,
         OTHER } state
       = START;
+  bool file_ends_with_newline = false;
+  int prevc = 0;
   for (;;) {
     int c = getc(fp);
-    if (c == EOF)
+    if (c == EOF) {
+      if ('\n' == prevc)
+       file_ends_with_newline = true;
       break;
+    }
     switch (state) {
     case START:
       if (c == '.')
@@ -342,32 +347,33 @@ static bool do_file(const char *filename)
     default:
       assert(0 == "unhandled state in file parser");
     }
+    prevc = c;
   }
   // We've reached the end of input.
   switch (state) {
   case SEEN_DOT:
-    fputs(".\n", stdout);
+    fputs(".", stdout);
     break;
   case SEEN_DOT_l:
-    fputs(".l\n", stdout);
+    fputs(".l", stdout);
     break;
   case SEEN_DOT_s:
-    fputs(".s\n", stdout);
+    fputs(".s", stdout);
     break;
   case SEEN_DOT_lf:
-    fputs(".lf\n", stdout);
+    fputs(".lf", stdout);
     break;
   case SEEN_DOT_so:
-    fputs(".so\n", stdout);
+    fputs(".so", stdout);
     break;
   case OTHER:
-    putc('\n', stdout);
-    break;
   case START:
     break;
   default:
     assert(0 == "unhandled state in file parser at EOF");
   }
+  if (!want_raw_output && !file_ends_with_newline)
+    putc('\n', stdout);
   if (fp != stdin)
     if (fclose(fp) < 0)
       fatal("cannot close '%1': %2", whole_filename.contents(),


+verbaitm+
commit 5090c70a472f0bf25b7f70a577dc31d7f5600bf7
Author: G. Branden Robinson <[email protected]>
Date:   Mon Nov 2 21:51:19 2026 -0600

    XXX [soelim]: Fix Savannah #68719 (2/2).
    
    Throw warning if an input or included file lacks a final newline.

diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp
index db9004caa..f5193f22e 100644
--- a/src/preproc/soelim/soelim.cpp
+++ b/src/preproc/soelim/soelim.cpp
@@ -372,8 +372,11 @@ static bool do_file(const char *filename)
   default:
     assert(0 == "unhandled state in file parser at EOF");
   }
-  if (!want_raw_output && !file_ends_with_newline)
-    putc('\n', stdout);
+  if (!file_ends_with_newline) {
+    warning("end of file lacks a newline");
+    if (!want_raw_output)
+      putc('\n', stdout);
+  }
   if (fp != stdin)
     if (fclose(fp) < 0)
       fatal("cannot close '%1': %2", whole_filename.contents(),
-verbatim-


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68719>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to