--- ray/src/common/badarg.c 1991/11/07 11:03:34 1.1 +++ ray/src/common/badarg.c 2014/03/01 18:54:08 2.9 @@ -1,39 +1,52 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: badarg.c,v 2.9 2014/03/01 18:54:08 greg Exp $"; #endif - /* * Check argument list against format string. + * + * External symbols declared in rtio.h */ -#define NULL 0 +#include "copyright.h" +#include + +#include "rtio.h" + + int -badarg(ac, av, fl) /* check argument list */ -int ac; -register char **av; -register char *fl; +badarg( /* check argument list */ +int ac, +char **av, +char *fl +) { - register int i; + int i; + char *s; if (fl == NULL) fl = ""; /* no arguments? */ for (i = 1; *fl; i++,av++,fl++) { if (i > ac || *av == NULL) return(-1); + s = *av; switch (*fl) { case 's': /* string */ - if (**av == '\0' || **av == ' ' || **av == '\t') + while (*s == ' ') + ++s; + if (!*s) return(i); + do + if (!isprint(*s)) + return(i); + while (*++s); break; case 'i': /* integer */ - if (!isintd(*av, " \t")) + if (!isintd(s, " \t\r\n")) return(i); break; case 'f': /* float */ - if (!isfltd(*av, " \t")) + if (!isfltd(s, " \t\r\n")) return(i); break; default: /* bad call! */