annotate 3rdparty/packages/ed/join.c @ 2609:9dd4f422aac7

Added NitrOS-9 ROM Kit from Cloud-9
author Boisy Pitre <boisy.pitre@nuance.com>
date Tue, 31 Jan 2012 13:57:35 -0600
parents bef1844de0dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
994
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
1 /* join.c */
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
2 #include <stdio.h>
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
3 #include "tools.h"
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
4 #include "ed.h"
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
5
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
6 extern int fchanged;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
7
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
8 int join(first, last)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
9 int first, last;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
10 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
11 char buf[MAXLINE];
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
12 char *cp = buf, *str;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
13 int num;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
14
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
15 if (first <= 0 || first > last || last > lastln) return(ERR);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
16 if (first == last) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
17 curln = first;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
18 return 0;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
19 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
20 for (num = first; num <= last; num++) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
21 str = gettxt(num);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
22
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
23 while (*str != NL && cp < buf + MAXLINE - 1) *cp++ = *str++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
24
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
25 if (cp == buf + MAXLINE - 1) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
26 printf("line too long\n");
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
27 return(ERR);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
28 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
29 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
30 *cp++ = NL;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
31 *cp = EOS;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
32 del(first, last);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
33 curln = first - 1;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
34 ins(buf);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
35 fchanged = TRUE;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
36 return 0;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
37 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
38