comparison scripts/io/strread.m @ 19630:0e1f5a750d00

maint: Periodic merge of gui-release to default.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 10:24:46 -0500
parents c573d9c70ae5 fe689210525c
children 4197fc428c7d
comparison
equal deleted inserted replaced
19626:37d37297acf8 19630:0e1f5a750d00
159 ## depends on the last character of @var{str}: 159 ## depends on the last character of @var{str}:
160 ## 160 ##
161 ## @table @asis 161 ## @table @asis
162 ## @item last character = @qcode{"\n"} 162 ## @item last character = @qcode{"\n"}
163 ## Data columns are padded with empty fields or Nan so that all columns 163 ## Data columns are padded with empty fields or Nan so that all columns
164 ## have equal length 164 ## have equal length
165 ## 165 ##
166 ## @item last character is not @qcode{"\n"} 166 ## @item last character is not @qcode{"\n"}
167 ## Data columns are not padded; strread returns columns of unequal length 167 ## Data columns are not padded; strread returns columns of unequal length
168 ## 168 ##
169 ## @end table 169 ## @end table
175 175
176 ## Check input 176 ## Check input
177 if (nargin < 1) 177 if (nargin < 1)
178 print_usage (); 178 print_usage ();
179 endif 179 endif
180 180
181 if (isempty (str)) 181 if (isempty (str))
182 ## Return empty args (no match), rather than raising an error 182 ## Return empty args (no match), rather than raising an error
183 varargout = cell (1, nargout); 183 varargout = cell (1, nargout);
184 return; 184 return;
185 endif 185 endif
302 else 302 else
303 ## Determine the number of words per line as a first guess. Forms 303 ## Determine the number of words per line as a first guess. Forms
304 ## like %f<literal>) (w/o delimiter in between) are fixed further on 304 ## like %f<literal>) (w/o delimiter in between) are fixed further on
305 format = strrep (format, "%", " %"); 305 format = strrep (format, "%", " %");
306 fmt_words = regexp (format, '[^ ]+', "match"); 306 fmt_words = regexp (format, '[^ ]+', "match");
307 307
308 ## Find position of conversion specifiers (they start with %) 308 ## Find position of conversion specifiers (they start with %)
309 fcs_ptrn = '(%\*?(\d*|\d*\.\d*)?[nfduscq]|%\*?\[)'; 309 fcs_ptrn = '(%\*?(\d*|\d*\.\d*)?[nfduscq]|%\*?\[)';
310 idy2 = find (! cellfun ("isempty", regexp (fmt_words, fcs_ptrn))); 310 idy2 = find (! cellfun ("isempty", regexp (fmt_words, fcs_ptrn)));
311 311
312 ## Check for unsupported format specifiers 312 ## Check for unsupported format specifiers