Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Fix round-trip of hid_usage_in_page(hid_parse_usage_in_page(...
details: https://anonhg.NetBSD.org/src/rev/8a1706e06281
branches: trunk
changeset: 342626:8a1706e06281
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sat Jan 02 01:04:15 2016 +0000
description:
Fix round-trip of hid_usage_in_page(hid_parse_usage_in_page()) when
the usage is a catch-all format string.
This should allow usbhidctl(1) to understand an item argument of
"Button:Button_65535".
diffstat:
lib/libusbhid/usage.c | 11 ++++++++---
tests/lib/libusbhid/t_usbhid.c | 7 ++-----
2 files changed, 10 insertions(+), 8 deletions(-)
diffs (60 lines):
diff -r 3f9bfddd8098 -r 8a1706e06281 lib/libusbhid/usage.c
--- a/lib/libusbhid/usage.c Fri Jan 01 23:46:04 2016 +0000
+++ b/lib/libusbhid/usage.c Sat Jan 02 01:04:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usage.c,v 1.7 2006/04/09 00:49:55 christos Exp $ */
+/* $NetBSD: usage.c,v 1.8 2016/01/02 01:04:15 jakllsch Exp $ */
/*
* Copyright (c) 1999 Lennart Augustsson <augustss%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: usage.c,v 1.7 2006/04/09 00:49:55 christos Exp $");
+__RCSID("$NetBSD: usage.c,v 1.8 2016/01/02 01:04:15 jakllsch Exp $");
#include <assert.h>
#include <ctype.h>
@@ -235,7 +235,12 @@
found:
sep++;
for (j = 0; j < pages[k].pagesize; j++)
- if (strcmp(pages[k].page_contents[j].name, sep) == 0)
+ if (pages[k].page_contents[j].usage == -1) {
+ if (sscanf(sep, fmtcheck(
+ pages[k].page_contents[j].name, "%u"), &l) == 1) {
+ return (pages[k].usage << 16) | l;
+ }
+ } else if (strcmp(pages[k].page_contents[j].name, sep) == 0)
return (pages[k].usage << 16) | pages[k].page_contents[j].usage;
return (-1);
}
diff -r 3f9bfddd8098 -r 8a1706e06281 tests/lib/libusbhid/t_usbhid.c
--- a/tests/lib/libusbhid/t_usbhid.c Fri Jan 01 23:46:04 2016 +0000
+++ b/tests/lib/libusbhid/t_usbhid.c Sat Jan 02 01:04:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_usbhid.c,v 1.4 2016/01/01 23:46:04 jakllsch Exp $ */
+/* $NetBSD: t_usbhid.c,v 1.5 2016/01/02 01:04:15 jakllsch Exp $ */
/*
* Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_usbhid.c,v 1.4 2016/01/01 23:46:04 jakllsch Exp $");
+__RCSID("$NetBSD: t_usbhid.c,v 1.5 2016/01/02 01:04:15 jakllsch Exp $");
#include <atf-c.h>
@@ -167,9 +167,6 @@
(void)strlcat(usages_path, "/test_usb_hid_usages",
sizeof(usages_path));
- atf_tc_expect_fail("hid_parse_*() fails because it doesn't use "
- "scanf()");
-
hid_init(usages_path);
ATF_CHECK_STREQ("t_usbhid_page", hid_usage_page(0xff1b));
Home |
Main Index |
Thread Index |
Old Index