Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match pci addresses with hex a-f in them #866

Merged
merged 3 commits into from
Jul 13, 2016
Merged

Conversation

petebristow
Copy link
Contributor

This does what is says on the tin, pci addresses are hex and can contain a-f as well as 0-9

@@ -163,7 +163,7 @@ end
--
-- example: qualified("01:00.0") -> "0000:01:00.0"
function qualified (address)
return address:gsub("^%d%d:%d%d[.]%d+$", "0000:%1")
return address:gsub("^[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][.][0-9a-f]+$", "0000:%1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! In Lua there's wildcard '%x' which matches hexadecimal digits. See http://www.lua.org/pil/20.2.html.

@eugeneia eugeneia self-assigned this Apr 12, 2016
@eugeneia
Copy link
Member

@petebristow @dpino Using %x will also match upper case letters (whereas [0-9a-f] does not), am I right?

@petebristow
Copy link
Contributor Author

No %x does not match upper case letters, or at least it didn't in my testing.
Linux uses lower case in it's paths, if we accept upper case we should probably flatten it to lower case as part of the process?

@eugeneia
Copy link
Member

@petebristow Just tested it on Lua and LuaJIT and %x managed to match upper case hexadecimal letters for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants