ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/setscan.c
Revision: 1.3
Committed: Thu Mar 14 17:38:27 1991 UTC (33 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +8 -4 lines
Log Message:
set setscan.h into its own file

File Contents

# User Rev Content
1 greg 1.1 /* Copyright (c) 1991 Regents of the University of California */
2    
3 greg 1.3 #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6 greg 1.1
7 greg 1.3 /*
8     * Convert angle ranges of the form a-b:s,c to discrete values
9     */
10 greg 1.1
11     #include <ctype.h>
12    
13 greg 1.3 #include "setscan.h"
14    
15 greg 1.1
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 greg 1.2 if (!isdigit(*arg))
42 greg 1.1 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     }