comparison scripts/io/textscan.m @ 12916:5d0478a75618

textscan: Fix multiple accesses, bug #33876. * textscan.m: correctly implement the repeated format.
author Ben Abbott <bpabbott@mac.com>
date Wed, 03 Aug 2011 19:54:37 -0400
parents ac00ae83ea2e
children e81ddf9cacd5
comparison
equal deleted inserted replaced
12915:9e1b9ca119eb 12916:5d0478a75618
160 endif 160 endif
161 if (isfinite (nlines) && (nlines >= 0)) 161 if (isfinite (nlines) && (nlines >= 0))
162 str = tmp_str = ""; 162 str = tmp_str = "";
163 n = 0; 163 n = 0;
164 ## FIXME: Can this be done without slow loop? 164 ## FIXME: Can this be done without slow loop?
165 while (ischar (tmp_str) && n++ <= nlines) 165 while (ischar (tmp_str) && n++ < nlines)
166 str = strcat (str, tmp_str);
167 tmp_str = fgets (fid); 166 tmp_str = fgets (fid);
167 if (ischar (tmp_str))
168 str = strcat (str, tmp_str);
169 endif
168 endwhile 170 endwhile
169 else 171 else
170 str = fread (fid, "char=>char").'; 172 str = fread (fid, "char=>char").';
171 endif 173 endif
172 endif 174 endif