10Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 20Sstevel@tonic-gate 3*1442Srobbin /* static char elsieid[] = "@(#)scheck.c 8.17"; */ 40Sstevel@tonic-gate 50Sstevel@tonic-gate /*LINTLIBRARY*/ 60Sstevel@tonic-gate 70Sstevel@tonic-gate #include "private.h" 80Sstevel@tonic-gate 9*1442Srobbin const char * scheck(string,format)100Sstevel@tonic-gatescheck(string, format) 110Sstevel@tonic-gate const char * const string; 12*1442Srobbin const char * const format; 130Sstevel@tonic-gate { 141138Srobbin register char *fbuf; 151138Srobbin register const char *fp; 161138Srobbin register char *tp; 170Sstevel@tonic-gate register int c; 18*1442Srobbin register const char *result; 190Sstevel@tonic-gate char dummy; 200Sstevel@tonic-gate 21*1442Srobbin result = ""; 220Sstevel@tonic-gate if (string == NULL || format == NULL) 230Sstevel@tonic-gate return (result); 241138Srobbin fbuf = imalloc((int)(2 * strlen(format) + 4)); 250Sstevel@tonic-gate if (fbuf == NULL) 260Sstevel@tonic-gate return (result); 270Sstevel@tonic-gate fp = format; 280Sstevel@tonic-gate tp = fbuf; 290Sstevel@tonic-gate while ((*tp++ = c = *fp++) != '\0') { 300Sstevel@tonic-gate if (c != '%') 310Sstevel@tonic-gate continue; 320Sstevel@tonic-gate if (*fp == '%') { 330Sstevel@tonic-gate *tp++ = *fp++; 340Sstevel@tonic-gate continue; 350Sstevel@tonic-gate } 360Sstevel@tonic-gate *tp++ = '*'; 370Sstevel@tonic-gate if (*fp == '*') 380Sstevel@tonic-gate ++fp; 390Sstevel@tonic-gate while (is_digit(*fp)) 400Sstevel@tonic-gate *tp++ = *fp++; 410Sstevel@tonic-gate if (*fp == 'l' || *fp == 'h') 420Sstevel@tonic-gate *tp++ = *fp++; 430Sstevel@tonic-gate else if (*fp == '[') 440Sstevel@tonic-gate do *tp++ = *fp++; 450Sstevel@tonic-gate while (*fp != '\0' && *fp != ']'); 460Sstevel@tonic-gate if ((*tp++ = *fp++) == '\0') 470Sstevel@tonic-gate break; 480Sstevel@tonic-gate } 490Sstevel@tonic-gate *(tp - 1) = '%'; 500Sstevel@tonic-gate *tp++ = 'c'; 510Sstevel@tonic-gate *tp = '\0'; 520Sstevel@tonic-gate if (sscanf(string, fbuf, &dummy) != 1) 531138Srobbin result = (char *)format; 540Sstevel@tonic-gate ifree(fbuf); 550Sstevel@tonic-gate return (result); 560Sstevel@tonic-gate } 57