]> mj.ucw.cz Git - pciutils.git/commitdiff
Filters: Allow leading "0x" for backward compatibility
authorMartin Mares <mj@ucw.cz>
Sat, 4 Mar 2023 15:02:43 +0000 (16:02 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 4 Mar 2023 15:02:43 +0000 (16:02 +0100)
lib/filter.c

index 703845156c5d75c26a96e4b986bb95bf587daffa..86486d3c7d0f31e2195aa5a91f92b3877a6f0809 100644 (file)
@@ -76,6 +76,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++;