From bug-octave-request at bevo dot che dot wisc dot edu Sun Dec 21 10:04:42 2003 Subject: fullfile([],'filename') is broken From: "John W. Eaton" To: Schloegl Alois Cc: bug-octave at bevo dot che dot wisc dot edu Date: Sun, 21 Dec 2003 09:57:38 -0600 On 20-Dec-2003, Schloegl Alois wrote: | if the first argument is empty, FULLFILE stops with an error. | | | Repeat-By: | --------- | | octave:10> fullfile([],'test','dir.001','filename') | error: invalid matrix index = 0 | error: evaluating argument list element number 1 | error: if: error evaluating conditional expression | error: evaluating if command near line 29, column 5 | error: evaluating if command near line 27, column 3 | error: called from `fullfile' in file | `/usr/local/share/octave/2.1.52/m/miscellaneous/fullfile.m' | | | Fix: | --- | | This patch fixes the problem. Thanks, I applied this change. | *** fullfile.m.old Fri Dec 19 21:11:38 2003 | --- fullfile.m Sat Dec 20 17:56:05 2003 | *************** | *** 26,31 **** | --- 26,32 ---- | | if (nargin > 0) | filename = varargin{1}; | + if length(filename) < 1, filename='.'; end; | if (strcmp (filename(end), "/")) | filename(end) = ""; | endif When writing code for Octave, please use parens around the conditions in IF or WHILE statemnts. I think it helps human readers to identify the condition. Then there is no need to use a comma to separate the condition of the IF from the subsequent statements. Please use the full ENDIF, ENDWHILE, etc., rather than just END. There is no need to use a semicolon after the ENDIF. Please also use double quote marks for strings. That way there is never any confusion with the transpose operator. Thanks, jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------