Set global errno value accordingly.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
[ci skip] Update the .gitignore file.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Make behaviour consistent among various versions of libmagic adhering to the POSIX standard.

This concerns the following IEEE 1003.1 standards:

  http://pubs.opengroup.org/onlinepubs/007904975/utilities/file.html
  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/file.html

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Add Ruby 2.1.1 to Travis CI.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Make messages in assertions more appropriate.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Remove surplus code.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Re-factor assertions.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Update Travis CI configuration.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Make Travis CI test against multiple versions of vanilla libmagic.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Remove caching of Ruby gems from Travis CI for the time being.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Configure Bundler under Travis CI.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fix Travis CI build ...

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
[ci skip] Add "apt" caching to Travis CI ...

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Add LLVM (clang) to build with to Travis CI.
Small fix.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Make sure that call to magic_buffer() is also synchronised.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fix. Override current locale settings temporarily to make libmagic's regex library work correctly.

This is to handle the following error on OS X (Darwin):

  line 163: regex error 17, (illegal byte sequence)

Which seem to be influenced by current locale settings where most likely UTF-8
encoding is causing it to break, given how to regular expression that the
error refers to looks like:

  163: > 0 regex/s,=\`(\r\n|;|[[]|\377\376),""]

And in turn fix the following issue:

 Assertion failed: (cstring != NULL && "Must be a valid pointer to `const char'
 type"), function rb_mgc_file, file ../../../../ext/magic/ruby-magic.c, line 410.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Change order - restore standard error output first.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fix. Use correct magic cookie.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Raise Magic::LibraryError appropriately from Magic#flags_to_a when the underlying Magic library is closed.

Plus, cache the map of flag values-to-names on the class level.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>