Masking in the MIME magic spec

Thomas Kluyver thomas at kluyver.me.uk
Tue Mar 19 06:57:04 PDT 2013


On 19 March 2013 13:28, David Faure <faure at kde.org> wrote:

> The other would be to write code that detects the cases where the database
> has
> values such that  (value & mask) != value, and fixing the database to
> specify
> (value & mask) as value from now on. This would allow implementations to
> avoid
> having to mask the value at runtime, which would lead to a minor speedup
> (and
> to the spec being correct after all).
> Such code would be easy to write, as part of any of the existing
> implementations, I would think.
>

Yes, I think that sounds reasonable, although of course implementations
will need to support the existing data for some time, even if newer
versions of shared-mime-info fix that. The downside is that
update-mime-database is written in C, and as I found yesterday, I'm lousy
at fixing C code. (Aside: this is an occasionally used script where
performance isn't that important - would it make sense to write it in
Python rather than C?)

I've just inspected the values I have. There aren't many rules using masks
at all. Of those that are, 5 need the mask applied, in all cases because
they use a placeholder character where the mask has a null byte.

- application/x-core, application/x-sharedlib and
application/vnd.adobe.photoshop use spaces
- image/bmp uses lowercase 'x'
- application/vnd.corel-draw uses an uppercase 'X'

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xdg/attachments/20130319/52ee0172/attachment.html>


More information about the xdg mailing list