Mercurial > hg > octave-lyh
annotate scripts/path/savepath.m @ 16618:13728d41fb6a
use functions to handle colors in Windows GUI terminal
* QWinTerminalImpl.cpp (QConsolePrivate::backgroundColor,
QConsolePrivate::foregroundColor, QConsolePrivate::selectionColor,
QConsolePrivate::cursorColor, QConsolePrivate::setBackgroundColor,
QConsolePrivate::setForegroundColor,
QConsolePrivate::setSelectionColor, QConsolePrivate::setCursorColor):
New functions.
(QConsolePrivate::m_backgroundColor,
QConsolePrivate::m_foregroundColor): Delete member variables.
(QConsolePrivate::QConsolePrivate): Call setBackgroundColor and
setForegroundColor to set default colors.
(QWinTerminalImpl::viewPaintEvent): Use functions to access colors.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 May 2013 02:20:01 -0400 |
parents | b3730ed107a6 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11589
diff
changeset
|
1 ## Copyright (C) 2005-2012 Bill Denney |
5732 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5732 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5732 | 18 |
19 ## -*- texinfo -*- | |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
20 ## @deftypefn {Function File} {} savepath () |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
21 ## @deftypefnx {Function File} {} savepath (@var{file}) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{status} =} savepath (@dots{}) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
23 ## Save the unique portion of the current function search path that is |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
24 ## not set during Octave's initialization process to @var{file}. |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
25 ## If @var{file} is omitted, @file{~/.octaverc} is used. If successful, |
5804 | 26 ## @code{savepath} returns 0. |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
27 ## @seealso{path, addpath, rmpath, genpath, pathdef} |
5732 | 28 ## @end deftypefn |
29 | |
30 ## Author: Bill Denney <bill@givebillmoney.com> | |
31 | |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
32 function retval = savepath (file) |
5732 | 33 |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
34 ret = 1; |
5732 | 35 |
36 beginstring = "## Begin savepath auto-created section, do not edit"; | |
37 endstring = "## End savepath auto-created section"; | |
38 | |
5733 | 39 if (nargin == 0) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
40 file = fullfile ("~", ".octaverc"); |
5732 | 41 endif |
42 | |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 ## parse the file if it exists to see if we should replace an |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
44 ## existing section or create a new section |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
45 startline = endline = 0; |
5732 | 46 filelines = {}; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
47 if (exist (file) == 2) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
48 [fid, msg] = fopen (file, "rt"); |
5732 | 49 if (fid < 0) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
50 error ("savepath: could not open file, %s: %s", file, msg); |
5732 | 51 endif |
7392 | 52 unwind_protect |
53 linenum = 0; | |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 while (ischar (line = fgetl (fid))) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 filelines{++linenum} = line; |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 ## find the first and last lines if they exist in the file |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 if (strcmp (line, beginstring)) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 startline = linenum; |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 elseif (strcmp (line, endstring)) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
60 endline = linenum; |
10549 | 61 endif |
7392 | 62 endwhile |
63 unwind_protect_cleanup | |
64 closeread = fclose (fid); | |
65 if (closeread < 0) | |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
66 error ("savepath: could not close file after reading, %s", file); |
5732 | 67 endif |
7392 | 68 end_unwind_protect |
5732 | 69 endif |
70 | |
5733 | 71 if (startline > endline || (startline > 0 && endline == 0)) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
72 error ("savepath: unable to parse file, %s", file); |
5732 | 73 endif |
74 | |
5733 | 75 ## put the current savepath lines into the file |
76 if (isempty (filelines) | |
77 || (startline == 1 && endline == length (filelines))) | |
78 ## savepath is the entire file | |
5732 | 79 pre = post = {}; |
80 elseif (endline == 0) | |
5733 | 81 ## drop the savepath statements at the end of the file |
5732 | 82 pre = filelines; |
83 post = {}; | |
84 elseif (startline == 1) | |
85 pre = {}; | |
86 post = filelines(endline+1:end); | |
8608 | 87 elseif (endline == length (filelines)) |
5732 | 88 pre = filelines(1:startline-1); |
89 post = {}; | |
90 else | |
5733 | 91 ## insert in the middle |
5732 | 92 pre = filelines(1:startline-1); |
93 post = filelines(endline+1:end); | |
94 endif | |
95 | |
5733 | 96 ## write the results |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
97 [fid, msg] = fopen (file, "wt"); |
5732 | 98 if (fid < 0) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
99 error ("savepath: unable to open file for writing, %s, %s", file, msg); |
7151 | 100 endif |
7392 | 101 unwind_protect |
102 for i = 1:length (pre) | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
103 fprintf (fid, "%s\n", pre{i}); |
7392 | 104 endfor |
5736 | 105 |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
106 ## Remove the portion of the path defined via the command line |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
107 ## and/or the environment. |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
108 workingpath = parsepath (path); |
8609
fcf762ba66cf
load-path.cc (Fcommand_line_path): rename from Fcommandlinepath
John W. Eaton <jwe@octave.org>
parents:
8608
diff
changeset
|
109 command_line_path = parsepath (command_line_path ()); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
110 octave_path = parsepath (getenv ("OCTAVE_PATH")); |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
111 pathdef = pathdef (); |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
112 if (isempty (pathdef)) |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
113 ## This occurs when running octave via run-octave. In this instance |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
114 ## the entire path is specified via the command line and pathdef() |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
115 ## is empty. |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
116 [~, n] = setdiff (workingpath, octave_path); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
117 default_path = command_line_path; |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
118 else |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
119 [~, n] = setdiff (workingpath, union (command_line_path, octave_path)); |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
120 default_path = parsepath (pathdef); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
121 endif |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
122 ## This is the path we'd like to preserve when octave is run. |
8608 | 123 path_to_preserve = workingpath (sort (n)); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
124 |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
125 ## Determine the path to Octave's user and sytem wide pkgs. |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
126 [pkg_user, pkg_system] = pkg ("list"); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
127 pkg_user_path = cell (1, numel (pkg_user)); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
128 pkg_system_path = cell (1, numel (pkg_system)); |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
129 for n = 1:numel (pkg_user) |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
130 pkg_user_path{n} = pkg_user{n}.archprefix; |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
131 endfor |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
132 for n = 1:numel (pkg_system) |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
133 pkg_system_path{n} = pkg_system{n}.archprefix; |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
134 endfor |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
135 pkg_path = union (pkg_user_path, pkg_system_path); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
136 |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
137 ## Rely on Octave's initialization to include the pkg path elements. |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
138 if (! isempty (pkg_path)) |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
139 [~, n] = setdiff (path_to_preserve, strcat (pkg_path, ":")); |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
140 path_to_preserve = path_to_preserve(sort (n)); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
141 endif |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
142 |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
143 ## Split the path to be saved into two groups. Those path elements that |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
144 ## belong at the beginning and those at the end. |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
145 if (! isempty (default_path)) |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
146 n1 = find (strcmp (default_path{1}, path_to_preserve)); |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
147 n2 = find (strcmp (default_path{end}, path_to_preserve)); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
148 n_middle = round (0.5*(n1+n2)); |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
149 [~, n] = setdiff (path_to_preserve, default_path); |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
150 path_to_save = path_to_preserve(sort (n)); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
151 ## Remove pwd |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
152 path_to_save = path_to_save(! strcmp (path_to_save, ["." pathsep])); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
153 n = ones (size (path_to_save)); |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
154 for m = 1:numel (path_to_save) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
155 n(m) = find (strcmp (path_to_save{m}, path_to_preserve)); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
156 endfor |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
157 path_to_save_begin = path_to_save(n <= n_middle); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
158 path_to_save_end = path_to_save(n > n_middle); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
159 else |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
160 path_to_save_begin = path_to_preserve; |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
161 path_to_save_end = {}; |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
162 endif |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
163 path_to_save_begin = cell2mat (path_to_save_begin); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
164 path_to_save_end = cell2mat (path_to_save_end); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
165 |
7392 | 166 ## Use single quotes for PATH argument to avoid string escape |
7393 | 167 ## processing. Since we are using single quotes around the arg, |
168 ## double any single quote characters found in the string. | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
169 fprintf (fid, "%s\n", beginstring); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
170 if (! isempty (path_to_save_begin)) |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
171 n = find (path_to_save_begin != pathsep, 1, "last"); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
172 fprintf (fid, " addpath ('%s', '-begin');\n", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
173 strrep (path_to_save_begin(1:n), "'", "''")); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
174 endif |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
175 if (! isempty (path_to_save_end)) |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
176 n = find (path_to_save_end != pathsep, 1, "last"); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
177 fprintf (fid, " addpath ('%s', '-end');\n", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
178 strrep (path_to_save_end(1:n), "'", "''")); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
179 endif |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
180 fprintf (fid, "%s\n", endstring); |
5736 | 181 |
7392 | 182 for i = 1:length (post) |
183 fprintf (fid, "%s\n", post{i}); | |
184 endfor | |
185 unwind_protect_cleanup | |
186 closeread = fclose (fid); | |
187 if (closeread < 0) | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
188 error ("savepath: could not close savefile after writing, %s", file); |
7392 | 189 elseif (nargin == 0) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
190 warning ("savepath: current path saved to %s", file); |
7392 | 191 endif |
192 end_unwind_protect | |
5732 | 193 |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
194 ret = 0; |
5732 | 195 |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
196 if (nargout > 0) |
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
197 retval = ret; |
5732 | 198 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
199 |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
200 endfunction |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
201 |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
202 function path_elements = parsepath (p) |
11032
c9b0a75b02e8
Make all regexp in Octave compatible with both POSIX and PCRE.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
203 pat = sprintf ('([^%s]+[%s$])', pathsep, pathsep); |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
204 path_elements = regexpi (strcat (p, pathsep), pat, "match"); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
205 endfunction |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
7393
diff
changeset
|
206 |