]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/filter.c
libpci: ecam: Fix detect sequence when addresses are not specified
[pciutils.git] / lib / filter.c
index 703845156c5d75c26a96e4b986bb95bf587daffa..0301f49f93ff76e6a29f6d781817c2dfd4f83886 100644 (file)
@@ -3,7 +3,9 @@
  *
  *     Copyright (c) 1998--2022 Martin Mares <mj@ucw.cz>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include <stdlib.h>
@@ -76,6 +78,11 @@ parse_hex_field(char *str, int *outp, unsigned int *maskp, unsigned int max)
   if (!field_defined(str))
     return 1;  // and keep the defaults
 
+  // Historically, filters allowed writing hexadecimal numbers with leading "0x".
+  // This was never intentional nor documented, but some people relied on it.
+  if (!maskp && str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
+    str += 2;
+
   while (*str)
     {
       int c = *str++;