Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2019 16:38:26 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r351759 - stable/12/sys/kern
Message-ID:  <201909031638.x83GcQXA047618@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Tue Sep  3 16:38:25 2019
New Revision: 351759
URL: https://svnweb.freebsd.org/changeset/base/351759

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

Modified:
  stable/12/sys/kern/subr_scanf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/subr_scanf.c
==============================================================================
--- stable/12/sys/kern/subr_scanf.c	Tue Sep  3 16:33:02 2019	(r351758)
+++ stable/12/sys/kern/subr_scanf.c	Tue Sep  3 16:38:25 2019	(r351759)
@@ -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++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909031638.x83GcQXA047618>