ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/badarg.c
Revision: 2.11
Committed: Fri Mar 7 17:32:12 2014 UTC (10 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R2P1, rad5R3
Changes since 2.10: +8 -6 lines
Log Message:
Fixed problem with newlines in string arguments, which should be allowed

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: badarg.c,v 2.10 2014/03/01 18:56:41 greg Exp $";
3 #endif
4 /*
5 * Check argument list against format string.
6 *
7 * External symbols declared in rtio.h
8 */
9
10 #include "copyright.h"
11
12 #include <ctype.h>
13
14 #include "rtio.h"
15
16
17 int
18 badarg( /* check argument list */
19 int ac,
20 char **av,
21 char *fl
22 )
23 {
24 int i;
25 char *s;
26
27 if (fl == NULL)
28 fl = ""; /* no arguments? */
29 for (i = 1; *fl; i++,av++,fl++) {
30 if (i > ac || *av == NULL)
31 return(-1);
32 s = *av;
33 switch (*fl) {
34 case 's': /* string */
35 while (isspace(*s))
36 ++s;
37 if (!isprint(*s))
38 return(i);
39 while (isprint(*s) | isspace(*s))
40 ++s;
41 if (*s)
42 return(i);
43 break;
44 case 'i': /* integer */
45 if (!isintd(s, " \t\r\n"))
46 return(i);
47 break;
48 case 'f': /* float */
49 if (!isfltd(s, " \t\r\n"))
50 return(i);
51 break;
52 default: /* bad call! */
53 return(-1);
54 }
55 }
56 return(0); /* all's well */
57 }