1988-02-17 20:02:19 -05:00
|
|
|
#ifndef lint
|
|
|
|
|
#ifndef NOID
|
1988-02-12 16:59:10 -05:00
|
|
|
static char elsieid[] = "%W%";
|
1988-02-17 20:02:19 -05:00
|
|
|
#endif /* !defined lint */
|
|
|
|
|
#endif /* !defined NOID */
|
1985-11-16 13:38:19 -05:00
|
|
|
|
1988-02-17 22:22:44 -05:00
|
|
|
/*LINTLIBRARY*/
|
|
|
|
|
|
|
|
|
|
#include "stdio.h"
|
1985-11-16 13:38:19 -05:00
|
|
|
#include "ctype.h"
|
1988-02-12 16:59:10 -05:00
|
|
|
#include "string.h"
|
1988-02-27 18:45:10 -05:00
|
|
|
#include "stdlib.h"
|
1988-02-18 11:33:37 -05:00
|
|
|
#include "nonstd.h"
|
1988-02-18 08:58:49 -05:00
|
|
|
|
|
|
|
|
extern char * imalloc P((int n));
|
|
|
|
|
extern void ifree P((char * p));
|
1985-11-16 13:41:25 -05:00
|
|
|
|
1986-03-05 18:40:08 -05:00
|
|
|
char *
|
|
|
|
|
scheck(string, format)
|
1989-02-20 20:44:23 -05:00
|
|
|
const char * const string;
|
|
|
|
|
const char * const format;
|
1985-11-16 13:38:19 -05:00
|
|
|
{
|
1988-02-18 08:58:49 -05:00
|
|
|
register char * fbuf;
|
|
|
|
|
register const char * fp;
|
|
|
|
|
register char * tp;
|
|
|
|
|
register int c;
|
|
|
|
|
register char * result;
|
|
|
|
|
char dummy;
|
1985-11-16 13:38:19 -05:00
|
|
|
|
1986-03-06 09:31:07 -05:00
|
|
|
result = "";
|
1985-11-16 13:38:19 -05:00
|
|
|
if (string == NULL || format == NULL)
|
1986-03-06 09:31:07 -05:00
|
|
|
return result;
|
1986-12-25 18:08:29 -05:00
|
|
|
fbuf = imalloc(2 * strlen(format) + 4);
|
|
|
|
|
if (fbuf == NULL)
|
1986-03-06 09:31:07 -05:00
|
|
|
return result;
|
1985-11-16 13:38:19 -05:00
|
|
|
fp = format;
|
|
|
|
|
tp = fbuf;
|
|
|
|
|
while ((*tp++ = c = *fp++) != '\0') {
|
|
|
|
|
if (c != '%')
|
|
|
|
|
continue;
|
|
|
|
|
if (*fp == '%') {
|
|
|
|
|
*tp++ = *fp++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1985-11-17 20:30:59 -05:00
|
|
|
*tp++ = '*';
|
1985-11-16 13:38:19 -05:00
|
|
|
if (*fp == '*')
|
1985-11-17 20:30:59 -05:00
|
|
|
++fp;
|
1986-03-05 18:42:17 -05:00
|
|
|
while (isascii(*fp) && isdigit(*fp))
|
1985-11-16 13:38:19 -05:00
|
|
|
*tp++ = *fp++;
|
1986-03-06 09:31:07 -05:00
|
|
|
if (*fp == 'l' || *fp == 'h')
|
1985-11-16 13:38:19 -05:00
|
|
|
*tp++ = *fp++;
|
|
|
|
|
else if (*fp == '[')
|
|
|
|
|
do *tp++ = *fp++;
|
|
|
|
|
while (*fp != '\0' && *fp != ']');
|
|
|
|
|
if ((*tp++ = *fp++) == '\0')
|
|
|
|
|
break;
|
|
|
|
|
}
|
1986-03-06 09:31:07 -05:00
|
|
|
*(tp - 1) = '%';
|
|
|
|
|
*tp++ = 'c';
|
1987-02-10 19:48:14 -05:00
|
|
|
*tp = '\0';
|
1986-03-06 09:31:07 -05:00
|
|
|
if (sscanf(string, fbuf, &dummy) != 1)
|
1989-02-20 20:44:23 -05:00
|
|
|
result = (char *) format;
|
1988-02-12 16:59:10 -05:00
|
|
|
ifree(fbuf);
|
1985-11-16 13:38:19 -05:00
|
|
|
return result;
|
|
|
|
|
}
|