comparison scripts/io/dlmwrite.m @ 24419:11d7cd4ece50 stable

dlmwrite.m: Close fid if filename is only one char long (bug #52679)
author Andreas Weber <andy.weber.aw@gmail.com>
date Sat, 16 Dec 2017 14:49:25 +0100
parents 3ac9f9ecfae5
children fc6354114864
comparison
equal deleted inserted replaced
24416:d400b09043dd 24419:11d7cd4ece50
158 delim = "\t"; 158 delim = "\t";
159 endif 159 endif
160 160
161 if (ischar (file)) 161 if (ischar (file))
162 [fid, msg] = fopen (file, opentype); 162 [fid, msg] = fopen (file, opentype);
163 elseif (isscalar (file) && isnumeric (file)) 163 elseif (is_valid_file_id (file))
164 [fid, msg] = deal (file, "invalid file number"); 164 [fid, msg] = deal (file, "invalid file number");
165 else 165 else
166 error ("dlmwrite: FILE must be a filename string or numeric FID"); 166 error ("dlmwrite: FILE must be a filename string or numeric FID");
167 endif 167 endif
168 168
192 b(2: 2 : end, :) = imag (M); 192 b(2: 2 : end, :) = imag (M);
193 fprintf (fid, template, b); 193 fprintf (fid, template, b);
194 else 194 else
195 fprintf (fid, template, M.'); 195 fprintf (fid, template, M.');
196 endif 196 endif
197 if (! isscalar (file)) 197 if (ischar (file))
198 fclose (fid); 198 fclose (fid);
199 endif 199 endif
200 endif 200 endif
201 201
202 endfunction 202 endfunction