ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/setscan.c
Revision: 2.4
Committed: Fri Mar 26 23:34:23 2004 UTC (20 years, 6 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad5R3, HEAD
Changes since 2.3: +2 -1 lines
Log Message:
Continued ANSIfication.

File Contents

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