nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Alert on unknown file: magic_file(...) failed: line 156


From: Michal Nowak
Subject: Re: [Nano-devel] Alert on unknown file: magic_file(...) failed: line 156: regex error 10
Date: Wed, 10 Apr 2019 13:53:13 +0200

On 03/26/19 04:54 PM, Benno Schulenberg wrote:

Hi Michal,

First off: thanks for reporting!


Hello Benno and thanks for looking into this.

Op 26-03-19 om 07:04 schreef Michal Nowak:
I work on updating GNU nano to 4.0 on OpenIndiana (illumos kernel). When
there's no suitable syntax highlighting file, there's an alert in nano like

$ nano 2019-03-14-07-13-49.050-VBoxSVC-6791.log [
magic_file(2019-03-14-07-13-49.050-VBoxSVC-6791.log) failed: line 156: regex
error 10 for `^[!-?A-~]{1,255}(    [^      ]+){11}', (invalid character range)
]

This is the content of the file:

Log created: 2019-03-14T07:13:49.501613000Z Executable:
/opt/VirtualBox/amd64/VBoxSVC Arg[0]: /opt/VirtualBox/amd64/VBoxSVC Arg[1]:
--auto-shutdown AddRef: illegal refcnt=3221225469 state=2

When I create a file with that content and that name, opening it with
nano (compiled without --disable-libmagic) does not give me any alert.

That's what I expect as this alert code is guarded by "#ifdef HAVE_LIBMAGIC".


But this alert is not about something being wrong in nano's regexes
but about the regexes in the magic data file.  My version of GNU file
is older (file-5.32).  Maybe a bug crept into the newer version?  Or
maybe you have additional magic data files parked in the paths that
GNU file searches?

With file "Makefile" file I see the highlighting as working, no alert:

Yes, because nano recognizes a Makefile through its name, not by using
libmagic.

Yes, now I see that this is what's happening. Highlighting works for file named "Makefile" but not for file named "m" of the same content.


(Ouch!  I now see that nano recognizes syntax/makefile.nanorc as
a Makefile, not as a nanorc file.  :|  A fairly recent change to
recognize more Makefile names probably broke that.  Thanks for
making me see that.)

So far, the alert seems not a very useful one to me,

It's not useful to the nano users, so it's fine to disable it.  But it
alerts you that there is some problem in the magic database.


As OpenIndiana is based on from illumos an non-GNU operating system, and GNU is now what's in many cases expected, in some cases functionality of the system are delivered "twice".

So, e.g. we ship two magic.h headers, the former one from https://github.com/file/file and the latter one from illumos:

usr/include/magic.h     pkg:/library/address@hidden
usr/include/ast/magic.h pkg:/system/address@hidden

Maybe the illumos ast/magic.h was picked instead of the GNU one? Though, we don't have a special libmagic.so library.

Is there a better way to deal with files which might not have syntax
highlighting file?
I think the value of letting libmagic "look" at files that are not
recognized from their name nor from their first line is very small,
so I normally build nano with --disable-libmagic.  This means that
opening plain text files, like logs or READMEs, is much faster: no
time is wasted by trying to recognize something that isn't there.

Benno


I think going with --disable-libmagic is the best for us for now.

Thanks,
Michal



reply via email to

[Prev in Thread] Current Thread [Next in Thread]