Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen Teach fmtcheck(3) about the flags a, A, F, G, t...
details: https://anonhg.NetBSD.org/src/rev/724f451a2ecb
branches: trunk
changeset: 357974:724f451a2ecb
user: rin <rin%NetBSD.org@localhost>
date: Wed Dec 06 12:28:53 2017 +0000
description:
Teach fmtcheck(3) about the flags a, A, F, G, t, and z. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev117014
diffstat:
lib/libc/gen/fmtcheck.c | 40 ++++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 10 deletions(-)
diffs (116 lines):
diff -r e03a92dc68b4 -r 724f451a2ecb lib/libc/gen/fmtcheck.c
--- a/lib/libc/gen/fmtcheck.c Wed Dec 06 11:33:34 2017 +0000
+++ b/lib/libc/gen/fmtcheck.c Wed Dec 06 12:28:53 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $ */
+/* $NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $");
+__RCSID("$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $");
#endif
#include "namespace.h"
@@ -49,11 +49,15 @@
FMTCHECK_INT,
FMTCHECK_LONG,
FMTCHECK_QUAD,
+ FMTCHECK_PTRDIFFT,
+ FMTCHECK_SIZET,
FMTCHECK_POINTER,
FMTCHECK_SHORTPOINTER,
FMTCHECK_INTPOINTER,
FMTCHECK_LONGPOINTER,
FMTCHECK_QUADPOINTER,
+ FMTCHECK_PTRDIFFTPOINTER,
+ FMTCHECK_SIZETPOINTER,
FMTCHECK_DOUBLE,
FMTCHECK_LONGDOUBLE,
FMTCHECK_STRING,
@@ -72,10 +76,10 @@
static EFT
get_next_format_from_precision(const char **pf)
{
- int sh, lg, quad, longdouble;
+ int sh, lg, quad, longdouble, ptrdifft, sizet;
const char *f;
- sh = lg = quad = longdouble = 0;
+ sh = lg = quad = longdouble = ptrdifft = sizet = 0;
f = *pf;
switch (*f) {
@@ -97,6 +101,14 @@
f++;
quad = 1;
break;
+ case 't':
+ f++;
+ ptrdifft = 1;
+ break;
+ case 'z':
+ f++;
+ sizet = 1;
+ break;
case 'L':
f++;
longdouble = 1;
@@ -129,6 +141,10 @@
RETURN(pf,f,FMTCHECK_LONG);
if (quad)
RETURN(pf,f,FMTCHECK_QUAD);
+ if (ptrdifft)
+ RETURN(pf,f,FMTCHECK_PTRDIFFT);
+ if (sizet)
+ RETURN(pf,f,FMTCHECK_SIZET);
RETURN(pf,f,FMTCHECK_INT);
}
if (*f == 'n') {
@@ -140,32 +156,36 @@
RETURN(pf,f,FMTCHECK_LONGPOINTER);
if (quad)
RETURN(pf,f,FMTCHECK_QUADPOINTER);
+ if (ptrdifft)
+ RETURN(pf,f,FMTCHECK_PTRDIFFTPOINTER);
+ if (sizet)
+ RETURN(pf,f,FMTCHECK_SIZETPOINTER);
RETURN(pf,f,FMTCHECK_INTPOINTER);
}
if (strchr("DOU", *f)) {
- if (sh + lg + quad + longdouble)
+ if (sh + lg + quad + longdouble + ptrdifft + sizet)
RETURN(pf,f,FMTCHECK_UNKNOWN);
RETURN(pf,f,FMTCHECK_LONG);
}
- if (strchr("eEfg", *f)) {
+ if (strchr("aAeEfFgG", *f)) {
if (longdouble)
RETURN(pf,f,FMTCHECK_LONGDOUBLE);
- if (sh + lg + quad)
+ if (sh + lg + quad + ptrdifft + sizet)
RETURN(pf,f,FMTCHECK_UNKNOWN);
RETURN(pf,f,FMTCHECK_DOUBLE);
}
if (*f == 'c') {
- if (sh + lg + quad + longdouble)
+ if (sh + lg + quad + longdouble + ptrdifft + sizet)
RETURN(pf,f,FMTCHECK_UNKNOWN);
RETURN(pf,f,FMTCHECK_INT);
}
if (*f == 's') {
- if (sh + lg + quad + longdouble)
+ if (sh + lg + quad + longdouble + ptrdifft + sizet)
RETURN(pf,f,FMTCHECK_UNKNOWN);
RETURN(pf,f,FMTCHECK_STRING);
}
if (*f == 'p') {
- if (sh + lg + quad + longdouble)
+ if (sh + lg + quad + longdouble + ptrdifft + sizet)
RETURN(pf,f,FMTCHECK_UNKNOWN);
RETURN(pf,f,FMTCHECK_POINTER);
}
Home |
Main Index |
Thread Index |
Old Index