gbranden pushed a commit to branch master
in repository groff.

commit 85c8daa27d73da849e221b1ca250d414f6902bd7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 1 18:28:02 2026 -0500

    src/roff/troff/env.cpp: Slightly refactor.
    
    * src/roff/troff/env.cpp: Make request handler functions more consistent
      such that calling `skip_line()` is the last thing they do before
      returning.  The goal is to build confidence that request handlers
      reliably leave the input stream in a well-defined state.  Doing so
      would prevent several bugs I introduced (and resolved, with help from
      fellow developers) in the groff 1.23.0 development cycle, but also
      cases like Savannah #68064, which lurked insidiously for about 35
      years.
    
      (read_hyphenation_patterns_from_file): Stop calling `tok.next()`
      before returning.
    
      (load_hyphenation_patterns_from_file_request)
      (append_hyphenation_patterns_from_file_request): Call `skip_line()`
      before returning.
---
 ChangeLog              | 17 +++++++++++++++++
 src/roff/troff/env.cpp |  7 ++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b63a4c4f6..f1c928df0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,23 @@
        disclose the specific format demanded.  Also tighten message
        wording.
 
+2026-04-01  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp: Slightly refactor.  Make request
+       handler functions more consistent such that calling
+       `skip_line()` is the last thing they do before returning.  The
+       goal is to build confidence that request handlers reliably leave
+       the input stream in a well-defined state.  Doing so would
+       prevent several bugs I introduced (and resolved, with help from
+       fellow developers) in the groff 1.23.0 development cycle, but
+       also cases like Savannah #68064, which lurked insidiously for
+       about 35 years.
+       (read_hyphenation_patterns_from_file): Stop calling `tok.next()`
+       before returning.
+       (load_hyphenation_patterns_from_file_request)
+       (append_hyphenation_patterns_from_file_request): Call
+       `skip_line()` before returning.
+
 2026-04-01  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/env.cpp (print_environment_request): Declare as
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 26a5fdc1b..bc2cb3cc0 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -4663,7 +4663,6 @@ static void read_hyphenation_patterns_from_file(bool 
append)
       current_language->patterns.read_patterns_file(filename, append,
        &current_language->exceptions);
   }
-  tok.next();
 }
 
 static void load_hyphenation_patterns_from_file_request() // .hpf
@@ -4675,8 +4674,7 @@ static void load_hyphenation_patterns_from_file_request() 
// .hpf
     return;
   }
   read_hyphenation_patterns_from_file(false /* append */);
-  // No `skip_line()` here; the above function calls
-  // `read_rest_of_line_as_argument()` and `tok.next()`.
+  skip_line();
 }
 
 static void append_hyphenation_patterns_from_file_request() // .hpfa
@@ -4688,8 +4686,7 @@ static void 
append_hyphenation_patterns_from_file_request() // .hpfa
     return;
   }
   read_hyphenation_patterns_from_file(true /* append */);
-  // No `skip_line()` here; the above function calls
-  // `read_rest_of_line_as_argument()` and `tok.next()`.
+  skip_line();
 }
 
 // Most hyphenation functionality is environment-specific; see

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

Reply via email to