degesch: clarify text wrapping algorithm
This commit is contained in:
parent
2ba8908024
commit
2ae916fc1a
11
degesch.c
11
degesch.c
|
@ -6849,13 +6849,14 @@ wrap_message (const char *message,
|
||||||
if (line_max <= 0)
|
if (line_max <= 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
for (size_t message_left = strlen (message); message_left; )
|
int message_left = strlen (message);
|
||||||
|
while (message_left > line_max)
|
||||||
{
|
{
|
||||||
struct str m;
|
struct str m;
|
||||||
str_init (&m);
|
str_init (&m);
|
||||||
|
|
||||||
size_t eaten = wrap_text_for_single_line (message,
|
size_t eaten = wrap_text_for_single_line
|
||||||
MIN ((size_t) line_max, message_left), message_left, &m);
|
(message, message_left, line_max, &m);
|
||||||
if (!eaten)
|
if (!eaten)
|
||||||
{
|
{
|
||||||
str_free (&m);
|
str_free (&m);
|
||||||
|
@ -6866,6 +6867,10 @@ wrap_message (const char *message,
|
||||||
message += eaten;
|
message += eaten;
|
||||||
message_left -= eaten;
|
message_left -= eaten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message_left)
|
||||||
|
str_vector_add (output, message);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Reference in New Issue