From 870e780ce28ddf39ea25009878201464f4c5a8ea Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 12 Jun 2000 18:41:59 +0000 Subject: Don't break on non-breaking spaces, don't keep non-breaking spaces that * e-msg-composer.c (format_text): Don't break on non-breaking spaces, don't keep non-breaking spaces that fall after a line wrap, and translate non-breaking spaces to regular ones after wrapping. svn path=/trunk/; revision=3530 --- composer/e-msg-composer.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'composer/e-msg-composer.c') diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 7be0994fa0..48eb7cf15b 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -161,19 +161,33 @@ format_text (char *text) while (*s) { len = strcspn (s, "\n"); if (len > LINE_LEN) { + /* If we can break anywhere between s and + * s + LINE_LEN, do that. We can break between + * space and anything but   + */ space = s + LINE_LEN; - while (*space != ' ' && space > s) + while (space > s && (*space != ' ' + || (*(space + 1) == '\240') + || (*(space - 1) == '\240'))) space--; if (space != s) len = space - s; } - memcpy (d, s, len); - s += len; - if (*s) + /* Copy the line... */ + while (len--) { + *d++ = (*s == '\240' ? ' ' : *s); s++; - d += len; + } + + /* Eat whitespace... */ + while (*s == ' ' || *s == '\240') + s++; + if (*s == '\n') + s++; + + /* And end the line. */ *d++ = '\n'; } -- cgit