994
|
1 /* getnum.c */
|
|
2 #include <stdio.h>
|
|
3 #include "tools.h"
|
|
4 #include "ed.h"
|
|
5
|
|
6 int mark['z' - 'a' + 1];
|
|
7
|
|
8 int getnum(first)
|
|
9 int first;
|
|
10 {
|
|
11 TOKEN *srchpat;
|
|
12 int num;
|
|
13 char c;
|
|
14
|
|
15 while (*inptr == SP || *inptr == HT) inptr++;
|
|
16
|
|
17 if (*inptr >= '0' && *inptr <= '9') { /* line number */
|
|
18 for (num = 0; *inptr >= '0' && *inptr <= '9';) {
|
|
19 num = (num * 10) + *inptr - '0';
|
|
20 inptr++;
|
|
21 }
|
|
22 return num;
|
|
23 }
|
|
24 switch (c = *inptr) {
|
|
25 case '.':
|
|
26 inptr++;
|
|
27 return(curln);
|
|
28
|
|
29 case '$':
|
|
30 inptr++;
|
|
31 return(lastln);
|
|
32
|
|
33 case '/':
|
|
34 case '?':
|
|
35 srchpat = optpat();
|
|
36 if (*inptr == c) inptr++;
|
|
37 return(find(srchpat, c == '/' ? 1 : 0));
|
|
38
|
|
39 case '-':
|
|
40 case '+':
|
|
41 return(first ? curln : 1);
|
|
42
|
|
43 case '\'':
|
|
44 inptr++;
|
|
45 if (*inptr < 'a' || *inptr > 'z') return(EOF);
|
|
46
|
|
47 return mark[*inptr++ - 'a'];
|
|
48
|
|
49 default:
|
|
50 return(first ? EOF : 1);/* unknown address */
|
|
51 }
|
|
52 }
|
|
53
|