1 /*
2  * Copyright (C) 1991,1992 NEC Corporation.
3  */
4 #ifndef lint
5 static char rcsid[] =
6 	"$Id: spacing.c,v 2.10 1994/04/19 10:17:05 uchida Exp $ (NEC)";
7 #endif
8 
9 #include <stdio.h>
10 #include <ctype.h>
11 #include "plain2.h"
12 /*
13  * Find newpage (^L) and open space (Large blank area)
14  */
spacing(begin,end)15 spacing(begin, end)
16 int	begin;
17 int	end;
18 {
19 	int	l;
20 	int	blanks = 0;
21 	struct	textBlock *tbp, *prevTbp = NULL;
22 	pageBp = NULL;
23 	DBG0(7, "spacing\n");
24 	for (l = begin; l < end; l++) {
25 		if (texts[l]->blank) {
26 			blanks++;
27 		}
28 		else {
29 			if (*texts[l]->body == 12) {
30 				/* new page (^L == 12)	*/
31 				tbp = newTextBlock(l, l+1, TB_PAGE);
32 				if (prevTbp)
33 					prevTbp->nextBlock = tbp;
34 				else
35 					pageBp = tbp;
36 				prevTbp = tbp;
37 				MSG1("%d ", l);
38 				texts[l]->length = 0;
39 				texts[l]->blank  = 1;
40 				texts[l]->block = tbp;
41 			}
42 			else if (blanks > MIN_SPACING) {
43 				/* Preparing	*/
44 				struct	textBlock *tbp;
45 				int	i;
46 				tbp = newTextBlock(l - blanks, l, TB_SPACE);
47 				MSG2("%d-%d ", l - blanks, l - 1);
48 				DBG2(3, "spacing %d-%d\n", l-blanks, l);
49 				for (i = l - blanks; i < l; i++)
50 					texts[i]->block = tbp;
51 			}
52 			blanks = 0;
53 		}
54 	}
55 }
56