From 3f57200e10b2b3cc8ef8164ed11d52c7a65dda79 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 9 Jan 2020 12:02:49 +0100 Subject: [PATCH] help: prevent double spaces from protruding across the right edge This fixes https://savannah.gnu.org/bugs/?57563. --- src/help.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/help.c b/src/help.c index 04845d26..ea11e347 100644 --- a/src/help.c +++ b/src/help.c @@ -51,7 +51,7 @@ void wrap_help_text_into_buffer(void) /* Copy the help text into the just-created new buffer. */ while (*ptr != '\0') { - int length; + int length, shim; char *oneline; if (ptr >= end_of_intro) @@ -64,7 +64,8 @@ void wrap_help_text_into_buffer(void) } else { length = break_line(ptr, wrapping_point, TRUE); oneline = nmalloc(length + 1); - snprintf(oneline, length + 1, "%s", ptr); + shim = (*(ptr + length - 1) == ' ') ? 0 : 1; + snprintf(oneline, length + shim, "%s", ptr); } free(openfile->current->data);