ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/setscan.c
Revision: 1.2
Committed: Wed Mar 13 16:23:49 1991 UTC (33 years, 8 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.1: +2 -2 lines
Log Message:
got rid of negative angles

File Contents

# Content
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 (-1)
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))
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 }