annotate 3rdparty/packages/ed/catsub.c @ 3158:927ba5ebc06e

mc09 l2: move MMU bit-field defines to defs file.
author Neal Crook <foofoobedoo@gmail.com>
date Thu, 06 Apr 2017 21:43:58 +0100
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 /* catsub.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 char *paropen[9], *parclose[9];
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
7
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
8 char *catsub(from, to, sub, new, newend)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
9 char *from, *to, *sub, *new, *newend;
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 *cp, *cp2;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
12
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
13 for (cp = new; *sub != EOS && cp < newend;) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
14 if (*sub == DITTO) for (cp2 = from; cp2 < to;) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
15 *cp++ = *cp2++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
16 if (cp >= newend) break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
17 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
18 else if (*sub == ESCAPE) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
19 sub++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
20 if ('1' <= *sub && *sub <= '9') {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
21 char *parcl = parclose[*sub - '1'];
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
22
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
23 for (cp2 = paropen[*sub - '1']; cp2 < parcl;) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
24 *cp++ = *cp2++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
25 if (cp >= newend) break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
26 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
27 } else
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
28 *cp++ = *sub;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
29 } else
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
30 *cp++ = *sub;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
31
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
32 sub++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
33 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
34
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
35 return(cp);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
36 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
37