1994-09-13 03:29:24 +00:00
|
|
|
#ifndef lint
|
|
|
|
#ifndef NOID
|
1999-01-21 17:46:19 +00:00
|
|
|
static char elsieid[] = "@(#)scheck.c 8.15";
|
1994-09-13 03:29:24 +00:00
|
|
|
#endif /* !defined lint */
|
|
|
|
#endif /* !defined NOID */
|
|
|
|
|
1997-10-29 07:27:56 +00:00
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] =
|
1999-01-21 17:46:19 +00:00
|
|
|
"$Id: scheck.c,v 1.3 1999/01/21 17:12:49 wollman Exp $";
|
1997-10-29 07:27:56 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
1994-09-13 03:29:24 +00:00
|
|
|
/*LINTLIBRARY*/
|
|
|
|
|
|
|
|
#include "private.h"
|
|
|
|
|
|
|
|
char *
|
|
|
|
scheck(string, format)
|
|
|
|
const char * const string;
|
1999-01-21 17:46:19 +00:00
|
|
|
const char * const format;
|
1994-09-13 03:29:24 +00:00
|
|
|
{
|
|
|
|
register char * fbuf;
|
|
|
|
register const char * fp;
|
|
|
|
register char * tp;
|
|
|
|
register int c;
|
|
|
|
register char * result;
|
|
|
|
char dummy;
|
1996-07-18 19:40:52 +00:00
|
|
|
static char nada;
|
1994-09-13 03:29:24 +00:00
|
|
|
|
1996-07-18 19:40:52 +00:00
|
|
|
result = &nada;
|
1994-09-13 03:29:24 +00:00
|
|
|
if (string == NULL || format == NULL)
|
|
|
|
return result;
|
1996-07-18 19:40:52 +00:00
|
|
|
fbuf = imalloc((int) (2 * strlen(format) + 4));
|
1994-09-13 03:29:24 +00:00
|
|
|
if (fbuf == NULL)
|
|
|
|
return result;
|
|
|
|
fp = format;
|
|
|
|
tp = fbuf;
|
|
|
|
while ((*tp++ = c = *fp++) != '\0') {
|
|
|
|
if (c != '%')
|
|
|
|
continue;
|
|
|
|
if (*fp == '%') {
|
|
|
|
*tp++ = *fp++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*tp++ = '*';
|
|
|
|
if (*fp == '*')
|
|
|
|
++fp;
|
1996-07-18 19:40:52 +00:00
|
|
|
while (is_digit(*fp))
|
1994-09-13 03:29:24 +00:00
|
|
|
*tp++ = *fp++;
|
|
|
|
if (*fp == 'l' || *fp == 'h')
|
|
|
|
*tp++ = *fp++;
|
|
|
|
else if (*fp == '[')
|
|
|
|
do *tp++ = *fp++;
|
|
|
|
while (*fp != '\0' && *fp != ']');
|
|
|
|
if ((*tp++ = *fp++) == '\0')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*(tp - 1) = '%';
|
|
|
|
*tp++ = 'c';
|
|
|
|
*tp = '\0';
|
|
|
|
if (sscanf(string, fbuf, &dummy) != 1)
|
|
|
|
result = (char *) format;
|
|
|
|
ifree(fbuf);
|
|
|
|
return result;
|
|
|
|
}
|