annotate 3rdparty/packages/ed/getlst.c @ 994:bef1844de0dc

The ED editor ported from Minix
author roug
date Sun, 23 Feb 2003 21:11:37 +0000
parents
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 /* getlst.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 getlst()
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 num;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
9
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
10 line2 = 0;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
11 for (nlines = 0; (num = getone()) >= 0;) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
12 line1 = line2;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
13 line2 = num;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
14 nlines++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
15 if (*inptr != ',' && *inptr != ';') break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
16 if (*inptr == ';') curln = num;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
17 inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
18 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
19 nlines = min(nlines, 2);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
20 if (nlines == 0) line2 = curln;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
21 if (nlines <= 1) line1 = line2;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
22
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
23 if (num == ERR)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
24 return(num);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
25 else
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
26 return(nlines);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
27 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
28