annotate scripts/plot/__gnuplot_version__.m @ 8794:f16aafdd99ca

__gnuplot_version__.m: don't use regexp to extract version number
author John W. Eaton <jwe@octave.org>
date Wed, 18 Feb 2009 01:10:43 -0500
parents 7d6e659acc1a
children 7d48766c21a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 2006, 2007 Daniel Sebald
6087
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
2 ##
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6087
diff changeset
3 ## This file is part of Octave.
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6087
diff changeset
4 ##
6087
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
6087
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
9 ##
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
14 ##
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6087
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
18
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6440
diff changeset
19 ## Undocumented internal function.
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6440
diff changeset
20
6087
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
21 ## Return the version of gnuplot we are using. Note that we do not
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
22 ## attempt to handle the case of the user switching to different
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
23 ## versions of gnuplot during the same session.
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
24
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
25 function version = __gnuplot_version__ ()
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
26
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
27 persistent __version__ = "";
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
28
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
29 if (isempty (__version__))
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
30 [status, output] = system (sprintf ("%s --version", gnuplot_binary ()));
7714
83ea845cda36 Display a (hopefully) informative error message if gnuplot isn't found
sh@sh-laptop
parents: 7017
diff changeset
31 if (status != 0)
7716
9c15f385811c __gnuplot_version__: use newline at end of message
John W. Eaton <jwe@octave.org>
parents: 7714
diff changeset
32 ## This message ends in a newline so that the traceback messages
9c15f385811c __gnuplot_version__: use newline at end of message
John W. Eaton <jwe@octave.org>
parents: 7714
diff changeset
33 ## are skipped and people might actually see the message, read it,
9c15f385811c __gnuplot_version__: use newline at end of message
John W. Eaton <jwe@octave.org>
parents: 7714
diff changeset
34 ## comprehend it, actually take the advice it gives, and stop
9c15f385811c __gnuplot_version__: use newline at end of message
John W. Eaton <jwe@octave.org>
parents: 7714
diff changeset
35 ## asking us why plotting fails when gnuplot is not found.
9c15f385811c __gnuplot_version__: use newline at end of message
John W. Eaton <jwe@octave.org>
parents: 7714
diff changeset
36 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");
7714
83ea845cda36 Display a (hopefully) informative error message if gnuplot isn't found
sh@sh-laptop
parents: 7017
diff changeset
37 endif
8794
f16aafdd99ca __gnuplot_version__.m: don't use regexp to extract version number
John W. Eaton <jwe@octave.org>
parents: 8163
diff changeset
38 output = strrep (output, "gnuplot", "");
f16aafdd99ca __gnuplot_version__.m: don't use regexp to extract version number
John W. Eaton <jwe@octave.org>
parents: 8163
diff changeset
39 output = strrep (output, "patchlevel", ".");
f16aafdd99ca __gnuplot_version__.m: don't use regexp to extract version number
John W. Eaton <jwe@octave.org>
parents: 8163
diff changeset
40 output = strrep (output, "\n", "");
f16aafdd99ca __gnuplot_version__.m: don't use regexp to extract version number
John W. Eaton <jwe@octave.org>
parents: 8163
diff changeset
41 output = strrep (output, "\r", "");
f16aafdd99ca __gnuplot_version__.m: don't use regexp to extract version number
John W. Eaton <jwe@octave.org>
parents: 8163
diff changeset
42 __version__ = strrep (output, " ", "");
6087
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
43 endif
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
44
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
45 version = __version__;
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
46
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
47 endfunction
700e121edb94 [project @ 2006-10-25 19:03:12 by jwe]
jwe
parents:
diff changeset
48