/* If the string doesn't end with a newline, append one. Then word-wrap it to 80 columns.  */
static void end_string(GString *str)
/* If the string doesn't end with a newline, append one. Then word-wrap it to 80 columns.  */
static void end_string(GString *str)
{
	size_t point;
	char *p, *q;
	point = str->len;
	if (point == 0 || str->str[point - 1] != '\n')
		g_string_append(str, "\n");
	p = str->str;
	while (*p != '\0') {
		q = strchr(p, '\n');
		if (q - p > 80) {
			q = p + 80;
			while (q > p && *q != ' ')
				q--;
			if (q != p)
				*q = '\n';
		}
		p = q + 1;
	}
}