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