|
|
594167 |
From 72d3b0c995403293f65ee9a47043ebd2fdafc1cd Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
594167 |
Date: Tue, 29 Mar 2022 12:17:51 +0200
|
|
|
594167 |
Subject: [PATCH] hwdb: fix parser to work with newer pyparsing
|
|
|
594167 |
|
|
|
594167 |
The handling of whitespace in pyparsing is a bother. There's some
|
|
|
594167 |
global state, and per-element state, and it's hard to get a handle on
|
|
|
594167 |
things. With python3-pyparsing-2.4.7-10.fc36.noarch the grammar would
|
|
|
594167 |
not match. After handling of tabs was fixed to not accept duplicate tabs,
|
|
|
594167 |
the grammar passes.
|
|
|
594167 |
|
|
|
594167 |
It seems that the entry for usb:v8087p8087*
|
|
|
594167 |
was generated incorrectly because we treated the interface line
|
|
|
594167 |
(with two TABs) as a device line (with one TAB).
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit f73d6895872cb9caffc523e1eddc53c9b98cfdec)
|
|
|
594167 |
|
|
|
594167 |
Related: #2087778
|
|
|
594167 |
---
|
|
|
594167 |
hwdb.d/20-usb-vendor-model.hwdb | 3 ---
|
|
|
594167 |
hwdb.d/ids_parser.py | 10 ++++++++--
|
|
|
594167 |
2 files changed, 8 insertions(+), 5 deletions(-)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/hwdb.d/20-usb-vendor-model.hwdb b/hwdb.d/20-usb-vendor-model.hwdb
|
|
|
594167 |
index f40a3947c7..9f457d9f65 100644
|
|
|
594167 |
--- a/hwdb.d/20-usb-vendor-model.hwdb
|
|
|
594167 |
+++ b/hwdb.d/20-usb-vendor-model.hwdb
|
|
|
594167 |
@@ -69815,9 +69815,6 @@ usb:v8087p8008*
|
|
|
594167 |
usb:v8087p800A*
|
|
|
594167 |
ID_MODEL_FROM_DATABASE=Hub
|
|
|
594167 |
|
|
|
594167 |
-usb:v8087p8087*
|
|
|
594167 |
- ID_MODEL_FROM_DATABASE=07da Centrino Advanced-N 6235
|
|
|
594167 |
-
|
|
|
594167 |
usb:v80EE*
|
|
|
594167 |
ID_VENDOR_FROM_DATABASE=VirtualBox
|
|
|
594167 |
|
|
|
594167 |
diff --git a/hwdb.d/ids_parser.py b/hwdb.d/ids_parser.py
|
|
|
594167 |
index 0ce79cd97e..811c12559b 100755
|
|
|
594167 |
--- a/hwdb.d/ids_parser.py
|
|
|
594167 |
+++ b/hwdb.d/ids_parser.py
|
|
|
594167 |
@@ -6,7 +6,7 @@ import sys
|
|
|
594167 |
from pyparsing import (Word, White, Literal, Regex,
|
|
|
594167 |
LineEnd, SkipTo,
|
|
|
594167 |
ZeroOrMore, OneOrMore, Combine, Optional, Suppress,
|
|
|
594167 |
- Group,
|
|
|
594167 |
+ Group, ParserElement,
|
|
|
594167 |
stringEnd, pythonStyleComment)
|
|
|
594167 |
|
|
|
594167 |
EOL = LineEnd().suppress()
|
|
|
594167 |
@@ -20,6 +20,8 @@ COMMENTLINE = pythonStyleComment + EOL
|
|
|
594167 |
EMPTYLINE = LineEnd()
|
|
|
594167 |
text_eol = lambda name: Regex(r'[^\n]+')(name) + EOL
|
|
|
594167 |
|
|
|
594167 |
+ParserElement.set_default_whitespace_chars(' \n')
|
|
|
594167 |
+
|
|
|
594167 |
def klass_grammar():
|
|
|
594167 |
klass_line = Literal('C ').suppress() + NUM2('klass') + text_eol('text')
|
|
|
594167 |
subclass_line = TAB + NUM2('subclass') + text_eol('text')
|
|
|
594167 |
@@ -35,8 +37,12 @@ def klass_grammar():
|
|
|
594167 |
def usb_ids_grammar():
|
|
|
594167 |
vendor_line = NUM4('vendor') + text_eol('text')
|
|
|
594167 |
device_line = TAB + NUM4('device') + text_eol('text')
|
|
|
594167 |
+ interface_line = TAB + TAB + NUM4('interface') + NUM4('interface2') + text_eol('text')
|
|
|
594167 |
+ device = (device_line +
|
|
|
594167 |
+ ZeroOrMore(Group(interface_line)
|
|
|
594167 |
+ ^ COMMENTLINE.suppress()))
|
|
|
594167 |
vendor = (vendor_line('VENDOR') +
|
|
|
594167 |
- ZeroOrMore(Group(device_line)('VENDOR_DEV*') ^ COMMENTLINE.suppress()))
|
|
|
594167 |
+ ZeroOrMore(Group(device)('VENDOR_DEV*') ^ COMMENTLINE.suppress()))
|
|
|
594167 |
|
|
|
594167 |
klass = klass_grammar()
|
|
|
594167 |
|