Module Name:    src
Committed By:   khorben
Date:           Mon Dec 24 01:20:12 UTC 2012

Modified Files:
        src/sbin/wsconsctl: util.c

Log Message:
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!)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sbin/wsconsctl/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/wsconsctl/util.c
diff -u src/sbin/wsconsctl/util.c:1.30 src/sbin/wsconsctl/util.c:1.31
--- src/sbin/wsconsctl/util.c:1.30	Thu Dec 15 14:25:12 2011
+++ src/sbin/wsconsctl/util.c	Mon Dec 24 01:20:12 2012
@@ -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 @@ pr_field(struct field *f, const char *se
 	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 @@ rd_field(struct field *f, char *val, int
 		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");

Reply via email to