comparison scripts/io/strread.m @ 18857:7bbe3658c5ef

maint: Use "FIXME:" coding convention in m-files. * flipdim.m, prepad.m, rotdim.m, doc.m, strread.m, textread.m, krylov.m, colon.m, dump_prefs.m, fileattrib.m, getappdata.m, __xzip__.m, unpack.m, fsolve.m, axis.m, meshc.m, print.m, __ghostscript__.m, __go_draw_axes__.m, __print_parse_opts__.m, struct2hdl.m, unique.m, spstats.m, treeplot.m, test.m, datestr.m: Use "FIXME:" coding convention in m-files.
author Rik <rik@octave.org>
date Wed, 25 Jun 2014 13:45:41 -0700
parents f8b7e8483b88
children 2b82d2f29a7b
comparison
equal deleted inserted replaced
18856:de8c67ba7ac4 18857:7bbe3658c5ef
243 (numel (varargin{n+1}) == 1 && iscellstr (varargin{n+1}))) 243 (numel (varargin{n+1}) == 1 && iscellstr (varargin{n+1})))
244 [comment_start, comment_end] = deal (char (varargin{n+1}), "eol_char"); 244 [comment_start, comment_end] = deal (char (varargin{n+1}), "eol_char");
245 elseif (iscellstr (varargin{n+1}) && numel (varargin{n+1}) == 2) 245 elseif (iscellstr (varargin{n+1}) && numel (varargin{n+1}) == 2)
246 [comment_start, comment_end] = deal (varargin{n+1}{:}); 246 [comment_start, comment_end] = deal (varargin{n+1}{:});
247 else 247 else
248 ## FIXME - a user may have numeric values specified: {'//', 7} 248 ## FIXME: A user may have numeric values specified: {'//', 7}
249 ## this will lead to an error in the warning message 249 ## this will lead to an error in the warning message
250 error ("strread: unknown or unrecognized comment style '%s'", 250 error ("strread: unknown or unrecognized comment style '%s'",
251 varargin{n+1}); 251 varargin{n+1});
252 endif 252 endif
253 endswitch 253 endswitch
254 case "delimiter" 254 case "delimiter"
675 min (num_words_per_line * format_repeat_count + m - 1, numel (words)); 675 min (num_words_per_line * format_repeat_count + m - 1, numel (words));
676 data = words(m:num_words_per_line:lastline); 676 data = words(m:num_words_per_line:lastline);
677 endif 677 endif
678 678
679 ## Map to format 679 ## Map to format
680 ## FIXME - add support for formats like "<%s>", "%[a-zA-Z]" 680 ## FIXME: Add support for formats like "<%s>", "%[a-zA-Z]"
681 ## Someone with regexp experience is needed. 681 ## Someone with regexp experience is needed.
682 switch (fmt_words{m}(1:min (2, length (fmt_words{m})))) 682 switch (fmt_words{m}(1:min (2, length (fmt_words{m}))))
683 case "%s" 683 case "%s"
684 if (pad_out) 684 if (pad_out)
685 data(end+1:num_lines) = {""}; 685 data(end+1:num_lines) = {""};
686 endif 686 endif
687 varargout{k} = data'; 687 varargout{k} = data';
688 k++; 688 k++;
689 case {"%d", "%u", "%f", "%n"} 689 case {"%d", "%u", "%f", "%n"}
690 n = cellfun ("isempty", data); 690 n = cellfun ("isempty", data);
691 ### FIXME - erroneously formatted data lead to NaN, not an error 691 ### FIXME: Erroneously formatted data lead to NaN, not an error
692 data = str2double (data); 692 data = str2double (data);
693 if (! isempty (regexp (fmt_words{m}, "%[du]"))) 693 if (! isempty (regexp (fmt_words{m}, "%[du]")))
694 ## Cast to integer 694 ## Cast to integer
695 ## FIXME: NaNs will be transformed into zeros 695 ## FIXME: NaNs will be transformed into zeros
696 data = int32 (data); 696 data = int32 (data);
707 nfmt = ostrsplit (fmt_words{m}(2:ew), "."); 707 nfmt = ostrsplit (fmt_words{m}(2:ew), ".");
708 swidth = str2double (nfmt{1}); 708 swidth = str2double (nfmt{1});
709 switch (fmt_words{m}(ew+1)) 709 switch (fmt_words{m}(ew+1))
710 case {"d", "u", "f", "n"} 710 case {"d", "u", "f", "n"}
711 n = cellfun ("isempty", data); 711 n = cellfun ("isempty", data);
712 ### FIXME - erroneously formatted data lead to NaN, not an error 712 ### FIXME: Erroneously formatted data lead to NaN, not an error
713 ### => ReturnOnError can't be implemented for numeric data 713 ### => ReturnOnError can't be implemented for numeric data
714 data = str2double (strtrunc (data, swidth)); 714 data = str2double (strtrunc (data, swidth));
715 data(n) = numeric_fill_value; 715 data(n) = numeric_fill_value;
716 if (pad_out) 716 if (pad_out)
717 data(end+1:num_lines) = numeric_fill_value; 717 data(end+1:num_lines) = numeric_fill_value;
718 endif 718 endif