Explain in "pr_wrap" why the line break is *only seemingly* off-by-one; it
is actually correct.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <[email protected]>
---
 generator/utils.ml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/generator/utils.ml b/generator/utils.ml
index 5ae87c1ba786..919572b73557 100644
--- a/generator/utils.ml
+++ b/generator/utils.ml
@@ -186,6 +186,9 @@ let
   | line :: rest ->
      let fields = nsplit (String.make 1 c) line in
      let maybe_wrap field =
+       (* Note that here we break even if we'd fill ‘maxcol‘ precisely;
+        * that's because...
+        *)
        if !col > wrapping_col && !col + String.length field >= maxcol then (
          pr "\n%s" (spaces wrapping_col);
          match span field " \t" with
@@ -197,7 +200,11 @@ let
      let rec loop = function
        | [] -> ()
        | f :: [] -> let f = maybe_wrap f in pr "%s" f;
-       | f :: fs -> let f = maybe_wrap f in pr "%s%c" f c; loop fs
+       | f :: fs ->
+           let f = maybe_wrap f in
+           (* ... here we append the separator. *)
+           pr "%s%c" f c;
+           loop fs
      in
      loop fields;
 

_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to