Bug 27205 - Octave files aren't recognised correctly
Summary: Octave files aren't recognised correctly
Status: RESOLVED FIXED
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: freedesktop.org.xml (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Shared Mime Info group
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-19 15:37 UTC by Søren Hauberg
Modified: 2015-01-19 18:27 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
5 simple examples (260 bytes, application/x-gzip)
2010-04-07 22:19 UTC, Søren Hauberg
Details

Description Søren Hauberg 2010-03-19 15:37:17 UTC
GNU Octave is a Free implementation of the Matlab language (a programming language for numerical computing). Octave/Matlab script files have a '.m' extension. However, it seems that Objective-C also use this extension, so magic is needed to tell Octave/Matlab apart from Objective-C.

It seems like a file is detected as being an Octave/Matlab script if it either starts with '%' (used for comments) or 'function'. Octave, however, also allows '#' to be used for comments (like pretty much all other scripted languages). So, it would be great if this could be recognised as well.

This might, however, collide with Objective-C as these programs are recognised as starting with '#import'. If this is an issue, I would recommend recognising Octave/Matlab also as starting with '# ' or '##'.

Thanks,
Søren
Comment 1 Pino Toscano 2010-04-06 12:46:43 UTC
Yes, the issue is there.
I just added to git/master few simple testscases for the issue, and the addition of the '##' pattern for matlab files. Not sure about '# ', can you have things like:
  #  import <stdio.h>
in Obj-C?

Also, can you attach a sample file misrecognized?
Comment 2 Søren Hauberg 2010-04-07 22:19:09 UTC
Created attachment 34794 [details]
5 simple examples

The attached tar.gz file contains 5 files that all should be recognised as being Octave source files. On my system, all of them are recognised as being Objective-C in gedit, but that might be an Ubuntu bug.

I am not an Objective-C coder so I don't know if you are allowed to do things like

  # import

but looking at online examples it seems nobody actually does this. From a practical point of view, I guess it is fine to ignore this issue.
Comment 3 Bastien Nocera 2013-02-13 10:13:40 UTC
Please follow the instructions at:
http://cgit.freedesktop.org/xdg/shared-mime-info/tree/HACKING#n31
for mime-type additions.
Comment 4 Carnë Draug 2015-01-19 18:27:55 UTC
The original recommendation, to use "##" at offset 0 as magic for Octave as already been implemented with commit a1f1b88f so I think this can be closed.

I am proposing a slightly different approach at bug #88596 , to have the x-matlab and x-octave mimetypes separated.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.