1 |
greg |
1.1 |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
|
3 |
|
|
/* SCCSid "$SunId$ LBL" */ |
4 |
|
|
|
5 |
|
|
/* Copyright (c) 1991 Regents of the University of California */ |
6 |
|
|
|
7 |
|
|
#include <ctype.h> |
8 |
|
|
|
9 |
|
|
#define ANGLE short |
10 |
|
|
#define AEND (-11111) |
11 |
|
|
|
12 |
|
|
setscan(ang, arg) /* set up scan according to arg */ |
13 |
|
|
register ANGLE *ang; |
14 |
|
|
register char *arg; |
15 |
|
|
{ |
16 |
|
|
int state = ','; |
17 |
|
|
int start, finish, step; |
18 |
|
|
|
19 |
|
|
while (state) { |
20 |
|
|
switch (state) { |
21 |
|
|
case ',': |
22 |
|
|
start = atoi(arg); |
23 |
|
|
finish = start; |
24 |
|
|
step = 1; |
25 |
|
|
break; |
26 |
|
|
case '-': |
27 |
|
|
finish = atoi(arg); |
28 |
|
|
if (finish < start) |
29 |
|
|
return(-1); |
30 |
|
|
break; |
31 |
|
|
case ':': |
32 |
|
|
step = atoi(arg); |
33 |
|
|
break; |
34 |
|
|
default: |
35 |
|
|
return(-1); |
36 |
|
|
} |
37 |
|
|
if (!isdigit(*arg) && *arg != '-' && *arg != '+') |
38 |
|
|
return(-1); |
39 |
|
|
do |
40 |
|
|
arg++; |
41 |
|
|
while (isdigit(*arg)); |
42 |
|
|
state = *arg++; |
43 |
|
|
if (!state || state == ',') |
44 |
|
|
while (start <= finish) { |
45 |
|
|
*ang++ = start; |
46 |
|
|
start += step; |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
|
*ang = AEND; |
50 |
|
|
return(0); |
51 |
|
|
} |