Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/packages/ed/join.c @ 994:bef1844de0dc
The ED editor ported from Minix
author | roug |
---|---|
date | Sun, 23 Feb 2003 21:11:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
993:57b5e715a417 | 994:bef1844de0dc |
---|---|
1 /* join.c */ | |
2 #include <stdio.h> | |
3 #include "tools.h" | |
4 #include "ed.h" | |
5 | |
6 extern int fchanged; | |
7 | |
8 int join(first, last) | |
9 int first, last; | |
10 { | |
11 char buf[MAXLINE]; | |
12 char *cp = buf, *str; | |
13 int num; | |
14 | |
15 if (first <= 0 || first > last || last > lastln) return(ERR); | |
16 if (first == last) { | |
17 curln = first; | |
18 return 0; | |
19 } | |
20 for (num = first; num <= last; num++) { | |
21 str = gettxt(num); | |
22 | |
23 while (*str != NL && cp < buf + MAXLINE - 1) *cp++ = *str++; | |
24 | |
25 if (cp == buf + MAXLINE - 1) { | |
26 printf("line too long\n"); | |
27 return(ERR); | |
28 } | |
29 } | |
30 *cp++ = NL; | |
31 *cp = EOS; | |
32 del(first, last); | |
33 curln = first - 1; | |
34 ins(buf); | |
35 fchanged = TRUE; | |
36 return 0; | |
37 } | |
38 |