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