From 43a3db20039256a6ea5a18a83785efd8cd60ca8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Sun, 18 Jan 2015 19:47:42 +0000 Subject: [PATCH] Create independent x-octave and x-matlab mimetypes (bug # 88596). Currently, the x-octave mimetype is an alias for x-matlab, even though Octave files are not parsed by Matlab. I understand that the two languages are very similar (with Octave aiming at having Matlab as a subset of his) but they are not the same. Note that if a file is written for Octave but uses Matlab only syntax, then it should be identified as Matlab. New x-octave mimetype can also be an application and we can recognize it by a shebang line. Also we should be able to distinguish them from the characters used for comments. Using "#" for comments is valid syntax for Octave only. And while "%" is valid for both Octave and Matlab, if it uses "%" for comments it is probably aiming at Matlab compatibility and should be identified as x-matlab. Octave scripts can define new functions (not possible in Matlab). To distinguish function files and scripts, the first statement must not be a function declaration. The "1;" statement is often used for this which can be used to identify an Octave script. --- freedesktop.org.xml.in | 31 +++++++++++++++++++++++++------ tests/an_octave_program | 2 ++ tests/an_octave_script.m | 7 +++++++ tests/list | 4 +++- 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100755 tests/an_octave_program create mode 100755 tests/an_octave_script.m diff --git a/freedesktop.org.xml.in b/freedesktop.org.xml.in index 263b0ff..114f80c 100644 --- a/freedesktop.org.xml.in +++ b/freedesktop.org.xml.in @@ -5482,20 +5482,39 @@ command to generate the output files. - - <_comment>MATLAB script/function + + <_comment>Octave script/function + - - + + + + + + + + + + + + + - + + + + + <_comment>MATLAB script/function + + + + - <_comment>Modelica model diff --git a/tests/an_octave_program b/tests/an_octave_program new file mode 100755 index 0000000..718fcb0 --- /dev/null +++ b/tests/an_octave_program @@ -0,0 +1,2 @@ +#!/usr/bin/octave +printf ("Hello world!"); diff --git a/tests/an_octave_script.m b/tests/an_octave_script.m new file mode 100755 index 0000000..417da85 --- /dev/null +++ b/tests/an_octave_script.m @@ -0,0 +1,7 @@ +1; + +function foo () + printf ("Hello world!\n"); +endfunction + +foo () diff --git a/tests/list b/tests/list index d0628ee..18e21e6 100644 --- a/tests/list +++ b/tests/list @@ -259,8 +259,10 @@ test.yaml application/x-yaml # hand-made mysum.m text/x-matlab x # taken from Octave 3.2 sources -isdir.m text/x-matlab x +isdir.m text/x-octave x # hand-made +an_octave_program text/x-octave x +an_octave_script.m text/x-octave x test.mo text/x-modelica xoo # From https://bugs.freedesktop.org/show_bug.cgi?id=29733 bibtex.bib text/x-bibtex -- 2.1.4