]> Creatis software - CreaPhase.git/blob - octave_packages/m/plot/private/__gnuplot_version__.m
update packages
[CreaPhase.git] / octave_packages / m / plot / private / __gnuplot_version__.m
1 ## Copyright (C) 2006-2012 Daniel Sebald
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {@var{version} =} __gnuplot_version__ ()
21 ## Undocumented internal function.
22 ## @end deftypefn
23
24 ## Return the version of gnuplot we are using.  Note that we do not
25 ## attempt to handle the case of the user switching to different
26 ## versions of gnuplot during the same session.
27
28 function version = __gnuplot_version__ ()
29
30   persistent __version__ = "";
31
32   if (isempty (__version__))
33     [status, output] = system (sprintf ("\"%s\" --version", gnuplot_binary ()));
34     if (status != 0)
35       ## This message ends in a newline so that the traceback messages
36       ## are skipped and people might actually see the message, read it,
37       ## comprehend it, actually take the advice it gives, and stop
38       ## asking us why plotting fails when gnuplot is not found.
39       error ("you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the 'gnuplot_binary' function\n");
40     endif
41     output = strrep (output, "gnuplot", "");
42     output = strrep (output, "patchlevel", ".");
43     output = strrep (output, "\n", "");
44     output = strrep (output, "\r", "");
45     __version__ = strrep (output, " ", "");
46   endif
47
48   version = __version__;
49
50 endfunction
51