aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-12-08 22:11:11 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-12-08 22:11:11 +0100
commit2ae916fc1a32a33cf9e576741cf9e62bc445776c (patch)
treef0e0446fe7476075be8b6d8a59237548650eea50 /degesch.c
parent2ba8908024158fab553c79f3b45b9e4b64845edb (diff)
downloadxK-2ae916fc1a32a33cf9e576741cf9e62bc445776c.tar.gz
xK-2ae916fc1a32a33cf9e576741cf9e62bc445776c.tar.xz
xK-2ae916fc1a32a33cf9e576741cf9e62bc445776c.zip
degesch: clarify text wrapping algorithm
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/degesch.c b/degesch.c
index 4ae824d..52141fc 100644
--- a/degesch.c
+++ b/degesch.c
@@ -6849,13 +6849,14 @@ wrap_message (const char *message,
if (line_max <= 0)
goto error;
- for (size_t message_left = strlen (message); message_left; )
+ int message_left = strlen (message);
+ while (message_left > line_max)
{
struct str m;
str_init (&m);
- size_t eaten = wrap_text_for_single_line (message,
- MIN ((size_t) line_max, message_left), message_left, &m);
+ size_t eaten = wrap_text_for_single_line
+ (message, message_left, line_max, &m);
if (!eaten)
{
str_free (&m);
@@ -6866,6 +6867,10 @@ wrap_message (const char *message,
message += eaten;
message_left -= eaten;
}
+
+ if (message_left)
+ str_vector_add (output, message);
+
return true;
error: