Mercurial > octave-nkf
changeset 19325:64f034147e9a
test.m: Eliminate needless use of feof().
* test.m (__extract_test_code): Use fgets, which returns a numeric value when
it encounters EOF, to simplify loop extracting test code from m-file.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 28 Oct 2014 13:45:32 -0700 |
parents | 93a33123fcfe |
children | 238522618904 |
files | scripts/testfun/test.m |
diffstat | 1 files changed, 3 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/testfun/test.m Tue Oct 28 13:15:49 2014 -0700 +++ b/scripts/testfun/test.m Tue Oct 28 13:45:32 2014 -0700 @@ -742,13 +742,9 @@ fid = fopen (nm, "rt"); body = []; if (fid >= 0) - while (! feof (fid)) - ln = fgetl (fid); - if (length (ln) >= 2 && strcmp (ln(1:2), "%!")) - body = [body, "\n"]; - if (length (ln) > 2) - body = [body, ln(3:end)]; - endif + while (ischar (ln = fgets (fid))) + if (strncmp (ln, "%!", 2)) + body = [body, ln(3:end)]; endif endwhile fclose (fid);