changeset 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 dea415e4216d
files scripts/testfun/rundemos.m scripts/testfun/runtests.m
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/testfun/rundemos.m	Sun Sep 22 08:15:59 2013 -0700
+++ b/scripts/testfun/rundemos.m	Sun Sep 22 09:27:56 2013 -0700
@@ -103,9 +103,9 @@
   if (f < 0)
     error ("rundemos: fopen failed: %s", f);
   else
-    str = fscanf (fid, "%s");
+    str = fread (fid, "*char").';
     fclose (fid);
-    retval = strfind (str, "%!demo");
+    retval = ! isempty (regexp (str, '^%!demo', 'lineanchors', 'once'));
   endif
 endfunction
 
--- a/scripts/testfun/runtests.m	Sun Sep 22 08:15:59 2013 -0700
+++ b/scripts/testfun/runtests.m	Sun Sep 22 09:27:56 2013 -0700
@@ -110,7 +110,7 @@
     if (fid >= 0)
       str = fread (fid, "*char")';
       fclose (fid);
-      retval = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD|DEFUNX)\>',
+      retval = ! isempty (regexp (str,'^(?:DEFUN|DEFUN_DLD|DEFUNX)\>',
                                       'lineanchors', 'once'));
     else
       error ("fopen failed: %s", f);