Start development on BSD 2
[unix-history] / .ref-BSD-1 / ex-1.1 / exj.c
CommitLineData
09a0104b
BJ
1#include "ex.h"
2/*
3 * Ex - a text editor
4 * Bill Joy UCB June/August 1977
5 */
6
7STATIC int jcount, jnoop();
8
9join(c)
10 char c;
11{
12 register *a1;
13 register char *cp, *cp1;
14
15 cp = genbuf;
16 *cp = 0;
17 for (a1 = addr1; a1 <= addr2; a1++) {
18 getline(*a1);
19 cp1 = linebuf;
20 if (a1 != addr1 && c == 0) {
21 while (*cp1 == ' ' || *cp1 == '\t')
22 cp1++;
23 if (*cp1 && cp > genbuf && cp[-1] != ' ' && cp[-1] != '\t')
24 *cp++ = ' ';
25 }
26 while (*cp++ = *cp1++)
27 if (cp > &genbuf[LBSIZE-2])
28 error("Line overflow|Result line of join would be longer than 510 characters");
29 cp--;
30 }
31 cp = genbuf;
32 cp1 = linebuf;
33 while (*cp1++ = *cp++)
34 continue;
35 delete();
36 jcount = 1;
37 append(jnoop, --addr1);
38}
39
40STATIC int
41jnoop()
42{
43 return(--jcount);
44}