37 #include <sys/cdefs.h>
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/ctype.h>
43 #include <sys/limits.h>
49 #include <machine/stdarg.h>
62 #define SHORTSHORT 0x4000
76 #define NZDIGITS 0x200
85 typedef u_quad_t (*
ccfntype)(
const char *,
char **, int);
87 static const u_char *
__sccl(
char *,
const u_char *);
90 sscanf(
const char *ibuf,
const char *fmt, ...)
102 vsscanf(
const char *inp,
char const *fmt0, va_list ap)
105 const u_char *fmt = (
const u_char *)fmt0;
121 static short basefix[17] =
122 { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
136 while (inr > 0 && isspace(*inp))
137 nread++, inr--, inp++;
183 case '0':
case '1':
case '2':
case '3':
case '4':
184 case '5':
case '6':
case '7':
case '8':
case '9':
185 width = width * 10 + c -
'0';
228 fmt =
__sccl(ccltab, fmt);
250 *va_arg(ap,
char *) = nread;
251 else if (flags & SHORT)
252 *va_arg(ap,
short *) = nread;
253 else if (flags & LONG)
254 *va_arg(ap,
long *) = nread;
255 else if (flags &
QUAD)
256 *va_arg(ap, quad_t *) = nread;
258 *va_arg(ap,
int *) = nread;
272 if ((flags &
NOSKIP) == 0) {
273 while (isspace(*inp)) {
299 if ((n = inr) < width) {
315 bcopy(inp, va_arg(ap,
char *), width);
329 if (flags & SUPPRESS) {
331 while (ccltab[(
unsigned char)*inp]) {
344 p0 = p = va_arg(ap,
char *);
345 while (ccltab[(
unsigned char)*inp]) {
370 if (flags & SUPPRESS) {
372 while (!isspace(*inp)) {
381 p0 = p = va_arg(ap,
char *);
382 while (!isspace(*inp)) {
400 if (width == 0 || width >
sizeof(buf) - 1)
401 width =
sizeof(
buf) - 1;
404 if (--width >
sizeof(buf) - 2)
405 width =
sizeof(buf) - 2;
409 for (p = buf; width; width--) {
441 case '1':
case '2':
case '3':
442 case '4':
case '5':
case '6':
case '7':
443 base = basefix[base];
449 base = basefix[base];
456 case 'A':
case 'B':
case 'C':
457 case 'D':
case 'E':
case 'F':
458 case 'a':
case 'b':
case 'c':
459 case 'd':
case 'e':
case 'f':
476 if (flags &
PFXOK && p == buf + 1) {
512 c = ((u_char *)p)[-1];
513 if (c ==
'x' || c ==
'X') {
518 if ((flags & SUPPRESS) == 0) {
522 res = (*ccfn)(
buf, (
char **)NULL, base);
524 *va_arg(ap,
void **) =
525 (
void *)(uintptr_t)res;
527 *va_arg(ap,
char *) = res;
528 else if (flags &
SHORT)
529 *va_arg(ap,
short *) = res;
530 else if (flags &
LONG)
531 *va_arg(ap,
long *) = res;
532 else if (flags &
QUAD)
533 *va_arg(ap, quad_t *) = res;
535 *va_arg(ap,
int *) = res;
545 return (nconversions != 0 ? nassigned : -1);
556 static const u_char *
570 for (n = 0; n < 256; n++)
613 if (n ==
']' || n < c) {
static const u_char * __sccl(char *, const u_char *)
u_quad_t(* ccfntype)(const char *, char **, int)
int sscanf(const char *ibuf, const char *fmt,...)
int vsscanf(const char *inp, char const *fmt0, va_list ap)