Add support for 'j', 't' and 'z' flags to kernel sscanf().
MFC after: 2 weeks
This commit is contained in:
parent
6b821a7455
commit
3a60f3dad0
@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/ctype.h>
|
#include <sys/ctype.h>
|
||||||
#include <sys/limits.h>
|
#include <sys/limits.h>
|
||||||
|
#include <sys/stddef.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that stdarg.h and the ANSI style va_start macro is used for both
|
* Note that stdarg.h and the ANSI style va_start macro is used for both
|
||||||
@ -61,6 +62,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define POINTER 0x10 /* weird %p pointer (`fake hex') */
|
#define POINTER 0x10 /* weird %p pointer (`fake hex') */
|
||||||
#define NOSKIP 0x20 /* do not skip blanks */
|
#define NOSKIP 0x20 /* do not skip blanks */
|
||||||
#define QUAD 0x400
|
#define QUAD 0x400
|
||||||
|
#define INTMAXT 0x800 /* j: intmax_t */
|
||||||
|
#define PTRDIFFT 0x1000 /* t: ptrdiff_t */
|
||||||
|
#define SIZET 0x2000 /* z: size_t */
|
||||||
#define SHORTSHORT 0x4000 /** hh: char */
|
#define SHORTSHORT 0x4000 /** hh: char */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -162,6 +166,9 @@ again: c = *fmt++;
|
|||||||
case '*':
|
case '*':
|
||||||
flags |= SUPPRESS;
|
flags |= SUPPRESS;
|
||||||
goto again;
|
goto again;
|
||||||
|
case 'j':
|
||||||
|
flags |= INTMAXT;
|
||||||
|
goto again;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (flags & LONG){
|
if (flags & LONG){
|
||||||
flags &= ~LONG;
|
flags &= ~LONG;
|
||||||
@ -173,6 +180,12 @@ again: c = *fmt++;
|
|||||||
case 'q':
|
case 'q':
|
||||||
flags |= QUAD;
|
flags |= QUAD;
|
||||||
goto again;
|
goto again;
|
||||||
|
case 't':
|
||||||
|
flags |= PTRDIFFT;
|
||||||
|
goto again;
|
||||||
|
case 'z':
|
||||||
|
flags |= SIZET;
|
||||||
|
goto again;
|
||||||
case 'h':
|
case 'h':
|
||||||
if (flags & SHORT){
|
if (flags & SHORT){
|
||||||
flags &= ~SHORT;
|
flags &= ~SHORT;
|
||||||
@ -256,6 +269,12 @@ again: c = *fmt++;
|
|||||||
*va_arg(ap, long *) = nread;
|
*va_arg(ap, long *) = nread;
|
||||||
else if (flags & QUAD)
|
else if (flags & QUAD)
|
||||||
*va_arg(ap, quad_t *) = nread;
|
*va_arg(ap, quad_t *) = nread;
|
||||||
|
else if (flags & INTMAXT)
|
||||||
|
*va_arg(ap, intmax_t *) = nread;
|
||||||
|
else if (flags & SIZET)
|
||||||
|
*va_arg(ap, size_t *) = nread;
|
||||||
|
else if (flags & PTRDIFFT)
|
||||||
|
*va_arg(ap, ptrdiff_t *) = nread;
|
||||||
else
|
else
|
||||||
*va_arg(ap, int *) = nread;
|
*va_arg(ap, int *) = nread;
|
||||||
continue;
|
continue;
|
||||||
@ -533,6 +552,12 @@ again: c = *fmt++;
|
|||||||
*va_arg(ap, long *) = res;
|
*va_arg(ap, long *) = res;
|
||||||
else if (flags & QUAD)
|
else if (flags & QUAD)
|
||||||
*va_arg(ap, quad_t *) = res;
|
*va_arg(ap, quad_t *) = res;
|
||||||
|
else if (flags & INTMAXT)
|
||||||
|
*va_arg(ap, intmax_t *) = res;
|
||||||
|
else if (flags & PTRDIFFT)
|
||||||
|
*va_arg(ap, ptrdiff_t *) = res;
|
||||||
|
else if (flags & SIZET)
|
||||||
|
*va_arg(ap, size_t *) = res;
|
||||||
else
|
else
|
||||||
*va_arg(ap, int *) = res;
|
*va_arg(ap, int *) = res;
|
||||||
nassigned++;
|
nassigned++;
|
||||||
|
Loading…
Reference in New Issue
Block a user