comparison scripts/path/savepath.m @ 10549:95c3e38098bf

Untabify .m scripts
author Rik <code@nomad.inbox5.com>
date Fri, 23 Apr 2010 11:28:50 -0700
parents fca0dc2fb042
children c9b0a75b02e8
comparison
equal deleted inserted replaced
10548:479536c5bb10 10549:95c3e38098bf
50 error ("savepath: could not open savefile, %s: %s", savefile, msg); 50 error ("savepath: could not open savefile, %s: %s", savefile, msg);
51 endif 51 endif
52 unwind_protect 52 unwind_protect
53 linenum = 0; 53 linenum = 0;
54 while (linenum >= 0) 54 while (linenum >= 0)
55 result = fgetl (fid); 55 result = fgetl (fid);
56 if (isnumeric (result)) 56 if (isnumeric (result))
57 ## end at the end of file 57 ## end at the end of file
58 linenum = -1; 58 linenum = -1;
59 else 59 else
60 linenum = linenum + 1; 60 linenum = linenum + 1;
61 filelines{linenum} = result; 61 filelines{linenum} = result;
62 ## find the first and last lines if they exist in the file 62 ## find the first and last lines if they exist in the file
63 if (strcmp (result, beginstring)) 63 if (strcmp (result, beginstring))
64 startline = linenum; 64 startline = linenum;
65 elseif (strcmp (result, endstring)) 65 elseif (strcmp (result, endstring))
66 endline = linenum; 66 endline = linenum;
67 endif 67 endif
68 endif 68 endif
69 endwhile 69 endwhile
70 unwind_protect_cleanup 70 unwind_protect_cleanup
71 closeread = fclose (fid); 71 closeread = fclose (fid);
72 if (closeread < 0) 72 if (closeread < 0)
73 error ("savepath: could not close savefile after reading, %s", 73 error ("savepath: could not close savefile after reading, %s",
74 savefile); 74 savefile);
75 endif 75 endif
76 end_unwind_protect 76 end_unwind_protect
77 endif 77 endif
78 78
79 if (startline > endline || (startline > 0 && endline == 0)) 79 if (startline > endline || (startline > 0 && endline == 0))
155 n_middle = round (0.5*(n1+n2)); 155 n_middle = round (0.5*(n1+n2));
156 [tmp, n] = setdiff (path_to_preserve, default_path); 156 [tmp, n] = setdiff (path_to_preserve, default_path);
157 path_to_save = path_to_preserve (sort (n)); 157 path_to_save = path_to_preserve (sort (n));
158 ## Remove pwd 158 ## Remove pwd
159 path_to_save = path_to_save (! strcmpi (path_to_save, 159 path_to_save = path_to_save (! strcmpi (path_to_save,
160 strcat (".", pathsep))); 160 strcat (".", pathsep)));
161 n = ones (size (path_to_save)); 161 n = ones (size (path_to_save));
162 for m = 1:numel(path_to_save) 162 for m = 1:numel(path_to_save)
163 n(m) = strmatch (path_to_save{m}, path_to_preserve); 163 n(m) = strmatch (path_to_save{m}, path_to_preserve);
164 endfor 164 endfor
165 path_to_save_begin = path_to_save(n <= n_middle); 165 path_to_save_begin = path_to_save(n <= n_middle);