Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/wsconsctl Added a field type for signed integers. This ...
details: https://anonhg.NetBSD.org/src/rev/2093437b827d
branches: trunk
changeset: 783469:2093437b827d
user: khorben <khorben%NetBSD.org@localhost>
date: Mon Dec 24 01:20:12 2012 +0000
description:
Added a field type for signed integers. This is required when handling
touchscreen calibration values, which is about to be implemented in
wsconsctl (see PR kern/45872).
Reviewed by uwe@ (thank you!)
diffstat:
sbin/wsconsctl/util.c | 15 +++++++++++++--
sbin/wsconsctl/wsconsctl.h | 5 +++--
2 files changed, 16 insertions(+), 4 deletions(-)
diffs (59 lines):
diff -r 2d8b4a931f0d -r 2093437b827d sbin/wsconsctl/util.c
--- a/sbin/wsconsctl/util.c Mon Dec 24 01:14:40 2012 +0000
+++ b/sbin/wsconsctl/util.c Mon Dec 24 01:20:12 2012 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: util.c,v 1.30 2011/12/15 14:25:12 phx Exp $ */
+/* $NetBSD: util.c,v 1.31 2012/12/24 01:20:12 khorben Exp $ */
/*-
- * Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -257,6 +257,9 @@
case FMT_UINT:
(void)printf("%u", *((unsigned int *) f->valp));
break;
+ case FMT_INT:
+ (void)printf("%d", *((int *) f->valp));
+ break;
case FMT_STRING:
(void)printf("\"%s\"", *((char **) f->valp));
break;
@@ -361,6 +364,14 @@
else
*((unsigned int *) f->valp) = u;
break;
+ case FMT_INT:
+ if (sscanf(val, "%d", &i) != 1)
+ errx(EXIT_FAILURE, "%s: not a number", val);
+ if (merge)
+ *((int *) f->valp) += i;
+ else
+ *((int *) f->valp) = i;
+ break;
case FMT_STRING:
if ((*((char **) f->valp) = strdup(val)) == NULL)
err(EXIT_FAILURE, "strdup");
diff -r 2d8b4a931f0d -r 2093437b827d sbin/wsconsctl/wsconsctl.h
--- a/sbin/wsconsctl/wsconsctl.h Mon Dec 24 01:14:40 2012 +0000
+++ b/sbin/wsconsctl/wsconsctl.h Mon Dec 24 01:20:12 2012 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: wsconsctl.h,v 1.11 2011/08/27 19:01:34 joerg Exp $ */
+/* $NetBSD: wsconsctl.h,v 1.12 2012/12/24 01:20:44 khorben Exp $ */
/*-
- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2004, 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -55,6 +55,7 @@
#define FMT_UINT 1 /* unsigned integer */
#define FMT_STRING 2 /* zero terminated string */
#define FMT_BITFIELD 3 /* bit field */
+#define FMT_INT 4 /* signed integer */
#define FMT_KBDTYPE 101 /* keyboard type */
#define FMT_MSTYPE 102 /* mouse type */
#define FMT_DPYTYPE 103 /* display type */
Home |
Main Index |
Thread Index |
Old Index