1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Check argument list against format string. |
6 |
+ |
* |
7 |
+ |
* External symbols declared in rtio.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
#define NULL 0 |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
+ |
#include <ctype.h> |
13 |
+ |
|
14 |
+ |
#include "rtio.h" |
15 |
+ |
|
16 |
+ |
|
17 |
|
int |
18 |
< |
badarg(ac, av, fl) /* check argument list */ |
19 |
< |
int ac; |
20 |
< |
register char **av; |
21 |
< |
register char *fl; |
18 |
> |
badarg( /* check argument list */ |
19 |
> |
int ac, |
20 |
> |
char **av, |
21 |
> |
char *fl |
22 |
> |
) |
23 |
|
{ |
24 |
< |
register int i; |
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 |
< |
if (**av == '\0' || **av == ' ' || **av == '\t') |
35 |
> |
while (isspace(*s)) |
36 |
> |
++s; |
37 |
> |
if (*s == '\0') |
38 |
|
return(i); |
39 |
+ |
while (*s) |
40 |
+ |
if (!isprint(*s++)) |
41 |
+ |
return(i); |
42 |
|
break; |
43 |
|
case 'i': /* integer */ |
44 |
< |
if (!isintd(*av, " \t")) |
44 |
> |
if (!isintd(s, " \t\r\n")) |
45 |
|
return(i); |
46 |
|
break; |
47 |
|
case 'f': /* float */ |
48 |
< |
if (!isfltd(*av, " \t")) |
48 |
> |
if (!isfltd(s, " \t\r\n")) |
49 |
|
return(i); |
50 |
|
break; |
51 |
|
default: /* bad call! */ |