svn commit: r351134 - head/sys/kern

Alexander Motin mav at FreeBSD.org
Fri Aug 16 19:46:22 UTC 2019


Author: mav
Date: Fri Aug 16 19:46:22 2019
New Revision: 351134
URL: https://svnweb.freebsd.org/changeset/base/351134

Log:
  Add support for 'j', 't' and 'z' flags to kernel sscanf().
  
  MFC after:	2 weeks

Modified:
  head/sys/kern/subr_scanf.c

Modified: head/sys/kern/subr_scanf.c
==============================================================================
--- head/sys/kern/subr_scanf.c	Fri Aug 16 19:27:05 2019	(r351133)
+++ head/sys/kern/subr_scanf.c	Fri Aug 16 19:46:22 2019	(r351134)
@@ -43,6 +43,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
@@ -61,6 +62,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 */
 
 /*
@@ -162,6 +166,9 @@ literal:
 		case '*':
 			flags |= SUPPRESS;
 			goto again;
+		case 'j':
+			flags |= INTMAXT;
+			goto again;
 		case 'l':
 			if (flags & LONG){
 				flags &= ~LONG;
@@ -173,6 +180,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;
@@ -256,6 +269,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;
@@ -533,6 +552,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-all mailing list