groff-commit
[Top][All Lists]
Advanced

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

[groff] 13/26: [troff]: Slightly refactor (read_string() duties).


From: G. Branden Robinson
Subject: [groff] 13/26: [troff]: Slightly refactor (read_string() duties).
Date: Thu, 14 Nov 2024 11:54:09 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 24e314b94c31c4b7b7908854455179cb97519001
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Nov 12 09:08:22 2024 -0600

    [troff]: Slightly refactor (read_string() duties).
    
    Shift responsibility for calling `tok.next()` onto callers of
    `read_string()` instead of doing it internally.  For the purpose I have
    in mind (migrating `so` and `mso` to use `read_string()`), the latter
    advances the input stream pointer too early--better to let the caller
    control that.
    
    * src/roff/troff/input.cpp (read_string): Drop `tok.next()` call.
    
    * src/roff/troff/env.cpp (override_sizes): Add `tok.next()` call.
---
 ChangeLog                | 13 +++++++++++++
 src/roff/troff/env.cpp   |  1 +
 src/roff/troff/input.cpp |  3 ++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 02336f0ba..96770fe01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-11-12  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Slightly refactor.  Shift responsibility for calling
+       `tok.next()` onto callers of `read_string()` instead of doing it
+       internally.  For the purpose I have in mind (migrating `so` and
+       `mso` to use `read_string()`), the latter advances the input
+       stream pointer too early--better to let the caller control that.
+
+       * src/roff/troff/input.cpp (read_string): Drop `tok.next()`
+       call.
+       * src/roff/troff/env.cpp (override_sizes): Add `tok.next()`
+       call.
+
 2024-11-12  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (read_string): Recognize a leading
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 82d4c44d4..d8ff4e0da 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1371,6 +1371,7 @@ void override_sizes()
     p = strtok(0, " \t");
   }
   font_size::init_size_list(sizes);
+  tok.next();
 }
 
 void space_size()
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 0c284bf5e..6ad2770eb 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8412,6 +8412,8 @@ void abort_request()
 // Consume the rest of the input line in copy mode; if, after spaces,
 // the argument starts with a `"`, discard it, letting any immediately
 // subsequent spaces populate the returned string.
+//
+// The caller must use `tok.next()` to advance the input stream pointer.
 char *read_string()
 {
   int len = 256;
@@ -8438,7 +8440,6 @@ char *read_string()
     c = get_copy(0 /* nullptr */);
   }
   s[i] = '\0';
-  tok.next();
   if (i == 0) {
     delete[] s;
     return 0 /* nullptr */;



reply via email to

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