annotate 3rdparty/packages/ed/doprnt.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 /* doprnt.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 int doprnt(from, to)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
7 int from, to;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
8 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
9 int i;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
10 LINE *lptr;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
11
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
12 from = from < 1 ? 1 : from;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
13 to = to > lastln ? lastln : to;
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 (to != 0) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
16 lptr = getptr(from);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
17 for (i = from; i <= to; i++) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
18 prntln(lptr->l_buff, lflg, (nflg ? i : 0));
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
19 lptr = lptr->l_next;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
20 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
21 curln = to;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
22 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
23 return(0);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
24 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
25
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
26 prntln(str, vflg, lin)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
27 char *str;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
28 int vflg, lin;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
29 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
30 if (lin) printf("%7d ", lin);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
31 while (*str && *str != NL) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
32 if (*str < ' ' || *str >= 0x7f) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
33 switch (*str) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
34 case '\t':
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
35 if (vflg)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
36 putcntl(*str, stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
37 else
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
38 putc(*str, stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
39 break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
40
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
41 case DEL:
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
42 putc('^', stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
43 putc('?', stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
44 break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
45
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
46 default:
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
47 putcntl(*str, stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
48 break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
49 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
50 } else
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
51 putc(*str, stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
52 str++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
53 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
54 if (vflg) putc('$', stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
55 putc('\n', stdout);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
56 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
57
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
58 putcntl(c, stream)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
59 char c;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
60 FILE *stream;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
61 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
62 putc('^', stream);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
63 putc((c & 31) | '@', stream);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
64 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
65