# HG changeset patch # User Rik # Date 1285530938 25200 # Node ID fa56fd98c0c5f104d0f6264b9527c45d13f2bcf9 # Parent cb62c7401ea2b568a3062e842b9d6e6c268c562c Remove requirement for PCRE in Octave. (Bug #31025) diff -r cb62c7401ea2 -r fa56fd98c0c5 scripts/ChangeLog --- a/scripts/ChangeLog Sat Sep 25 17:17:51 2010 -0400 +++ b/scripts/ChangeLog Sun Sep 26 12:55:38 2010 -0700 @@ -1,3 +1,8 @@ +2010-09-26 Rik + + * testfun/runtests.m (has_tests): Recode to remove requirement for PCRE. + Bug #31025. + 2010-09-25 Ben Abbott * plot/__print_parse_opts__.m: Recongize gs devices {eps/pdf/ps}write. diff -r cb62c7401ea2 -r fa56fd98c0c5 scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m Sat Sep 25 17:17:51 2010 -0400 +++ b/scripts/testfun/runtests.m Sun Sep 26 12:55:38 2010 -0700 @@ -17,7 +17,8 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} rundtests (@var{directory}) +## @deftypefn {Function File} {} runtests (@var{directory}) +## Execute built-in tests for all function files in the specified directory. ## @end deftypefn ## Author: jwe @@ -69,23 +70,19 @@ endif endfor if (! isempty (no_tests)) - printf ("\nThe following files in have no tests:\n\n", directory); + printf ("\nThe following files in %s have no tests:\n\n", directory); printf ("%s", list_in_columns (no_tests)); endif endfunction function retval = has_tests (f) - retval = false; fid = fopen (f); if (fid >= 0) - while (! feof (fid)) - ln = fgetl (fid); - if (! isempty (regexp (ln, "%!(assert|error|test)", "lineanchors"))) - retval = true; - break; - endif - endwhile + str = fread (fid, "*char")'; fclose (fid); + ## Avoid PCRE 'lineanchors' by searching for newline followed by PTN. + ## Equivalent to regexp ('^PTN','lineanchors') + retval = ! isempty (regexp (str, '[\r\n]\s*%!(test|assert|error|warning)', "once")); else error ("runtests: fopen failed: %s", f); endif diff -r cb62c7401ea2 -r fa56fd98c0c5 test/ChangeLog --- a/test/ChangeLog Sat Sep 25 17:17:51 2010 -0400 +++ b/test/ChangeLog Sun Sep 26 12:55:38 2010 -0700 @@ -1,3 +1,8 @@ +2010-09-26 Rik + + * fntests.m (has_tests, has_functions): Recode to remove requirement + for PCRE. + 2010-09-24 Rik * fntests.m: Rephrase output for clarity. diff -r cb62c7401ea2 -r fa56fd98c0c5 test/fntests.m --- a/test/fntests.m Sat Sep 25 17:17:51 2010 -0400 +++ b/test/fntests.m Sun Sep 26 12:55:38 2010 -0700 @@ -68,34 +68,34 @@ puts ("\n"); endfunction -function y = hasfunctions (f) +function retval = has_functions (f) n = length (f); if (n > 3 && strcmp (f((end-2):end), ".cc")) fid = fopen (f); - if (fid < 0) - error ("fopen failed: %s", f); - else + if (fid >= 0) str = fread (fid, "*char")'; fclose (fid); - y = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD)\b', "lineanchors")); + retval = ! isempty (regexp (str,'[\r\n](DEFUN|DEFUN_DLD)\b', "once")); + else + error ("fopen failed: %s", f); endif elseif (n > 2 && strcmp (f((end-1):end), ".m")) - y = true; + retval = true; else - y = false; + retval = false; endif endfunction -## FIXME -- should we only try match the keyword at the start of a line? -function y = hastests (f) +function retval = has_tests (f) fid = fopen (f); - if (fid < 0) - error ("fopen failed: %s", f); - else + if (fid >= 0) str = fread (fid, "*char")'; fclose (fid); - y = ! isempty (regexp (str, "^[ \t]*%!(test|assert|error|warning)", - "lineanchors")); + ## Avoid PCRE 'lineanchors' by searching for newline followed by PTN. + ## Equivalent to regexp ('^PTN','lineanchors') + retval = ! isempty (regexp (str, '[\r\n]\s*%!(test|assert|error|warning)', "once")); + else + error ("fopen failed: %s", f); endif endfunction @@ -110,7 +110,7 @@ && strcmp (nm((end-1):end), ".m")) p = n = xf = sk = 0; ffnm = fullfile (d, nm); - if (hastests (ffnm)) + if (has_tests (ffnm)) print_test_file_name (nm); [p, n, xf, sk] = test (nm(1:(end-2)), "quiet", fid); print_pass_fail (n, p); @@ -155,7 +155,7 @@ (length (nm) > 3 && strcmp (nm((end-2):end), ".cc"))) p = n = xf = 0; ## Only run if it contains %!test, %!assert %!error or %!warning - if (hastests (f)) + if (has_tests (f)) tmp = strrep (f, [topsrcdir, "/"], ""); tmp = strrep (tmp, [topbuilddir, "/"], "../"); print_test_file_name (tmp); @@ -166,7 +166,7 @@ dxf += xf; dsk += sk; files_with_tests(end+1) = f; - elseif (hasfunctions (f)) + elseif (has_functions (f)) ## To reduce the list length, only mark .cc files that contain ## DEFUN definitions. files_with_no_tests(end+1) = f; @@ -196,7 +196,7 @@ function n = num_elts_matching_pattern (lst, pat) n = 0; for i = 1:length (lst) - if (! isempty (regexp (lst{i}, pat))) + if (! isempty (regexp (lst{i}, pat, "once"))) n++; endif endfor