Mercurial > octave-nkf
comparison scripts/testfun/rundemos.m @ 17460:9411ad1afa84
rundemos.m: Use regexp, instead of strfind, to report whether a file has_demos.
* scripts/testfun/rundemos.m: Use regexp so that occurrences of '%!demo',
possibly in comments, do not trigger running demos.
* scripts/testfun/runtests.m: Don't bother to capture regexp pattern which
is just discarded.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 22 Sep 2013 09:27:56 -0700 |
parents | f271fa40074d |
children | d63878346099 |
comparison
equal
deleted
inserted
replaced
17459:f271fa40074d | 17460:9411ad1afa84 |
---|---|
101 function retval = has_demos (f) | 101 function retval = has_demos (f) |
102 fid = fopen (f); | 102 fid = fopen (f); |
103 if (f < 0) | 103 if (f < 0) |
104 error ("rundemos: fopen failed: %s", f); | 104 error ("rundemos: fopen failed: %s", f); |
105 else | 105 else |
106 str = fscanf (fid, "%s"); | 106 str = fread (fid, "*char").'; |
107 fclose (fid); | 107 fclose (fid); |
108 retval = strfind (str, "%!demo"); | 108 retval = ! isempty (regexp (str, '^%!demo', 'lineanchors', 'once')); |
109 endif | 109 endif |
110 endfunction | 110 endfunction |
111 | 111 |
112 | 112 |
113 %!error rundemos ("foo", 1) | 113 %!error rundemos ("foo", 1) |