Mercurial > octave
comparison scripts/io/textscan.m @ 20220:481fa65e5cab stable
textread.m, textscan.m: Fix handling of format repeat count (bug #45047)
* textread.m: Clarify docstring describing format repeat count argument
Add examples
Fix bug occurring when last read line has no trailing EOL
Add tests
* textcan.m: Fix bug occurring when last read line has no trailing EOL
author | Philip Nienhuis <prnienhuis@users.sf.net> |
---|---|
date | Sun, 24 May 2015 22:47:55 +0200 |
parents | e51473fdb622 |
children | 1b4bef838aaf |
comparison
equal
deleted
inserted
replaced
20216:9866b3202c52 | 20220:481fa65e5cab |
---|---|
273 eoi = findstr (str, eol_char); | 273 eoi = findstr (str, eol_char); |
274 n_eoi += numel (eoi); | 274 n_eoi += numel (eoi); |
275 ++nblks; | 275 ++nblks; |
276 endif | 276 endif |
277 endwhile | 277 endwhile |
278 ## Handle case of missing trailing EOL | |
279 if (! strcmp (str(end - length (eol_char) + 1 : end), eol_char)) | |
280 eoi = [ eoi (length (str)) ]; | |
281 ++n_eoi; | |
282 endif | |
278 ## OK, found EOL delimiting last requested line. Compute ptr (incl. EOL) | 283 ## OK, found EOL delimiting last requested line. Compute ptr (incl. EOL) |
279 if (isempty (eoi)) | 284 if (isempty (eoi)) |
280 disp ("textscan: format repeat count specified but no endofline found"); | 285 disp ("textscan: format repeat count specified but no endofline found"); |
281 data_size = nblks * BUFLENGTH + count; | 286 data_size = nblks * BUFLENGTH + count; |
282 else | 287 else |