/*
 *	$Source$
 *	$Author$
 *	$Header$
 */

#ifndef lint
static char *rcsid_display_c = "$Header$";
#endif lint

#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include "bible.h"

display(s, width)
	char	*s;
	int	width;
{
	char	*tmp;
	char	*lines[256];	/* Max lines to word wrap */
	int	num = 0, i;
	register char	*cp, *start;
	
	if (width < 1)
		return;
	start = tmp = strdup(s);
	while (1) {
		lines[num++] = start;
		if (strlen(start) < width)
			break;
		cp = start + width-1;
		while ((cp > start) && !isspace(*cp))
			cp--;
		if (cp == start) {
			cp = start+width; 
			while (*cp && !isspace(*cp))
				cp++;
		}
		if (!*cp)
			break;
		*cp = '\0';
		start = cp+1;
	}
	for (i = 0; i <num; i++)
		printf("%s\n", lines[i]);
	free(tmp);
}


	
