svn commit: r351760 - stable/11/sys/kern
Alexander Motin
mav at FreeBSD.org
Tue Sep 3 16:38:53 UTC 2019
Author: mav
Date: Tue Sep 3 16:38:52 2019
New Revision: 351760
URL: https://svnweb.freebsd.org/changeset/base/351760
Log:
MFC r351134: Add support for 'j', 't' and 'z' flags to kernel sscanf().
Modified:
stable/11/sys/kern/subr_scanf.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/kern/subr_scanf.c
==============================================================================
--- stable/11/sys/kern/subr_scanf.c Tue Sep 3 16:38:25 2019 (r351759)
+++ stable/11/sys/kern/subr_scanf.c Tue Sep 3 16:38:52 2019 (r351760)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/ctype.h>
#include <sys/limits.h>
+#include <sys/stddef.h>
/*
* Note that stdarg.h and the ANSI style va_start macro is used for both
@@ -59,6 +60,9 @@ __FBSDID("$FreeBSD$");
#define POINTER 0x10 /* weird %p pointer (`fake hex') */
#define NOSKIP 0x20 /* do not skip blanks */
#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 */
/*
@@ -160,6 +164,9 @@ literal:
case '*':
flags |= SUPPRESS;
goto again;
+ case 'j':
+ flags |= INTMAXT;
+ goto again;
case 'l':
if (flags & LONG){
flags &= ~LONG;
@@ -171,6 +178,12 @@ literal:
case 'q':
flags |= QUAD;
goto again;
+ case 't':
+ flags |= PTRDIFFT;
+ goto again;
+ case 'z':
+ flags |= SIZET;
+ goto again;
case 'h':
if (flags & SHORT){
flags &= ~SHORT;
@@ -254,6 +267,12 @@ literal:
*va_arg(ap, long *) = nread;
else if (flags & QUAD)
*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
*va_arg(ap, int *) = nread;
continue;
@@ -531,6 +550,12 @@ literal:
*va_arg(ap, long *) = res;
else if (flags & QUAD)
*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
*va_arg(ap, int *) = res;
nassigned++;
More information about the svn-src-stable
mailing list