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