/************************************************************************/ /* */ /* Copyright (C) 1984, 1992 Lugaru Software Ltd. */ /* */ /* All Rights Reserved */ /* */ /************************************************************************/ #include "eel.h" /* Replacement for obsolete line_fill() primitive, broken in v6.0 and * deleted from next version. */ line_fill_subr(line, end, margin_right, startcol, period, ignore) char *line; int end, margin_right, startcol; char *period, *ignore; { int l = point, lastspace = -1L; char *lastsp, *p = line; int room, sentend = 0, c; room = ptrlen(line) - 1; end = narrow_position(end); for (; p - line + startcol < margin_right || lastspace == -1L; l++) { if (l >= end || p - line >= room) { *p = 0; point = l; return 1; } *p++ = c = character(l); if (index(period, c)) sentend = 1; else if (index(ignore, c)) continue; else if (!isspace(c)) sentend = 0; else if (l <= 0L || isspace(character(l - 1L))) --p; else { lastspace = l; *(lastsp = p - 1) = ' '; if (character(l) == ' ' && character(l + 1L) != ' ') continue; if (sentend) *p++ = ' '; } } *lastsp++ = '\n', *lastsp = 0; point = lastspace; return 0; }