diff options
author | Peter Wu <peter@lekensteyn.nl> | 2019-04-14 22:24:58 +0100 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2019-04-14 21:36:58 +0000 |
commit | 1c4885deaf448e0ed30d8266043d3f776bcc8c33 (patch) | |
tree | f21dddca9a4e4991e22ba1424cc029e6355fc774 | |
parent | 651bdf592b0334d559c0e5e90d787fda635ecaf3 (diff) |
make-usb.py: use octal escape sequences
Fixes errors like:
epan/dissectors/usb.c:15220:42: error: hex escape sequence out of range
{ 0x0cad9001, "PowerPad Pocket PC\xc2\xa0Device" },
Change-Id: I8c120892c0d52aceb3f6767401e7944353495825
Fixes: v3.1.0rc0-524-g6f57aa72a8 ("Make a couple of scripts Python 3 only.")
Reviewed-on: https://code.wireshark.org/review/32854
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r-- | epan/dissectors/usb.c | 36 | ||||
-rwxr-xr-x | tools/make-usb.py | 14 |
2 files changed, 28 insertions, 22 deletions
diff --git a/epan/dissectors/usb.c b/epan/dissectors/usb.c index 05ad91fd8c..4b35f82f58 100644 --- a/epan/dissectors/usb.c +++ b/epan/dissectors/usb.c @@ -5112,7 +5112,7 @@ static const value_string usb_products_vals[] = { { 0x045e0008, "SideWinder Precision Pro" }, { 0x045e0009, "IntelliMouse" }, { 0x045e000b, "Natural Keyboard Elite" }, - { 0x045e000e, "SideWinder\xc2\xae Freestyle Pro" }, + { 0x045e000e, "SideWinder\302\256 Freestyle Pro" }, { 0x045e0014, "Digital Sound System 80" }, { 0x045e001a, "SideWinder Precision Racing Wheel" }, { 0x045e001b, "SideWinder Force Feedback 2 Joystick" }, @@ -6214,7 +6214,7 @@ static const value_string usb_products_vals[] = { { 0x04830afb, "Android Fastboot device" }, { 0x04831307, "Cytronix 6in1 Card Reader" }, { 0x0483163d, "Cool Icam Digi-MP3" }, - { 0x04832015, "TouchChip\xc2\xae Fingerprint Reader" }, + { 0x04832015, "TouchChip\302\256 Fingerprint Reader" }, { 0x04832016, "Fingerprint Reader" }, { 0x04832017, "Biometric Smart Card Reader" }, { 0x04832018, "BioSimKey" }, @@ -8071,18 +8071,18 @@ static const value_string usb_products_vals[] = { { 0x04e6e003, "SPR532 PinPad SmartCard Reader" }, { 0x04e70001, "TouchScreen" }, { 0x04e70002, "Touchmonitor Interface 2600 Rev 2" }, - { 0x04e70004, "4000U CarrollTouch\xc2\xae Touchmonitor Interface" }, - { 0x04e70007, "2500U IntelliTouch\xc2\xae Touchmonitor Interface" }, - { 0x04e70008, "3000U AccuTouch\xc2\xae Touchmonitor Interface" }, - { 0x04e70009, "4000U CarrollTouch\xc2\xae Touchmonitor Interface" }, + { 0x04e70004, "4000U CarrollTouch\302\256 Touchmonitor Interface" }, + { 0x04e70007, "2500U IntelliTouch\302\256 Touchmonitor Interface" }, + { 0x04e70008, "3000U AccuTouch\302\256 Touchmonitor Interface" }, + { 0x04e70009, "4000U CarrollTouch\302\256 Touchmonitor Interface" }, { 0x04e70020, "Touchscreen Interface (2700)" }, { 0x04e70021, "Touchmonitor Interface" }, - { 0x04e70030, "4500U CarrollTouch\xc2\xae Touchmonitor Interface" }, + { 0x04e70030, "4500U CarrollTouch\302\256 Touchmonitor Interface" }, { 0x04e70032, "Touchmonitor Interface" }, { 0x04e70033, "Touchmonitor Interface" }, { 0x04e70041, "5010 Surface Capacitive Touchmonitor Interface" }, { 0x04e70042, "Touchmonitor Interface" }, - { 0x04e70050, "2216 AccuTouch\xc2\xae Touchmonitor Interface" }, + { 0x04e70050, "2216 AccuTouch\302\256 Touchmonitor Interface" }, { 0x04e70071, "Touchmonitor Interface" }, { 0x04e70072, "Touchmonitor Interface" }, { 0x04e70081, "Touchmonitor Interface" }, @@ -13493,9 +13493,9 @@ static const value_string usb_products_vals[] = { { 0x091e2295, "Colorado 300" }, { 0x091e22b6, "eTrex Vista HCx (Mass Storage mode)" }, { 0x091e231b, "Oregon 400t" }, - { 0x091e2353, "N\xc3\xbcvi 205T" }, + { 0x091e2353, "N\303\274vi 205T" }, { 0x091e2380, "Oregon series" }, - { 0x091e23cc, "n\xc3\xbcvi 1350" }, + { 0x091e23cc, "n\303\274vi 1350" }, { 0x091e2459, "GPSmap 62/78 series" }, { 0x091e2491, "Edge 800" }, { 0x091e2519, "eTrex 30" }, @@ -13568,7 +13568,7 @@ static const value_string usb_products_vals[] = { { 0x09300509, "BT EDR Dongle" }, { 0x09300706, "PocketPC e740" }, { 0x09300707, "Pocket PC e330 Series" }, - { 0x09300708, "Pocket PC e350\xc2\xa0Series" }, + { 0x09300708, "Pocket PC e350\302\240Series" }, { 0x09300709, "Pocket PC e750 Series" }, { 0x0930070a, "Pocket PC e400 Series" }, { 0x0930070b, "Pocket PC e800 Series" }, @@ -14830,7 +14830,7 @@ static const value_string usb_products_vals[] = { { 0x0bda5730, "HP 2.0MP High Definition Webcam" }, { 0x0bda5751, "Integrated Webcam" }, { 0x0bda5775, "HP \"Truevision HD\" laptop camera" }, - { 0x0bda57b3, "Acer 640 \xc3\x97 480 laptop camera" }, + { 0x0bda57b3, "Acer 640 \303\227 480 laptop camera" }, { 0x0bda57da, "Built-In Video Camera" }, { 0x0bda58c8, "Integrated Webcam HD" }, { 0x0bda8150, "RTL8150 Fast Ethernet Adapter" }, @@ -15217,7 +15217,7 @@ static const value_string usb_products_vals[] = { { 0x0cad1030, "APX Series Radio (Portable)" }, { 0x0cad1031, "APX Series Radio (Mobile)" }, { 0x0cad1602, "IMPRES Battery Data Reader" }, - { 0x0cad9001, "PowerPad Pocket PC\xc2\xa0Device" }, + { 0x0cad9001, "PowerPad Pocket PC\302\240Device" }, { 0x0caf2507, "Hi-Speed USB-to-IDE Bridge Controller" }, { 0x0caf2515, "Flash Disk Embedded Hub" }, { 0x0caf2516, "Flash Disk Security Device" }, @@ -15241,7 +15241,7 @@ static const value_string usb_products_vals[] = { { 0x0ccd0035, "Miditech Play'n Roll" }, { 0x0ccd0036, "Cinergy 250 Audio" }, { 0x0ccd0037, "Cinergy 250 Audio" }, - { 0x0ccd0038, "Cinergy T\xc2\xb2 DVB-T Receiver" }, + { 0x0ccd0038, "Cinergy T\302\262 DVB-T Receiver" }, { 0x0ccd0039, "Grabster AV 400" }, { 0x0ccd003b, "Cinergy 400" }, { 0x0ccd003c, "Grabster AV 250" }, @@ -15250,7 +15250,7 @@ static const value_string usb_products_vals[] = { { 0x0ccd004e, "Cinergy T XS" }, { 0x0ccd004f, "Cinergy Analog XS" }, { 0x0ccd0055, "Cinergy T XE (Version 1, AF9005)" }, - { 0x0ccd005c, "Cinergy T\xc2\xb2" }, + { 0x0ccd005c, "Cinergy T\302\262" }, { 0x0ccd0069, "Cinergy T XE (Version 2, AF9015)" }, { 0x0ccd006b, "Cinergy HT PVR (EU)" }, { 0x0ccd0072, "Cinergy Hybrid T" }, @@ -19364,7 +19364,7 @@ static const value_string usb_products_vals[] = { { 0x1e290402, "FTDI232 [EasyPort]" }, { 0x1e290403, "FTDI232 [EasyPort Mini]" }, { 0x1e290404, "FTDI232 [Netzteil-GL]" }, - { 0x1e290405, "FTDI232 [MotorPr\xc3\xbcfstand]" }, + { 0x1e290405, "FTDI232 [MotorPr\303\274fstand]" }, { 0x1e290406, "STM32F103 [EasyKit]" }, { 0x1e290407, "LPC2378 [Robotino]" }, { 0x1e290408, "LPC2378 [Robotino-Arm]" }, @@ -20422,8 +20422,8 @@ static const value_string usb_products_vals[] = { { 0x80862448, "82801 PCI Bridge" }, { 0x80863100, "PRO/DSL 3220 Modem - WAN" }, { 0x80863101, "PRO/DSL 3220 Modem" }, - { 0x80863240, "AnyPoint\xc2\xae 3240 Modem - WAN" }, - { 0x80863241, "AnyPoint\xc2\xae 3240 Modem" }, + { 0x80863240, "AnyPoint\302\256 3240 Modem - WAN" }, + { 0x80863241, "AnyPoint\302\256 3240 Modem" }, { 0x80868602, "Miniature Card Slot" }, { 0x80869303, "Intel 8x930Hx Hub" }, { 0x80869500, "CE 9500 DVB-T" }, diff --git a/tools/make-usb.py b/tools/make-usb.py index 19d776bd85..b63f477314 100755 --- a/tools/make-usb.py +++ b/tools/make-usb.py @@ -34,15 +34,21 @@ products = dict() vendors_str="static const value_string usb_vendors_vals[] = {\n" products_str="static const value_string usb_products_vals[] = {\n" +# Escape backslashes, quotes, control characters and non-ASCII characters. +escapes = {} +for i in range(256): + if i in b'\\"': + escapes[i] = '\\%c' % i + elif i in range(0x20, 0x80) or i in b'\t': + escapes[i] = chr(i) + else: + escapes[i] = '\\%03o' % i for utf8line in lines: # Convert single backslashes to double (escaped) backslashes, escape quotes, etc. utf8line = utf8line.rstrip() - utf8line = utf8line.replace('\\', '\\\\') - utf8line = utf8line.replace('"', '\\"') utf8line = re.sub("\?+", "?", utf8line) - # Finally, convert non-ASCII UTF-8 sequences to C-style escapes - line = utf8line.encode('UTF-8').decode('ascii', 'backslashreplace') + line = ''.join(escapes[byte] for byte in utf8line.encode('utf8')) if line == "# Vendors, devices and interfaces. Please keep sorted.": mode = MODE_VENDOR_PRODUCT |